nettyrpc 与 zookeeper 集成日志

         context = new ClassPathXmlApplicationContext("classpath:rpc-invoke-config-jdbc-client.xml");
        MyPojo manage = (MyPojo) context.getBean("MyPojoJdbc");

        try {

            // 在这里,启动2个服务器
            List<Tao> list = manage.queryList();
            for (int i = 0; i < list.size(); i++) {
                System.out.println(list.get(i));
            }

            Thread.sleep(20000);

            // 关掉第一次请求的服务器
            list = manage.queryList();
            for (int i = 0; i < list.size(); i++) {
                System.out.println(list.get(i));
            }

            Thread.sleep(20000);

            // 开启第一次请求的服务器,关闭第2次请求的服务器
            list = manage.queryList();
            for (int i = 0; i < list.size(); i++) {
                System.out.println(list.get(i));
            }

        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            context.destroy();
        }


以上是客户端的代码,日志如下:

[INFO] {main} com.newlandframework.rpc.zookeeper.ServiceDiscovery.watchNode(117) | node data refresh: [192.168.31.104:18885, 192.168.31.104:18887]
[INFO] {Thread-2} com.newlandframework.rpc.zookeeper.ServiceDiscoveryThread.run(24) | start to refresh servers 1
[INFO] {Thread-2} com.newlandframework.rpc.netty.RpcServerLoader.loadAll(114) | discover new zookeeper node server : 192.168.31.104:18885
[author tangjie] Netty RPC Client start success!
ip:192.168.31.104
port:18885
protocol:RpcSerializeProtocol[serializeProtocol=protostuff,name=PROTOSTUFFSERIALIZE,ordinal=3]

[INFO] {Thread-2} com.newlandframework.rpc.netty.RpcServerLoader.loadAll(114) | discover new zookeeper node server : 192.168.31.104:18887
[author tangjie] Netty RPC Client start success!
ip:192.168.31.104
port:18887
protocol:RpcSerializeProtocol[serializeProtocol=protostuff,name=PROTOSTUFFSERIALIZE,ordinal=3]

[INFO] {Thread-2} com.newlandframework.rpc.zookeeper.ServiceDiscoveryThread.run(44) | end refresh servers 1
[INFO] {main} com.newlandframework.rpc.zookeeper.ServiceDiscovery.discover(78) | using random data: 192.168.31.104:18885
Tao <<col1:1 col2:22>>
[INFO] {main-EventThread} com.newlandframework.rpc.zookeeper.ServiceDiscovery.watchNode(117) | node data refresh: [192.168.31.104:18887]
[INFO] {Thread-3} com.newlandframework.rpc.zookeeper.ServiceDiscoveryThread.run(24) | start to refresh servers 2
[INFO] {Thread-3} com.newlandframework.rpc.zookeeper.ServiceDiscoveryThread.run(44) | end refresh servers 2
[INFO] {main} com.newlandframework.rpc.zookeeper.ServiceDiscovery.discover(75) | using only data: 192.168.31.104:18887
Tao <<col1:1 col2:22>>
[INFO] {main-EventThread} com.newlandframework.rpc.zookeeper.ServiceDiscovery.watchNode(117) | node data refresh: [192.168.31.104:18885, 192.168.31.104:18887]
[INFO] {Thread-4} com.newlandframework.rpc.zookeeper.ServiceDiscoveryThread.run(24) | start to refresh servers 3
[INFO] {Thread-4} com.newlandframework.rpc.netty.RpcServerLoader.loadAll(114) | discover new zookeeper node server : 192.168.31.104:18885
[author tangjie] Netty RPC Client start success!
ip:192.168.31.104
port:18885
protocol:RpcSerializeProtocol[serializeProtocol=protostuff,name=PROTOSTUFFSERIALIZE,ordinal=3]

