Commit b7eea6f2 by huangfusuper

Rpc插件 客户端源码解析

parent 4a24f8ee
......@@ -23,4 +23,6 @@ spring:
host: 10.0.120.218
port: 6379
password:
authentication:
user:
pub-key: "huangfu"
......@@ -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()) {
......
......@@ -47,7 +47,7 @@ public abstract class ServiceRegistry {
public abstract boolean remove(Set<String> keys, String value);
/**
* discovery services, for mult
*多种发现服务
*
* @param keys
* @return
......
......@@ -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
......
......@@ -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);
......
......@@ -192,7 +192,7 @@ public class RpcProviderFactory {
}
/**
* make service key
* 制作服务密钥
*
* @param iface
* @param version
......
......@@ -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) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment