Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
byit-myth-job
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
liyuan
byit-myth-job
Commits
fa323143
Commit
fa323143
authored
Apr 01, 2020
by
guo_minglei@163.com
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/developer' into developer
parents
4d4ebfde
dd74a46b
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
140 additions
and
135 deletions
+140
-135
AdminRegisterConfig.java
...in/src/main/java/com/byit/config/AdminRegisterConfig.java
+8
-0
RpcSpringInvokerFactory.java
...it/rpc/remoting/invoker/impl/RpcSpringInvokerFactory.java
+1
-1
RpcReferenceBean.java
...byit/rpc/remoting/invoker/reference/RpcReferenceBean.java
+128
-131
ConnectClient.java
.../java/com/byit/rpc/remoting/net/common/ConnectClient.java
+1
-1
AddComplexPy.java
...-demo-client/src/main/java/com/byit/job/AddComplexPy.java
+1
-1
AddComplexPy1.java
...demo-client/src/main/java/com/byit/job/AddComplexPy1.java
+1
-1
No files found.
byit-myth-admin/src/main/java/com/byit/config/AdminRegisterConfig.java
View file @
fa323143
...
@@ -25,6 +25,10 @@ public class AdminRegisterConfig {
...
@@ -25,6 +25,10 @@ public class AdminRegisterConfig {
// @Value("${myth-rpc.registry.port}")
// @Value("${myth-rpc.registry.port}")
// private int port;
// private int port;
/**
* 初始化 rpc客户端 属于消费者
* @return
*/
@Bean
@Bean
public
RpcSpringInvokerFactory
invokerFactory
(){
public
RpcSpringInvokerFactory
invokerFactory
(){
RpcSpringInvokerFactory
invokerFactory
=
new
RpcSpringInvokerFactory
();
RpcSpringInvokerFactory
invokerFactory
=
new
RpcSpringInvokerFactory
();
...
@@ -39,6 +43,10 @@ public class AdminRegisterConfig {
...
@@ -39,6 +43,10 @@ public class AdminRegisterConfig {
return
invokerFactory
;
return
invokerFactory
;
}
}
/**
* 设置对外提供服务的接口 这个其实是配合网关调用的方式 属于生产者
* @return
*/
@Bean
@Bean
public
RpcSpringProviderFactory
rpcSpringProviderFactory
()
{
public
RpcSpringProviderFactory
rpcSpringProviderFactory
()
{
RpcSpringProviderFactory
providerFactory
=
new
RpcSpringProviderFactory
();
RpcSpringProviderFactory
providerFactory
=
new
RpcSpringProviderFactory
();
...
...
byit-myth-rpc/src/main/java/com/byit/rpc/remoting/invoker/impl/RpcSpringInvokerFactory.java
View file @
fa323143
...
@@ -87,7 +87,7 @@ public class RpcSpringInvokerFactory extends InstantiationAwareBeanPostProcessor
...
@@ -87,7 +87,7 @@ public class RpcSpringInvokerFactory extends InstantiationAwareBeanPostProcessor
null
,
null
,
rpcInvokerFactory
rpcInvokerFactory
);
);
//获取一个代理对象
Object
serviceProxy
=
referenceBean
.
getObject
();
Object
serviceProxy
=
referenceBean
.
getObject
();
// set bean
// set bean
...
...
byit-myth-rpc/src/main/java/com/byit/rpc/remoting/invoker/reference/RpcReferenceBean.java
View file @
fa323143
...
@@ -136,154 +136,151 @@ public class RpcReferenceBean {
...
@@ -136,154 +136,151 @@ public class RpcReferenceBean {
public
Object
getObject
()
{
public
Object
getObject
()
{
return
Proxy
.
newProxyInstance
(
Thread
.
currentThread
()
return
Proxy
.
newProxyInstance
(
Thread
.
currentThread
()
.
getContextClassLoader
(),
new
Class
[]
{
iface
},
.
getContextClassLoader
(),
new
Class
[]
{
iface
},
new
InvocationHandler
()
{
(
proxy
,
method
,
args
)
->
{
@Override
public
Object
invoke
(
Object
proxy
,
Method
method
,
Object
[]
args
)
throws
Throwable
{
// method param
String
className
=
method
.
getDeclaringClass
().
getName
();
// iface.getName()
// method param
String
varsion_
=
version
;
String
className
=
method
.
getDeclaringClass
().
getName
();
// iface.getName()
String
methodName
=
method
.
getName
();
String
varsion_
=
version
;
Class
<?>[]
parameterTypes
=
method
.
getParameterTypes
();
String
methodName
=
method
.
getName
();
Object
[]
parameters
=
args
;
Class
<?>[]
parameterTypes
=
method
.
getParameterTypes
();
Object
[]
parameters
=
args
;
// filters for generic
if
(
className
.
equals
(
RpcGenericService
.
class
.
getName
())
&&
methodName
.
equals
(
"invoke"
))
{
// filters for generic
if
(
className
.
equals
(
RpcGenericService
.
class
.
getName
())
&&
methodName
.
equals
(
"invoke"
))
{
Class
<?>[]
paramTypes
=
null
;
if
(
args
[
3
]!=
null
)
{
Class
<?>[]
paramTypes
=
null
;
String
[]
paramTypes_str
=
(
String
[])
args
[
3
];
if
(
args
[
3
]!=
null
)
{
if
(
paramTypes_str
.
length
>
0
)
{
String
[]
paramTypes_str
=
(
String
[])
args
[
3
];
paramTypes
=
new
Class
[
paramTypes_str
.
length
];
if
(
paramTypes_str
.
length
>
0
)
{
for
(
int
i
=
0
;
i
<
paramTypes_str
.
length
;
i
++)
{
paramTypes
=
new
Class
[
paramTypes_str
.
length
];
paramTypes
[
i
]
=
ClassUtil
.
resolveClass
(
paramTypes_str
[
i
]);
for
(
int
i
=
0
;
i
<
paramTypes_str
.
length
;
i
++)
{
paramTypes
[
i
]
=
ClassUtil
.
resolveClass
(
paramTypes_str
[
i
]);
}
}
}
}
}
className
=
(
String
)
args
[
0
];
varsion_
=
(
String
)
args
[
1
];
methodName
=
(
String
)
args
[
2
];
parameterTypes
=
paramTypes
;
parameters
=
(
Object
[])
args
[
4
];
}
}
// filters method like "Object.toString()"
className
=
(
String
)
args
[
0
];
if
(
className
.
equals
(
Object
.
class
.
getName
()))
{
varsion_
=
(
String
)
args
[
1
];
logger
.
info
(
">>>>>>>>>>> myth-rpc proxy class-method not support [{}#{}]"
,
className
,
methodName
);
methodName
=
(
String
)
args
[
2
];
throw
new
RpcException
(
"myth-rpc proxy class-method not support"
);
parameterTypes
=
paramTypes
;
}
parameters
=
(
Object
[])
args
[
4
];
}
// address
// filters method like "Object.toString()"
String
finalAddress
=
address
;
if
(
className
.
equals
(
Object
.
class
.
getName
()))
{
if
(
finalAddress
==
null
||
finalAddress
.
trim
().
length
()==
0
)
{
logger
.
info
(
">>>>>>>>>>> myth-rpc proxy class-method not support [{}#{}]"
,
className
,
methodName
);
if
(
invokerFactory
!=
null
&&
invokerFactory
.
getServiceRegistry
()!=
null
)
{
throw
new
RpcException
(
"myth-rpc proxy class-method not support"
);
// discovery
}
String
serviceKey
=
RpcProviderFactory
.
makeServiceKey
(
className
,
varsion_
);
TreeSet
<
String
>
addressSet
=
invokerFactory
.
getServiceRegistry
().
discovery
(
serviceKey
);
// load balance
if
(
addressSet
==
null
||
addressSet
.
size
()==
0
)
{
// pass
}
else
if
(
addressSet
.
size
()==
1
)
{
//TODO 这里就是根据路由规则选出的路由地址
finalAddress
=
addressSet
.
first
();
}
else
{
finalAddress
=
loadBalance
.
rpcInvokerRouter
.
route
(
serviceKey
,
addressSet
);
}
// address
String
finalAddress
=
address
;
if
(
finalAddress
==
null
||
finalAddress
.
trim
().
length
()==
0
)
{
if
(
invokerFactory
!=
null
&&
invokerFactory
.
getServiceRegistry
()!=
null
)
{
// discovery
String
serviceKey
=
RpcProviderFactory
.
makeServiceKey
(
className
,
varsion_
);
TreeSet
<
String
>
addressSet
=
invokerFactory
.
getServiceRegistry
().
discovery
(
serviceKey
);
// load balance
if
(
addressSet
==
null
||
addressSet
.
size
()==
0
)
{
// pass
}
else
if
(
addressSet
.
size
()==
1
)
{
//TODO 这里就是根据路由规则选出的路由地址
finalAddress
=
addressSet
.
first
();
}
else
{
finalAddress
=
loadBalance
.
rpcInvokerRouter
.
route
(
serviceKey
,
addressSet
);
}
}
}
}
if
(
finalAddress
==
null
||
finalAddress
.
trim
().
length
()==
0
)
{
}
throw
new
RpcException
(
"myth-rpc reference bean["
+
className
+
"] address empty"
);
if
(
finalAddress
==
null
||
finalAddress
.
trim
().
length
()==
0
)
{
}
throw
new
RpcException
(
"myth-rpc reference bean["
+
className
+
"] address empty"
);
}
// request
// request
RpcRequest
rpcRequest
=
new
RpcRequest
();
RpcRequest
rpcRequest
=
new
RpcRequest
();
rpcRequest
.
setRequestId
(
UUID
.
randomUUID
().
toString
());
rpcRequest
.
setRequestId
(
UUID
.
randomUUID
().
toString
());
rpcRequest
.
setCreateMillisTime
(
System
.
currentTimeMillis
());
rpcRequest
.
setCreateMillisTime
(
System
.
currentTimeMillis
());
rpcRequest
.
setAccessToken
(
accessToken
);
rpcRequest
.
setAccessToken
(
accessToken
);
rpcRequest
.
setClassName
(
className
);
rpcRequest
.
setClassName
(
className
);
rpcRequest
.
setMethodName
(
methodName
);
rpcRequest
.
setMethodName
(
methodName
);
rpcRequest
.
setParameterTypes
(
parameterTypes
);
rpcRequest
.
setParameterTypes
(
parameterTypes
);
rpcRequest
.
setParameters
(
parameters
);
rpcRequest
.
setParameters
(
parameters
);
// send
// send
if
(
CallType
.
SYNC
==
callType
)
{
if
(
CallType
.
SYNC
==
callType
)
{
// future-response set
// future-response set
RpcFutureResponse
futureResponse
=
new
RpcFutureResponse
(
invokerFactory
,
rpcRequest
,
null
);
RpcFutureResponse
futureResponse
=
new
RpcFutureResponse
(
invokerFactory
,
rpcRequest
,
null
);
try
{
try
{
// do invoke
// do invoke
client
.
asyncSend
(
finalAddress
,
rpcRequest
);
client
.
asyncSend
(
finalAddress
,
rpcRequest
);
// future get
// future get
RpcResponse
rpcResponse
=
futureResponse
.
get
(
timeout
,
TimeUnit
.
MILLISECONDS
);
RpcResponse
rpcResponse
=
futureResponse
.
get
(
timeout
,
TimeUnit
.
MILLISECONDS
);
if
(
rpcResponse
.
getErrorMsg
()
!=
null
)
{
if
(
rpcResponse
.
getErrorMsg
()
!=
null
)
{
throw
new
RpcException
(
rpcResponse
.
getErrorMsg
());
throw
new
RpcException
(
rpcResponse
.
getErrorMsg
());
}
return
rpcResponse
.
getResult
();
}
catch
(
Exception
e
)
{
logger
.
info
(
">>>>>>>>>>> myth-rpc, invoke error, address:{}, RpcRequest{}"
,
finalAddress
,
rpcRequest
);
throw
(
e
instanceof
RpcException
)?
e:
new
RpcException
(
e
);
}
finally
{
// future-response remove
futureResponse
.
removeInvokerFuture
();
}
}
else
if
(
CallType
.
FUTURE
==
callType
)
{
// future-response set
RpcFutureResponse
futureResponse
=
new
RpcFutureResponse
(
invokerFactory
,
rpcRequest
,
null
);
try
{
// invoke future set
RpcInvokeFuture
invokeFuture
=
new
RpcInvokeFuture
(
futureResponse
);
RpcInvokeFuture
.
setFuture
(
invokeFuture
);
// do invoke
client
.
asyncSend
(
finalAddress
,
rpcRequest
);
return
null
;
}
catch
(
Exception
e
)
{
logger
.
info
(
">>>>>>>>>>> myth-rpc, invoke error, address:{}, RpcRequest{}"
,
finalAddress
,
rpcRequest
);
// future-response remove
futureResponse
.
removeInvokerFuture
();
throw
(
e
instanceof
RpcException
)?
e:
new
RpcException
(
e
);
}
}
else
if
(
CallType
.
CALLBACK
==
callType
)
{
// get callback
RpcInvokeCallback
finalInvokeCallback
=
invokeCallback
;
RpcInvokeCallback
threadInvokeCallback
=
RpcInvokeCallback
.
getCallback
();
if
(
threadInvokeCallback
!=
null
)
{
finalInvokeCallback
=
threadInvokeCallback
;
}
if
(
finalInvokeCallback
==
null
)
{
throw
new
RpcException
(
"myth-rpc RpcInvokeCallback(CallType="
+
CallType
.
CALLBACK
.
name
()
+
") cannot be null."
);
}
}
return
rpcResponse
.
getResult
();
}
catch
(
Exception
e
)
{
logger
.
info
(
">>>>>>>>>>> myth-rpc, invoke error, address:{}, RpcRequest{}"
,
finalAddress
,
rpcRequest
);
throw
(
e
instanceof
RpcException
)?
e:
new
RpcException
(
e
);
}
finally
{
// future-response remove
futureResponse
.
removeInvokerFuture
();
}
}
else
if
(
CallType
.
FUTURE
==
callType
)
{
// future-response set
RpcFutureResponse
futureResponse
=
new
RpcFutureResponse
(
invokerFactory
,
rpcRequest
,
null
);
try
{
// invoke future set
RpcInvokeFuture
invokeFuture
=
new
RpcInvokeFuture
(
futureResponse
);
RpcInvokeFuture
.
setFuture
(
invokeFuture
);
// future-response set
// do invoke
RpcFutureResponse
futureResponse
=
new
RpcFutureResponse
(
invokerFactory
,
rpcRequest
,
finalInvokeCallback
);
client
.
asyncSend
(
finalAddress
,
rpcRequest
);
try
{
client
.
asyncSend
(
finalAddress
,
rpcRequest
);
}
catch
(
Exception
e
)
{
logger
.
info
(
">>>>>>>>>>> myth-rpc, invoke error, address:{}, RpcRequest{}"
,
finalAddress
,
rpcRequest
);
// future-response remove
return
null
;
futureResponse
.
removeInvokerFuture
();
}
catch
(
Exception
e
)
{
logger
.
info
(
">>>>>>>>>>> myth-rpc, invoke error, address:{}, RpcRequest{}"
,
finalAddress
,
rpcRequest
);
throw
(
e
instanceof
RpcException
)?
e:
new
RpcException
(
e
);
// future-response remove
}
futureResponse
.
removeInvokerFuture
();
throw
(
e
instanceof
RpcException
)?
e:
new
RpcException
(
e
);
}
}
else
if
(
CallType
.
CALLBACK
==
callType
)
{
return
null
;
// get callback
}
else
if
(
CallType
.
ONEWAY
==
callType
)
{
RpcInvokeCallback
finalInvokeCallback
=
invokeCallback
;
client
.
asyncSend
(
finalAddress
,
rpcRequest
);
RpcInvokeCallback
threadInvokeCallback
=
RpcInvokeCallback
.
getCallback
();
return
null
;
if
(
threadInvokeCallback
!=
null
)
{
}
else
{
finalInvokeCallback
=
threadInvokeCallback
;
throw
new
RpcException
(
"myth-rpc callType["
+
callType
+
"] invalid"
);
}
if
(
finalInvokeCallback
==
null
)
{
throw
new
RpcException
(
"myth-rpc RpcInvokeCallback(CallType="
+
CallType
.
CALLBACK
.
name
()
+
") cannot be null."
);
}
}
// future-response set
RpcFutureResponse
futureResponse
=
new
RpcFutureResponse
(
invokerFactory
,
rpcRequest
,
finalInvokeCallback
);
try
{
client
.
asyncSend
(
finalAddress
,
rpcRequest
);
}
catch
(
Exception
e
)
{
logger
.
info
(
">>>>>>>>>>> myth-rpc, invoke error, address:{}, RpcRequest{}"
,
finalAddress
,
rpcRequest
);
// future-response remove
futureResponse
.
removeInvokerFuture
();
throw
(
e
instanceof
RpcException
)?
e:
new
RpcException
(
e
);
}
return
null
;
}
else
if
(
CallType
.
ONEWAY
==
callType
)
{
client
.
asyncSend
(
finalAddress
,
rpcRequest
);
return
null
;
}
else
{
throw
new
RpcException
(
"myth-rpc callType["
+
callType
+
"] invalid"
);
}
}
});
});
}
}
...
...
byit-myth-rpc/src/main/java/com/byit/rpc/remoting/net/common/ConnectClient.java
View file @
fa323143
...
@@ -82,7 +82,7 @@ public abstract class ConnectClient {
...
@@ -82,7 +82,7 @@ public abstract class ConnectClient {
if
(
connectClient
!=
null
&&
connectClient
.
isValidate
())
{
if
(
connectClient
!=
null
&&
connectClient
.
isValidate
())
{
return
connectClient
;
return
connectClient
;
}
}
//获取对应地址的锁对象
// lock
// lock
Object
clientLock
=
connectClientLockMap
.
get
(
address
);
Object
clientLock
=
connectClientLockMap
.
get
(
address
);
if
(
clientLock
==
null
)
{
if
(
clientLock
==
null
)
{
...
...
demo-client/byit-demo-client/src/main/java/com/byit/job/AddComplexPy.java
View file @
fa323143
...
@@ -19,7 +19,7 @@ public class AddComplexPy {
...
@@ -19,7 +19,7 @@ public class AddComplexPy {
runNode
.
setNodeId
(
"2"
);
runNode
.
setNodeId
(
"2"
);
runNode
.
setNodeName
(
"lijkki"
);
runNode
.
setNodeName
(
"lijkki"
);
runNode
.
setRunCmd
(
"python ${biz_file}"
);
runNode
.
setRunCmd
(
"python ${biz_file}"
);
JobUtils
.
setRequestUrl
(
"http://1
27.0.0.1:8081/myth-job-admin
"
);
JobUtils
.
setRequestUrl
(
"http://1
0.0.120.208:8081/myth-job-admin/
"
);
JobUtils
.
setTOKEN
(
"test"
);
JobUtils
.
setTOKEN
(
"test"
);
JobUtils
.
realExectNode
(
runNode
);
JobUtils
.
realExectNode
(
runNode
);
/* PluginPackage pluginPackage = new PluginPackage();
/* PluginPackage pluginPackage = new PluginPackage();
...
...
demo-client/byit-demo-client/src/main/java/com/byit/job/AddComplexPy1.java
View file @
fa323143
...
@@ -16,7 +16,7 @@ public class AddComplexPy1 {
...
@@ -16,7 +16,7 @@ public class AddComplexPy1 {
PluginPackage
pluginPackage
=
new
PluginPackage
();
PluginPackage
pluginPackage
=
new
PluginPackage
();
pluginPackage
.
setWorkspaceName
(
"test"
);
pluginPackage
.
setWorkspaceName
(
"test"
);
pluginPackage
.
setFlow
(
createFlow
());
pluginPackage
.
setFlow
(
createFlow
());
JobUtils
.
setRequestUrl
(
"http://1
27.0.0.1
:8081/myth-job-admin"
);
JobUtils
.
setRequestUrl
(
"http://1
0.0.120.208
:8081/myth-job-admin"
);
JobUtils
.
setTOKEN
(
"test"
);
JobUtils
.
setTOKEN
(
"test"
);
JobUtils
.
publish
(
pluginPackage
);
JobUtils
.
publish
(
pluginPackage
);
}
}
...
...
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