Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add bml module #123

Closed
wants to merge 11 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions assembly/src/main/assembly/assembly.xml
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,18 @@
</includes>
</fileSet>

<!--bmlserver-->
<fileSet>
<directory>
${project.parent.basedir}/bml/bmlserver/target/
</directory>
<outputDirectory>share/linkis/bml/</outputDirectory>
<includes>
<include>*.zip</include>
</includes>
</fileSet>


<!--gateway-->
<fileSet>
<directory>
Expand Down
76 changes: 76 additions & 0 deletions bml/bmlclient/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<?xml version="1.0" encoding="UTF-8"?>
<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>linkis</artifactId>
<groupId>com.webank.wedatasphere.linkis</groupId>
<version>0.9.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>linkis-bmlclient</artifactId>


<properties>
<httpcomponents-client.version>4.4</httpcomponents-client.version>
</properties>

<dependencies>
<dependency>
<groupId>com.webank.wedatasphere.linkis</groupId>
<artifactId>linkis-bmlcommon</artifactId>
<version>${linkis.version}</version>
</dependency>
<dependency>
<groupId>com.webank.wedatasphere.linkis</groupId>
<artifactId>linkis-storage</artifactId>
<version>${linkis.version}</version>
</dependency>
<dependency>
<groupId>com.webank.wedatasphere.linkis</groupId>
<artifactId>linkis-common</artifactId>
<version>${linkis.version}</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>${httpcomponents-client.version}</version>
</dependency>
<dependency>
<groupId>com.webank.wedatasphere.linkis</groupId>
<artifactId>linkis-gateway-httpclient-support</artifactId>
<version>${linkis.version}</version>
</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>${basedir}/src/main/resources</directory>
</resource>
</resources>
</build>





</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* 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.linkis.bml.client;

import java.util.Map;

/**
* created by cooperyang on 2019/5/15
* Description:
*/
public abstract class AbstractBmlClient implements BmlClient{
protected String user;
protected java.util.Map<String, Object> properties;

public String getUser() {
return user;
}

public void setUser(String user) {
this.user = user;
}

public Map<String, Object> getProperties() {
return properties;
}

public void setProperties(Map<String, Object> properties) {
this.properties = properties;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
/*
* 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.linkis.bml.client;

import com.webank.wedatasphere.linkis.bml.protocol.*;

import java.io.InputStream;

/**
* created by cooperyang on 2019/5/15
* Description:
*/
public interface BmlClient {
/**
* 传入resourceID bmlclient会resource的输入流,如果不传入version,默认返回最新的版本
* @param resourceID resourceID
* @return InputStream
*/
public BmlDownloadResponse downloadResource(String user, String resourceID);

public BmlDownloadResponse downloadResource(String user, String resourceId, String version);


public BmlDownloadResponse downloadResource(String user, String resourceId, String version, String path, boolean overwrite);


/**
* relateResource方法将targetFilePath路径的文件关联到resourceID下面
* targetFilePath需要包括schema,如果不包含schema,默认是hdfs
* @param resourceID resourceID
* @param targetFilePath 指定文件目录
* @return BmlRelateResult 包含resourceId和新的version
*/
public BmlRelateResponse relateResource(String resourceID, String targetFilePath);


/**
* 更新资源信息
* @param resourceID 资源id
* @param filePath 目标文件路径
* @return resourceId 新的版本信息
*/

public BmlUpdateResponse updateResource(String user, String resourceID, String filePath);

public BmlUpdateResponse updateResource(String user, String resourceID, String filePath, InputStream inputStream);




/**
* 上传资源,用户指定输入流
* @param user 用户名
* @param filePath 上传的资源的路径
* @param inputStream 上传资源的输入流
* @return 包含resourceId和version
*/
public BmlUploadResponse uploadResource(String user, String filePath, InputStream inputStream);

/**
* 上传文件,用户指定文件路径,客户端自动获取输入流
* @param user 用户名
* @param filePath 文件路径
* @return 包含resourceId和version
*/
public BmlUploadResponse uploadResource(String user, String filePath);





/**
* 获取resource的所有版本
* @param user 用户名
* @param resourceId 资源Id
* @return resourceId对应下的所有版本信息
*/
public BmlResourceVersionsResponse getVersions(String user, String resourceId);


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* 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.linkis.bml.client;

import com.webank.wedatasphere.linkis.bml.client.impl.HttpBmlClient;

import java.util.Map;

/**
* created by cooperyang on 2019/5/15
* Description:
*/
public class BmlClientFactory {
public static BmlClient createBmlClient(){
return createBmlClient(null, null);
}


public static BmlClient createBmlClient(String user){
return createBmlClient(user, null);
}


public static BmlClient createBmlClient(String user, Map<String, Object> properties){
AbstractBmlClient bmlClient = new HttpBmlClient();
bmlClient.setUser(user);
bmlClient.setProperties(properties);
return bmlClient;
}


}
Loading