-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
062c6c5
commit 1d29349
Showing
11 changed files
with
682 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Apply the java-library plugin to add support for Java Library | ||
plugins { | ||
id 'java' | ||
id 'com.github.sherter.google-java-format' | ||
} | ||
dependencies{ | ||
compile project(":wedpr-components-mybatis") | ||
compile project(":wedpr-components-uuid") | ||
compile project(":wedpr-components-sys-config") | ||
} | ||
googleJavaFormat { | ||
//toolVersion = '1.7' | ||
options style: 'AOSP' | ||
source = sourceSets*.allJava | ||
include '**/*.java' | ||
//source = *.allJava | ||
} |
55 changes: 55 additions & 0 deletions
55
...ter/src/main/java/com/webank/wedpr/components/integration/jupyter/core/JupyterStatus.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* Copyright 2017-2025 [webank-wedpr] | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except | ||
* in compliance with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License | ||
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express | ||
* or implied. See the License for the specific language governing permissions and limitations under | ||
* the License. | ||
* | ||
*/ | ||
|
||
package com.webank.wedpr.components.integration.jupyter.core; | ||
|
||
import org.apache.commons.lang3.StringUtils; | ||
|
||
public enum JupyterStatus { | ||
Ready("Ready"), | ||
Running("Running"), | ||
OpenFailed("OpenFailed"), | ||
Closed("Closed"); | ||
|
||
private final String status; | ||
|
||
JupyterStatus(String status) { | ||
this.status = status; | ||
} | ||
|
||
public String getStatus() { | ||
return this.status; | ||
} | ||
|
||
public static JupyterStatus deserialize(String status) { | ||
if (StringUtils.isBlank(status)) { | ||
return null; | ||
} | ||
for (JupyterStatus jupyterStatus : JupyterStatus.values()) { | ||
if (jupyterStatus.status.compareToIgnoreCase(status) == 0) { | ||
return jupyterStatus; | ||
} | ||
} | ||
return null; | ||
} | ||
|
||
public boolean isRunning() { | ||
return ordinal() == JupyterStatus.Running.ordinal(); | ||
} | ||
|
||
public boolean isClosed() { | ||
return ordinal() == JupyterStatus.Closed.ordinal(); | ||
} | ||
} |
63 changes: 63 additions & 0 deletions
63
...yter/src/main/java/com/webank/wedpr/components/integration/jupyter/dao/JupyterInfoDO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* Copyright 2017-2025 [webank-wedpr] | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except | ||
* in compliance with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License | ||
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express | ||
* or implied. See the License for the specific language governing permissions and limitations under | ||
* the License. | ||
* | ||
*/ | ||
|
||
package com.webank.wedpr.components.integration.jupyter.dao; | ||
|
||
import com.fasterxml.jackson.annotation.JsonIgnore; | ||
import com.webank.wedpr.components.integration.jupyter.core.JupyterStatus; | ||
import com.webank.wedpr.components.uuid.generator.WeDPRUuidGenerator; | ||
import com.webank.wedpr.core.utils.TimeRange; | ||
import lombok.Data; | ||
|
||
@Data | ||
public class JupyterInfoDO extends TimeRange { | ||
private String id = WeDPRUuidGenerator.generateID(); | ||
private String owner; | ||
private String agency; | ||
private String accessEntry; | ||
private String setting; | ||
private String status; | ||
private String createTime; | ||
private String lastUpdateTime; | ||
@JsonIgnore private JupyterStatus jupyterStatus; | ||
|
||
public JupyterInfoDO() {} | ||
|
||
public JupyterInfoDO(boolean resetID) { | ||
if (resetID) { | ||
setId(null); | ||
} | ||
} | ||
|
||
public JupyterInfoDO(String id) { | ||
setId(id); | ||
} | ||
|
||
public void setStatus(String status) { | ||
this.status = status; | ||
if (this.status.isEmpty()) { | ||
return; | ||
} | ||
this.jupyterStatus = JupyterStatus.deserialize(status); | ||
} | ||
|
||
public void setJupyterStatus(JupyterStatus jupyterStatus) { | ||
this.jupyterStatus = jupyterStatus; | ||
if (jupyterStatus == null) { | ||
return; | ||
} | ||
this.status = jupyterStatus.getStatus(); | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
...yter/src/main/java/com/webank/wedpr/components/integration/jupyter/dao/JupyterMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* Copyright 2017-2025 [webank-wedpr] | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except | ||
* in compliance with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License | ||
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express | ||
* or implied. See the License for the specific language governing permissions and limitations under | ||
* the License. | ||
* | ||
*/ | ||
|
||
package com.webank.wedpr.components.integration.jupyter.dao; | ||
|
||
import java.util.List; | ||
import org.apache.ibatis.annotations.Mapper; | ||
import org.apache.ibatis.annotations.Param; | ||
|
||
@Mapper | ||
public interface JupyterMapper { | ||
/** | ||
* insert the jupyter record | ||
* | ||
* @param jupyterInfo the jupyter record to be inserted into | ||
* @return | ||
*/ | ||
public int insertJupyterInfo(@Param("jupyterInfo") JupyterInfoDO jupyterInfo); | ||
|
||
/** | ||
* update the jupyter record | ||
* | ||
* @param id the jupyter record that need to be updated | ||
* @param updatedInfo the updated info | ||
* @return | ||
*/ | ||
public int updateJupyterInfo(@Param("updatedInfo") JupyterInfoDO updatedInfo); | ||
|
||
/** | ||
* delete the jupyter record | ||
* | ||
* @param id the jupyter that need to be deleted | ||
* @return | ||
*/ | ||
public Integer deleteJupyterInfo(@Param("id") String id, @Param("owner") String owner); | ||
|
||
/** | ||
* query the jupyter information by condition | ||
* | ||
* @param condition the condition used to query | ||
* @return the result | ||
*/ | ||
public List<JupyterInfoDO> queryJupyterInfos(@Param("condition") JupyterInfoDO condition); | ||
|
||
public Integer queryJupyterRecordCount(@Param("condition") JupyterInfoDO condition); | ||
} |
64 changes: 64 additions & 0 deletions
64
...src/main/java/com/webank/wedpr/components/integration/jupyter/service/JupyterService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* Copyright 2017-2025 [webank-wedpr] | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except | ||
* in compliance with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License | ||
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express | ||
* or implied. See the License for the specific language governing permissions and limitations under | ||
* the License. | ||
* | ||
*/ | ||
|
||
package com.webank.wedpr.components.integration.jupyter.service; | ||
|
||
import com.webank.wedpr.components.integration.jupyter.dao.JupyterInfoDO; | ||
import java.util.List; | ||
|
||
public interface JupyterService { | ||
|
||
/** | ||
* allocate the jupyter environment for given user | ||
* | ||
* @param user the user that apply the jupyter | ||
* @param agency the agency of the person | ||
* @return success or failed | ||
*/ | ||
public abstract String allocate(String user, String agency) throws Exception; | ||
|
||
/** | ||
* query jupyters by condition | ||
* | ||
* @param condition | ||
* @return | ||
*/ | ||
public abstract List<JupyterInfoDO> queryJupyters( | ||
boolean admin, String queryUser, JupyterInfoDO condition) throws Exception; | ||
|
||
/** | ||
* open the jupyter according to given id | ||
* | ||
* @param id the jupyter id | ||
* @return success/failed | ||
*/ | ||
public abstract JupyterInfoDO open(String currentUser, String id) throws Exception; | ||
|
||
/** | ||
* close the jupyter according to given id | ||
* | ||
* @param id specify the jupyter to close | ||
* @return success/failed | ||
*/ | ||
public abstract JupyterInfoDO close(String currentUser, String id) throws Exception; | ||
|
||
/** | ||
* destroy the specified jupyter | ||
* | ||
* @param id specify the jupyter to destory | ||
* @return success/failed | ||
*/ | ||
public abstract boolean destroy(boolean admin, String currentUser, String id); | ||
} |
39 changes: 39 additions & 0 deletions
39
...main/java/com/webank/wedpr/components/integration/jupyter/service/impl/JupyterConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Copyright 2017-2025 [webank-wedpr] | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except | ||
* in compliance with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License | ||
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express | ||
* or implied. See the License for the specific language governing permissions and limitations under | ||
* the License. | ||
* | ||
*/ | ||
|
||
package com.webank.wedpr.components.integration.jupyter.service.impl; | ||
|
||
import com.webank.wedpr.core.config.WeDPRConfig; | ||
|
||
public class JupyterConfig { | ||
|
||
private static Integer MAX_JUPYTER_PER_HOST = | ||
WeDPRConfig.apply("wedpr.jupyter.max_count_per_host", 3); | ||
private static String JUPYTER_HOST_CONFIGUATINON_KEY = | ||
WeDPRConfig.apply("wedpr.jupyter.host_configuration_key", "jupyter_entrypoints"); | ||
private static String JUPYTER_ENTRYPOINT_SPLITTER = ";"; | ||
|
||
public static String getJupyterHostConfiguatinonKey() { | ||
return JUPYTER_HOST_CONFIGUATINON_KEY; | ||
} | ||
|
||
public static Integer getMaxJupyterPerHost() { | ||
return MAX_JUPYTER_PER_HOST; | ||
} | ||
|
||
public static String getJupyterEntrypointSplitter() { | ||
return JUPYTER_ENTRYPOINT_SPLITTER; | ||
} | ||
} |
Oops, something went wrong.