[INFO] {Thread-4} com.newlandframework.rpc.zookeeper.ServiceDiscoveryThread.run(44) | end refresh servers 3
[INFO] {main-EventThread} com.newlandframework.rpc.zookeeper.ServiceDiscovery.watchNode(117) | node data refresh: [192.168.31.104:18885]
[INFO] {Thread-5} com.newlandframework.rpc.zookeeper.ServiceDiscoveryThread.run(24) | start to refresh servers 4
[INFO] {Thread-5} com.newlandframework.rpc.zookeeper.ServiceDiscoveryThread.run(44) | end refresh servers 4
[INFO] {main} com.newlandframework.rpc.zookeeper.ServiceDiscovery.discover(75) | using only data: 192.168.31.104:18885
Tao <<col1:1 col2:22>>

Process finished with exit code 0



[INFO] {main} com.newlandframework.rpc.zookeeper.ServiceDiscovery.watchNode(117) | node data refresh: [192.168.31.104:18885, 192.168.31.104:18887]

最初情况,启动两台服务器,分别是18885和18887端口,zookeeper最初情况下监测到两个可用节点


[INFO] {Thread-2} com.newlandframework.rpc.zookeeper.ServiceDiscoveryThread.run(24) | start to refresh servers 1

第一次开始构建netty通道


[INFO] {Thread-2} com.newlandframework.rpc.netty.RpcServerLoader.loadAll(114) | discover new zookeeper node server : 192.168.31.104:18885
[author tangjie] Netty RPC Client start success!
ip:192.168.31.104
port:18885
protocol:RpcSerializeProtocol[serializeProtocol=protostuff,name=PROTOSTUFFSERIALIZE,ordinal=3]

第一个通道,对18885端口服务器建立长连接通道



[INFO] {Thread-2} com.newlandframework.rpc.netty.RpcServerLoader.loadAll(114) | discover new zookeeper node server : 192.168.31.104:18887
[author tangjie] Netty RPC Client start success!
ip:192.168.31.104
port:18887
protocol:RpcSerializeProtocol[serializeProtocol=protostuff,name=PROTOSTUFFSERIALIZE,ordinal=3]

第二个通道,对18887端口服务器建立长连接通道



[INFO] {Thread-2} com.newlandframework.rpc.zookeeper.ServiceDiscoveryThread.run(44) | end refresh servers 1

第一次构建netty通道结束


[INFO] {main} com.newlandframework.rpc.zookeeper.ServiceDiscovery.discover(78) | using random data: 192.168.31.104:18885

客户端正式第一次请求,从两个节点种选中18885节点


Tao <<col1:1 col2:22>>

请求返回成功



[INFO] {main-EventThread} com.newlandframework.rpc.zookeeper.ServiceDiscovery.watchNode(117) | node data refresh: [192.168.31.104:18887]

乘主线程睡眠20秒期间手动关闭18885服务器,5秒后zookeeper通知客户端,重新监测可用节点,这里可见,仅剩余一个18887节点


[INFO] {Thread-3} com.newlandframework.rpc.zookeeper.ServiceDiscoveryThread.run(24) | start to refresh servers 2

开始第2构建netty通道,由于没有新节点可用,什么都不做


[INFO] {Thread-3} com.newlandframework.rpc.zookeeper.ServiceDiscoveryThread.run(44) | end refresh servers 2



[INFO] {main} com.newlandframework.rpc.zookeeper.ServiceDiscovery.discover(75) | using only data: 192.168.31.104:18887

第2次客户端请求,正常使用了仅有的一个zookeeper所返回的可用节点18887,这里一系列动作考察宕机后,客户端是否会规避该宕机的服务器


Tao <<col1:1 col2:22>>

第2次请求成功返回


[INFO] {main-EventThread} com.newlandframework.rpc.zookeeper.ServiceDiscovery.watchNode(117) | node data refresh: [192.168.31.104:18885, 192.168.31.104:18887]

乘第2次主线程睡眠,手动开启刚才关闭的18885节点服务器,5秒后zookeeper通知客户端重新监测可用节点,这里可见重新监测到2台服务器


[INFO] {Thread-4} com.newlandframework.rpc.zookeeper.ServiceDiscoveryThread.run(24) | start to refresh servers 3

