Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
dinky
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wangpeng
dinky
Commits
6f689ac7
Unverified
Commit
6f689ac7
authored
Nov 14, 2023
by
ZackYoung
Committed by
GitHub
Nov 14, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Feature][Admin] Git compilation package and Resource integration (#2523)
* git_add_resources * git_add_resources * git_add_resources
parent
e50059b6
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
148 additions
and
18 deletions
+148
-18
TenantInterceptor.java
...rc/main/java/org/dinky/interceptor/TenantInterceptor.java
+5
-3
TokenService.java
...in/src/main/java/org/dinky/service/impl/TokenService.java
+4
-0
BaseResourceManager.java
.../java/org/dinky/service/resource/BaseResourceManager.java
+3
-0
ResourcesService.java
...ain/java/org/dinky/service/resource/ResourcesService.java
+6
-0
HdfsResourceManager.java
.../org/dinky/service/resource/impl/HdfsResourceManager.java
+14
-0
OssResourceManager.java
...a/org/dinky/service/resource/impl/OssResourceManager.java
+12
-0
ResourceServiceImpl.java
.../org/dinky/service/resource/impl/ResourceServiceImpl.java
+59
-5
AnalysisUdfClassStepSse.java
.../main/java/org/dinky/sse/git/AnalysisUdfClassStepSse.java
+2
-2
AnalysisUdfPythonStepSse.java
...main/java/org/dinky/sse/git/AnalysisUdfPythonStepSse.java
+4
-4
GetJarsStepSse.java
...admin/src/main/java/org/dinky/sse/git/GetJarsStepSse.java
+19
-2
PythonZipStepSse.java
...min/src/main/java/org/dinky/sse/git/PythonZipStepSse.java
+15
-0
MavenUtil.java
dinky-admin/src/main/java/org/dinky/utils/MavenUtil.java
+1
-1
RuntimeUtils.java
dinky-admin/src/main/java/org/dinky/utils/RuntimeUtils.java
+4
-1
No files found.
dinky-admin/src/main/java/org/dinky/interceptor/TenantInterceptor.java
View file @
6f689ac7
...
@@ -27,6 +27,7 @@ import org.dinky.data.model.Tenant;
...
@@ -27,6 +27,7 @@ import org.dinky.data.model.Tenant;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.collections4.CollectionUtils
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
...
@@ -68,9 +69,10 @@ public class TenantInterceptor implements AsyncHandlerInterceptor {
...
@@ -68,9 +69,10 @@ public class TenantInterceptor implements AsyncHandlerInterceptor {
}
}
int
finalTenantId
=
Integer
.
parseInt
(
cookie
.
getValue
());
int
finalTenantId
=
Integer
.
parseInt
(
cookie
.
getValue
());
List
<
Tenant
>
tenants
=
userInfo
.
getTenantList
().
stream
()
List
<
Tenant
>
tenants
=
.
filter
(
t
->
t
.
getId
()
==
finalTenantId
)
Opt
.
ofNullable
(
userInfo
.
getTenantList
()).
orElse
(
new
ArrayList
<>()).
stream
()
.
collect
(
Collectors
.
toList
());
.
filter
(
t
->
t
.
getId
()
==
finalTenantId
)
.
collect
(
Collectors
.
toList
());
if
(
CollectionUtils
.
isEmpty
(
tenants
))
{
if
(
CollectionUtils
.
isEmpty
(
tenants
))
{
StpUtil
.
logout
(
StpUtil
.
getLoginIdAsInt
());
StpUtil
.
logout
(
StpUtil
.
getLoginIdAsInt
());
return
false
;
return
false
;
...
...
dinky-admin/src/main/java/org/dinky/service/impl/TokenService.java
View file @
6f689ac7
...
@@ -23,8 +23,10 @@ import org.dinky.context.UserInfoContextHolder;
...
@@ -23,8 +23,10 @@ import org.dinky.context.UserInfoContextHolder;
import
org.dinky.data.dto.UserDTO
;
import
org.dinky.data.dto.UserDTO
;
import
org.dinky.data.model.SysToken
;
import
org.dinky.data.model.SysToken
;
import
org.dinky.data.model.User
;
import
org.dinky.data.model.User
;
import
org.dinky.mapper.TenantMapper
;
import
org.dinky.mapper.TokenMapper
;
import
org.dinky.mapper.TokenMapper
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.concurrent.ConcurrentHashMap
;
...
@@ -53,6 +55,7 @@ public class TokenService implements SaTokenDao {
...
@@ -53,6 +55,7 @@ public class TokenService implements SaTokenDao {
private
final
TokenMapper
tokenMapper
;
private
final
TokenMapper
tokenMapper
;
private
final
StpLogic
stpLogic
;
private
final
StpLogic
stpLogic
;
private
final
TenantMapper
tenantMapper
;
/**
/**
* 存储数据的集合
* 存储数据的集合
...
@@ -307,6 +310,7 @@ public class TokenService implements SaTokenDao {
...
@@ -307,6 +310,7 @@ public class TokenService implements SaTokenDao {
User
user
=
new
User
();
User
user
=
new
User
();
user
.
setId
(
userId
);
user
.
setId
(
userId
);
userInfo
.
setUser
(
user
);
userInfo
.
setUser
(
user
);
userInfo
.
setTenantList
(
Collections
.
singletonList
(
tenantMapper
.
selectById
(
sysToken
.
getTenantId
())));
UserInfoContextHolder
.
set
(
userId
,
userInfo
);
UserInfoContextHolder
.
set
(
userId
,
userInfo
);
if
(
sysToken
.
getExpireType
()
==
1
)
{
if
(
sysToken
.
getExpireType
()
==
1
)
{
expireMap
.
put
(
stpLogic
.
splicingKeyTokenValue
(
sysToken
.
getTokenValue
()),
NEVER_EXPIRE
);
expireMap
.
put
(
stpLogic
.
splicingKeyTokenValue
(
sysToken
.
getTokenValue
()),
NEVER_EXPIRE
);
...
...
dinky-admin/src/main/java/org/dinky/service/resource/BaseResourceManager.java
View file @
6f689ac7
...
@@ -23,6 +23,7 @@ import org.dinky.data.model.SystemConfiguration;
...
@@ -23,6 +23,7 @@ import org.dinky.data.model.SystemConfiguration;
import
org.dinky.service.resource.impl.HdfsResourceManager
;
import
org.dinky.service.resource.impl.HdfsResourceManager
;
import
org.dinky.service.resource.impl.OssResourceManager
;
import
org.dinky.service.resource.impl.OssResourceManager
;
import
java.io.File
;
import
java.io.InputStream
;
import
java.io.InputStream
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.multipart.MultipartFile
;
...
@@ -39,6 +40,8 @@ public interface BaseResourceManager {
...
@@ -39,6 +40,8 @@ public interface BaseResourceManager {
void
putFile
(
String
path
,
MultipartFile
file
);
void
putFile
(
String
path
,
MultipartFile
file
);
void
putFile
(
String
path
,
File
file
);
String
getFileContent
(
String
path
);
String
getFileContent
(
String
path
);
InputStream
readFile
(
String
path
);
InputStream
readFile
(
String
path
);
...
...
dinky-admin/src/main/java/org/dinky/service/resource/ResourcesService.java
View file @
6f689ac7
...
@@ -27,6 +27,7 @@ import java.io.File;
...
@@ -27,6 +27,7 @@ import java.io.File;
import
java.util.List
;
import
java.util.List
;
import
java.util.function.Function
;
import
java.util.function.Function
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.multipart.MultipartFile
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.baomidou.mybatisplus.extension.service.IService
;
...
@@ -43,6 +44,8 @@ public interface ResourcesService extends IService<Resources> {
...
@@ -43,6 +44,8 @@ public interface ResourcesService extends IService<Resources> {
*/
*/
TreeNodeDTO
createFolder
(
Integer
pid
,
String
fileName
,
String
desc
);
TreeNodeDTO
createFolder
(
Integer
pid
,
String
fileName
,
String
desc
);
TreeNodeDTO
createFolderOrGet
(
Integer
pid
,
String
fileName
,
String
desc
);
/**
/**
* Rename an existing folder with the specified parameters.
* Rename an existing folder with the specified parameters.
*
*
...
@@ -86,6 +89,9 @@ public interface ResourcesService extends IService<Resources> {
...
@@ -86,6 +89,9 @@ public interface ResourcesService extends IService<Resources> {
*/
*/
File
getFile
(
Integer
id
);
File
getFile
(
Integer
id
);
@Transactional
(
rollbackFor
=
Exception
.
class
)
void
uploadFile
(
Integer
pid
,
String
desc
,
File
file
);
/**
/**
* Upload a file to the specified folder.
* Upload a file to the specified folder.
*
*
...
...
dinky-admin/src/main/java/org/dinky/service/resource/impl/HdfsResourceManager.java
View file @
6f689ac7
...
@@ -26,11 +26,13 @@ import org.apache.hadoop.fs.FSDataOutputStream;
...
@@ -26,11 +26,13 @@ import org.apache.hadoop.fs.FSDataOutputStream;
import
org.apache.hadoop.fs.FileSystem
;
import
org.apache.hadoop.fs.FileSystem
;
import
org.apache.hadoop.fs.Path
;
import
org.apache.hadoop.fs.Path
;
import
java.io.File
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.InputStream
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.multipart.MultipartFile
;
import
cn.hutool.core.io.FileUtil
;
import
cn.hutool.core.io.IoUtil
;
import
cn.hutool.core.io.IoUtil
;
public
class
HdfsResourceManager
implements
BaseResourceManager
{
public
class
HdfsResourceManager
implements
BaseResourceManager
{
...
@@ -66,6 +68,18 @@ public class HdfsResourceManager implements BaseResourceManager {
...
@@ -66,6 +68,18 @@ public class HdfsResourceManager implements BaseResourceManager {
}
}
}
}
@Override
public
void
putFile
(
String
path
,
File
file
)
{
try
{
FSDataOutputStream
stream
=
getHdfs
().
create
(
new
Path
(
getFilePath
(
path
)),
true
);
stream
.
write
(
FileUtil
.
readBytes
(
file
));
stream
.
flush
();
stream
.
close
();
}
catch
(
IOException
e
)
{
throw
BusException
.
valueOf
(
"file.upload.failed"
,
e
);
}
}
@Override
@Override
public
String
getFileContent
(
String
path
)
{
public
String
getFileContent
(
String
path
)
{
return
IoUtil
.
readUtf8
(
readFile
(
path
));
return
IoUtil
.
readUtf8
(
readFile
(
path
));
...
...
dinky-admin/src/main/java/org/dinky/service/resource/impl/OssResourceManager.java
View file @
6f689ac7
...
@@ -24,6 +24,7 @@ import org.dinky.data.exception.DinkyException;
...
@@ -24,6 +24,7 @@ import org.dinky.data.exception.DinkyException;
import
org.dinky.service.resource.BaseResourceManager
;
import
org.dinky.service.resource.BaseResourceManager
;
import
org.dinky.utils.OssTemplate
;
import
org.dinky.utils.OssTemplate
;
import
java.io.File
;
import
java.io.InputStream
;
import
java.io.InputStream
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.multipart.MultipartFile
;
...
@@ -31,6 +32,7 @@ import org.springframework.web.multipart.MultipartFile;
...
@@ -31,6 +32,7 @@ import org.springframework.web.multipart.MultipartFile;
import
com.amazonaws.services.s3.model.CopyObjectRequest
;
import
com.amazonaws.services.s3.model.CopyObjectRequest
;
import
com.amazonaws.services.s3.model.DeleteObjectRequest
;
import
com.amazonaws.services.s3.model.DeleteObjectRequest
;
import
cn.hutool.core.io.FileUtil
;
import
cn.hutool.core.io.IoUtil
;
import
cn.hutool.core.io.IoUtil
;
public
class
OssResourceManager
implements
BaseResourceManager
{
public
class
OssResourceManager
implements
BaseResourceManager
{
...
@@ -63,6 +65,16 @@ public class OssResourceManager implements BaseResourceManager {
...
@@ -63,6 +65,16 @@ public class OssResourceManager implements BaseResourceManager {
}
}
}
}
@Override
public
void
putFile
(
String
path
,
File
file
)
{
try
{
getOssTemplate
()
.
putObject
(
getOssTemplate
().
getBucketName
(),
getFilePath
(
path
),
FileUtil
.
getInputStream
(
file
));
}
catch
(
Exception
e
)
{
throw
new
DinkyException
(
e
);
}
}
@Override
@Override
public
String
getFileContent
(
String
path
)
{
public
String
getFileContent
(
String
path
)
{
return
IoUtil
.
readUtf8
(
readFile
(
path
));
return
IoUtil
.
readUtf8
(
readFile
(
path
));
...
...
dinky-admin/src/main/java/org/dinky/service/resource/impl/ResourceServiceImpl.java
View file @
6f689ac7
...
@@ -33,6 +33,7 @@ import java.io.File;
...
@@ -33,6 +33,7 @@ import java.io.File;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Comparator
;
import
java.util.Comparator
;
import
java.util.List
;
import
java.util.List
;
import
java.util.function.Consumer
;
import
java.util.function.Function
;
import
java.util.function.Function
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
...
@@ -75,6 +76,30 @@ public class ResourceServiceImpl extends ServiceImpl<ResourcesMapper, Resources>
...
@@ -75,6 +76,30 @@ public class ResourceServiceImpl extends ServiceImpl<ResourcesMapper, Resources>
return
convertTree
(
resources
);
return
convertTree
(
resources
);
}
}
@Override
public
TreeNodeDTO
createFolderOrGet
(
Integer
pid
,
String
fileName
,
String
desc
)
{
String
path
=
"/"
+
fileName
;
Resources
resources
;
long
count
=
count
(
new
LambdaQueryWrapper
<
Resources
>().
eq
(
Resources:
:
getPid
,
pid
).
eq
(
Resources:
:
getFileName
,
fileName
));
if
(
count
>
0
)
{
resources
=
getOne
(
new
LambdaQueryWrapper
<
Resources
>()
.
eq
(
Resources:
:
getPid
,
pid
)
.
eq
(
Resources:
:
getFileName
,
fileName
));
}
else
{
resources
=
new
Resources
();
resources
.
setPid
(
pid
);
resources
.
setFileName
(
fileName
);
resources
.
setIsDirectory
(
true
);
resources
.
setType
(
0
);
resources
.
setFullName
(
pid
<
1
?
path
:
getById
(
pid
).
getFullName
()
+
path
);
resources
.
setSize
(
0L
);
resources
.
setDescription
(
desc
);
save
(
resources
);
}
return
convertTree
(
resources
);
}
@Override
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
rename
(
Integer
id
,
String
fileName
,
String
desc
)
{
public
void
rename
(
Integer
id
,
String
fileName
,
String
desc
)
{
...
@@ -174,15 +199,29 @@ public class ResourceServiceImpl extends ServiceImpl<ResourcesMapper, Resources>
...
@@ -174,15 +199,29 @@ public class ResourceServiceImpl extends ServiceImpl<ResourcesMapper, Resources>
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Override
@Override
public
void
uploadFile
(
Integer
pid
,
String
desc
,
Multipart
File
file
)
{
public
void
uploadFile
(
Integer
pid
,
String
desc
,
File
file
)
{
Resources
pResource
=
RESOURCES_CACHE
.
get
(
pid
,
()
->
getById
(
pid
));
Resources
pResource
=
RESOURCES_CACHE
.
get
(
pid
,
()
->
getById
(
pid
));
if
(!
pResource
.
getIsDirectory
())
{
if
(!
pResource
.
getIsDirectory
())
{
RESOURCES_CACHE
.
remove
(
pid
);
RESOURCES_CACHE
.
remove
(
pid
);
Integer
realPid
=
pResource
.
getPid
();
Integer
realPid
=
pResource
.
getPid
();
pResource
=
RESOURCES_CACHE
.
get
(
pid
,
()
->
getById
(
realPid
));
pResource
=
RESOURCES_CACHE
.
get
(
pid
,
()
->
getById
(
realPid
));
}
}
long
size
=
file
.
getSize
();
long
size
=
file
.
length
();
String
fileName
=
file
.
getOriginalFilename
();
String
fileName
=
file
.
getName
();
upload
(
pid
,
desc
,
(
fullName
)
->
getBaseResourceManager
().
putFile
(
fullName
,
file
),
fileName
,
pResource
,
size
);
}
/**
*
* @param pid pid
* @param desc desc
* @param uploadAction uploadAction
* @param fileName fileName
* @param pResource pResource
* @param size size
*/
private
void
upload
(
Integer
pid
,
String
desc
,
Consumer
<
String
>
uploadAction
,
String
fileName
,
Resources
pResource
,
long
size
)
{
Resources
currentUploadResource
=
getOne
(
Resources
currentUploadResource
=
getOne
(
new
LambdaQueryWrapper
<
Resources
>().
eq
(
Resources:
:
getPid
,
pid
).
eq
(
Resources:
:
getFileName
,
fileName
));
new
LambdaQueryWrapper
<
Resources
>().
eq
(
Resources:
:
getPid
,
pid
).
eq
(
Resources:
:
getFileName
,
fileName
));
String
fullName
;
String
fullName
;
...
@@ -205,13 +244,27 @@ public class ResourceServiceImpl extends ServiceImpl<ResourcesMapper, Resources>
...
@@ -205,13 +244,27 @@ public class ResourceServiceImpl extends ServiceImpl<ResourcesMapper, Resources>
resources
.
setDescription
(
desc
);
resources
.
setDescription
(
desc
);
saveOrUpdate
(
resources
);
saveOrUpdate
(
resources
);
}
}
getBaseResourceManager
().
putFile
(
fullName
,
fil
e
);
uploadAction
.
accept
(
fullNam
e
);
List
<
Resources
>
resourceByPidToParent
=
getResourceByPidToParent
(
new
ArrayList
<>(),
pid
);
List
<
Resources
>
resourceByPidToParent
=
getResourceByPidToParent
(
new
ArrayList
<>(),
pid
);
resourceByPidToParent
.
forEach
(
x
->
x
.
setSize
(
x
.
getSize
()
+
size
));
resourceByPidToParent
.
forEach
(
x
->
x
.
setSize
(
x
.
getSize
()
+
size
));
updateBatchById
(
resourceByPidToParent
);
updateBatchById
(
resourceByPidToParent
);
}
}
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Override
public
void
uploadFile
(
Integer
pid
,
String
desc
,
MultipartFile
file
)
{
Resources
pResource
=
RESOURCES_CACHE
.
get
(
pid
,
()
->
getById
(
pid
));
if
(!
pResource
.
getIsDirectory
())
{
RESOURCES_CACHE
.
remove
(
pid
);
Integer
realPid
=
pResource
.
getPid
();
pResource
=
RESOURCES_CACHE
.
get
(
pid
,
()
->
getById
(
realPid
));
}
long
size
=
file
.
getSize
();
String
fileName
=
file
.
getOriginalFilename
();
upload
(
pid
,
desc
,
(
fullName
)
->
getBaseResourceManager
().
putFile
(
fullName
,
file
),
fileName
,
pResource
,
size
);
}
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Override
@Override
public
boolean
remove
(
Integer
id
)
{
public
boolean
remove
(
Integer
id
)
{
...
@@ -306,6 +359,7 @@ public class ResourceServiceImpl extends ServiceImpl<ResourcesMapper, Resources>
...
@@ -306,6 +359,7 @@ public class ResourceServiceImpl extends ServiceImpl<ResourcesMapper, Resources>
* @param filterFunction filter function
* @param filterFunction filter function
* @return {@link Result}< {@link List}< {@link Resources}>>}
* @return {@link Result}< {@link List}< {@link Resources}>>}
*/
*/
@Override
public
List
<
Resources
>
getResourcesTreeByFilter
(
Function
<
Resources
,
Boolean
>
filterFunction
)
{
public
List
<
Resources
>
getResourcesTreeByFilter
(
Function
<
Resources
,
Boolean
>
filterFunction
)
{
List
<
Resources
>
list
=
this
.
list
();
List
<
Resources
>
list
=
this
.
list
();
return
buildResourcesTree
(
return
buildResourcesTree
(
...
@@ -388,7 +442,7 @@ public class ResourceServiceImpl extends ServiceImpl<ResourcesMapper, Resources>
...
@@ -388,7 +442,7 @@ public class ResourceServiceImpl extends ServiceImpl<ResourcesMapper, Resources>
* @return
* @return
*/
*/
private
boolean
hasChild
(
List
<
Resources
>
resourcesList
,
Resources
resources
)
{
private
boolean
hasChild
(
List
<
Resources
>
resourcesList
,
Resources
resources
)
{
return
getChildList
(
resourcesList
,
resources
).
size
()
>
0
;
return
!
getChildList
(
resourcesList
,
resources
).
isEmpty
()
;
}
}
private
BaseResourceManager
getBaseResourceManager
()
{
private
BaseResourceManager
getBaseResourceManager
()
{
...
...
dinky-admin/src/main/java/org/dinky/sse/git/AnalysisUdfClassStepSse.java
View file @
6f689ac7
...
@@ -24,8 +24,8 @@ import org.dinky.data.exception.DinkyException;
...
@@ -24,8 +24,8 @@ import org.dinky.data.exception.DinkyException;
import
org.dinky.data.model.GitProject
;
import
org.dinky.data.model.GitProject
;
import
org.dinky.function.util.UDFUtil
;
import
org.dinky.function.util.UDFUtil
;
import
org.dinky.sse.StepSse
;
import
org.dinky.sse.StepSse
;
import
org.dinky.utils.URLUtils
;
import
java.io.File
;
import
java.nio.charset.StandardCharsets
;
import
java.nio.charset.StandardCharsets
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Comparator
;
import
java.util.Comparator
;
...
@@ -70,7 +70,7 @@ public class AnalysisUdfClassStepSse extends StepSse {
...
@@ -70,7 +70,7 @@ public class AnalysisUdfClassStepSse extends StepSse {
throw
new
DinkyException
(
"flink dependency not found"
);
throw
new
DinkyException
(
"flink dependency not found"
);
}
}
pathList
.
parallelStream
().
forEach
(
jar
->
{
pathList
.
parallelStream
().
forEach
(
jar
->
{
List
<
Class
<?>>
udfClassByJar
=
UDFUtil
.
getUdfClassByJar
(
new
File
(
jar
));
List
<
Class
<?>>
udfClassByJar
=
UDFUtil
.
getUdfClassByJar
(
URLUtils
.
to
File
(
jar
));
udfMap
.
put
(
jar
,
udfClassByJar
);
udfMap
.
put
(
jar
,
udfClassByJar
);
sendMsg
(
Dict
.
create
().
set
(
jar
,
udfClassByJar
));
sendMsg
(
Dict
.
create
().
set
(
jar
,
udfClassByJar
));
});
});
...
...
dinky-admin/src/main/java/org/dinky/sse/git/AnalysisUdfPythonStepSse.java
View file @
6f689ac7
...
@@ -53,16 +53,16 @@ public class AnalysisUdfPythonStepSse extends StepSse {
...
@@ -53,16 +53,16 @@ public class AnalysisUdfPythonStepSse extends StepSse {
@Override
@Override
public
void
exec
()
{
public
void
exec
()
{
File
zipFile
=
(
File
)
params
.
get
(
"zipFile"
);
File
zipFile
=
(
File
)
params
.
get
(
"zipFile"
);
File
projectFile
=
(
File
)
params
.
get
(
"projectFile
"
);
String
zipFilePath
=
params
.
getStr
(
"zipFilePath
"
);
try
{
try
{
Thread
.
currentThread
().
getContextClassLoader
().
loadClass
(
"org.apache.flink.table.api.ValidationException"
);
Thread
.
currentThread
().
getContextClassLoader
().
loadClass
(
"org.apache.flink.table.api.ValidationException"
);
}
catch
(
ClassNotFoundException
e
)
{
}
catch
(
ClassNotFoundException
e
)
{
throw
new
DinkyException
(
"flink dependency not found"
);
throw
new
DinkyException
(
"flink dependency not found"
);
}
}
List
<
String
>
pythonUdfList
=
UDFUtil
.
getPythonUdfList
(
List
<
String
>
pythonUdfList
=
SystemConfiguration
.
getInstances
().
getPythonHome
(),
project
File
.
getAbsolutePath
());
UDFUtil
.
getPythonUdfList
(
SystemConfiguration
.
getInstances
().
getPythonHome
(),
zip
File
.
getAbsolutePath
());
GitAnalysisJarDTO
gitAnalysisJarDTO
=
new
GitAnalysisJarDTO
();
GitAnalysisJarDTO
gitAnalysisJarDTO
=
new
GitAnalysisJarDTO
();
gitAnalysisJarDTO
.
setJarPath
(
zipFile
.
getAbsolutePath
()
);
gitAnalysisJarDTO
.
setJarPath
(
zipFile
Path
);
gitAnalysisJarDTO
.
setClassList
(
pythonUdfList
);
gitAnalysisJarDTO
.
setClassList
(
pythonUdfList
);
List
<
GitAnalysisJarDTO
>
dataList
=
CollUtil
.
newArrayList
(
gitAnalysisJarDTO
);
List
<
GitAnalysisJarDTO
>
dataList
=
CollUtil
.
newArrayList
(
gitAnalysisJarDTO
);
...
...
dinky-admin/src/main/java/org/dinky/sse/git/GetJarsStepSse.java
View file @
6f689ac7
...
@@ -19,6 +19,9 @@
...
@@ -19,6 +19,9 @@
package
org
.
dinky
.
sse
.
git
;
package
org
.
dinky
.
sse
.
git
;
import
org.dinky.data.dto.TreeNodeDTO
;
import
org.dinky.data.model.GitProject
;
import
org.dinky.service.resource.ResourcesService
;
import
org.dinky.sse.StepSse
;
import
org.dinky.sse.StepSse
;
import
org.dinky.utils.MavenUtil
;
import
org.dinky.utils.MavenUtil
;
...
@@ -30,7 +33,9 @@ import java.util.stream.Collectors;
...
@@ -30,7 +33,9 @@ import java.util.stream.Collectors;
import
org.springframework.web.servlet.mvc.method.annotation.SseEmitter
;
import
org.springframework.web.servlet.mvc.method.annotation.SseEmitter
;
import
cn.hutool.core.convert.Convert
;
import
cn.hutool.core.lang.Dict
;
import
cn.hutool.core.lang.Dict
;
import
cn.hutool.extra.spring.SpringUtil
;
/**
/**
* @author ZackYoung
* @author ZackYoung
...
@@ -51,10 +56,22 @@ public class GetJarsStepSse extends StepSse {
...
@@ -51,10 +56,22 @@ public class GetJarsStepSse extends StepSse {
@Override
@Override
public
void
exec
()
{
public
void
exec
()
{
List
<
File
>
jars
=
MavenUtil
.
getJars
((
File
)
params
.
get
(
"pom"
));
List
<
File
>
jars
=
MavenUtil
.
getJars
((
File
)
params
.
get
(
"pom"
));
List
<
String
>
pathList
=
uploadResources
(
jars
);
List
<
String
>
pathList
=
jars
.
stream
().
map
(
File:
:
getAbsolutePath
).
collect
(
Collectors
.
toList
());
addFileMsg
(
pathList
);
addFileMsg
(
pathList
);
params
.
put
(
"jarPath"
,
pathList
);
params
.
put
(
"jarPath"
,
pathList
);
}
}
private
List
<
String
>
uploadResources
(
List
<
File
>
jars
)
{
GitProject
gitProject
=
(
GitProject
)
params
.
get
(
"gitProject"
);
ResourcesService
resourcesService
=
SpringUtil
.
getBean
(
ResourcesService
.
class
);
TreeNodeDTO
gitFolder
=
resourcesService
.
createFolderOrGet
(
0
,
"git"
,
""
);
TreeNodeDTO
treeNodeDTO
=
resourcesService
.
createFolderOrGet
(
Convert
.
toInt
(
gitFolder
.
getId
()),
gitProject
.
getName
(),
""
);
return
jars
.
stream
()
.
peek
(
f
->
resourcesService
.
uploadFile
(
Convert
.
toInt
(
treeNodeDTO
.
getId
()),
""
,
f
))
.
map
(
x
->
"rs:/git/"
+
gitProject
.
getName
()
+
"/"
+
x
.
getName
())
.
collect
(
Collectors
.
toList
());
}
}
}
dinky-admin/src/main/java/org/dinky/sse/git/PythonZipStepSse.java
View file @
6f689ac7
...
@@ -19,7 +19,9 @@
...
@@ -19,7 +19,9 @@
package
org
.
dinky
.
sse
.
git
;
package
org
.
dinky
.
sse
.
git
;
import
org.dinky.data.dto.TreeNodeDTO
;
import
org.dinky.data.model.GitProject
;
import
org.dinky.data.model.GitProject
;
import
org.dinky.service.resource.ResourcesService
;
import
org.dinky.sse.StepSse
;
import
org.dinky.sse.StepSse
;
import
org.dinky.utils.GitRepository
;
import
org.dinky.utils.GitRepository
;
...
@@ -30,9 +32,11 @@ import java.util.concurrent.atomic.AtomicInteger;
...
@@ -30,9 +32,11 @@ import java.util.concurrent.atomic.AtomicInteger;
import
org.springframework.web.servlet.mvc.method.annotation.SseEmitter
;
import
org.springframework.web.servlet.mvc.method.annotation.SseEmitter
;
import
cn.hutool.core.convert.Convert
;
import
cn.hutool.core.io.FileUtil
;
import
cn.hutool.core.io.FileUtil
;
import
cn.hutool.core.lang.Dict
;
import
cn.hutool.core.lang.Dict
;
import
cn.hutool.core.util.ZipUtil
;
import
cn.hutool.core.util.ZipUtil
;
import
cn.hutool.extra.spring.SpringUtil
;
public
class
PythonZipStepSse
extends
StepSse
{
public
class
PythonZipStepSse
extends
StepSse
{
public
PythonZipStepSse
(
public
PythonZipStepSse
(
...
@@ -51,8 +55,19 @@ public class PythonZipStepSse extends StepSse {
...
@@ -51,8 +55,19 @@ public class PythonZipStepSse extends StepSse {
File
file
=
FileUtil
.
file
(
GitRepository
.
getProjectDir
(
gitProject
.
getName
()),
gitProject
.
getBranch
());
File
file
=
FileUtil
.
file
(
GitRepository
.
getProjectDir
(
gitProject
.
getName
()),
gitProject
.
getBranch
());
File
zipFile
=
ZipUtil
.
zip
(
file
);
File
zipFile
=
ZipUtil
.
zip
(
file
);
String
zipFilePath
=
uploadResources
(
zipFile
,
gitProject
);
addFileMsgLog
(
"ZipFile Path is: "
+
zipFile
);
addFileMsgLog
(
"ZipFile Path is: "
+
zipFile
);
params
.
put
(
"zipFile"
,
zipFile
);
params
.
put
(
"zipFile"
,
zipFile
);
params
.
put
(
"zipFilePath"
,
zipFilePath
);
params
.
put
(
"projectFile"
,
file
);
params
.
put
(
"projectFile"
,
file
);
}
}
private
String
uploadResources
(
File
zipFile
,
GitProject
gitProject
)
{
ResourcesService
resourcesService
=
SpringUtil
.
getBean
(
ResourcesService
.
class
);
TreeNodeDTO
gitFolder
=
resourcesService
.
createFolderOrGet
(
0
,
"git"
,
""
);
TreeNodeDTO
treeNodeDTO
=
resourcesService
.
createFolderOrGet
(
Convert
.
toInt
(
gitFolder
.
getId
()),
gitProject
.
getName
(),
""
);
resourcesService
.
uploadFile
(
Convert
.
toInt
(
treeNodeDTO
.
getId
()),
""
,
zipFile
);
return
"rs:/git/"
+
gitProject
.
getName
()
+
"/"
+
zipFile
.
getName
();
}
}
}
dinky-admin/src/main/java/org/dinky/utils/MavenUtil.java
View file @
6f689ac7
...
@@ -161,7 +161,7 @@ public class MavenUtil {
...
@@ -161,7 +161,7 @@ public class MavenUtil {
settingsPath
=
StrUtil
.
wrap
(
settingsPath
,
"\""
);
settingsPath
=
StrUtil
.
wrap
(
settingsPath
,
"\""
);
List
<
String
>
commandLine
=
new
LinkedList
<>();
List
<
String
>
commandLine
=
new
LinkedList
<>();
commandLine
.
add
(
mavenHome
+
"/bin/mvn"
);
commandLine
.
add
(
(
mavenHome
+
"/bin/mvn"
).
replaceAll
(
" "
,
"\" \""
)
);
commandLine
.
add
(
"-Dmaven.multiModuleProjectDirectory="
+
projectDir
);
commandLine
.
add
(
"-Dmaven.multiModuleProjectDirectory="
+
projectDir
);
commandLine
.
add
(
"-Dmaven.home="
+
StrUtil
.
wrap
(
mavenHome
,
"\""
));
commandLine
.
add
(
"-Dmaven.home="
+
StrUtil
.
wrap
(
mavenHome
,
"\""
));
Opt
.
ofBlankAble
(
repositoryDir
)
Opt
.
ofBlankAble
(
repositoryDir
)
...
...
dinky-admin/src/main/java/org/dinky/utils/RuntimeUtils.java
View file @
6f689ac7
...
@@ -31,6 +31,7 @@ import java.util.stream.Collectors;
...
@@ -31,6 +31,7 @@ import java.util.stream.Collectors;
import
cn.hutool.core.exceptions.ExceptionUtil
;
import
cn.hutool.core.exceptions.ExceptionUtil
;
import
cn.hutool.core.lang.Opt
;
import
cn.hutool.core.lang.Opt
;
import
cn.hutool.system.SystemUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
@Slf4j
@Slf4j
...
@@ -41,11 +42,13 @@ public class RuntimeUtils {
...
@@ -41,11 +42,13 @@ public class RuntimeUtils {
run
(
shell
,
log:
:
info
,
log:
:
error
);
run
(
shell
,
log:
:
info
,
log:
:
error
);
}
}
public
static
final
String
SHELL
=
SystemUtil
.
getOsInfo
().
isWindows
()
?
"cmd /c "
:
"/bin/bash -c "
;
public
static
int
run
(
String
shell
,
Consumer
<
String
>
outputConsumer
,
Consumer
<
String
>
errorConsumer
)
{
public
static
int
run
(
String
shell
,
Consumer
<
String
>
outputConsumer
,
Consumer
<
String
>
errorConsumer
)
{
Process
process
;
Process
process
;
int
waitValue
=
1
;
int
waitValue
=
1
;
try
{
try
{
process
=
Runtime
.
getRuntime
().
exec
(
shell
);
process
=
Runtime
.
getRuntime
().
exec
(
SHELL
+
shell
);
RUNNING
.
add
(
process
);
RUNNING
.
add
(
process
);
new
Thread
(()
->
{
new
Thread
(()
->
{
InputStream
inputStream
=
process
.
getInputStream
();
InputStream
inputStream
=
process
.
getInputStream
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment