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
b7eea6f2
Commit
b7eea6f2
authored
Apr 07, 2020
by
huangfusuper
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rpc插件 客户端源码解析
parent
4a24f8ee
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
17 additions
and
6 deletions
+17
-6
application-local.yml
...-executor-server/src/main/resources/application-local.yml
+3
-1
RegistryClient.java
...rc/main/java/com/byit/registry/client/RegistryClient.java
+2
-2
ServiceRegistry.java
.../src/main/java/com/byit/rpc/registry/ServiceRegistry.java
+1
-1
RpcSpringInvokerFactory.java
...it/rpc/remoting/invoker/impl/RpcSpringInvokerFactory.java
+2
-1
RpcReferenceBean.java
...byit/rpc/remoting/invoker/reference/RpcReferenceBean.java
+1
-0
RpcProviderFactory.java
...va/com/byit/rpc/remoting/provider/RpcProviderFactory.java
+1
-1
DataSourceServiceRegistry.java
...ain/java/com/byit/registry/DataSourceServiceRegistry.java
+7
-0
No files found.
byit-myth-executor/myth-executor-server/src/main/resources/application-local.yml
View file @
b7eea6f2
...
...
@@ -23,4 +23,6 @@ spring:
host
:
10.0.120.218
port
:
6379
password
:
authentication
:
user
:
pub-key
:
"
huangfu"
byit-myth-register/myth-register-client/src/main/java/com/byit/registry/client/RegistryClient.java
View file @
b7eea6f2
...
...
@@ -63,7 +63,7 @@ public class RegistryClient {
registryThread
.
setDaemon
(
true
);
registryThread
.
start
();
//
discovery thread
//
发现线程 这一步猜测 应该是为了不间断的查询数据库 并且发现线程
discoveryThread
=
new
Thread
(
new
Runnable
()
{
@Override
public
void
run
()
{
...
...
@@ -230,7 +230,7 @@ public class RegistryClient {
// discovery mult
Map
<
String
,
TreeSet
<
String
>>
updatedData
=
new
HashMap
<>();
//这一步似乎查询了什么
Map
<
String
,
TreeSet
<
String
>>
keyValueListData
=
registryBaseClient
.
discovery
(
keys
);
if
(
keyValueListData
!=
null
)
{
for
(
String
keyItem:
keyValueListData
.
keySet
())
{
...
...
byit-myth-rpc/src/main/java/com/byit/rpc/registry/ServiceRegistry.java
View file @
b7eea6f2
...
...
@@ -47,7 +47,7 @@ public abstract class ServiceRegistry {
public
abstract
boolean
remove
(
Set
<
String
>
keys
,
String
value
);
/**
*
discovery services, for mult
*
多种发现服务
*
* @param keys
* @return
...
...
byit-myth-rpc/src/main/java/com/byit/rpc/remoting/invoker/impl/RpcSpringInvokerFactory.java
View file @
b7eea6f2
...
...
@@ -51,6 +51,7 @@ public class RpcSpringInvokerFactory extends InstantiationAwareBeanPostProcessor
public
void
afterPropertiesSet
()
throws
Exception
{
// start invoker factory
rpcInvokerFactory
=
new
RpcInvokerFactory
(
serviceRegistryClass
,
serviceRegistryParam
);
//这一步实际上是将数据库对象实例化了出来
rpcInvokerFactory
.
start
();
}
...
...
@@ -87,7 +88,7 @@ public class RpcSpringInvokerFactory extends InstantiationAwareBeanPostProcessor
null
,
rpcInvokerFactory
);
//获取一个代理对象
//获取一个代理对象
这个代理对象传入了 rpcInvokerFactory
Object
serviceProxy
=
referenceBean
.
getObject
();
// set bean
...
...
byit-myth-rpc/src/main/java/com/byit/rpc/remoting/invoker/reference/RpcReferenceBean.java
View file @
b7eea6f2
...
...
@@ -124,6 +124,7 @@ public class RpcReferenceBean {
private
void
initClient
()
{
try
{
client
=
netType
.
clientClass
.
newInstance
();
//他将自己当做对象传递 自己的对象包好rpcInvokerFactory对象 这里又存在发送信息的方法 钩子方法
client
.
init
(
this
);
}
catch
(
InstantiationException
|
IllegalAccessException
e
)
{
throw
new
RpcException
(
e
);
...
...
byit-myth-rpc/src/main/java/com/byit/rpc/remoting/provider/RpcProviderFactory.java
View file @
b7eea6f2
...
...
@@ -192,7 +192,7 @@ public class RpcProviderFactory {
}
/**
*
make service key
*
制作服务密钥
*
* @param iface
* @param version
...
...
byit-plugin-core/byit-plugin-rpc-common/src/main/java/com/byit/registry/DataSourceServiceRegistry.java
View file @
b7eea6f2
...
...
@@ -26,6 +26,13 @@ public class DataSourceServiceRegistry extends PluginServiceRegistry {
registryClient
=
new
RegistryClient
(
registryUrl
,
null
,
biz
,
env
);
}
public
static
void
main
(
String
[]
args
)
{
RegistryClient
registryClient
=
new
RegistryClient
(
"http://localhost:8080/myth-register"
,
null
,
"byit-myth-job"
,
"plugin_test"
);
TreeSet
<
String
>
discovery
=
registryClient
.
discovery
(
"01Test"
);
System
.
out
.
println
(
discovery
);
}
@Override
public
void
stop
()
{
if
(
registryClient
!=
null
)
{
...
...
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