第3构建netty通道


[INFO] {Thread-4} com.newlandframework.rpc.netty.RpcServerLoader.loadAll(114) | discover new zookeeper node server : 192.168.31.104:18885
[author tangjie] Netty RPC Client start success!
ip:192.168.31.104
port:18885
protocol:RpcSerializeProtocol[serializeProtocol=protostuff,name=PROTOSTUFFSERIALIZE,ordinal=3]

发现一个新节点,于是重新为该节点建立通道



[INFO] {Thread-4} com.newlandframework.rpc.zookeeper.ServiceDiscoveryThread.run(44) | end refresh servers 3

结束


[INFO] {main-EventThread} com.newlandframework.rpc.zookeeper.ServiceDiscovery.watchNode(117) | node data refresh: [192.168.31.104:18885]

刚才在开启18885服务器时,同时也关闭18887服务器,zookeeper也通知了重新监测可用节点的指令,于是重新监测,这里可见,18887已不可用


[INFO] {Thread-5} com.newlandframework.rpc.zookeeper.ServiceDiscoveryThread.run(24) | start to refresh servers 4

开始第4次netty通道建立,因为是干掉了18887,并没有新增节点,故什么也不干


[INFO] {Thread-5} com.newlandframework.rpc.zookeeper.ServiceDiscoveryThread.run(44) | end refresh servers 4



[INFO] {main} com.newlandframework.rpc.zookeeper.ServiceDiscovery.discover(75) | using only data: 192.168.31.104:18885

客户端第3次请求,选用了刚才关闭了,又重新开启的18885服务器所重新建立的netty通道


Tao <<col1:1 col2:22>>

第3次请求成功,这里一系列的动作考察宕机修复重新开启新增节点后客户端重新建立的netty通道是否可用


Process finished with exit code 0






弱点:

zookeeper自服务器宕机至5秒后重新建立netty通道成功期间,netty客户端的请求失败







将这种方式扩展多多台服务:


