Skip to content

Commit

Permalink
Defines the basic class of the orchestration module. #354
Browse files Browse the repository at this point in the history
  • Loading branch information
liuyou2 authored and yangzhiyue committed Aug 20, 2021
1 parent fdbfe5b commit fc03550
Show file tree
Hide file tree
Showing 13 changed files with 823 additions and 0 deletions.
116 changes: 116 additions & 0 deletions dss-orchestrator/dss-orchestrator-core/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright 2019 WeBank
~ 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.
~
-->

<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>dss</artifactId>
<groupId>com.webank.wedatasphere.dss</groupId>
<version>1.0.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>dss-orchestrator-core</artifactId>
<dependencies>
<dependency>
<groupId>com.webank.wedatasphere.linkis</groupId>
<artifactId>linkis-module</artifactId>
<version>${linkis.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.webank.wedatasphere.dss</groupId>
<artifactId>dss-appconn-core</artifactId>
<version>${dss.version}</version>
</dependency>

<dependency>
<artifactId>linkis-bml-client</artifactId>
<exclusions>
<exclusion>
<artifactId>gson</artifactId>
<groupId>com.google.code.gson</groupId>
</exclusion>
</exclusions>
<groupId>com.webank.wedatasphere.linkis</groupId>
<version>${linkis.version}</version>
</dependency>

<dependency>
<groupId>com.webank.wedatasphere.dss</groupId>
<artifactId>dss-contextservice</artifactId>
<version>${dss.version}</version>
</dependency>

<dependency>
<groupId>com.webank.wedatasphere.linkis</groupId>
<artifactId>linkis-rpc</artifactId>
<version>${linkis.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.webank.wedatasphere.dss</groupId>
<artifactId>dss-orchestrator-common</artifactId>
<version>${dss.version}</version>
<scope>compile</scope>
</dependency>

<dependency>
<groupId>com.webank.wedatasphere.dss</groupId>
<artifactId>dss-common</artifactId>
<version>${dss.version}</version>
<scope>provided</scope>
</dependency>


</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
</plugin>

<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.xml</include>
</includes>
</resource>
<resource>
<directory>src/main/resources</directory>
<excludes>
<exclude>**/*.xml</exclude>
<exclude>**/*.properties</exclude>
<exclude>**/*.yml</exclude>
</excludes>
</resource>
</resources>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
* Copyright 2019 WeBank
* 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.wedatasphere.dss.orchestrator.core;

import com.webank.wedatasphere.dss.appconn.core.AppConn;
import com.webank.wedatasphere.dss.common.label.DSSLabel;
import java.util.List;



public interface DSSOrchestrator {

/**
* 返回Orchestrator的名称,如workflow
* @return
*/
String getName();


/**
* 返回编排关联的AppConn
* @return
*/
AppConn getAppConn();

DSSOrchestratorContext getDSSOrchestratorContext();

void setAppConn(AppConn appConn);

/**
*添加当前编排需要使用到在appconn
* @param appconn
*/
void addLinkedAppConn(AppConn appconn);


/**
* 为编排提供标签说明,如DEV
* @param dssLabel
*/
void addLinkedDssLabels(DSSLabel dssLabel);

/**
* 返回所有已经关联到的AppConn
* @return
*/
List<AppConn> getLinkedAppConn();

/**
* 用于工具条功能按钮展示,可以查到该模式可以提供的功能按钮
* @return
*/
List<String> getToolBars();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Copyright 2019 WeBank
* 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.wedatasphere.dss.orchestrator.core;

import com.webank.wedatasphere.dss.common.exception.DSSRuntimeException;
import com.webank.wedatasphere.dss.orchestrator.core.plugin.DSSOrchestratorPlugin;
import java.io.Closeable;
import java.util.List;
import java.util.Map;


public interface DSSOrchestratorContext extends Closeable {

void initialize();

Map<String, Object> getConfigMap();

List<DSSOrchestratorPlugin> getOrchestratorPlugins();

default <T extends DSSOrchestratorPlugin> T getDSSOrchestratorPlugin(Class<T> clazz) {
return (T) getOrchestratorPlugins().stream().filter(clazz::isInstance)
.findFirst().orElseThrow(() -> new DSSRuntimeException(50321, "Cannot find " + clazz.getSimpleName()));
}

boolean isActive();

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Copyright 2019 WeBank
* 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.wedatasphere.dss.orchestrator.core.exception;

import com.webank.wedatasphere.dss.common.exception.DSSErrorException;


public class DSSOrchestratorErrorException extends DSSErrorException {
public DSSOrchestratorErrorException(int errCode, String desc) {
super(errCode, desc);
}

public DSSOrchestratorErrorException(int errCode, String desc, String ip, int port, String serviceKind) {
super(errCode, desc, ip, port, serviceKind);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Copyright 2019 WeBank
* 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.wedatasphere.dss.orchestrator.core.impl;

import com.webank.wedatasphere.dss.common.utils.DSSExceptionUtils;
import com.webank.wedatasphere.dss.orchestrator.core.DSSOrchestratorContext;
import com.webank.wedatasphere.dss.orchestrator.core.plugin.DSSOrchestratorPlugin;
import java.util.HashMap;
import java.util.Map;


public abstract class AbstractDSSOrchestratorContext implements DSSOrchestratorContext {

private boolean isClosed = false;
private Map<String, Object> configMap = new HashMap<>();


@Override
public Map<String, Object> getConfigMap() {
return configMap;
}

@Override
public boolean isActive() {
return !isClosed;
}

@Override
public void close() {
isClosed = true;
getOrchestratorPlugins().forEach(DSSExceptionUtils.handling(DSSOrchestratorPlugin::close));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* Copyright 2019 WeBank
* 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.wedatasphere.dss.orchestrator.core.impl;

import com.webank.wedatasphere.dss.orchestrator.core.DSSOrchestrator;

import com.webank.wedatasphere.dss.orchestrator.core.DSSOrchestratorContext;
import java.util.Arrays;
import java.util.List;


abstract class AbstractOrchestrator implements DSSOrchestrator {

private volatile DSSOrchestratorContext dssOrchestratorContext;

@Override
public List<String> getToolBars() {
String[] toolNames = {"参数", "资源", "执行", "发布","保存"};
return Arrays.asList(toolNames);
}

protected abstract DSSOrchestratorContext createOrchestratorContext();

@Override
public DSSOrchestratorContext getDSSOrchestratorContext() {
if(dssOrchestratorContext == null) {
synchronized (this) {
if(dssOrchestratorContext == null) {
dssOrchestratorContext = createOrchestratorContext();
}
}
}
return dssOrchestratorContext;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Copyright 2019 WeBank
* 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.wedatasphere.dss.orchestrator.core.impl;

import com.webank.wedatasphere.dss.common.utils.ClassUtils;
import com.webank.wedatasphere.dss.orchestrator.core.plugin.DSSOrchestratorPlugin;
import java.util.List;


public class DSSOrchestratorContextImpl extends AbstractDSSOrchestratorContext {

private List<DSSOrchestratorPlugin> plugins;

@Override
public void initialize() {
plugins = ClassUtils.getInstances(DSSOrchestratorPlugin.class);
plugins.forEach(DSSOrchestratorPlugin::init);
}

@Override
public List<DSSOrchestratorPlugin> getOrchestratorPlugins() {
return plugins;
}

}
Loading

0 comments on commit fc03550

Please sign in to comment.