Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
data-adapter
Overview
Overview
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
黄营
data-adapter
Commits
32e961b4
Commit
32e961b4
authored
Feb 26, 2024
by
hy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add some api for console end-point
parent
f8055e3b
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
47 additions
and
12 deletions
+47
-12
PluginController.java
.../tbyf/dataadapter/console/controlle/PluginController.java
+2
-1
WorkerController.java
.../tbyf/dataadapter/console/controlle/WorkerController.java
+9
-1
GroupDTO.java
...java/com/tbyf/dataadapter/console/model/dto/GroupDTO.java
+13
-0
pom.xml
dataadapter-core/pom.xml
+6
-0
GroupNode.java
...rc/main/java/com/tbyf/dataadapter/registry/GroupNode.java
+3
-1
WorkerNode.java
...c/main/java/com/tbyf/dataadapter/registry/WorkerNode.java
+4
-0
ZookeeperWorkerRegistry.java
...dataadapter/registry/support/ZookeeperWorkerRegistry.java
+8
-7
worker.conf
dataadapter-worker/src/main/resources/worker.conf
+2
-2
No files found.
dataadapter-console/src/main/java/com/tbyf/dataadapter/console/controlle/PluginController.java
View file @
32e961b4
package
com
.
tbyf
.
dataadapter
.
console
.
controlle
;
package
com
.
tbyf
.
dataadapter
.
console
.
controlle
;
import
com.fasterxml.jackson.annotation.JsonInclude
;
import
com.tbyf.dataadapter.api.vo.ProcessorVo
;
import
com.tbyf.dataadapter.api.vo.ProcessorVo
;
import
com.tbyf.dataadapter.api.vo.Result
;
import
com.tbyf.dataadapter.api.vo.Result
;
import
com.tbyf.dataadapter.task.processor.plugin.DataProcessorExtension
;
import
com.tbyf.dataadapter.task.processor.plugin.DataProcessorExtension
;
...
@@ -70,7 +71,7 @@ public class PluginController {
...
@@ -70,7 +71,7 @@ public class PluginController {
file
.
transferTo
(
pluginPath
);
file
.
transferTo
(
pluginPath
);
processorManager
.
installPlugin
(
pluginPath
.
toString
());
processorManager
.
installPlugin
(
pluginPath
.
toString
());
return
Result
.
ok
(
true
);
return
Result
.
ok
(
true
);
}
catch
(
IO
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
(),
e
);
log
.
error
(
e
.
getMessage
(),
e
);
return
Result
.
ok
(
false
);
return
Result
.
ok
(
false
);
}
}
...
...
dataadapter-console/src/main/java/com/tbyf/dataadapter/console/controlle/WorkerController.java
View file @
32e961b4
package
com
.
tbyf
.
dataadapter
.
console
.
controlle
;
package
com
.
tbyf
.
dataadapter
.
console
.
controlle
;
import
com.tbyf.dataadapter.api.vo.Result
;
import
com.tbyf.dataadapter.api.vo.Result
;
import
com.tbyf.dataadapter.console.model.dto.GroupDTO
;
import
com.tbyf.dataadapter.registry.GroupNode
;
import
com.tbyf.dataadapter.registry.GroupNode
;
import
com.tbyf.dataadapter.registry.WorkerRegistry
;
import
com.tbyf.dataadapter.registry.WorkerRegistry
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
@@ -8,7 +9,9 @@ import org.springframework.web.bind.annotation.GetMapping;
...
@@ -8,7 +9,9 @@ import org.springframework.web.bind.annotation.GetMapping;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
import
java.util.stream.Collectors
;
@RestController
@RestController
@RequestMapping
(
"/worker"
)
@RequestMapping
(
"/worker"
)
...
@@ -20,6 +23,11 @@ public class WorkerController {
...
@@ -20,6 +23,11 @@ public class WorkerController {
@GetMapping
(
"/groups"
)
@GetMapping
(
"/groups"
)
public
Result
<?>
getWorkerGroups
()
{
public
Result
<?>
getWorkerGroups
()
{
List
<
GroupNode
>
workerGroups
=
workerRegistry
.
getWorkerGroups
();
List
<
GroupNode
>
workerGroups
=
workerRegistry
.
getWorkerGroups
();
return
Result
.
ok
(
workerGroups
);
return
Result
.
ok
(
workerGroups
.
stream
().
map
(
g
->{
GroupDTO
dto
=
new
GroupDTO
();
dto
.
setName
(
g
.
getName
());
dto
.
setWorkerNodes
(
new
ArrayList
<>(
g
.
getWorkerNodes
().
values
()));
return
dto
;
}).
collect
(
Collectors
.
toList
()));
}
}
}
}
dataadapter-console/src/main/java/com/tbyf/dataadapter/console/model/dto/GroupDTO.java
0 → 100644
View file @
32e961b4
package
com
.
tbyf
.
dataadapter
.
console
.
model
.
dto
;
import
com.tbyf.dataadapter.registry.WorkerNode
;
import
lombok.Data
;
import
java.util.*
;
@Data
public
class
GroupDTO
{
private
String
name
;
private
List
<
WorkerNode
>
workerNodes
=
new
ArrayList
<>();
}
dataadapter-core/pom.xml
View file @
32e961b4
...
@@ -63,5 +63,10 @@
...
@@ -63,5 +63,10 @@
<groupId>
com.squareup.okhttp3
</groupId>
<groupId>
com.squareup.okhttp3
</groupId>
<artifactId>
logging-interceptor
</artifactId>
<artifactId>
logging-interceptor
</artifactId>
</dependency>
</dependency>
<dependency>
<groupId>
com.fasterxml.jackson.core
</groupId>
<artifactId>
jackson-annotations
</artifactId>
<scope>
provided
</scope>
</dependency>
</dependencies>
</dependencies>
</project>
</project>
\ No newline at end of file
dataadapter-core/src/main/java/com/tbyf/dataadapter/registry/GroupNode.java
View file @
32e961b4
...
@@ -2,12 +2,14 @@ package com.tbyf.dataadapter.registry;
...
@@ -2,12 +2,14 @@ package com.tbyf.dataadapter.registry;
import
lombok.Data
;
import
lombok.Data
;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
java.util.HashSet
;
import
java.util.Map
;
import
java.util.Set
;
import
java.util.Set
;
@Data
@Data
public
class
GroupNode
{
public
class
GroupNode
{
private
String
name
;
private
String
name
;
private
Set
<
WorkerNode
>
workerNodes
=
new
HashSet
<>();
private
Map
<
String
,
WorkerNode
>
workerNodes
=
new
HashMap
<>();
}
}
dataadapter-core/src/main/java/com/tbyf/dataadapter/registry/WorkerNode.java
View file @
32e961b4
package
com
.
tbyf
.
dataadapter
.
registry
;
package
com
.
tbyf
.
dataadapter
.
registry
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
com.tbyf.dataadapter.api.impl.WorkerBizClient
;
import
lombok.Data
;
import
lombok.Data
;
@Data
@Data
...
@@ -7,4 +9,6 @@ public class WorkerNode {
...
@@ -7,4 +9,6 @@ public class WorkerNode {
private
String
name
;
private
String
name
;
private
String
address
;
private
String
address
;
@JsonIgnore
private
WorkerBizClient
client
;
}
}
dataadapter-core/src/main/java/com/tbyf/dataadapter/registry/support/ZookeeperWorkerRegistry.java
View file @
32e961b4
...
@@ -2,6 +2,7 @@ package com.tbyf.dataadapter.registry.support;
...
@@ -2,6 +2,7 @@ package com.tbyf.dataadapter.registry.support;
import
com.tbyf.dataadapter.TimeoutException
;
import
com.tbyf.dataadapter.TimeoutException
;
import
com.tbyf.dataadapter.Worker
;
import
com.tbyf.dataadapter.Worker
;
import
com.tbyf.dataadapter.api.impl.WorkerBizClient
;
import
com.tbyf.dataadapter.registry.GroupNode
;
import
com.tbyf.dataadapter.registry.GroupNode
;
import
com.tbyf.dataadapter.registry.WorkerNode
;
import
com.tbyf.dataadapter.registry.WorkerNode
;
import
com.tbyf.dataadapter.registry.WorkerRegistry
;
import
com.tbyf.dataadapter.registry.WorkerRegistry
;
...
@@ -73,17 +74,17 @@ public class ZookeeperWorkerRegistry implements WorkerRegistry {
...
@@ -73,17 +74,17 @@ public class ZookeeperWorkerRegistry implements WorkerRegistry {
return
;
return
;
}
}
String
workerName
=
ZKPaths
.
getNodeFromPath
(
data
.
getPath
());
String
workerName
=
ZKPaths
.
getNodeFromPath
(
data
.
getPath
());
String
workerUrl
=
new
String
(
data
.
getData
(),
StandardCharsets
.
UTF_8
);
WorkerNode
workerNode
=
new
WorkerNode
();
workerNode
.
setName
(
workerName
);
workerNode
.
setAddress
(
workerUrl
);
switch
(
event
.
getType
())
{
switch
(
event
.
getType
())
{
case
CHILD_ADDED:
case
CHILD_ADDED:
groupNodes
.
get
(
groupName
).
getWorkerNodes
().
add
(
workerNode
);
String
workerUrl
=
new
String
(
data
.
getData
(),
StandardCharsets
.
UTF_8
);
WorkerNode
workerNode
=
new
WorkerNode
();
workerNode
.
setName
(
workerName
);
workerNode
.
setAddress
(
workerUrl
);
workerNode
.
setClient
(
new
WorkerBizClient
(
workerUrl
));
groupNodes
.
get
(
groupName
).
getWorkerNodes
().
put
(
workerName
,
workerNode
);
break
;
break
;
case
CHILD_REMOVED:
case
CHILD_REMOVED:
groupNodes
.
get
(
groupName
).
getWorkerNodes
().
remove
(
workerNod
e
);
groupNodes
.
get
(
groupName
).
getWorkerNodes
().
remove
(
workerNam
e
);
break
;
break
;
}
}
});
});
...
...
dataadapter-worker/src/main/resources/worker.conf
View file @
32e961b4
name
=
w008
name
=
w008
group
=
biz0
2
group
=
biz0
3
registryAddress
=
127
.
0
.
0
.
1
:
2181
registryAddress
=
127
.
0
.
0
.
1
:
2181
port
=
808
3
port
=
808
4
pluginsRoot
=
plugin01
pluginsRoot
=
plugin01
pluginRepositoryUrl
=
http
://
localhost
:
8082
/
plugin
/
download
pluginRepositoryUrl
=
http
://
localhost
:
8082
/
plugin
/
download
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