[NettyRPC 2.0,Build 2016/10/7,Author:tangjie http://www.cnblogs.com/jietang/]
ThreadPool Core[threads:16, queues:-1]
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/Users/sunyuming/.m2/repository/org/apache/logging/log4j/log4j-slf4j-impl/2.4.1/log4j-slf4j-impl-2.4.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/Users/sunyuming/.m2/repository/org/slf4j/slf4j-log4j12/1.6.1/slf4j-log4j12-1.6.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]
[INFO] {main} com.newlandframework.rpc.zookeeper.ServiceDiscovery.watchNode(120) | service[pj1] node data (total 2) refresh: [192.168.31.104:18887, 192.168.31.104:18885]
[INFO] {Thread-2} com.newlandframework.rpc.zookeeper.ServiceDiscoveryThread.run(29) | start to refresh servers [pj1]
[INFO] {Thread-2} com.newlandframework.rpc.netty.RpcServerLoader.loadAll(137) | discover new zookeeper node server : 192.168.31.104:18887:pj1
[INFO] {Thread-2} com.newlandframework.rpc.netty.RpcServerLoader.load(163) | [author tangjie] Netty RPC Client start success!
regName:pj1 ip:192.168.31.104 port:18887protocol:RpcSerializeProtocol[serializeProtocol=protostuff,name=PROTOSTUFFSERIALIZE,ordinal=3]
[INFO] {Thread-2} com.newlandframework.rpc.netty.RpcServerLoader.loadAll(137) | discover new zookeeper node server : 192.168.31.104:18885:pj1
[INFO] {Thread-2} com.newlandframework.rpc.netty.RpcServerLoader.load(163) | [author tangjie] Netty RPC Client start success!
regName:pj1 ip:192.168.31.104 port:18885protocol:RpcSerializeProtocol[serializeProtocol=protostuff,name=PROTOSTUFFSERIALIZE,ordinal=3]
[INFO] {Thread-2} com.newlandframework.rpc.zookeeper.ServiceDiscoveryThread.run(47) | end refresh servers [pj1]
set:192.168.31.104:18887:pj1:[id: 0x347500d1, L:/192.168.31.104:62431 - R:/192.168.31.104:18887]
set:192.168.31.104:18885:pj1:[id: 0x5d219b02, L:/192.168.31.104:62432 - R:/192.168.31.104:18885]
[INFO] {main} com.newlandframework.rpc.zookeeper.ServiceDiscovery.watchNode(120) | service[pj2] node data (total 2) refresh: [192.168.31.104:18897, 192.168.31.104:18895]
[INFO] {Thread-3} com.newlandframework.rpc.zookeeper.ServiceDiscoveryThread.run(29) | start to refresh servers [pj2]
[INFO] {Thread-3} com.newlandframework.rpc.netty.RpcServerLoader.loadAll(137) | discover new zookeeper node server : 192.168.31.104:18897:pj2
[INFO] {Thread-3} com.newlandframework.rpc.netty.RpcServerLoader.load(163) | [author tangjie] Netty RPC Client start success!
regName:pj2 ip:192.168.31.104 port:18897protocol:RpcSerializeProtocol[serializeProtocol=jdknative,name=JDKSERIALIZE,ordinal=0]
[INFO] {Thread-3} com.newlandframework.rpc.netty.RpcServerLoader.loadAll(137) | discover new zookeeper node server : 192.168.31.104:18895:pj2
[INFO] {Thread-3} com.newlandframework.rpc.netty.RpcServerLoader.load(163) | [author tangjie] Netty RPC Client start success!
regName:pj2 ip:192.168.31.104 port:18895protocol:RpcSerializeProtocol[serializeProtocol=jdknative,name=JDKSERIALIZE,ordinal=0]
[INFO] {Thread-3} com.newlandframework.rpc.zookeeper.ServiceDiscoveryThread.run(47) | end refresh servers [pj2]
set:192.168.31.104:18897:pj2:[id: 0x879af2a0, L:/192.168.31.104:62433 - R:/192.168.31.104:18897]
set:192.168.31.104:18895:pj2:[id: 0x25c16cd0, L:/192.168.31.104:62434 - R:/192.168.31.104:18895]
[INFO] {main} com.newlandframework.rpc.zookeeper.ServiceDiscovery.discover(81) | using random data: 192.168.31.104:18885
get:192.168.31.104:18885:pj1:[id: 0x5d219b02, L:/192.168.31.104:62432 - R:/192.168.31.104:18885]
Tao <<col1:1 col2:pj122>>
[INFO] {main} com.newlandframework.rpc.zookeeper.ServiceDiscovery.discover(81) | using random data: 192.168.31.104:18897
get:192.168.31.104:18897:pj2:[id: 0x879af2a0, L:/192.168.31.104:62433 - R:/192.168.31.104:18897]
Tao <<col1:1 col2:pj222>>
[INFO] {main-EventThread} com.newlandframework.rpc.zookeeper.ServiceDiscovery.watchNode(120) | service[pj1] node data (total 1) refresh: [192.168.31.104:18887]
[INFO] {Thread-4} com.newlandframework.rpc.zookeeper.ServiceDiscoveryThread.run(29) | start to refresh servers [pj1]
[INFO] {Thread-4} com.newlandframework.rpc.zookeeper.ServiceDiscoveryThread.run(47) | end refresh servers [pj1]
[INFO] {main-EventThread} com.newlandframework.rpc.zookeeper.ServiceDiscovery.watchNode(120) | service[pj2] node data (total 1) refresh: [192.168.31.104:18895]
[INFO] {Thread-5} com.newlandframework.rpc.zookeeper.ServiceDiscoveryThread.run(29) | start to refresh servers [pj2]
[INFO] {Thread-5} com.newlandframework.rpc.zookeeper.ServiceDiscoveryThread.run(47) | end refresh servers [pj2]
[INFO] {main} com.newlandframework.rpc.zookeeper.ServiceDiscovery.discover(78) | using only data: 192.168.31.104:18887
get:192.168.31.104:18887:pj1:[id: 0x347500d1, L:/192.168.31.104:62431 - R:/192.168.31.104:18887]
Tao <<col1:1 col2:pj122>>
[INFO] {main} com.newlandframework.rpc.zookeeper.ServiceDiscovery.discover(78) | using only data: 192.168.31.104:18895
get:192.168.31.104:18895:pj2:[id: 0x25c16cd0, L:/192.168.31.104:62434 - R:/192.168.31.104:18895]
Tao <<col1:1 col2:pj222>>
[INFO] {main-EventThread} com.newlandframework.rpc.zookeeper.ServiceDiscovery.watchNode(120) | service[pj2] node data (total 2) refresh: [192.168.31.104:18895, 192.168.31.104:18897]
[INFO] {Thread-6} com.newlandframework.rpc.zookeeper.ServiceDiscoveryThread.run(29) | start to refresh servers [pj2]
[INFO] {Thread-6} com.newlandframework.rpc.netty.RpcServerLoader.loadAll(137) | discover new zookeeper node server : 192.168.31.104:18897:pj2
[INFO] {Thread-6} com.newlandframework.rpc.netty.RpcServerLoader.load(163) | [author tangjie] Netty RPC Client start success!
regName:pj2 ip:192.168.31.104 port:18897protocol:RpcSerializeProtocol[serializeProtocol=jdknative,name=JDKSERIALIZE,ordinal=0]
[INFO] {Thread-6} com.newlandframework.rpc.zookeeper.ServiceDiscoveryThread.run(47) | end refresh servers [pj2]
set:192.168.31.104:18897:pj2:[id: 0xc1792485, L:/192.168.31.104:62456 - R:/192.168.31.104:18897]
[INFO] {main-EventThread} com.newlandframework.rpc.zookeeper.ServiceDiscovery.watchNode(120) | service[pj1] node data (total 2) refresh: [192.168.31.104:18887, 192.168.31.104:18885]
[INFO] {Thread-7} com.newlandframework.rpc.zookeeper.ServiceDiscoveryThread.run(29) | start to refresh servers [pj1]
[INFO] {Thread-7} com.newlandframework.rpc.netty.RpcServerLoader.loadAll(137) | discover new zookeeper node server : 192.168.31.104:18885:pj1
[INFO] {Thread-7} com.newlandframework.rpc.netty.RpcServerLoader.load(163) | [author tangjie] Netty RPC Client start success!
regName:pj1 ip:192.168.31.104 port:18885protocol:RpcSerializeProtocol[serializeProtocol=protostuff,name=PROTOSTUFFSERIALIZE,ordinal=3]
[INFO] {Thread-7} com.newlandframework.rpc.zookeeper.ServiceDiscoveryThread.run(47) | end refresh servers [pj1]
set:192.168.31.104:18885:pj1:[id: 0xc2a6e7d7, L:/192.168.31.104:62460 - R:/192.168.31.104:18885]
[INFO] {main-EventThread} com.newlandframework.rpc.zookeeper.ServiceDiscovery.watchNode(120) | service[pj1] node data (total 1) refresh: [192.168.31.104:18885]
[INFO] {Thread-8} com.newlandframework.rpc.zookeeper.ServiceDiscoveryThread.run(29) | start to refresh servers [pj1]
[INFO] {Thread-8} com.newlandframework.rpc.zookeeper.ServiceDiscoveryThread.run(47) | end refresh servers [pj1]
[INFO] {main-EventThread} com.newlandframework.rpc.zookeeper.ServiceDiscovery.watchNode(120) | service[pj2] node data (total 1) refresh: [192.168.31.104:18897]
[INFO] {Thread-9} com.newlandframework.rpc.zookeeper.ServiceDiscoveryThread.run(29) | start to refresh servers [pj2]
[INFO] {Thread-9} com.newlandframework.rpc.zookeeper.ServiceDiscoveryThread.run(47) | end refresh servers [pj2]
[INFO] {main} com.newlandframework.rpc.zookeeper.ServiceDiscovery.discover(78) | using only data: 192.168.31.104:18885
get:192.168.31.104:18885:pj1:[id: 0xc2a6e7d7, L:/192.168.31.104:62460 - R:/192.168.31.104:18885]
Tao <<col1:1 col2:pj122>>
[INFO] {main} com.newlandframework.rpc.zookeeper.ServiceDiscovery.discover(78) | using only data: 192.168.31.104:18897
get:192.168.31.104:18897:pj2:[id: 0xc1792485, L:/192.168.31.104:62456 - R:/192.168.31.104:18897]
Tao <<col1:1 col2:pj222>>



