Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
S
seatunnel-web
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
宋勇
seatunnel-web
Commits
359abc74
提交
359abc74
authored
12月 07, 2023
作者:
李纤
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
修改minio连接
上级
4ed9e844
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
86 行增加
和
13 行删除
+86
-13
S3ClientService.java
...pache/seatunnel/datasource/plugin/s3/S3ClientService.java
+4
-9
S3DatasourceChannel.java
...e/seatunnel/datasource/plugin/s3/S3DatasourceChannel.java
+82
-4
没有找到文件。
seatunnel-datasource/seatunnel-datasource-plugins/datasource-s3/src/main/java/org/apache/seatunnel/datasource/plugin/s3/S3ClientService.java
浏览文件 @
359abc74
...
...
@@ -32,15 +32,10 @@ public class S3ClientService {
setMinioClient
(
endpoint
,
provider
,
username
,
password
,
bucket
,
port
);
}
/**
* @param endpoint
* @param provider
* @param username
* @param password
* @param bucket
* @param port
* @throws MinioException
*/
public
MinioClient
getMinioClient
()
{
return
minioClient
;
}
public
void
setMinioClient
(
String
endpoint
,
String
provider
,
...
...
seatunnel-datasource/seatunnel-datasource-plugins/datasource-s3/src/main/java/org/apache/seatunnel/datasource/plugin/s3/S3DatasourceChannel.java
浏览文件 @
359abc74
...
...
@@ -23,12 +23,31 @@ import org.apache.seatunnel.datasource.plugin.api.DataSourceChannel;
import
org.apache.seatunnel.datasource.plugin.api.DataSourcePluginException
;
import
org.apache.seatunnel.datasource.plugin.api.model.TableField
;
import
io.minio.BucketExistsArgs
;
import
io.minio.ListObjectsArgs
;
import
io.minio.MinioClient
;
import
io.minio.Result
;
import
io.minio.errors.ErrorResponseException
;
import
io.minio.errors.InsufficientDataException
;
import
io.minio.errors.InternalException
;
import
io.minio.errors.InvalidResponseException
;
import
io.minio.errors.MinioException
;
import
io.minio.errors.ServerException
;
import
io.minio.errors.XmlParserException
;
import
io.minio.messages.Bucket
;
import
io.minio.messages.Item
;
import
lombok.NonNull
;
import
java.io.IOException
;
import
java.security.InvalidKeyException
;
import
java.security.NoSuchAlgorithmException
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
public
class
S3DatasourceChannel
implements
DataSourceChannel
{
private
S3ClientService
s3ClientService
;
public
static
class
Holder
{
private
static
final
S3DatasourceChannel
INSTANCE
=
new
S3DatasourceChannel
();
}
...
...
@@ -53,13 +72,73 @@ public class S3DatasourceChannel implements DataSourceChannel {
Map
<
String
,
String
>
requestParams
,
String
database
,
Map
<
String
,
String
>
options
)
{
throw
new
UnsupportedOperationException
(
"getTables is not supported for S3 datasource"
);
MinioClient
minioClient
=
s3ClientService
.
getMinioClient
();
List
<
String
>
tab
=
new
ArrayList
<>();
try
{
boolean
b
=
minioClient
.
bucketExists
(
BucketExistsArgs
.
builder
().
bucket
(
database
).
build
());
if
(!
b
)
{
return
tab
;
// throw new MinioException("桶不存在");
}
Iterable
<
Result
<
Item
>>
results
=
minioClient
.
listObjects
(
ListObjectsArgs
.
builder
().
bucket
(
database
).
build
());
results
.
forEach
(
x
->
{
try
{
boolean
dir
=
x
.
get
().
isDir
();
if
(!
dir
)
{
String
s
=
x
.
get
().
objectName
();
tab
.
add
(
s
);
}
}
catch
(
ErrorResponseException
|
InsufficientDataException
|
InternalException
|
InvalidKeyException
|
InvalidResponseException
|
IOException
|
NoSuchAlgorithmException
|
ServerException
|
XmlParserException
e
)
{
throw
new
RuntimeException
(
e
);
}
});
return
tab
;
}
catch
(
InvalidKeyException
|
IOException
|
NoSuchAlgorithmException
|
MinioException
e
)
{
throw
new
RuntimeException
(
e
);
}
// throw new UnsupportedOperationException("getTables is not supported for S3
// datasource");
}
@Override
public
List
<
String
>
getDatabases
(
@NonNull
String
pluginName
,
@NonNull
Map
<
String
,
String
>
requestParams
)
{
throw
new
UnsupportedOperationException
(
"getDatabases is not supported for S3 datasource"
);
MinioClient
minioClient
=
s3ClientService
.
getMinioClient
();
List
<
String
>
db
=
new
ArrayList
<>();
try
{
List
<
Bucket
>
buckets
=
minioClient
.
listBuckets
();
buckets
.
forEach
(
x
->
{
String
name
=
x
.
name
();
db
.
add
(
name
);
});
return
db
;
}
catch
(
ServerException
|
ErrorResponseException
|
InsufficientDataException
|
IOException
|
NoSuchAlgorithmException
|
InvalidKeyException
|
InvalidResponseException
|
XmlParserException
|
InternalException
e
)
{
throw
new
RuntimeException
(
e
);
}
// throw new UnsupportedOperationException("getDatabases is not supported for S3
// datasource");
}
@Override
...
...
@@ -114,9 +193,8 @@ public class S3DatasourceChannel implements DataSourceChannel {
String
password
=
requestParams
.
get
(
"secret_key"
)
+
""
;
String
bucket
=
requestParams
.
get
(
"bucket"
)
+
""
;
try
{
S3ClientService
s3ClientService
=
s3ClientService
=
new
S3ClientService
(
endpoint
,
provider
,
username
,
password
,
bucket
,
port
);
return
s3ClientService
;
}
catch
(
Exception
e
)
{
throw
new
SeaTunnelException
(
"创建Mqtt客户端错误!"
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论