分析:


pj1和pj2两个服务


#pj1 使用 18887和18885 端口,protostuff建立服务
#pj2 使用 18897和18895 端口,jdk建立服务


[NettyRPC 2.0,Build 2016/10/7,Author:tangjie http://www.cnblogs.com/jietang/]
ThreadPool Core[threads:16, queues:-1]
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/Users/sunyuming/.m2/repository/org/apache/logging/log4j/log4j-slf4j-impl/2.4.1/log4j-slf4j-impl-2.4.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/Users/sunyuming/.m2/repository/org/slf4j/slf4j-log4j12/1.6.1/slf4j-log4j12-1.6.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]




[INFO] {main} com.newlandframework.rpc.zookeeper.ServiceDiscovery.watchNode(120) | service[pj1] node data (total 2) refresh: [192.168.31.104:18887, 192.168.31.104:18885]
[INFO] {Thread-2} com.newlandframework.rpc.zookeeper.ServiceDiscoveryThread.run(29) | start to refresh servers [pj1]


[INFO] {Thread-2} com.newlandframework.rpc.netty.RpcServerLoader.loadAll(137) | discover new zookeeper node server : 192.168.31.104:18887:pj1
[INFO] {Thread-2} com.newlandframework.rpc.netty.RpcServerLoader.load(163) | [author tangjie] Netty RPC Client start success!
regName:pj1 ip:192.168.31.104 port:18887protocol:RpcSerializeProtocol[serializeProtocol=protostuff,name=PROTOSTUFFSERIALIZE,ordinal=3]


[INFO] {Thread-2} com.newlandframework.rpc.netty.RpcServerLoader.loadAll(137) | discover new zookeeper node server : 192.168.31.104:18885:pj1
[INFO] {Thread-2} com.newlandframework.rpc.netty.RpcServerLoader.load(163) | [author tangjie] Netty RPC Client start success!
regName:pj1 ip:192.168.31.104 port:18885protocol:RpcSerializeProtocol[serializeProtocol=protostuff,name=PROTOSTUFFSERIALIZE,ordinal=3]


[INFO] {Thread-2} com.newlandframework.rpc.zookeeper.ServiceDiscoveryThread.run(47) | end refresh servers [pj1]



set:192.168.31.104:18887:pj1:[id: 0x347500d1, L:/192.168.31.104:62431 - R:/192.168.31.104:18887]
set:192.168.31.104:18885:pj1:[id: 0x5d219b02, L:/192.168.31.104:62432 - R:/192.168.31.104:18885]



[INFO] {main} com.newlandframework.rpc.zookeeper.ServiceDiscovery.watchNode(120) | service[pj2] node data (total 2) refresh: [192.168.31.104:18897, 192.168.31.104:18895]
[INFO] {Thread-3} com.newlandframework.rpc.zookeeper.ServiceDiscoveryThread.run(29) | start to refresh servers [pj2]


[INFO] {Thread-3} com.newlandframework.rpc.netty.RpcServerLoader.loadAll(137) | discover new zookeeper node server : 192.168.31.104:18897:pj2
[INFO] {Thread-3} com.newlandframework.rpc.netty.RpcServerLoader.load(163) | [author tangjie] Netty RPC Client start success!
regName:pj2 ip:192.168.31.104 port:18897protocol:RpcSerializeProtocol[serializeProtocol=jdknative,name=JDKSERIALIZE,ordinal=0]


[INFO] {Thread-3} com.newlandframework.rpc.netty.RpcServerLoader.loadAll(137) | discover new zookeeper node server : 192.168.31.104:18895:pj2
[INFO] {Thread-3} com.newlandframework.rpc.netty.RpcServerLoader.load(163) | [author tangjie] Netty RPC Client start success!
regName:pj2 ip:192.168.31.104 port:18895protocol:RpcSerializeProtocol[serializeProtocol=jdknative,name=JDKSERIALIZE,ordinal=0]


[INFO] {Thread-3} com.newlandframework.rpc.zookeeper.ServiceDiscoveryThread.run(47) | end refresh servers [pj2]



set:192.168.31.104:18897:pj2:[id: 0x879af2a0, L:/192.168.31.104:62433 - R:/192.168.31.104:18897]
set:192.168.31.104:18895:pj2:[id: 0x25c16cd0, L:/192.168.31.104:62434 - R:/192.168.31.104:18895]


总共建立4条通道



[INFO] {main} com.newlandframework.rpc.zookeeper.ServiceDiscovery.discover(81) | using random data: 192.168.31.104:18885
get:192.168.31.104:18885:pj1:[id: 0x5d219b02, L:/192.168.31.104:62432 - R:/192.168.31.104:18885]
Tao <<col1:1 col2:pj122>>
[INFO] {main} com.newlandframework.rpc.zookeeper.ServiceDiscovery.discover(81) | using random data: 192.168.31.104:18897
get:192.168.31.104:18897:pj2:[id: 0x879af2a0, L:/192.168.31.104:62433 - R:/192.168.31.104:18897]
Tao <<col1:1 col2:pj222>>


干掉 蓝色的两台服务器,zk通知客户端



[INFO] {main-EventThread} com.newlandframework.rpc.zookeeper.ServiceDiscovery.watchNode(120) | service[pj1] node data (total 1) refresh: [192.168.31.104:18887]
[INFO] {Thread-4} com.newlandframework.rpc.zookeeper.ServiceDiscoveryThread.run(29) | start to refresh servers [pj1]
[INFO] {Thread-4} com.newlandframework.rpc.zookeeper.ServiceDiscoveryThread.run(47) | end refresh servers [pj1]
[INFO] {main-EventThread} com.newlandframework.rpc.zookeeper.ServiceDiscovery.watchNode(120) | service[pj2] node data (total 1) refresh: [192.168.31.104:18895]
[INFO] {Thread-5} com.newlandframework.rpc.zookeeper.ServiceDiscoveryThread.run(29) | start to refresh servers [pj2]
[INFO] {Thread-5} com.newlandframework.rpc.zookeeper.ServiceDiscoveryThread.run(47) | end refresh servers [pj2]


干掉两台第1次请求的服务器,没有新服务器什么都不干


[INFO] {main} com.newlandframework.rpc.zookeeper.ServiceDiscovery.discover(78) | using only data: 192.168.31.104:18887
get:192.168.31.104:18887:pj1:[id: 0x347500d1, L:/192.168.31.104:62431 - R:/192.168.31.104:18887]
Tao <<col1:1 col2:pj122>>
[INFO] {main} com.newlandframework.rpc.zookeeper.ServiceDiscovery.discover(78) | using only data: 192.168.31.104:18895
get:192.168.31.104:18895:pj2:[id: 0x25c16cd0, L:/192.168.31.104:62434 - R:/192.168.31.104:18895]
Tao <<col1:1 col2:pj222>>


重启192.168.31.104:18885,192.168.31.104:18897


[INFO] {main-EventThread} com.newlandframework.rpc.zookeeper.ServiceDiscovery.watchNode(120) | service[pj2] node data (total 2) refresh: [192.168.31.104:18895, 192.168.31.104:18897]
[INFO] {Thread-6} com.newlandframework.rpc.zookeeper.ServiceDiscoveryThread.run(29) | start to refresh servers [pj2]
[INFO] {Thread-6} com.newlandframework.rpc.netty.RpcServerLoader.loadAll(137) | discover new zookeeper node server : 192.168.31.104:18897:pj2(发现pj2下一台新服务)
[INFO] {Thread-6} com.newlandframework.rpc.netty.RpcServerLoader.load(163) | [author tangjie] Netty RPC Client start success!
regName:pj2 ip:192.168.31.104 port:18897protocol:RpcSerializeProtocol[serializeProtocol=jdknative,name=JDKSERIALIZE,ordinal=0]
[INFO] {Thread-6} com.newlandframework.rpc.zookeeper.ServiceDiscoveryThread.run(47) | end refresh servers [pj2]
set:192.168.31.104:18897:pj2:[id: 0xc1792485, L:/192.168.31.104:62456 - R:/192.168.31.104:18897]    (新的通道)
[INFO] {main-EventThread} com.newlandframework.rpc.zookeeper.ServiceDiscovery.watchNode(120) | service[pj1] node data (total 2) refresh: [192.168.31.104:18887, 192.168.31.104:18885]
[INFO] {Thread-7} com.newlandframework.rpc.zookeeper.ServiceDiscoveryThread.run(29) | start to refresh servers [pj1]
[INFO] {Thread-7} com.newlandframework.rpc.netty.RpcServerLoader.loadAll(137) | discover new zookeeper node server : 192.168.31.104:18885:pj1(发现pj1下一台新服务)
[INFO] {Thread-7} com.newlandframework.rpc.netty.RpcServerLoader.load(163) | [author tangjie] Netty RPC Client start success!
regName:pj1 ip:192.168.31.104 port:18885protocol:RpcSerializeProtocol[serializeProtocol=protostuff,name=PROTOSTUFFSERIALIZE,ordinal=3]
[INFO] {Thread-7} com.newlandframework.rpc.zookeeper.ServiceDiscoveryThread.run(47) | end refresh servers [pj1]
set:192.168.31.104:18885:pj1:[id: 0xc2a6e7d7, L:/192.168.31.104:62460 - R:/192.168.31.104:18885]    (新的通道)


下面一部分干掉两台第2次请求的服务器192.168.31.104:18887,192.168.31.104:18895    (为了强制客户端discover使用重启服务并重建通道的192.168.31.104:18885,192.168.31.104:18897


[INFO] {main-EventThread} com.newlandframework.rpc.zookeeper.ServiceDiscovery.watchNode(120) | service[pj1] node data (total 1) refresh: [192.168.31.104:18885]
[INFO] {Thread-8} com.newlandframework.rpc.zookeeper.ServiceDiscoveryThread.run(29) | start to refresh servers [pj1]
[INFO] {Thread-8} com.newlandframework.rpc.zookeeper.ServiceDiscoveryThread.run(47) | end refresh servers [pj1]
[INFO] {main-EventThread} com.newlandframework.rpc.zookeeper.ServiceDiscovery.watchNode(120) | service[pj2] node data (total 1) refresh: [192.168.31.104:18897]
[INFO] {Thread-9} com.newlandframework.rpc.zookeeper.ServiceDiscoveryThread.run(29) | start to refresh servers [pj2]
[INFO] {Thread-9} com.newlandframework.rpc.zookeeper.ServiceDiscoveryThread.run(47) | end refresh servers [pj2]


没有新增,什么都不干(因为时差的关系)


[INFO] {main} com.newlandframework.rpc.zookeeper.ServiceDiscovery.discover(78) | using only data: 192.168.31.104:18885
get:192.168.31.104:18885:pj1:[id: 0xc2a6e7d7, L:/192.168.31.104:62460 - R:/192.168.31.104:18885]
Tao <<col1:1 col2:pj122>>
[INFO] {main} com.newlandframework.rpc.zookeeper.ServiceDiscovery.discover(78) | using only data: 192.168.31.104:18897
get:192.168.31.104:18897:pj2:[id: 0xc1792485, L:/192.168.31.104:62456 - R:/192.168.31.104:18897]
Tao <<col1:1 col2:pj222>>

posted on 2017-12-26 16:50  silyvin  阅读(390)  评论(0编辑  收藏  举报