├── .gitignore ├── LICENSE ├── README.md ├── docs ├── Spring配置.md ├── 入门实例.md ├── 官方文档.docx └── 官方文档.pdf ├── hasting-cluster ├── README.md ├── doc │ ├── README.md │ └── rpc-doc.pdf ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── lindzh │ │ │ └── hasting │ │ │ └── cluster │ │ │ ├── JSONUtils.java │ │ │ ├── MD5Utils.java │ │ │ ├── MessageListener.java │ │ │ ├── ProtostuffUtils.java │ │ │ ├── RpcClusterConst.java │ │ │ ├── RpcClusterUtils.java │ │ │ ├── RpcMessage.java │ │ │ ├── admin │ │ │ ├── RpcAdminService.java │ │ │ └── SimpleRpcAdminService.java │ │ │ ├── etcd │ │ │ ├── EtcdRpcAdminService.java │ │ │ ├── EtcdRpcClient.java │ │ │ ├── EtcdRpcClientExecutor.java │ │ │ ├── EtcdRpcServer.java │ │ │ └── EtcdUtils.java │ │ │ ├── hash │ │ │ ├── Hashing.java │ │ │ ├── RandomHashing.java │ │ │ └── RoundRobinHashing.java │ │ │ ├── limit │ │ │ ├── LimitCache.java │ │ │ ├── LimitConst.java │ │ │ ├── LimitDefine.java │ │ │ └── LimitFilter.java │ │ │ ├── redis │ │ │ ├── JedisCallback.java │ │ │ ├── RedisRpcAdminService.java │ │ │ ├── RedisRpcClient.java │ │ │ ├── RedisRpcClientExecutor.java │ │ │ ├── RedisRpcServer.java │ │ │ ├── RedisUtils.java │ │ │ ├── RpcJedisDelegatePool.java │ │ │ └── SimpleJedisPubListener.java │ │ │ ├── serializer │ │ │ ├── HessianSerializer.java │ │ │ ├── JSONSerializer.java │ │ │ ├── ProtostuffSerializer.java │ │ │ └── simple │ │ │ │ ├── SimpleConst.java │ │ │ │ ├── SimpleInput.java │ │ │ │ ├── SimpleOutput.java │ │ │ │ ├── SimpleSerializer.java │ │ │ │ └── SimpleType.java │ │ │ ├── store │ │ │ └── ConfStoreService.java │ │ │ └── zk │ │ │ ├── ZKUtils.java │ │ │ ├── ZkRpcAdminService.java │ │ │ ├── ZkRpcClient.java │ │ │ ├── ZkRpcClientExecutor.java │ │ │ └── ZkRpcServer.java │ └── resources │ │ └── log4j.properties │ └── test │ └── java │ └── com │ └── lindzh │ └── hasting │ └── cluster │ ├── HelloRpcService.java │ ├── HelloRpcServiceImpl.java │ ├── HelloRpcTestService.java │ ├── HelloRpcTestServiceImpl.java │ ├── LoginRpcService.java │ ├── LoginRpcServiceImpl.java │ ├── TestBean.java │ ├── TestRemoteBean.java │ ├── etcd │ ├── EtcdClientTest.java │ ├── EtcdRpcAdminTest.java │ ├── EtcdServerTest.java │ └── Etcdtest.java │ ├── generic │ ├── EtcdGenericServiceTest.java │ ├── GenericClientTest.java │ └── RedisGenericServiceTest.java │ ├── redis │ ├── RedisSubscribeMonitor.java │ ├── RpcJedisClientTest.java │ ├── RpcJedisClusterTest.java │ └── RpcRedisAdminServiceTest.java │ ├── serialize │ ├── AbstractSerializer.java │ ├── HessianTest.java │ ├── JSONSerializerTest.java │ ├── ProtostuffTest.java │ ├── SerializeTest.java │ ├── SimpleoutTest.java │ └── ZipSerializeTest.java │ ├── simple │ ├── LimitBuilder.java │ ├── SimpleAdminTest.java │ ├── SimpleRpcClientTest.java │ ├── SimpleRpcServerTest.java │ └── SimpleRpcTest.java │ └── zk │ ├── RpcZkAdminTest.java │ ├── RpcZkClientTest.java │ └── RpcZkServerTest.java ├── hasting-netty ├── README.md ├── pom.xml └── src │ ├── main │ └── java │ │ └── com │ │ └── lindzh │ │ └── hasting │ │ └── netty │ │ ├── NettyUtils.java │ │ ├── RpcNettyAcceptor.java │ │ ├── RpcNettyConnector.java │ │ ├── codec │ │ ├── RpcNettyDecoder.java │ │ └── RpcNettyEncoder.java │ │ └── handler │ │ └── NettyRpcInBoundHandler.java │ └── test │ └── java │ └── com │ └── lindzh │ └── hasting │ └── netty │ ├── AppTest.java │ ├── HelloRpcService.java │ ├── HelloRpcServiceImpl.java │ ├── LoginRpcService.java │ ├── LoginRpcServiceImpl.java │ ├── NettyClientTest.java │ ├── NettyServerTest.java │ ├── TestBean.java │ ├── TestRemoteBean.java │ └── generic │ ├── GenericClientTest.java │ └── GenericServerTest.java ├── hasting-rpc ├── README.md ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── lindzh │ │ │ └── hasting │ │ │ └── rpc │ │ │ ├── RemoteCall.java │ │ │ ├── RemoteExecutor.java │ │ │ ├── RpcCallSync.java │ │ │ ├── RpcContext.java │ │ │ ├── RpcObject.java │ │ │ ├── RpcService.java │ │ │ ├── RpcServiceBean.java │ │ │ ├── Service.java │ │ │ ├── aio │ │ │ ├── RpcAcceptCompletionHandler.java │ │ │ ├── RpcAioAcceptor.java │ │ │ ├── RpcAioConnector.java │ │ │ ├── RpcAioWriter.java │ │ │ ├── RpcReadCompletionHandler.java │ │ │ └── RpcWriteCompletionHandler.java │ │ │ ├── client │ │ │ ├── AbstractClientRemoteExecutor.java │ │ │ ├── AbstractRpcClient.java │ │ │ ├── MultiClientRemoteExecutor.java │ │ │ ├── MultiRpcClient.java │ │ │ ├── SimpleClientRemoteExecutor.java │ │ │ ├── SimpleClientRemoteProxy.java │ │ │ └── SimpleRpcClient.java │ │ │ ├── cluster1 │ │ │ ├── AbstractRpcClusterClientExecutor.java │ │ │ ├── ConsumeRpcObject.java │ │ │ ├── HostWeight.java │ │ │ ├── RpcClusterClient.java │ │ │ ├── RpcClusterServer.java │ │ │ ├── RpcHostAndPort.java │ │ │ └── TokenFilter.java │ │ │ ├── exception │ │ │ ├── RpcException.java │ │ │ ├── RpcExceptionHandler.java │ │ │ ├── RpcNetExceptionHandler.java │ │ │ └── SimpleRpcExceptionHandler.java │ │ │ ├── filter │ │ │ ├── RpcFilter.java │ │ │ ├── RpcFilterChain.java │ │ │ ├── RpcStatFilter.java │ │ │ ├── SimpleLogFilter.java │ │ │ └── SimpleRpcFilterChain.java │ │ │ ├── generic │ │ │ ├── ArgsParser.java │ │ │ ├── GenericService.java │ │ │ ├── SimpleArgsParser.java │ │ │ └── SimpleGenericService.java │ │ │ ├── monitor │ │ │ ├── RpcMonitorService.java │ │ │ ├── RpcMonitorServiceImpl.java │ │ │ └── StatMonitor.java │ │ │ ├── net │ │ │ ├── AbstractRpcAcceptor.java │ │ │ ├── AbstractRpcConnector.java │ │ │ ├── AbstractRpcNetworkBase.java │ │ │ ├── AbstractRpcWriter.java │ │ │ ├── RpcCallListener.java │ │ │ ├── RpcMultiConnector.java │ │ │ ├── RpcNetBase.java │ │ │ ├── RpcNetListener.java │ │ │ ├── RpcOutputNofity.java │ │ │ └── RpcSender.java │ │ │ ├── nio │ │ │ ├── AbstractRpcNioSelector.java │ │ │ ├── ConcurrentRpcNioSelector.java │ │ │ ├── RpcNioAcceptor.java │ │ │ ├── RpcNioBuffer.java │ │ │ ├── RpcNioConnector.java │ │ │ └── SimpleRpcNioSelector.java │ │ │ ├── oio │ │ │ ├── AbstractRpcOioWriter.java │ │ │ ├── PooledRpcOioWriter.java │ │ │ ├── RpcOioAcceptor.java │ │ │ ├── RpcOioConnector.java │ │ │ └── SimpleRpcOioWriter.java │ │ │ ├── serializer │ │ │ ├── JdkSerializer.java │ │ │ └── RpcSerializer.java │ │ │ ├── server │ │ │ ├── AbstractRpcServer.java │ │ │ ├── ConcurrentRpcServer.java │ │ │ ├── RpcServiceProvider.java │ │ │ ├── RpcServicesHolder.java │ │ │ ├── SimpleRpcServer.java │ │ │ └── SimpleServerRemoteExecutor.java │ │ │ ├── sync │ │ │ ├── RpcSync.java │ │ │ ├── SimpleFutureRpcSync.java │ │ │ └── SimpleJdkRpcSync.java │ │ │ └── utils │ │ │ ├── NioUtils.java │ │ │ ├── RpcUtils.java │ │ │ ├── SSLUtils.java │ │ │ ├── XAliasUtils.java │ │ │ ├── XName.java │ │ │ └── XNamespace.java │ ├── resources │ │ └── log4j.properties │ └── script │ │ ├── client.sh │ │ ├── log4j.properties │ │ └── server.sh │ └── test │ └── java │ └── com │ └── lindzh │ └── hasting │ ├── cluster │ ├── SimpleClientTest.java │ └── SimpleClusterExecutor.java │ └── rpc │ ├── HelloRpcService.java │ ├── HelloRpcServiceImpl.java │ ├── HelloRpcTestService.java │ ├── HelloRpcTestServiceImpl.java │ ├── HostTest.java │ ├── LoginRpcService.java │ ├── LoginRpcServiceImpl.java │ ├── MyTestRpcFilter.java │ ├── RpcLoginCheckFilter.java │ ├── RpcTestNioClient.java │ ├── RpcTestNioServer.java │ ├── RpcTestOioClient.java │ ├── RpcTestOioServer.java │ ├── TestBean.java │ ├── TestRemoteBean.java │ ├── aio │ ├── ClientTest.java │ ├── Sender.java │ ├── ServerTest.java │ ├── SimpleAioConnector.java │ ├── SimpleAioEchoService.java │ ├── SocketAcceptHandler.java │ ├── SocketReadHandler.java │ └── SocketWriteHandler.java │ ├── aiorpc │ ├── AioClientTest.java │ └── AioServerTest.java │ ├── generic │ ├── GenericClientTest.java │ ├── GenericParserTest.java │ ├── GenericServerTest.java │ └── RpcContextClearFilter.java │ ├── nio │ ├── MyBuftest.java │ ├── NioByteBufferTest.java │ ├── NioTestClient.java │ └── NioTestServer.java │ ├── serialize │ ├── BeanSizeTest.java │ ├── HelloBean.java │ ├── SerializeTest.java │ └── ZipSerializeTest.java │ └── service │ ├── RpcClientTest.java │ ├── RpcServerTest.java │ └── StatisticsFilter.java ├── hasting-spring ├── README.md ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── lindzh │ │ │ └── hasting │ │ │ └── spring │ │ │ ├── annotation │ │ │ ├── RpcInvokerService.java │ │ │ ├── RpcProviderFilter.java │ │ │ └── RpcProviderService.java │ │ │ ├── invoker │ │ │ ├── RpcAnnotationInvokerClassFilter.java │ │ │ ├── RpcInvokerAnnotationConfigurer.java │ │ │ ├── RpcInvokerAnnotationScanner.java │ │ │ ├── RpcInvokerClassFilter.java │ │ │ └── RpcInvokerFactoryBean.java │ │ │ └── provider │ │ │ └── RpcProviderProcessor.java │ └── resources │ │ ├── log4j.properties │ │ ├── rpc-invoker-config.xml │ │ └── rpc-provider-config.xml │ └── test │ ├── java │ └── com │ │ └── lindzh │ │ └── hasting │ │ └── spring │ │ ├── AbstractTestCase.java │ │ ├── RpcInvokerTestCase.java │ │ ├── RpcProviderTestCase.java │ │ ├── filter │ │ └── RpcTestFilter.java │ │ ├── impl │ │ ├── HelloRpcServiceImpl.java │ │ ├── HelloRpcTestServiceImpl.java │ │ └── LoginRpcServiceImpl.java │ │ └── test │ │ ├── CallService.java │ │ ├── HelloRpcService.java │ │ ├── HelloRpcTestService.java │ │ ├── LoginRpcService.java │ │ ├── TestBean.java │ │ └── TestRemoteBean.java │ └── resources │ ├── rpc-invoker-config-backup.xml │ └── rpc-provider-config-backup.xml ├── hasting-webui ├── README.md ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── lindzh │ │ │ └── hasting │ │ │ └── webui │ │ │ ├── biz │ │ │ ├── AppService.java │ │ │ ├── ConsumerService.java │ │ │ ├── HostService.java │ │ │ ├── LimitService.java │ │ │ ├── ProviderService.java │ │ │ └── ServiceInfoService.java │ │ │ ├── controller │ │ │ ├── AppController.java │ │ │ ├── BasicController.java │ │ │ ├── HealthServlet.java │ │ │ ├── HostController.java │ │ │ ├── LimitController.java │ │ │ ├── ServiceController.java │ │ │ ├── StaticController.java │ │ │ └── WeightController.java │ │ │ ├── dao │ │ │ ├── AppInfoDao.java │ │ │ ├── HostInfoDao.java │ │ │ ├── LimitInfoDao.java │ │ │ ├── ServiceConsumerInfoDao.java │ │ │ ├── ServiceInfoDao.java │ │ │ └── ServiceProviderInfoDao.java │ │ │ ├── manager │ │ │ └── ManagerService.java │ │ │ ├── pojo │ │ │ ├── AppInfo.java │ │ │ ├── HostInfo.java │ │ │ ├── LimitInfo.java │ │ │ ├── ServiceConsumerInfo.java │ │ │ ├── ServiceInfo.java │ │ │ └── ServiceProviderInfo.java │ │ │ ├── service │ │ │ ├── RpcConfig.java │ │ │ ├── RpcFetchService.java │ │ │ ├── RpcInfoListener.java │ │ │ ├── RpcWebuiService.java │ │ │ └── RpcWebuiServiceImpl.java │ │ │ ├── servlet │ │ │ ├── EncodingFilter.java │ │ │ ├── FreemarkerService.java │ │ │ ├── FtlDateParser.java │ │ │ ├── RpcWebuiController.java │ │ │ ├── ServletExceptionHandler.java │ │ │ ├── ServletUtils.java │ │ │ ├── SimpleServletExceptionHandler.java │ │ │ └── WebuiServlet.java │ │ │ └── utils │ │ │ ├── BizException.java │ │ │ ├── CollectionUtils.java │ │ │ ├── ConUtils.java │ │ │ ├── Const.java │ │ │ ├── DTOUtils.java │ │ │ ├── PackUtils.java │ │ │ └── RpcTransaction.java │ ├── resources │ │ ├── conf.properties │ │ ├── console.sql │ │ ├── log4j.properties │ │ ├── mybatis-config.xml │ │ ├── spring-admin.xml │ │ ├── spring-mvc.xml │ │ ├── sqlmap │ │ │ ├── AppInfoDao.xml │ │ │ ├── HostInfoDao.xml │ │ │ ├── LimitInfoDao.xml │ │ │ ├── ServiceConsumerInfoDao.xml │ │ │ ├── ServiceInfoDao.xml │ │ │ └── ServiceProviderInfoDao.xml │ │ └── webui.json │ └── webapp │ │ ├── WEB-INF │ │ ├── classes │ │ │ ├── com │ │ │ │ └── linda │ │ │ │ │ └── rpc │ │ │ │ │ └── webui │ │ │ │ │ ├── biz │ │ │ │ │ ├── AppService.class │ │ │ │ │ ├── ConsumerService.class │ │ │ │ │ ├── HostService.class │ │ │ │ │ ├── LimitService.class │ │ │ │ │ ├── ProviderService.class │ │ │ │ │ └── ServiceInfoService.class │ │ │ │ │ ├── controller │ │ │ │ │ ├── AppController.class │ │ │ │ │ ├── BasicController.class │ │ │ │ │ ├── HealthServlet.class │ │ │ │ │ ├── HostController.class │ │ │ │ │ ├── LimitController$1.class │ │ │ │ │ ├── LimitController.class │ │ │ │ │ ├── ServiceController.class │ │ │ │ │ ├── StaticController.class │ │ │ │ │ ├── WeightController$1.class │ │ │ │ │ └── WeightController.class │ │ │ │ │ ├── dao │ │ │ │ │ ├── AppInfoDao.class │ │ │ │ │ ├── HostInfoDao.class │ │ │ │ │ ├── LimitInfoDao.class │ │ │ │ │ ├── ServiceConsumerInfoDao.class │ │ │ │ │ ├── ServiceInfoDao.class │ │ │ │ │ └── ServiceProviderInfoDao.class │ │ │ │ │ ├── manager │ │ │ │ │ └── ManagerService.class │ │ │ │ │ ├── pojo │ │ │ │ │ ├── AppInfo.class │ │ │ │ │ ├── HostInfo.class │ │ │ │ │ ├── LimitInfo.class │ │ │ │ │ ├── ServiceConsumerInfo.class │ │ │ │ │ ├── ServiceInfo.class │ │ │ │ │ └── ServiceProviderInfo.class │ │ │ │ │ ├── service │ │ │ │ │ ├── RpcConfig$RpcProtocol.class │ │ │ │ │ ├── RpcConfig.class │ │ │ │ │ ├── RpcFetchService$1.class │ │ │ │ │ ├── RpcFetchService$2.class │ │ │ │ │ ├── RpcFetchService.class │ │ │ │ │ ├── RpcInfoListener.class │ │ │ │ │ ├── RpcWebuiService.class │ │ │ │ │ └── RpcWebuiServiceImpl.class │ │ │ │ │ ├── servlet │ │ │ │ │ ├── EncodingFilter.class │ │ │ │ │ ├── FreemarkerService.class │ │ │ │ │ ├── FtlDateParser.class │ │ │ │ │ ├── RpcWebuiController.class │ │ │ │ │ ├── ServletExceptionHandler.class │ │ │ │ │ ├── ServletUtils.class │ │ │ │ │ ├── SimpleServletExceptionHandler.class │ │ │ │ │ ├── WebuiServlet$1.class │ │ │ │ │ └── WebuiServlet.class │ │ │ │ │ └── utils │ │ │ │ │ ├── BizException.class │ │ │ │ │ ├── CollectionUtils.class │ │ │ │ │ ├── ConUtils.class │ │ │ │ │ ├── Const.class │ │ │ │ │ ├── DTOUtils.class │ │ │ │ │ ├── PackUtils.class │ │ │ │ │ └── RpcTransaction.class │ │ │ ├── conf.properties │ │ │ ├── console.sql │ │ │ ├── log4j.properties │ │ │ ├── mybatis-config.xml │ │ │ ├── spring-admin.xml │ │ │ ├── spring-mvc.xml │ │ │ ├── sqlmap │ │ │ │ ├── AppInfoDao.xml │ │ │ │ ├── HostInfoDao.xml │ │ │ │ ├── LimitInfoDao.xml │ │ │ │ ├── ServiceConsumerInfoDao.xml │ │ │ │ ├── ServiceInfoDao.xml │ │ │ │ └── ServiceProviderInfoDao.xml │ │ │ └── webui.json │ │ ├── lib │ │ │ ├── aopalliance-1.0.jar │ │ │ ├── aspectjweaver-1.8.4.jar │ │ │ ├── commons-codec-1.6.jar │ │ │ ├── commons-fileupload-1.3.1.jar │ │ │ ├── commons-io-2.4.jar │ │ │ ├── commons-lang-2.6.jar │ │ │ ├── commons-lang3-3.3.2.jar │ │ │ ├── commons-logging-1.1.3.jar │ │ │ ├── commons-pool2-2.0.jar │ │ │ ├── curator-client-2.7.1.jar │ │ │ ├── curator-framework-2.7.1.jar │ │ │ ├── druid-1.0.12.jar │ │ │ ├── framework-rpc-0.1.2-SNAPSHOT.jar │ │ │ ├── framework-rpc-cluster-0.0.2-SNAPSHOT.jar │ │ │ ├── freemarker-2.3.20.jar │ │ │ ├── guava-14.0.1.jar │ │ │ ├── httpasyncclient-4.0-beta4.jar │ │ │ ├── httpclient-4.3-beta1.jar │ │ │ ├── httpcore-4.3-beta2.jar │ │ │ ├── httpcore-nio-4.3-beta2.jar │ │ │ ├── jackson-annotations-2.2.0.jar │ │ │ ├── jackson-core-2.2.0.jar │ │ │ ├── jackson-databind-2.2.0.jar │ │ │ ├── javax.servlet-api-3.1.0.jar │ │ │ ├── jedis-2.5.2.jar │ │ │ ├── jetcd-0.0.1-SNAPSHOT.jar │ │ │ ├── jline-0.9.94.jar │ │ │ ├── log4j-1.2.16.jar │ │ │ ├── lombok-1.16.2.jar │ │ │ ├── mybatis-3.2.8.jar │ │ │ ├── mybatis-generator-1.0.3.jar │ │ │ ├── mybatis-spring-1.2.2.jar │ │ │ ├── mysql-connector-java-5.1.34.jar │ │ │ ├── netty-3.7.0.Final.jar │ │ │ ├── objenesis-2.1.jar │ │ │ ├── ognl-2.6.9.jar │ │ │ ├── protostuff-api-1.0.8.jar │ │ │ ├── protostuff-collectionschema-1.0.8.jar │ │ │ ├── protostuff-core-1.0.8.jar │ │ │ ├── protostuff-runtime-1.0.8.jar │ │ │ ├── quartz-1.8.6.jar │ │ │ ├── slf4j-api-1.6.0.jar │ │ │ ├── spring-aop-3.2.15.RELEASE.jar │ │ │ ├── spring-beans-3.2.15.RELEASE.jar │ │ │ ├── spring-context-3.2.15.RELEASE.jar │ │ │ ├── spring-context-support-3.2.15.RELEASE.jar │ │ │ ├── spring-core-3.2.15.RELEASE.jar │ │ │ ├── spring-expression-3.2.15.RELEASE.jar │ │ │ ├── spring-jdbc-3.2.15.RELEASE.jar │ │ │ ├── spring-oxm-3.2.15.RELEASE.jar │ │ │ ├── spring-tx-3.2.15.RELEASE.jar │ │ │ ├── spring-web-3.2.15.RELEASE.jar │ │ │ ├── spring-webmvc-3.2.15.RELEASE.jar │ │ │ ├── xpp3_min-1.1.4c.jar │ │ │ ├── xstream-1.3.1.jar │ │ │ └── zookeeper-3.4.6.jar │ │ ├── template │ │ │ ├── 404.ftl │ │ │ ├── app_consumers.ftl │ │ │ ├── app_detail.ftl │ │ │ ├── app_edit.ftl │ │ │ ├── app_list.ftl │ │ │ ├── configs.ftl │ │ │ ├── host_detail.ftl │ │ │ ├── host_list.ftl │ │ │ ├── host_services.ftl │ │ │ ├── hosts.ftl │ │ │ ├── limit_detail.ftl │ │ │ ├── limit_edit.ftl │ │ │ ├── limit_list.ftl │ │ │ ├── navbar.ftl │ │ │ ├── service_detail.ftl │ │ │ ├── service_hosts.ftl │ │ │ ├── service_list.ftl │ │ │ ├── services.ftl │ │ │ ├── weight_edit.ftl │ │ │ ├── weight_list.ftl │ │ │ └── wrap │ │ │ │ └── navbar.ftl │ │ ├── web.xml │ │ └── web2.xml │ │ ├── bootstrap │ │ ├── css │ │ │ ├── bootstrap-theme.css │ │ │ ├── bootstrap-theme.css.map │ │ │ ├── bootstrap-theme.min.css │ │ │ ├── bootstrap.css │ │ │ ├── bootstrap.css.map │ │ │ ├── bootstrap.min.css │ │ │ └── tt.css │ │ ├── fonts │ │ │ ├── glyphicons-halflings-regular.eot │ │ │ ├── glyphicons-halflings-regular.svg │ │ │ ├── glyphicons-halflings-regular.ttf │ │ │ ├── glyphicons-halflings-regular.woff │ │ │ └── glyphicons-halflings-regular.woff2 │ │ └── js │ │ │ ├── bootstrap.js │ │ │ ├── bootstrap.min.js │ │ │ └── npm.js │ │ ├── css │ │ └── webui.css │ │ ├── images │ │ └── github.jpg │ │ ├── jquery │ │ ├── additional-methods.js │ │ ├── jquery-2.1.3.min.js │ │ ├── jquery-upload.min.js │ │ ├── jquery.base64.js │ │ ├── jquery.form.js │ │ ├── jquery.md5.js │ │ ├── jquery.sha1.js │ │ └── jquery.validate.js │ │ └── js │ │ └── weight.js │ └── test │ └── java │ └── com │ └── lindzh │ └── hasting │ └── webui │ ├── AbstractTestCase.java │ ├── AppTest.java │ ├── AtoGenDao.java │ ├── RpcConfigGen.java │ └── SimpleTest.java └── pom.xml /.gitignore: -------------------------------------------------------------------------------- 1 | *dependency-reduced-pom.xml 2 | .classpath 3 | .project 4 | .settings/ 5 | target/ 6 | devenv 7 | *.log* 8 | *.iml 9 | .idea/ 10 | *.versionsBackup 11 | !NOTICE-BIN 12 | !LICENSE-BIN 13 | .DS_Store -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Copyright (c) 2013-1018 lindzh, lindzh.com 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy 5 | of this software and associated documentation files (the "Software"), to deal 6 | in the Software without restriction, including without limitation the rights 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the Software is 9 | furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in 12 | all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | THE SOFTWARE. -------------------------------------------------------------------------------- /docs/官方文档.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/docs/官方文档.docx -------------------------------------------------------------------------------- /docs/官方文档.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/docs/官方文档.pdf -------------------------------------------------------------------------------- /hasting-cluster/README.md: -------------------------------------------------------------------------------- 1 | ##### Hasting分布式服务化框架 集群支持组件 2 | -------------------------------------------------------------------------------- /hasting-cluster/doc/rpc-doc.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-cluster/doc/rpc-doc.pdf -------------------------------------------------------------------------------- /hasting-cluster/src/main/java/com/lindzh/hasting/cluster/MessageListener.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.cluster; 2 | 3 | 4 | /** 5 | * 6 | * @author lindezhi 7 | * 消息监听器,方便接收消息提供给上层 8 | */ 9 | public interface MessageListener { 10 | 11 | public void onMessage(RpcMessage message); 12 | 13 | } 14 | -------------------------------------------------------------------------------- /hasting-cluster/src/main/java/com/lindzh/hasting/cluster/RpcClusterConst.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.cluster; 2 | 3 | /** 4 | * 5 | * @author lindezhi 6 | * 集群对象key 7 | */ 8 | public interface RpcClusterConst { 9 | 10 | public static final String RPC_REDIS_CHANNEL = "rpc_cluster_notify_channel"; 11 | 12 | public static final String RPC_REDIS_HOSTS_KEY = "rpc_cluster_hosts"; 13 | 14 | public static final String RPC_REDIS_SERVER_SERVICE_PREFIX = "rpc_cluster_node_"; 15 | 16 | public static final int RPC_REDIS_TTL = 10000; 17 | 18 | public static final int CODE_SERVER_START = 100; 19 | 20 | public static final int CODE_SERVER_STOP = 200; 21 | 22 | public static final int CODE_SERVER_ADD_RPC = 300; 23 | 24 | public static final int CODE_SERVER_HEART = 400; 25 | 26 | } 27 | -------------------------------------------------------------------------------- /hasting-cluster/src/main/java/com/lindzh/hasting/cluster/RpcClusterUtils.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.cluster; 2 | 3 | import com.lindzh.hasting.rpc.cluster1.RpcHostAndPort; 4 | 5 | import java.util.HashSet; 6 | import java.util.List; 7 | import java.util.Set; 8 | 9 | public class RpcClusterUtils { 10 | 11 | public static Set toString(List hostAndPorts){ 12 | Set set = new HashSet(); 13 | for(RpcHostAndPort hap:hostAndPorts){ 14 | set.add(hap.toString()); 15 | } 16 | return set; 17 | } 18 | 19 | public static RpcHostAndPort genConsumerInfo(String application,String ip){ 20 | RpcHostAndPort rpcHostAndPort = new RpcHostAndPort(); 21 | rpcHostAndPort.setToken("simple"); 22 | rpcHostAndPort.setApplication(application); 23 | rpcHostAndPort.setWeight(100); 24 | rpcHostAndPort.setPort(100); 25 | rpcHostAndPort.setHost(ip); 26 | rpcHostAndPort.setTime(System.currentTimeMillis()); 27 | return rpcHostAndPort; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /hasting-cluster/src/main/java/com/lindzh/hasting/cluster/RpcMessage.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.cluster; 2 | 3 | public class RpcMessage { 4 | 5 | private int messageType; 6 | 7 | private T message; 8 | 9 | public RpcMessage(){ 10 | 11 | } 12 | 13 | public RpcMessage(int messageType,T message){ 14 | this.messageType = messageType; 15 | this.message = message; 16 | } 17 | 18 | public int getMessageType() { 19 | return messageType; 20 | } 21 | 22 | public void setMessageType(int messageType) { 23 | this.messageType = messageType; 24 | } 25 | 26 | public T getMessage() { 27 | return message; 28 | } 29 | 30 | public void setMessage(T message) { 31 | this.message = message; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /hasting-cluster/src/main/java/com/lindzh/hasting/cluster/admin/RpcAdminService.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.cluster.admin; 2 | 3 | import java.util.List; 4 | 5 | import com.lindzh.hasting.rpc.RpcService; 6 | import com.lindzh.hasting.rpc.Service; 7 | import com.lindzh.hasting.rpc.cluster1.ConsumeRpcObject; 8 | import com.lindzh.hasting.rpc.cluster1.RpcHostAndPort; 9 | import com.lindzh.hasting.rpc.cluster1.HostWeight; 10 | import com.lindzh.hasting.cluster.limit.LimitDefine; 11 | import com.lindzh.hasting.rpc.serializer.RpcSerializer; 12 | 13 | public abstract class RpcAdminService implements Service{ 14 | 15 | public abstract List getRpcServers(); 16 | 17 | public abstract List getRpcServices(RpcHostAndPort rpcServer); 18 | 19 | public abstract String getNamespace(); 20 | 21 | public abstract void setNamespace(String namespace); 22 | 23 | public abstract void setSerializer(RpcSerializer serializer); 24 | 25 | /** 26 | * 获取权重列表 27 | * @param application 28 | * @return 29 | */ 30 | public abstract List getWeights(String application); 31 | 32 | /** 33 | * 设置权重列表 34 | * @param application 35 | * @param weight 36 | */ 37 | public abstract void setWeight(String application,HostWeight weight); 38 | 39 | public abstract List getConsumers(String group, String service, String version); 40 | 41 | public abstract void setLimits(String application,List limits); 42 | 43 | } 44 | -------------------------------------------------------------------------------- /hasting-cluster/src/main/java/com/lindzh/hasting/cluster/etcd/EtcdRpcClient.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.cluster.etcd; 2 | 3 | import com.lindzh.hasting.rpc.client.AbstractClientRemoteExecutor; 4 | import com.lindzh.hasting.rpc.cluster1.RpcClusterClient; 5 | 6 | public class EtcdRpcClient extends RpcClusterClient { 7 | 8 | private String etcdUrl; 9 | 10 | private String namespace; 11 | 12 | private EtcdRpcClientExecutor executor; 13 | 14 | public String getEtcdUrl() { 15 | return etcdUrl; 16 | } 17 | 18 | public void setEtcdUrl(String etcdUrl) { 19 | this.etcdUrl = etcdUrl; 20 | } 21 | 22 | public String getNamespace() { 23 | return namespace; 24 | } 25 | 26 | public void setNamespace(String namespace) { 27 | this.namespace = namespace; 28 | } 29 | 30 | @Override 31 | public T register(Class iface, String version, String group) { 32 | this.checkExecutor(); 33 | return super.register(iface, version, group); 34 | } 35 | 36 | private void checkExecutor(){ 37 | if(executor==null){ 38 | executor = new EtcdRpcClientExecutor(); 39 | executor.setEtcdUrl(etcdUrl); 40 | if(namespace!=null){ 41 | executor.setNamespace(namespace); 42 | } 43 | super.setRemoteExecutor(executor); 44 | } 45 | } 46 | 47 | @Override 48 | public AbstractClientRemoteExecutor getRemoteExecutor() { 49 | this.checkExecutor(); 50 | return executor; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /hasting-cluster/src/main/java/com/lindzh/hasting/cluster/etcd/EtcdUtils.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.cluster.etcd; 2 | 3 | /** 4 | * Created by Administrator on 2017/2/15. 5 | */ 6 | public class EtcdUtils { 7 | 8 | /** 9 | * 限流配置 10 | * @return 11 | */ 12 | public static String genLimitKey(String namespace,String application){ 13 | return "/"+namespace+"/limit/" + application; 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /hasting-cluster/src/main/java/com/lindzh/hasting/cluster/hash/Hashing.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.cluster.hash; 2 | 3 | import com.lindzh.hasting.cluster.JSONUtils; 4 | import com.lindzh.hasting.rpc.cluster1.RpcHostAndPort; 5 | import com.lindzh.hasting.rpc.exception.RpcException; 6 | 7 | import java.util.ArrayList; 8 | import java.util.List; 9 | 10 | /** 11 | * 12 | * @author lindezhi 13 | * 集群hashing 服务端列表支持 14 | * 需求:需要增加权重 15 | */ 16 | public abstract class Hashing { 17 | 18 | /** 19 | * 通过权重过滤,权重<0表示禁止访问 20 | * @param servers 21 | * @return 22 | */ 23 | protected List filterServers(List servers){ 24 | ArrayList list = new ArrayList(); 25 | 26 | for(RpcHostAndPort server:servers){ 27 | if(server.getWeight()>0){ 28 | list.add(server); 29 | } 30 | } 31 | 32 | return list; 33 | } 34 | 35 | 36 | public abstract String doHash(List servers); 37 | 38 | /** 39 | * 通过权重过滤 40 | * @param servers 41 | * @return 42 | */ 43 | public String hash(List servers){ 44 | if(servers!=null){ 45 | System.out.println(JSONUtils.toJSON(servers)); 46 | List fServers = this.filterServers(servers); 47 | if(fServers.size()<1){ 48 | throw new RpcException("no provider use for the request weight limited"); 49 | } 50 | if(fServers.size()==1){ 51 | return fServers.get(0).toString(); 52 | } 53 | String result = this.doHash(fServers); 54 | return result; 55 | }else{ 56 | throw new RpcException("no provider use for the request,no servers"); 57 | } 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /hasting-cluster/src/main/java/com/lindzh/hasting/cluster/hash/RandomHashing.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.cluster.hash; 2 | 3 | import com.lindzh.hasting.rpc.cluster1.RpcHostAndPort; 4 | import com.lindzh.hasting.rpc.exception.RpcException; 5 | 6 | import java.util.List; 7 | import java.util.Random; 8 | 9 | /** 10 | * 11 | * @author lindezhi 12 | * 随机服务器hash 13 | */ 14 | public class RandomHashing extends Hashing{ 15 | 16 | private Random random = new Random(); 17 | 18 | @Override 19 | public String doHash(List servers) { 20 | int sum = 0; 21 | for(RpcHostAndPort server:servers){ 22 | sum += server.getWeight(); 23 | } 24 | 25 | int idx = random.nextInt(sum); 26 | 27 | for(RpcHostAndPort server:servers){ 28 | idx = idx-server.getWeight(); 29 | if(idx<0){ 30 | return server.toString(); 31 | } 32 | } 33 | throw new RpcException("no provider use random hash do hash"); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /hasting-cluster/src/main/java/com/lindzh/hasting/cluster/limit/LimitConst.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.cluster.limit; 2 | 3 | /** 4 | * Created by lin on 2017/1/24. 5 | * 说明:限流全都在方法上 6 | */ 7 | public class LimitConst { 8 | 9 | /** 10 | * 全局限流 11 | */ 12 | public static final int LIMIT_ALL = 0; 13 | 14 | /** 15 | * service限流 16 | */ 17 | public static final int LIMIT_SERVICE = 1; 18 | 19 | /** 20 | * 方法限流 21 | */ 22 | public static final int LIMIT_METHOD = 2; 23 | 24 | 25 | /** 26 | * 指定应用限流 27 | */ 28 | public static final int LIMIT_APP_ALL = 10; 29 | 30 | /** 31 | * 指定应用限流 32 | */ 33 | public static final int LIMIT_APP_SERVICE = 11; 34 | 35 | /** 36 | * 指定应用限流 37 | */ 38 | public static final int LIMIT_APP_METHOD = 12; 39 | 40 | public static final String SYSTEM_LIMIT = "SYSTEM_DEFAULT"; 41 | 42 | public static final String OUTER_LIMIT = "OUTER_DEFAULT"; 43 | } 44 | -------------------------------------------------------------------------------- /hasting-cluster/src/main/java/com/lindzh/hasting/cluster/limit/LimitFilter.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.cluster.limit; 2 | 3 | import com.lindzh.hasting.rpc.RemoteCall; 4 | import com.lindzh.hasting.rpc.RpcContext; 5 | import com.lindzh.hasting.rpc.RpcObject; 6 | import com.lindzh.hasting.rpc.exception.RpcException; 7 | import com.lindzh.hasting.rpc.filter.RpcFilter; 8 | import com.lindzh.hasting.rpc.filter.RpcFilterChain; 9 | import com.lindzh.hasting.rpc.net.RpcSender; 10 | import org.apache.log4j.Logger; 11 | 12 | /** 13 | * Created by lin on 2017/1/24. 14 | * 限流 15 | */ 16 | public class LimitFilter implements RpcFilter { 17 | 18 | private Logger logger = Logger.getLogger("rpcCluster"); 19 | 20 | private LimitCache limitCache; 21 | 22 | public LimitFilter(LimitCache limitCache){ 23 | this.limitCache = limitCache; 24 | } 25 | 26 | @Override 27 | public void doFilter(RpcObject rpc, RemoteCall call, RpcSender sender, RpcFilterChain chain) { 28 | if(limitCache!=null){ 29 | String application = (String)RpcContext.getContext().getAttachment("Application"); 30 | boolean accept = limitCache.accept(application, call.getService(), call.getMethod()); 31 | if(accept){ 32 | chain.nextFilter(rpc, call, sender); 33 | }else{ 34 | throw new RpcException("request limited ,service is too busy"); 35 | } 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /hasting-cluster/src/main/java/com/lindzh/hasting/cluster/redis/JedisCallback.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.cluster.redis; 2 | 3 | import redis.clients.jedis.Jedis; 4 | 5 | /** 6 | * 7 | * @author lindezhi 8 | * redis unsafe call back 9 | */ 10 | public interface JedisCallback { 11 | 12 | public Object callback(Jedis jedis); 13 | 14 | } 15 | -------------------------------------------------------------------------------- /hasting-cluster/src/main/java/com/lindzh/hasting/cluster/serializer/ProtostuffSerializer.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.cluster.serializer; 2 | 3 | import java.io.Serializable; 4 | 5 | import com.lindzh.hasting.cluster.ProtostuffUtils; 6 | import com.lindzh.hasting.rpc.serializer.RpcSerializer; 7 | 8 | public class ProtostuffSerializer implements RpcSerializer { 9 | 10 | private static class ProtostuffObject implements Serializable{ 11 | 12 | private static final long serialVersionUID = -1518242254508266543L; 13 | private Object refer; 14 | 15 | } 16 | 17 | @Override 18 | public byte[] serialize(Object obj) { 19 | ProtostuffObject stuff = new ProtostuffObject(); 20 | stuff.refer = obj; 21 | return ProtostuffUtils.serialize(stuff); 22 | } 23 | 24 | @Override 25 | public Object deserialize(byte[] bytes) { 26 | ProtostuffObject stuff = ProtostuffUtils.deserialize(bytes, ProtostuffObject.class); 27 | return stuff.refer; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /hasting-cluster/src/main/java/com/lindzh/hasting/cluster/serializer/simple/SimpleSerializer.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.cluster.serializer.simple; 2 | 3 | import com.lindzh.hasting.rpc.exception.RpcException; 4 | import com.lindzh.hasting.rpc.serializer.RpcSerializer; 5 | 6 | import java.io.*; 7 | 8 | /** 9 | * Created by lin on 2016/12/2. 10 | * 跨语言序列化 11 | */ 12 | public class SimpleSerializer implements RpcSerializer{ 13 | 14 | @Override 15 | public byte[] serialize(Object obj) { 16 | SimpleOutput out = new SimpleOutput(obj); 17 | try { 18 | byte[] result = out.writeObject(); 19 | return result; 20 | } catch (IOException e) { 21 | throw new RpcException(e); 22 | } 23 | } 24 | 25 | @Override 26 | public Object deserialize(byte[] bytes) { 27 | SimpleInput input = new SimpleInput(bytes); 28 | try { 29 | Object result = input.readObject(); 30 | return result; 31 | } catch (IOException e) { 32 | throw new RpcException(e); 33 | } catch (ClassNotFoundException e) { 34 | throw new RpcException(e); 35 | } catch (IllegalAccessException e) { 36 | throw new RpcException(e); 37 | } catch (InstantiationException e) { 38 | throw new RpcException(e); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /hasting-cluster/src/main/java/com/lindzh/hasting/cluster/serializer/simple/SimpleType.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.cluster.serializer.simple; 2 | 3 | /** 4 | * Created by lin on 2016/12/5. 5 | */ 6 | public class SimpleType { 7 | 8 | private byte type; 9 | 10 | private String name; 11 | 12 | public SimpleType(){ 13 | 14 | } 15 | 16 | public SimpleType(byte type,String name){ 17 | this.type = type; 18 | this.name = name; 19 | } 20 | 21 | public byte getType() { 22 | return type; 23 | } 24 | 25 | public void setType(byte type) { 26 | this.type = type; 27 | } 28 | 29 | public String getName() { 30 | return name; 31 | } 32 | 33 | public void setName(String name) { 34 | this.name = name; 35 | } 36 | 37 | public SimpleType copy(){ 38 | return new SimpleType(this.type,this.name); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /hasting-cluster/src/main/java/com/lindzh/hasting/cluster/store/ConfStoreService.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.cluster.store; 2 | 3 | /** 4 | * Created by lin on 2016/12/21. 5 | */ 6 | public class ConfStoreService { 7 | } 8 | -------------------------------------------------------------------------------- /hasting-cluster/src/main/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | log4j.rootLogger=INFO,stdout,store 2 | 3 | log4j.appender.stdout=org.apache.log4j.ConsoleAppender 4 | log4j.appender.stdout.Target=System.out 5 | log4j.appender.stdout.layout=org.apache.log4j.PatternLayout 6 | log4j.appender.stdout.layout.ConversionPattern=%d %-4r [%t] (%F:%L) %-5p - %m%n 7 | 8 | log4j.appender.store=org.apache.log4j.DailyRollingFileAppender 9 | log4j.appender.store.File=D:\\rpc\\client\\log 10 | log4j.appender.store.Append=true 11 | log4j.appender.store.DatePattern ='_'yyyy-MM-dd'.log' 12 | log4j.appender.store.layout=org.apache.log4j.PatternLayout 13 | log4j.appender.store.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-4r [%t] (%F:%L) %-5p - %m%n -------------------------------------------------------------------------------- /hasting-cluster/src/test/java/com/lindzh/hasting/cluster/HelloRpcService.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.cluster; 2 | 3 | import java.util.List; 4 | import java.util.Set; 5 | 6 | public interface HelloRpcService { 7 | 8 | public void sayHello(String message,int tt); 9 | 10 | public String getHello(); 11 | 12 | public TestRemoteBean getBean(TestBean bean,int id); 13 | 14 | public List getString(Set hahah); 15 | 16 | public String[] hahahString(String[] haha); 17 | 18 | public int callException(boolean exception); 19 | 20 | } 21 | -------------------------------------------------------------------------------- /hasting-cluster/src/test/java/com/lindzh/hasting/cluster/HelloRpcServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.cluster; 2 | 3 | import org.apache.log4j.Logger; 4 | 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | import java.util.Set; 8 | 9 | public class HelloRpcServiceImpl implements HelloRpcService{ 10 | 11 | private Logger logger = Logger.getLogger(HelloRpcServiceImpl.class); 12 | 13 | @Override 14 | public void sayHello(String message,int tt) { 15 | System.out.println("sayHello:"+message+" intValue:"+tt); 16 | } 17 | 18 | @Override 19 | public String getHello() { 20 | return "this is hello service"; 21 | } 22 | 23 | @Override 24 | public TestRemoteBean getBean(TestBean bean, int id) { 25 | //logger.info("id:"+id+" bean:"+bean.toString()); 26 | TestRemoteBean remoteBean = new TestRemoteBean(); 27 | remoteBean.setAction("fff-"+id); 28 | remoteBean.setAge(id*2); 29 | remoteBean.setName("serviceBean"); 30 | return remoteBean; 31 | } 32 | 33 | @Override 34 | public int callException(boolean exception) { 35 | if(exception){ 36 | throw new RuntimeException("happen"); 37 | } 38 | return 1; 39 | } 40 | 41 | @Override 42 | public List getString(Set hahah) { 43 | System.out.println("getString"); 44 | return new ArrayList(hahah); 45 | } 46 | 47 | @Override 48 | public String[] hahahString(String[] haha) { 49 | return haha; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /hasting-cluster/src/test/java/com/lindzh/hasting/cluster/HelloRpcTestService.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.cluster; 2 | 3 | public interface HelloRpcTestService { 4 | 5 | public String index(int index,String key); 6 | 7 | } 8 | -------------------------------------------------------------------------------- /hasting-cluster/src/test/java/com/lindzh/hasting/cluster/HelloRpcTestServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.cluster; 2 | 3 | import org.apache.log4j.Logger; 4 | 5 | public class HelloRpcTestServiceImpl implements HelloRpcTestService{ 6 | 7 | private Logger logger = Logger.getLogger(HelloRpcTestServiceImpl.class); 8 | 9 | @Override 10 | public String index(int index, String key) { 11 | //logger.info("index:"+index+" key:"+key); 12 | return "HelloRpcTestServiceImpl-"+index+" key:"+key; 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /hasting-cluster/src/test/java/com/lindzh/hasting/cluster/LoginRpcService.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.cluster; 2 | 3 | public interface LoginRpcService { 4 | 5 | public boolean login(String username,String password); 6 | 7 | } 8 | -------------------------------------------------------------------------------- /hasting-cluster/src/test/java/com/lindzh/hasting/cluster/LoginRpcServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.cluster; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | import org.apache.log4j.Logger; 7 | 8 | public class LoginRpcServiceImpl implements LoginRpcService{ 9 | 10 | private Logger logger = Logger.getLogger(LoginRpcServiceImpl.class); 11 | 12 | private Map cache = new HashMap(); 13 | 14 | @Override 15 | public boolean login(String username, String password) { 16 | //logger.info("login user:"+username+" password:"+password); 17 | String pass = cache.get(username); 18 | return pass!=null&&pass.equals(password); 19 | } 20 | 21 | public LoginRpcServiceImpl(){ 22 | cache.put("linda", "123456"); 23 | cache.put("test", "123456"); 24 | cache.put("admin", "123456"); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /hasting-cluster/src/test/java/com/lindzh/hasting/cluster/TestBean.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.cluster; 2 | 3 | import java.io.Serializable; 4 | 5 | public class TestBean implements Serializable { 6 | 7 | private static final long serialVersionUID = -6778119358481557931L; 8 | private int limit; 9 | private int offset; 10 | private String order; 11 | private String message; 12 | 13 | public int getLimit() { 14 | return limit; 15 | } 16 | 17 | public void setLimit(int limit) { 18 | this.limit = limit; 19 | } 20 | 21 | public int getOffset() { 22 | return offset; 23 | } 24 | 25 | public void setOffset(int offset) { 26 | this.offset = offset; 27 | } 28 | 29 | public String getOrder() { 30 | return order; 31 | } 32 | 33 | public void setOrder(String order) { 34 | this.order = order; 35 | } 36 | 37 | public String getMessage() { 38 | return message; 39 | } 40 | 41 | public void setMessage(String message) { 42 | this.message = message; 43 | } 44 | 45 | @Override 46 | public String toString() { 47 | return "TestBean [limit=" + limit + ", offset=" + offset + ", order=" 48 | + order + ", message=" + message + "]"; 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /hasting-cluster/src/test/java/com/lindzh/hasting/cluster/TestRemoteBean.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.cluster; 2 | 3 | import java.io.Serializable; 4 | 5 | public class TestRemoteBean implements Serializable { 6 | 7 | private static final long serialVersionUID = 2448105590901413899L; 8 | private String name; 9 | private String action; 10 | private int age; 11 | 12 | public String getName() { 13 | return name; 14 | } 15 | 16 | public void setName(String name) { 17 | this.name = name; 18 | } 19 | 20 | public String getAction() { 21 | return action; 22 | } 23 | 24 | public void setAction(String action) { 25 | this.action = action; 26 | } 27 | 28 | public int getAge() { 29 | return age; 30 | } 31 | 32 | public void setAge(int age) { 33 | this.age = age; 34 | } 35 | 36 | @Override 37 | public String toString() { 38 | return "TestRemoteBean [name=" + name + ", action=" + action + ", age=" 39 | + age + "]"; 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /hasting-cluster/src/test/java/com/lindzh/hasting/cluster/etcd/EtcdClientTest.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.cluster.etcd; 2 | 3 | import com.lindzh.hasting.cluster.HelloRpcService; 4 | import com.lindzh.hasting.cluster.serializer.simple.SimpleSerializer; 5 | 6 | public class EtcdClientTest { 7 | 8 | public static void main(String[] args) throws InterruptedException { 9 | 10 | EtcdRpcClient client = new EtcdRpcClient(); 11 | client.setEtcdUrl("http://192.168.139.128:2911"); 12 | client.setNamespace("myapp"); 13 | client.setApplication("test"); 14 | client.setSerializer(new SimpleSerializer()); 15 | client.startService(); 16 | HelloRpcService rpcService = client.register(HelloRpcService.class); 17 | 18 | int index = 50000; 19 | 20 | while(true){ 21 | try{ 22 | rpcService.sayHello("this is rpc etcd test-"+index, index); 23 | String hello = rpcService.getHello(); 24 | System.out.println(hello); 25 | index++; 26 | }catch (Exception e){ 27 | e.printStackTrace(); 28 | }finally { 29 | try { 30 | Thread.sleep(1000L); 31 | } catch (InterruptedException e) { 32 | e.printStackTrace(); 33 | } 34 | } 35 | 36 | } 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /hasting-cluster/src/test/java/com/lindzh/hasting/cluster/etcd/EtcdServerTest.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.cluster.etcd; 2 | 3 | import com.lindzh.hasting.cluster.HelloRpcService; 4 | import com.lindzh.hasting.cluster.HelloRpcServiceImpl; 5 | import com.lindzh.hasting.cluster.HelloRpcTestService; 6 | import com.lindzh.hasting.cluster.HelloRpcTestServiceImpl; 7 | import com.lindzh.hasting.cluster.LoginRpcService; 8 | import com.lindzh.hasting.cluster.LoginRpcServiceImpl; 9 | import com.lindzh.hasting.cluster.serializer.simple.SimpleSerializer; 10 | 11 | public class EtcdServerTest { 12 | 13 | public static void main(String[] args) { 14 | 15 | EtcdRpcServer rpcServer = new EtcdRpcServer(); 16 | rpcServer.setEtcdUrl("http://192.168.139.128:2911"); 17 | rpcServer.setNamespace("myapp"); 18 | rpcServer.setApplication("simple"); 19 | rpcServer.setSerializer(new SimpleSerializer()); 20 | rpcServer.setPort(3354); 21 | rpcServer.register(HelloRpcService.class, new HelloRpcServiceImpl()); 22 | rpcServer.register(LoginRpcService.class, new LoginRpcServiceImpl()); 23 | rpcServer.register(HelloRpcTestService.class, new HelloRpcTestServiceImpl()); 24 | rpcServer.startService(); 25 | System.out.println("--------etcd client start---------"); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /hasting-cluster/src/test/java/com/lindzh/hasting/cluster/etcd/Etcdtest.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.cluster.etcd; 2 | 3 | import com.lindzh.hasting.cluster.JSONUtils; 4 | import com.lindzh.hasting.cluster.limit.LimitConst; 5 | import com.lindzh.hasting.cluster.limit.LimitDefine; 6 | import com.lindzh.jetcd.EtcdClient; 7 | 8 | import java.util.ArrayList; 9 | 10 | /** 11 | * Created by lin on 2016/12/12. 12 | */ 13 | public class Etcdtest { 14 | public static void main(String[] args) { 15 | EtcdClient client = new EtcdClient("http://192.168.139.128:2911"); 16 | 17 | client.start(); 18 | 19 | ArrayList limitDefines = new ArrayList(); 20 | LimitDefine define = new LimitDefine(); 21 | define.setType(LimitConst.LIMIT_ALL); 22 | define.setCount(4); 23 | define.setTtl(7000); 24 | limitDefines.add(define); 25 | 26 | // client.set("/myapp/weight/simple/weights/172.17.9.251:3351","50"); 27 | // 28 | // client.set("/myapp/weight/simple/node","455555"); 29 | 30 | client.set("/myapp/limit/simple", JSONUtils.toJSON(limitDefines)); 31 | client.stop(); 32 | 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /hasting-cluster/src/test/java/com/lindzh/hasting/cluster/generic/EtcdGenericServiceTest.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.cluster.generic; 2 | 3 | import java.util.HashMap; 4 | 5 | import com.lindzh.hasting.cluster.JSONUtils; 6 | import com.lindzh.hasting.cluster.etcd.EtcdRpcClient; 7 | import com.lindzh.hasting.rpc.generic.GenericService; 8 | import com.lindzh.hasting.rpc.utils.RpcUtils; 9 | 10 | public class EtcdGenericServiceTest { 11 | 12 | public static void main(String[] args) { 13 | 14 | EtcdRpcClient client = new EtcdRpcClient(); 15 | client.setEtcdUrl("http://192.168.139.129:2911"); 16 | client.setNamespace("lindezhi"); 17 | client.startService(); 18 | GenericService genericService = client.register(GenericService.class); 19 | int index = 10000; 20 | while(true){ 21 | String[] getBeanTypes = new String[]{"TestBean","int"}; 22 | HashMap map = new HashMap(); 23 | map.put("limit", index); 24 | map.put("offset", index*10); 25 | map.put("order", "index-"+index); 26 | map.put("message", "this is a test index+"+index); 27 | Object[] getBeanArgs = new Object[]{map,index*100+5}; 28 | Object hh = genericService.invoke(null,"HelloRpcService", RpcUtils.DEFAULT_VERSION, "getBean", getBeanTypes, getBeanArgs); 29 | System.out.println(JSONUtils.toJSON(hh)); 30 | index++; 31 | try { 32 | Thread.sleep(3000L); 33 | } catch (InterruptedException e) { 34 | e.printStackTrace(); 35 | } 36 | } 37 | 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /hasting-cluster/src/test/java/com/lindzh/hasting/cluster/generic/GenericClientTest.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.cluster.generic; 2 | 3 | import java.util.HashMap; 4 | 5 | import com.lindzh.hasting.rpc.client.SimpleRpcClient; 6 | import com.lindzh.hasting.cluster.serializer.simple.SimpleSerializer; 7 | import com.lindzh.hasting.rpc.generic.GenericService; 8 | import com.lindzh.hasting.rpc.utils.RpcUtils; 9 | 10 | public class GenericClientTest { 11 | 12 | public static void main(String[] a) { 13 | SimpleRpcClient client = new SimpleRpcClient(); 14 | client.setHost("127.0.0.1"); 15 | client.setPort(4321); 16 | client.setSerializer(new SimpleSerializer()); 17 | client.startService(); 18 | GenericService service = client.register(GenericService.class); 19 | 20 | String[] getBeanTypes = new String[]{"TestBean","int"}; 21 | HashMap map = new HashMap(); 22 | map.put("limit", 111); 23 | map.put("offset", 322); 24 | map.put("order", "trtr"); 25 | map.put("message", "this is a test"); 26 | Object[] getBeanArgs = new Object[]{map,543543}; 27 | Object hh = service.invoke(null,"HelloRpcService", RpcUtils.DEFAULT_VERSION, "getBean", getBeanTypes, getBeanArgs); 28 | System.out.println(hh); 29 | 30 | String[] argTypes = new String[]{"java.lang.String","int"}; 31 | Object[] args = new Object[]{"hello,this is linda",543543}; 32 | Object invoke = service.invoke(null,"HelloRpcService", RpcUtils.DEFAULT_VERSION, "sayHello", argTypes, args); 33 | System.out.println("result:"+invoke); 34 | System.out.println("---------------"); 35 | client.stopService(); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /hasting-cluster/src/test/java/com/lindzh/hasting/cluster/generic/RedisGenericServiceTest.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.cluster.generic; 2 | 3 | import java.util.HashMap; 4 | 5 | import com.lindzh.hasting.cluster.JSONUtils; 6 | import com.lindzh.hasting.cluster.redis.RedisRpcClient; 7 | import com.lindzh.hasting.rpc.generic.GenericService; 8 | import com.lindzh.hasting.rpc.utils.RpcUtils; 9 | 10 | public class RedisGenericServiceTest { 11 | 12 | public static void main(String[] args) { 13 | 14 | RedisRpcClient client = new RedisRpcClient(); 15 | client.setRedisHost("192.168.139.129"); 16 | client.setRedisPort(7770); 17 | client.startService(); 18 | GenericService genericService = client.register(GenericService.class); 19 | int index = 10000; 20 | while(true){ 21 | String[] getBeanTypes = new String[]{"TestBean","int"}; 22 | HashMap map = new HashMap(); 23 | map.put("limit", index); 24 | map.put("offset", index*10); 25 | map.put("order", "index-"+index); 26 | map.put("message", "this is a test index+"+index); 27 | Object[] getBeanArgs = new Object[]{map,index*100+5}; 28 | Object hh = genericService.invoke(null,"HelloRpcService", RpcUtils.DEFAULT_VERSION, "getBean", getBeanTypes, getBeanArgs); 29 | System.out.println(JSONUtils.toJSON(hh)); 30 | index++; 31 | try { 32 | Thread.sleep(3000L); 33 | } catch (InterruptedException e) { 34 | e.printStackTrace(); 35 | } 36 | } 37 | 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /hasting-cluster/src/test/java/com/lindzh/hasting/cluster/redis/RpcJedisClientTest.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.cluster.redis; 2 | 3 | import java.util.Date; 4 | 5 | import com.lindzh.hasting.cluster.HelloRpcService; 6 | import com.lindzh.hasting.cluster.HelloRpcTestService; 7 | import com.lindzh.hasting.cluster.LoginRpcService; 8 | 9 | public class RpcJedisClientTest { 10 | 11 | public static void main(String[] args) throws InterruptedException { 12 | RedisRpcClient rpcClient = new RedisRpcClient(); 13 | rpcClient.setRedisHost("127.0.0.1"); 14 | rpcClient.setRedisPort(6379); 15 | 16 | rpcClient.setApplication("redis-client"); 17 | HelloRpcTestService helloRpcTestService = rpcClient.register(HelloRpcTestService.class); 18 | HelloRpcService helloRpcService = rpcClient.register(HelloRpcService.class); 19 | LoginRpcService loginRpcService = rpcClient.register(LoginRpcService.class); 20 | 21 | rpcClient.startService(); 22 | 23 | int idx = 1000; 24 | while(true){ 25 | try{ 26 | boolean login = loginRpcService.login("linda", "123456"); 27 | System.out.println("login---:"+login); 28 | 29 | helloRpcService.sayHello("hihii "+new Date(), idx); 30 | idx++; 31 | String index = helloRpcTestService.index(idx, "idx--"+new Date()); 32 | System.out.println("index:"+index); 33 | idx++; 34 | Thread.currentThread().sleep(3000L); 35 | }catch(Exception e){ 36 | e.printStackTrace(); 37 | Thread.currentThread().sleep(3000L); 38 | } 39 | } 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /hasting-cluster/src/test/java/com/lindzh/hasting/cluster/redis/RpcJedisClusterTest.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.cluster.redis; 2 | 3 | import com.lindzh.hasting.cluster.LoginRpcServiceImpl; 4 | import com.lindzh.hasting.cluster.HelloRpcService; 5 | import com.lindzh.hasting.cluster.HelloRpcServiceImpl; 6 | import com.lindzh.hasting.cluster.HelloRpcTestService; 7 | import com.lindzh.hasting.cluster.HelloRpcTestServiceImpl; 8 | import com.lindzh.hasting.cluster.LoginRpcService; 9 | 10 | public class RpcJedisClusterTest { 11 | 12 | public static void main(String[] args) { 13 | RedisRpcServer rpcServer = new RedisRpcServer(); 14 | rpcServer.setPort(3323); 15 | rpcServer.setHost("127.0.0.1"); 16 | rpcServer.setRedisHost("127.0.0.1"); 17 | rpcServer.setRedisPort(6379); 18 | rpcServer.setApplication("redis-server"); 19 | rpcServer.register(HelloRpcService.class, new HelloRpcServiceImpl()); 20 | rpcServer.register(LoginRpcService.class, new LoginRpcServiceImpl()); 21 | rpcServer.register(HelloRpcTestService.class, new HelloRpcTestServiceImpl()); 22 | rpcServer.startService(); 23 | System.out.println("--------started----------"); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /hasting-cluster/src/test/java/com/lindzh/hasting/cluster/serialize/AbstractSerializer.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.cluster.serialize; 2 | 3 | import com.lindzh.hasting.rpc.RemoteCall; 4 | import com.lindzh.hasting.cluster.HelloRpcService; 5 | import com.lindzh.hasting.cluster.TestBean; 6 | 7 | public class AbstractSerializer { 8 | 9 | public RemoteCall getCall(){ 10 | String service = HelloRpcService.class.getName(); 11 | String method = "getBean"; 12 | String version = "534543"; 13 | TestBean testBean = new TestBean(); 14 | testBean.setLimit(4); 15 | testBean.setMessage("ggggggggggggggggggggggggggggggggggggggggggggg"); 16 | testBean.setOffset(43432); 17 | testBean.setOrder("645gdfghdfghdf"); 18 | RemoteCall call = new RemoteCall(service, method); 19 | call.setArgs(new Object[]{testBean,654645}); 20 | call.setVersion(version); 21 | return call; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /hasting-cluster/src/test/java/com/lindzh/hasting/cluster/serialize/JSONSerializerTest.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.cluster.serialize; 2 | 3 | import com.lindzh.hasting.rpc.RemoteCall; 4 | import com.lindzh.hasting.cluster.serializer.JSONSerializer; 5 | import com.lindzh.hasting.rpc.serializer.RpcSerializer; 6 | 7 | public class JSONSerializerTest extends AbstractSerializer { 8 | 9 | public static void main(String[] args) { 10 | SerializeTest test = new SerializeTest(); 11 | RemoteCall call = test.getCall(); 12 | RpcSerializer serializer = new JSONSerializer(); 13 | long start = System.currentTimeMillis(); 14 | byte[] bs = serializer.serialize(call); 15 | long end = System.currentTimeMillis(); 16 | long cost = end-start; 17 | System.out.println("json serializer length:"+bs.length+" cost:"+cost); 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /hasting-cluster/src/test/java/com/lindzh/hasting/cluster/serialize/SerializeTest.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.cluster.serialize; 2 | 3 | import com.lindzh.hasting.rpc.RemoteCall; 4 | import com.lindzh.hasting.rpc.serializer.JdkSerializer; 5 | 6 | public class SerializeTest extends AbstractSerializer{ 7 | 8 | public static void main(String[] args) { 9 | SerializeTest test = new SerializeTest(); 10 | RemoteCall call = test.getCall(); 11 | JdkSerializer serializer = new JdkSerializer(); 12 | long start = System.currentTimeMillis(); 13 | byte[] bs = serializer.serialize(call); 14 | long end = System.currentTimeMillis(); 15 | long cost = end-start; 16 | System.out.println("jdk serializer length:"+bs.length+" cost:"+cost); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /hasting-cluster/src/test/java/com/lindzh/hasting/cluster/serialize/ZipSerializeTest.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.cluster.serialize; 2 | 3 | import java.io.ByteArrayOutputStream; 4 | import java.io.IOException; 5 | import java.io.ObjectOutputStream; 6 | import java.util.zip.GZIPOutputStream; 7 | 8 | import com.lindzh.hasting.cluster.TestBean; 9 | import com.lindzh.hasting.rpc.serializer.JdkSerializer; 10 | 11 | public class ZipSerializeTest { 12 | 13 | public static void main(String[] args) throws IOException { 14 | TestBean testBean = new TestBean(); 15 | testBean.setLimit(4); 16 | testBean.setMessage("ggggggggggggggggggggggggggggggggggggggggggggg"); 17 | testBean.setOffset(43432); 18 | testBean.setOrder("645gdfghdfghdf"); 19 | 20 | JdkSerializer serializer = new JdkSerializer(); 21 | byte[] bs = serializer.serialize(testBean); 22 | 23 | ByteArrayOutputStream bos = new ByteArrayOutputStream(); 24 | GZIPOutputStream zos = new GZIPOutputStream(bos); 25 | 26 | ObjectOutputStream oos = new ObjectOutputStream(zos); 27 | 28 | oos.writeObject(testBean); 29 | 30 | oos.close(); 31 | 32 | // zis.close(); 33 | // bos.close(); 34 | 35 | byte[] os = bos.toByteArray(); 36 | System.out.println(bs.length+" dest---:"+os.length); 37 | //187 dest---:161 38 | 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /hasting-cluster/src/test/java/com/lindzh/hasting/cluster/simple/LimitBuilder.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.cluster.simple; 2 | 3 | import com.lindzh.hasting.cluster.JSONUtils; 4 | import com.lindzh.hasting.cluster.limit.LimitConst; 5 | import com.lindzh.hasting.cluster.limit.LimitDefine; 6 | 7 | import java.util.ArrayList; 8 | 9 | /** 10 | * Created by Administrator on 2017/2/15. 11 | */ 12 | public class LimitBuilder { 13 | public static void main(String[] args) { 14 | ArrayList limitDefines = new ArrayList(); 15 | LimitDefine define = new LimitDefine(); 16 | define.setType(LimitConst.LIMIT_ALL); 17 | define.setCount(5); 18 | define.setTtl(7000); 19 | limitDefines.add(define); 20 | System.out.println(JSONUtils.toJSON(limitDefines)); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /hasting-cluster/src/test/java/com/lindzh/hasting/cluster/simple/SimpleAdminTest.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.cluster.simple; 2 | 3 | import java.util.List; 4 | 5 | import com.lindzh.hasting.rpc.RpcService; 6 | import com.lindzh.hasting.rpc.client.SimpleRpcClient; 7 | import com.lindzh.hasting.cluster.JSONUtils; 8 | import com.lindzh.hasting.cluster.LoginRpcService; 9 | import com.lindzh.hasting.rpc.cluster1.RpcHostAndPort; 10 | import com.lindzh.hasting.cluster.admin.SimpleRpcAdminService; 11 | 12 | public class SimpleAdminTest { 13 | 14 | public static void main(String[] args) { 15 | SimpleRpcAdminService adminService = new SimpleRpcAdminService(); 16 | 17 | adminService.setHost("127.0.0.1"); 18 | adminService.setPort(4321); 19 | 20 | adminService.startService(); 21 | List rpcServers = adminService.getRpcServers(); 22 | System.out.println(JSONUtils.toJSON(rpcServers)); 23 | for (RpcHostAndPort server : rpcServers) { 24 | List services = adminService.getRpcServices(server); 25 | System.out.println(JSONUtils.toJSON(server.getHost() + ":" 26 | + server.getPort() + " " + services)); 27 | } 28 | 29 | } 30 | 31 | public static void test() { 32 | SimpleRpcClient rpcClient = new SimpleRpcClient(); 33 | rpcClient.setHost("192.168.132.87"); 34 | rpcClient.setPort(4321); 35 | LoginRpcService loginRpcService = rpcClient.register(LoginRpcService.class); 36 | rpcClient.startService(); 37 | boolean loginResult = loginRpcService.login("admin", "admin"); 38 | rpcClient.stopService(); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /hasting-cluster/src/test/java/com/lindzh/hasting/cluster/simple/SimpleRpcTest.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.cluster.simple; 2 | 3 | import com.lindzh.hasting.rpc.client.SimpleRpcClient; 4 | import com.lindzh.hasting.cluster.HelloRpcService; 5 | 6 | /** 7 | * Created by lin on 2016/12/9. 8 | */ 9 | public class SimpleRpcTest { 10 | 11 | public static void main(String[] args) { 12 | SimpleRpcClient client = new SimpleRpcClient(); 13 | client.setHost("127.0.0.1"); 14 | client.setPort(3333); 15 | client.setApplication("test"); 16 | 17 | HelloRpcService hello = client.register(HelloRpcService.class,null,"hello"); 18 | 19 | client.startService(); 20 | 21 | hello.sayHello("664567",66); 22 | 23 | String hello1 = hello.getHello(); 24 | 25 | System.out.println("hahahah----------"); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /hasting-cluster/src/test/java/com/lindzh/hasting/cluster/zk/RpcZkClientTest.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.cluster.zk; 2 | 3 | import com.lindzh.hasting.cluster.HelloRpcService; 4 | 5 | public class RpcZkClientTest { 6 | 7 | public static void main(String[] args) { 8 | ZkRpcClient client = new ZkRpcClient(); 9 | client.setConnectString("127.0.0.1:2181"); 10 | client.setNamespace("myrpc"); 11 | client.setApplication("test"); 12 | 13 | client.startService(); 14 | HelloRpcService rpcService = client.register(HelloRpcService.class,null,"hello"); 15 | 16 | 17 | 18 | 19 | 20 | int index = 50000; 21 | 22 | while(true){ 23 | try{ 24 | rpcService.sayHello("this is rpc etcd test-"+index, index); 25 | String hello = rpcService.getHello(); 26 | System.out.println(hello); 27 | index++; 28 | }catch (Exception e){ 29 | e.printStackTrace(); 30 | }finally { 31 | try { 32 | Thread.sleep(1000L); 33 | } catch (InterruptedException e) { 34 | e.printStackTrace(); 35 | } 36 | } 37 | 38 | } 39 | 40 | 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /hasting-cluster/src/test/java/com/lindzh/hasting/cluster/zk/RpcZkServerTest.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.cluster.zk; 2 | 3 | import com.lindzh.hasting.cluster.HelloRpcService; 4 | import com.lindzh.hasting.cluster.HelloRpcServiceImpl; 5 | import com.lindzh.hasting.cluster.HelloRpcTestServiceImpl; 6 | import com.lindzh.hasting.cluster.LoginRpcServiceImpl; 7 | import com.lindzh.hasting.cluster.HelloRpcTestService; 8 | import com.lindzh.hasting.cluster.LoginRpcService; 9 | 10 | public class RpcZkServerTest { 11 | 12 | public static void main(String[] args) { 13 | ZkRpcServer rpcServer = new ZkRpcServer(); 14 | rpcServer.setConnectString("127.0.0.1:2181"); 15 | rpcServer.setNamespace("myrpc"); 16 | rpcServer.setHost("127.0.0.1"); 17 | rpcServer.setPort(3335); 18 | rpcServer.setApplication("myapp"); 19 | rpcServer.setValidateToken(true); 20 | rpcServer.register(HelloRpcService.class, new HelloRpcServiceImpl(),null,"hello"); 21 | rpcServer.register(LoginRpcService.class, new LoginRpcServiceImpl(),null,"hello"); 22 | rpcServer.register(HelloRpcTestService.class, new HelloRpcTestServiceImpl(),null,"hello"); 23 | rpcServer.startService(); 24 | System.out.println("--------started----------"); 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /hasting-netty/README.md: -------------------------------------------------------------------------------- 1 | #### Hasting netty支持组件 2 | 3 | >加入rpc对netty的支持,网络层。和rpc框架实现的nio,oio完全兼容,通信协议一样 4 | 5 | ##### 启动服务端 6 | 7 | ```java 8 | SimpleRpcServer rpcServer = new SimpleRpcServer(); 9 | rpcServer.setAcceptor(new RpcNettyAcceptor()); 10 | rpcServer.setHost("127.0.0.1"); 11 | rpcServer.setPort(5555); 12 | rpcServer.register(LoginRpcService.class, new LoginRpcServiceImpl()); 13 | rpcServer.startService(); 14 | ``` 15 | ##### 启动客户端 16 | 17 | ```java 18 | SimpleRpcClient client = new SimpleRpcClient(); 19 | client.setHost("127.0.0.1"); 20 | client.setPort(5555); 21 | client.setConnectorClass(RpcNettyConnector.class); 22 | LoginRpcService loginRpcService = client.register(LoginRpcService.class); 23 | client.startService(); 24 | ``` -------------------------------------------------------------------------------- /hasting-netty/src/main/java/com/lindzh/hasting/netty/codec/RpcNettyDecoder.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.netty.codec; 2 | 3 | import io.netty.buffer.ByteBuf; 4 | import io.netty.channel.ChannelHandlerContext; 5 | import io.netty.handler.codec.ByteToMessageDecoder; 6 | 7 | import java.util.List; 8 | 9 | import com.lindzh.hasting.rpc.RpcObject; 10 | import com.lindzh.hasting.rpc.exception.RpcException; 11 | import com.lindzh.hasting.rpc.utils.NioUtils; 12 | import com.lindzh.hasting.rpc.utils.RpcUtils; 13 | import com.lindzh.hasting.rpc.utils.RpcUtils.RpcType; 14 | 15 | public class RpcNettyDecoder extends ByteToMessageDecoder{ 16 | 17 | @Override 18 | protected void decode(ChannelHandlerContext ctx, ByteBuf in, 19 | List out) throws Exception { 20 | int readableBytes = in.readableBytes(); 21 | if(readableBytes>=NioUtils.RPC_PROTOCOL_HEAD_LEN){ 22 | in.markReaderIndex(); 23 | int type = in.readInt();//type 24 | long threadId = in.readLong();//threadId 25 | int index = in.readInt();//index 26 | int length = in.readInt();// data length 27 | if(length>RpcUtils.MEM_1M){ 28 | throw new RpcException("rpc data too long "+ length); 29 | } 30 | if(in.readableBytes()>=length){ 31 | byte[] buf = new byte[length]; 32 | if(length>0){ 33 | in.readBytes(buf); 34 | } 35 | RpcObject rpc = new RpcObject(); 36 | rpc.setType(RpcType.getByType(type)); 37 | rpc.setThreadId(threadId); 38 | rpc.setIndex(index); 39 | rpc.setLength(length); 40 | rpc.setData(buf); 41 | out.add(rpc); 42 | }else{ 43 | in.resetReaderIndex(); 44 | } 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /hasting-netty/src/main/java/com/lindzh/hasting/netty/codec/RpcNettyEncoder.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.netty.codec; 2 | 3 | import io.netty.buffer.ByteBuf; 4 | import io.netty.channel.ChannelHandlerContext; 5 | import io.netty.handler.codec.MessageToByteEncoder; 6 | 7 | import com.lindzh.hasting.rpc.RpcObject; 8 | import com.lindzh.hasting.rpc.exception.RpcException; 9 | import com.lindzh.hasting.rpc.utils.RpcUtils; 10 | 11 | 12 | /** 13 | * 14 | * @author linda 15 | * RPC Object encoder 16 | * @See RpcUtils 17 | * 18 | */ 19 | public class RpcNettyEncoder extends MessageToByteEncoder{ 20 | 21 | @Override 22 | protected void encode(ChannelHandlerContext ctx, RpcObject msg, ByteBuf out) 23 | throws Exception { 24 | out.writeInt(msg.getType().getType()); 25 | out.writeLong(msg.getThreadId()); 26 | out.writeInt(msg.getIndex()); 27 | out.writeInt(msg.getLength()); 28 | if(msg.getLength()>0){ 29 | if(msg.getLength()>RpcUtils.MEM_1M){ 30 | throw new RpcException("rpc data too long "+ msg.getLength()); 31 | } 32 | out.writeBytes(msg.getData()); 33 | } 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /hasting-netty/src/test/java/com/lindzh/hasting/netty/AppTest.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.netty; 2 | 3 | import junit.framework.Test; 4 | import junit.framework.TestCase; 5 | import junit.framework.TestSuite; 6 | 7 | /** 8 | * Unit test for simple App. 9 | */ 10 | public class AppTest 11 | extends TestCase 12 | { 13 | /** 14 | * Create the test case 15 | * 16 | * @param testName name of the test case 17 | */ 18 | public AppTest( String testName ) 19 | { 20 | super( testName ); 21 | } 22 | 23 | /** 24 | * @return the suite of tests being tested 25 | */ 26 | public static Test suite() 27 | { 28 | return new TestSuite( AppTest.class ); 29 | } 30 | 31 | /** 32 | * Rigourous Test :-) 33 | */ 34 | public void testApp() 35 | { 36 | assertTrue( true ); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /hasting-netty/src/test/java/com/lindzh/hasting/netty/HelloRpcService.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.netty; 2 | 3 | public interface HelloRpcService { 4 | 5 | public void sayHello(String message,int tt); 6 | 7 | public String getHello(); 8 | 9 | public TestRemoteBean getBean(TestBean bean,int id); 10 | 11 | public int callException(boolean exception); 12 | 13 | } 14 | -------------------------------------------------------------------------------- /hasting-netty/src/test/java/com/lindzh/hasting/netty/HelloRpcServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.netty; 2 | 3 | import org.apache.log4j.Logger; 4 | 5 | public class HelloRpcServiceImpl implements HelloRpcService{ 6 | 7 | private Logger logger = Logger.getLogger(HelloRpcServiceImpl.class); 8 | 9 | @Override 10 | public void sayHello(String message,int tt) { 11 | //logger.info("sayHello:"+message+" intValue:"+tt); 12 | } 13 | 14 | @Override 15 | public String getHello() { 16 | return "this is hello service"; 17 | } 18 | 19 | @Override 20 | public TestRemoteBean getBean(TestBean bean, int id) { 21 | //logger.info("id:"+id+" bean:"+bean.toString()); 22 | TestRemoteBean remoteBean = new TestRemoteBean(); 23 | remoteBean.setAction("fff-"+id); 24 | remoteBean.setAge(id*2); 25 | remoteBean.setName("serviceBean"); 26 | return remoteBean; 27 | } 28 | 29 | @Override 30 | public int callException(boolean exception) { 31 | if(exception){ 32 | throw new RuntimeException("happen"); 33 | } 34 | return 1; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /hasting-netty/src/test/java/com/lindzh/hasting/netty/LoginRpcService.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.netty; 2 | 3 | public interface LoginRpcService { 4 | 5 | public boolean login(String username,String password); 6 | 7 | } 8 | -------------------------------------------------------------------------------- /hasting-netty/src/test/java/com/lindzh/hasting/netty/LoginRpcServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.netty; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | import org.apache.log4j.Logger; 7 | 8 | public class LoginRpcServiceImpl implements LoginRpcService{ 9 | 10 | private Logger logger = Logger.getLogger(LoginRpcServiceImpl.class); 11 | 12 | private Map cache = new HashMap(); 13 | 14 | @Override 15 | public boolean login(String username, String password) { 16 | logger.info("login user:"+username+" password:"+password); 17 | String pass = cache.get(username); 18 | return pass!=null&&pass.equals(password); 19 | } 20 | 21 | public LoginRpcServiceImpl(){ 22 | cache.put("linda", "123456"); 23 | cache.put("test", "123456"); 24 | cache.put("admin", "123456"); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /hasting-netty/src/test/java/com/lindzh/hasting/netty/NettyServerTest.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.netty; 2 | 3 | import com.lindzh.hasting.rpc.server.SimpleRpcServer; 4 | 5 | public class NettyServerTest { 6 | 7 | public static void main(String[] args) { 8 | SimpleRpcServer rpcServer = new SimpleRpcServer(); 9 | rpcServer.setAcceptor(new RpcNettyAcceptor()); 10 | rpcServer.setHost("127.0.0.1"); 11 | rpcServer.setPort(5555); 12 | rpcServer.register(LoginRpcService.class, new LoginRpcServiceImpl()); 13 | rpcServer.startService(); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /hasting-netty/src/test/java/com/lindzh/hasting/netty/TestBean.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.netty; 2 | 3 | import java.io.Serializable; 4 | 5 | public class TestBean implements Serializable { 6 | 7 | private static final long serialVersionUID = -6778119358481557931L; 8 | private int limit; 9 | private int offset; 10 | private String order; 11 | private String message; 12 | 13 | public int getLimit() { 14 | return limit; 15 | } 16 | 17 | public void setLimit(int limit) { 18 | this.limit = limit; 19 | } 20 | 21 | public int getOffset() { 22 | return offset; 23 | } 24 | 25 | public void setOffset(int offset) { 26 | this.offset = offset; 27 | } 28 | 29 | public String getOrder() { 30 | return order; 31 | } 32 | 33 | public void setOrder(String order) { 34 | this.order = order; 35 | } 36 | 37 | public String getMessage() { 38 | return message; 39 | } 40 | 41 | public void setMessage(String message) { 42 | this.message = message; 43 | } 44 | 45 | @Override 46 | public String toString() { 47 | return "TestBean [limit=" + limit + ", offset=" + offset + ", order=" 48 | + order + ", message=" + message + "]"; 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /hasting-netty/src/test/java/com/lindzh/hasting/netty/TestRemoteBean.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.netty; 2 | 3 | import java.io.Serializable; 4 | 5 | public class TestRemoteBean implements Serializable { 6 | 7 | private static final long serialVersionUID = 2448105590901413899L; 8 | private String name; 9 | private String action; 10 | private int age; 11 | 12 | public String getName() { 13 | return name; 14 | } 15 | 16 | public void setName(String name) { 17 | this.name = name; 18 | } 19 | 20 | public String getAction() { 21 | return action; 22 | } 23 | 24 | public void setAction(String action) { 25 | this.action = action; 26 | } 27 | 28 | public int getAge() { 29 | return age; 30 | } 31 | 32 | public void setAge(int age) { 33 | this.age = age; 34 | } 35 | 36 | @Override 37 | public String toString() { 38 | return "TestRemoteBean [name=" + name + ", action=" + action + ", age=" 39 | + age + "]"; 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /hasting-netty/src/test/java/com/lindzh/hasting/netty/generic/GenericClientTest.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.netty.generic; 2 | 3 | import java.util.HashMap; 4 | 5 | import com.lindzh.hasting.rpc.client.SimpleRpcClient; 6 | import com.lindzh.hasting.rpc.generic.GenericService; 7 | import com.lindzh.hasting.netty.RpcNettyConnector; 8 | import com.lindzh.hasting.rpc.utils.RpcUtils; 9 | 10 | public class GenericClientTest { 11 | 12 | public static void main(String[] a) { 13 | SimpleRpcClient client = new SimpleRpcClient(); 14 | client.setConnectorClass(RpcNettyConnector.class); 15 | client.setHost("127.0.0.1"); 16 | client.setPort(4445); 17 | client.startService(); 18 | GenericService service = client.register(GenericService.class); 19 | 20 | String[] getBeanTypes = new String[]{"com.lindzh.hasting.netty.TestBean","int"}; 21 | HashMap map = new HashMap(); 22 | map.put("limit", 111); 23 | map.put("offset", 322); 24 | map.put("order", "trtr"); 25 | map.put("message", "this is a test"); 26 | Object[] getBeanArgs = new Object[]{map,543543}; 27 | Object hh = service.invoke(null,"com.lindzh.hasting.netty.HelloRpcService", RpcUtils.DEFAULT_VERSION, "getBean", getBeanTypes, getBeanArgs); 28 | System.out.println(hh); 29 | 30 | String[] argTypes = new String[]{"java.lang.String","int"}; 31 | Object[] args = new Object[]{"hello,this is generic",543543}; 32 | service.invoke(null,"com.lindzh.hasting.netty.HelloRpcService", RpcUtils.DEFAULT_VERSION, "sayHello", argTypes, args); 33 | 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /hasting-netty/src/test/java/com/lindzh/hasting/netty/generic/GenericServerTest.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.netty.generic; 2 | 3 | 4 | import com.lindzh.hasting.netty.HelloRpcService; 5 | import com.lindzh.hasting.netty.HelloRpcServiceImpl; 6 | import com.lindzh.hasting.netty.RpcNettyAcceptor; 7 | import com.lindzh.hasting.rpc.server.SimpleRpcServer; 8 | 9 | public class GenericServerTest { 10 | 11 | public static void main(String[] args) { 12 | SimpleRpcServer server = new SimpleRpcServer(); 13 | server.setAcceptor(new RpcNettyAcceptor()); 14 | server.setHost("0.0.0.0"); 15 | server.setPort(4445); 16 | server.register(HelloRpcService.class, new HelloRpcServiceImpl()); 17 | server.startService(); 18 | System.out.println("server startup"); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /hasting-rpc/README.md: -------------------------------------------------------------------------------- 1 | #### 服务化框架直连Rpc框架 -------------------------------------------------------------------------------- /hasting-rpc/src/main/java/com/lindzh/hasting/rpc/RemoteExecutor.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.rpc; 2 | 3 | import com.lindzh.hasting.rpc.utils.RpcUtils.RpcType; 4 | 5 | /** 6 | * rpc请求执行,客户端代理执行,服务提供端真正执行 7 | * @author lindezhi 8 | * 2016年3月9日 上午11:27:06 9 | */ 10 | public interface RemoteExecutor extends Service{ 11 | 12 | /** 13 | * 无返回值执行,无论是否异常 14 | * @param call 15 | */ 16 | public void oneway(RemoteCall call); 17 | 18 | /** 19 | * 有返回值执行 20 | * @param call 21 | * @return 22 | */ 23 | public Object invoke(RemoteCall call); 24 | 25 | public static final int ONEWAY = RpcType.ONEWAY.getType(); 26 | 27 | public static final int INVOKE = RpcType.INVOKE.getType(); 28 | 29 | } 30 | -------------------------------------------------------------------------------- /hasting-rpc/src/main/java/com/lindzh/hasting/rpc/RpcContext.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.rpc; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | /** 7 | * rpc上下文,用于传递附件,获取当前环境值 8 | * @author lindezhi 9 | * 2016年3月9日 上午11:25:26 10 | */ 11 | public class RpcContext { 12 | 13 | private static ThreadLocal context = new ThreadLocal(){ 14 | @Override 15 | protected RpcContext initialValue() { 16 | return new RpcContext(); 17 | } 18 | }; 19 | 20 | public static RpcContext getContext(){ 21 | return context.get(); 22 | } 23 | 24 | public void clear(){ 25 | context.remove(); 26 | } 27 | 28 | private Map attachment = new HashMap(); 29 | 30 | public void putAll(Map attachment){ 31 | if(attachment!=null){ 32 | this.attachment.putAll(attachment); 33 | } 34 | } 35 | 36 | public Map getAttachment(){ 37 | return this.attachment; 38 | } 39 | 40 | public int size(){ 41 | return this.attachment.size(); 42 | } 43 | 44 | public Object getAttachment(String key){ 45 | return attachment.get(key); 46 | } 47 | 48 | public void setAttachment(String key,Object value){ 49 | this.attachment.put(key, value); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /hasting-rpc/src/main/java/com/lindzh/hasting/rpc/Service.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.rpc; 2 | 3 | /** 4 | * 服务启动与终止 5 | * @author lindezhi 6 | * 2016年3月9日 上午11:14:12 7 | */ 8 | public interface Service { 9 | 10 | void startService(); 11 | 12 | void stopService(); 13 | 14 | } 15 | -------------------------------------------------------------------------------- /hasting-rpc/src/main/java/com/lindzh/hasting/rpc/aio/RpcAioWriter.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.rpc.aio; 2 | 3 | import com.lindzh.hasting.rpc.net.AbstractRpcConnector; 4 | import com.lindzh.hasting.rpc.net.AbstractRpcWriter; 5 | 6 | /** 7 | * 8 | * @author lindezhi 9 | * 10 | */ 11 | public class RpcAioWriter extends AbstractRpcWriter { 12 | 13 | public RpcAioWriter(){ 14 | super(); 15 | } 16 | 17 | /** 18 | * 使用channel执行发送 19 | */ 20 | @Override 21 | public boolean doSend(AbstractRpcConnector connector) { 22 | RpcAioConnector aioConnector = (RpcAioConnector)connector; 23 | aioConnector.exeSend(); 24 | return true; 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /hasting-rpc/src/main/java/com/lindzh/hasting/rpc/aio/RpcReadCompletionHandler.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.rpc.aio; 2 | 3 | import java.nio.channels.CompletionHandler; 4 | 5 | /** 6 | * 7 | * @author lindezhi 8 | * 2015年6月13日 下午4:15:31 9 | */ 10 | public class RpcReadCompletionHandler implements CompletionHandler { 11 | 12 | /** 13 | * 数据接收回调 14 | */ 15 | @Override 16 | public void completed(Integer num, RpcAioConnector connector) { 17 | if(num!=null){ 18 | connector.readCallback(num); 19 | } 20 | } 21 | 22 | /** 23 | * 连接异常回调 24 | */ 25 | @Override 26 | public void failed(Throwable e, RpcAioConnector connector) { 27 | connector.handleFail(e, connector); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /hasting-rpc/src/main/java/com/lindzh/hasting/rpc/aio/RpcWriteCompletionHandler.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.rpc.aio; 2 | 3 | import java.nio.channels.CompletionHandler; 4 | 5 | /** 6 | * 7 | * @author lindezhi 8 | * 2015年6月13日 下午4:23:09 9 | */ 10 | public class RpcWriteCompletionHandler implements CompletionHandler { 11 | 12 | /** 13 | * 写发送成功回调 14 | */ 15 | @Override 16 | public void completed(Integer num, RpcAioConnector connector) { 17 | if(num!=null){ 18 | connector.writeCallback(num); 19 | } 20 | } 21 | 22 | /** 23 | * 写失败回调,如网络异常 24 | */ 25 | @Override 26 | public void failed(Throwable e, RpcAioConnector connector) { 27 | connector.handleFail(e, connector); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /hasting-rpc/src/main/java/com/lindzh/hasting/rpc/client/MultiClientRemoteExecutor.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.rpc.client; 2 | 3 | import com.lindzh.hasting.rpc.RemoteCall; 4 | import com.lindzh.hasting.rpc.RemoteExecutor; 5 | import com.lindzh.hasting.rpc.Service; 6 | import com.lindzh.hasting.rpc.exception.RpcException; 7 | import com.lindzh.hasting.rpc.net.AbstractRpcConnector; 8 | import com.lindzh.hasting.rpc.net.RpcCallListener; 9 | import com.lindzh.hasting.rpc.net.RpcMultiConnector; 10 | 11 | public class MultiClientRemoteExecutor extends AbstractClientRemoteExecutor implements RemoteExecutor,RpcCallListener,Service{ 12 | 13 | private RpcMultiConnector connector; 14 | 15 | public MultiClientRemoteExecutor(RpcMultiConnector connector){ 16 | super(); 17 | connector.addRpcCallListener(this); 18 | this.connector = connector; 19 | } 20 | 21 | @Override 22 | public void startService() { 23 | connector.startService(); 24 | } 25 | 26 | @Override 27 | public void stopService() { 28 | connector.stopService(); 29 | } 30 | 31 | @Override 32 | public AbstractRpcConnector getRpcConnector(RemoteCall call) { 33 | AbstractRpcConnector resource = connector.getResource(); 34 | if(resource==null){ 35 | throw new RpcException("connection lost"); 36 | } 37 | return resource; 38 | } 39 | 40 | 41 | } 42 | -------------------------------------------------------------------------------- /hasting-rpc/src/main/java/com/lindzh/hasting/rpc/client/MultiRpcClient.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.rpc.client; 2 | 3 | import com.lindzh.hasting.rpc.net.RpcMultiConnector; 4 | import com.lindzh.hasting.rpc.nio.RpcNioConnector; 5 | 6 | public class MultiRpcClient extends AbstractRpcClient{ 7 | 8 | private MultiClientRemoteExecutor executor; 9 | private RpcMultiConnector connector; 10 | private int connections = 2; 11 | 12 | public AbstractClientRemoteExecutor getRemoteExecutor() { 13 | return executor; 14 | } 15 | 16 | public int getConnections() { 17 | return connections; 18 | } 19 | 20 | public void setConnections(int connections) { 21 | this.connections = connections; 22 | } 23 | 24 | @Override 25 | public void initConnector(int threadCount) { 26 | checkConnector(); 27 | connector.setHost(this.getHost()); 28 | connector.setPort(this.getPort()); 29 | connector.setConnectionCount(connections); 30 | connector.setExecutorThreadCount(threadCount); 31 | executor = new MultiClientRemoteExecutor(connector); 32 | } 33 | 34 | private void checkConnector() { 35 | if(connector==null){ 36 | connector = new RpcMultiConnector(); 37 | if(connectorClass==null){ 38 | connectorClass = RpcNioConnector.class; 39 | } 40 | connector.setConnectorClass(connectorClass); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /hasting-rpc/src/main/java/com/lindzh/hasting/rpc/client/SimpleClientRemoteExecutor.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.rpc.client; 2 | 3 | import com.lindzh.hasting.rpc.RemoteCall; 4 | import com.lindzh.hasting.rpc.RemoteExecutor; 5 | import com.lindzh.hasting.rpc.Service; 6 | import com.lindzh.hasting.rpc.net.AbstractRpcConnector; 7 | import com.lindzh.hasting.rpc.net.RpcCallListener; 8 | import com.lindzh.hasting.rpc.oio.RpcOioConnector; 9 | 10 | public class SimpleClientRemoteExecutor extends AbstractClientRemoteExecutor implements RemoteExecutor,RpcCallListener,Service{ 11 | 12 | private AbstractRpcConnector connector; 13 | 14 | public SimpleClientRemoteExecutor(AbstractRpcConnector connector){ 15 | super(); 16 | connector.addRpcCallListener(this); 17 | this.connector = connector; 18 | } 19 | 20 | public AbstractRpcConnector getConnector() { 21 | return connector; 22 | } 23 | 24 | public void setConnector(RpcOioConnector connector) { 25 | this.connector = connector; 26 | } 27 | 28 | @Override 29 | public void startService() { 30 | connector.startService(); 31 | } 32 | 33 | @Override 34 | public void stopService() { 35 | connector.stopService(); 36 | } 37 | 38 | @Override 39 | public AbstractRpcConnector getRpcConnector(RemoteCall call) { 40 | return connector; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /hasting-rpc/src/main/java/com/lindzh/hasting/rpc/client/SimpleRpcClient.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.rpc.client; 2 | 3 | import com.lindzh.hasting.rpc.net.AbstractRpcConnector; 4 | import com.lindzh.hasting.rpc.utils.RpcUtils; 5 | 6 | public class SimpleRpcClient extends AbstractRpcClient{ 7 | 8 | private AbstractRpcConnector connector; 9 | private AbstractClientRemoteExecutor executor; 10 | 11 | private void checkConnector(){ 12 | if(connector==null){ 13 | connector = RpcUtils.createConnector(connectorClass); 14 | } 15 | } 16 | 17 | @Override 18 | public AbstractClientRemoteExecutor getRemoteExecutor() { 19 | return executor; 20 | } 21 | 22 | @Override 23 | public void initConnector(int threadCount) { 24 | checkConnector(); 25 | connector.setHost(this.getHost()); 26 | connector.setPort(this.getPort()); 27 | connector.setExecutorThreadCount(threadCount); 28 | executor = new SimpleClientRemoteExecutor(connector); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /hasting-rpc/src/main/java/com/lindzh/hasting/rpc/cluster1/ConsumeRpcObject.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.rpc.cluster1; 2 | 3 | /** 4 | * Created by lin on 2016/12/9. 5 | */ 6 | public class ConsumeRpcObject { 7 | 8 | /** 9 | * 消费者所属应用 10 | */ 11 | private String application; 12 | 13 | /** 14 | * 消费者ip 15 | */ 16 | private String ip; 17 | 18 | /** 19 | * 依赖class 20 | */ 21 | private String className; 22 | 23 | /** 24 | * 依赖class版本 25 | */ 26 | private String version; 27 | 28 | /** 29 | * 隔离组 30 | */ 31 | private String group; 32 | 33 | public String getApplication() { 34 | return application; 35 | } 36 | 37 | public void setApplication(String application) { 38 | this.application = application; 39 | } 40 | 41 | public String getIp() { 42 | return ip; 43 | } 44 | 45 | public void setIp(String ip) { 46 | this.ip = ip; 47 | } 48 | 49 | public String getClassName() { 50 | return className; 51 | } 52 | 53 | public void setClassName(String className) { 54 | this.className = className; 55 | } 56 | 57 | public String getVersion() { 58 | return version; 59 | } 60 | 61 | public void setVersion(String version) { 62 | this.version = version; 63 | } 64 | 65 | public String getGroup() { 66 | return group; 67 | } 68 | 69 | public void setGroup(String group) { 70 | this.group = group; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /hasting-rpc/src/main/java/com/lindzh/hasting/rpc/cluster1/HostWeight.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.rpc.cluster1; 2 | 3 | /** 4 | * Created by lin on 2016/12/10. 5 | */ 6 | public class HostWeight { 7 | 8 | private String host; 9 | 10 | private int port; 11 | 12 | private int weight; 13 | 14 | public String getKey(){ 15 | return host+":"+port; 16 | } 17 | 18 | public String getHost() { 19 | return host; 20 | } 21 | 22 | public void setHost(String host) { 23 | this.host = host; 24 | } 25 | 26 | public int getPort() { 27 | return port; 28 | } 29 | 30 | public void setPort(int port) { 31 | this.port = port; 32 | } 33 | 34 | public int getWeight() { 35 | return weight; 36 | } 37 | 38 | public void setWeight(int weight) { 39 | this.weight = weight; 40 | } 41 | 42 | public void setKey(String key){ 43 | //do nothing 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /hasting-rpc/src/main/java/com/lindzh/hasting/rpc/exception/RpcException.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.rpc.exception; 2 | 3 | /** 4 | * rpc异常定义 5 | * @author lindezhi 6 | * 2014年6月13日 下午4:47:35 7 | */ 8 | public class RpcException extends RuntimeException{ 9 | 10 | private static final long serialVersionUID = 6238589897120159526L; 11 | 12 | public RpcException(){ 13 | super(); 14 | } 15 | 16 | public RpcException(String message){ 17 | super(message); 18 | } 19 | 20 | public RpcException(Throwable thr){ 21 | super(thr); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /hasting-rpc/src/main/java/com/lindzh/hasting/rpc/exception/RpcExceptionHandler.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.rpc.exception; 2 | 3 | import com.lindzh.hasting.rpc.RemoteCall; 4 | import com.lindzh.hasting.rpc.RpcObject; 5 | 6 | /** 7 | * 异常处理 8 | * @author lindezhi 9 | * 2014年6月13日 下午4:47:49 10 | */ 11 | public interface RpcExceptionHandler { 12 | 13 | public void handleException(RpcObject rpc, RemoteCall call, Throwable e); 14 | 15 | } 16 | -------------------------------------------------------------------------------- /hasting-rpc/src/main/java/com/lindzh/hasting/rpc/exception/RpcNetExceptionHandler.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.rpc.exception; 2 | 3 | /** 4 | * 网络异常处理 5 | * @author lindezhi 6 | * 2016年6月13日 下午4:48:03 7 | */ 8 | public interface RpcNetExceptionHandler { 9 | 10 | public void handleNetException(Exception e); 11 | 12 | } 13 | -------------------------------------------------------------------------------- /hasting-rpc/src/main/java/com/lindzh/hasting/rpc/exception/SimpleRpcExceptionHandler.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.rpc.exception; 2 | 3 | import com.lindzh.hasting.rpc.RemoteCall; 4 | import com.lindzh.hasting.rpc.RpcObject; 5 | import org.apache.log4j.Logger; 6 | 7 | /** 8 | * 简单异常处理器 9 | * @author lindezhi 10 | * 2016年6月13日 下午4:48:15 11 | */ 12 | public class SimpleRpcExceptionHandler implements RpcExceptionHandler{ 13 | 14 | private Logger logger = Logger.getLogger(SimpleRpcExceptionHandler.class); 15 | 16 | @Override 17 | public void handleException(RpcObject rpc, RemoteCall call, Throwable e) { 18 | if(e instanceof RpcException){ 19 | logger.info("rpcException "+e.getMessage()); 20 | }else{ 21 | e.printStackTrace(); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /hasting-rpc/src/main/java/com/lindzh/hasting/rpc/filter/RpcFilter.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.rpc.filter; 2 | 3 | import com.lindzh.hasting.rpc.RemoteCall; 4 | import com.lindzh.hasting.rpc.RpcObject; 5 | import com.lindzh.hasting.rpc.net.RpcSender; 6 | 7 | /** 8 | * rpc过滤器,类似于tomcat的servlet filter 9 | * @author lindezhi 10 | * 2016年6月13日 下午4:31:02 11 | */ 12 | public interface RpcFilter { 13 | 14 | /** 15 | * 执行过滤 16 | * @param rpc 17 | * @param call 18 | * @param sender 19 | * @param chain 20 | */ 21 | public void doFilter(RpcObject rpc,RemoteCall call,RpcSender sender,RpcFilterChain chain); 22 | 23 | } 24 | -------------------------------------------------------------------------------- /hasting-rpc/src/main/java/com/lindzh/hasting/rpc/filter/RpcFilterChain.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.rpc.filter; 2 | 3 | import com.lindzh.hasting.rpc.RemoteCall; 4 | import com.lindzh.hasting.rpc.RpcObject; 5 | import com.lindzh.hasting.rpc.net.RpcSender; 6 | 7 | /** 8 | * 过滤器责任链定义 9 | * @author lindezhi 10 | * 2016年6月13日 下午4:31:56 11 | */ 12 | public interface RpcFilterChain { 13 | 14 | /** 15 | * 执行过滤 16 | * @param rpc 17 | * @param call 18 | * @param sender 19 | */ 20 | public void nextFilter(RpcObject rpc,RemoteCall call,RpcSender sender); 21 | 22 | /** 23 | * 按顺序添加过滤器 24 | * @param filter 25 | */ 26 | public void addRpcFilter(RpcFilter filter); 27 | 28 | /** 29 | * 启动chain 30 | * @param rpc 31 | * @param call 32 | * @param sender 33 | */ 34 | public void startFilter(RpcObject rpc,RemoteCall call,RpcSender sender); 35 | 36 | } 37 | -------------------------------------------------------------------------------- /hasting-rpc/src/main/java/com/lindzh/hasting/rpc/filter/SimpleLogFilter.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.rpc.filter; 2 | 3 | import com.lindzh.hasting.rpc.RpcObject; 4 | import org.apache.log4j.Logger; 5 | 6 | import com.lindzh.hasting.rpc.RemoteCall; 7 | import com.lindzh.hasting.rpc.net.RpcSender; 8 | 9 | /** 10 | * 访问日志,方便agent做日志分析统计访问次数,给manager做负载均衡 11 | * @author linda 12 | * 13 | */ 14 | public class SimpleLogFilter implements RpcFilter{ 15 | 16 | private Logger logger = Logger.getLogger("rpcstream"); 17 | 18 | private String logFormat = "{\"host\":\"%s\",\"port\":%d,\"service\":\"%s\",\"version\":\"%s\",\"method\":\"%s\"}"; 19 | 20 | private String genLogMessage(String host,int port,String service,String version,String method){ 21 | return String.format(logFormat, host,port,service,version,method); 22 | } 23 | 24 | /** 25 | * 日志打印 26 | */ 27 | @Override 28 | public void doFilter(RpcObject rpc, RemoteCall call, RpcSender sender, 29 | RpcFilterChain chain) { 30 | logger.info(this.genLogMessage(rpc.getHost(), rpc.getPort(), call.getService(), call.getVersion(), call.getMethod())); 31 | chain.nextFilter(rpc, call, sender); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /hasting-rpc/src/main/java/com/lindzh/hasting/rpc/generic/ArgsParser.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.rpc.generic; 2 | 3 | /** 4 | * 参数转换器 5 | * @author lindezhi 6 | * 2016年6月13日 下午4:40:52 7 | */ 8 | public interface ArgsParser { 9 | 10 | /** 11 | * 入参转换 12 | * @param argtype 13 | * @param args 14 | * @return 15 | */ 16 | public Object[] parseArgs(String[] argtype,Object[] args); 17 | 18 | /** 19 | * 结果集转换 20 | * @param result 21 | * @return 22 | */ 23 | public Object parseResult(Object result); 24 | 25 | /** 26 | * 参数类型检查 27 | * @param argtype 28 | * @param args 29 | */ 30 | public void checkArgs(String[] argtype,Object[] args); 31 | } 32 | -------------------------------------------------------------------------------- /hasting-rpc/src/main/java/com/lindzh/hasting/rpc/generic/GenericService.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.rpc.generic; 2 | 3 | /** 4 | * 泛型 5 | * @author linda 6 | * 7 | * 8 | */ 9 | public interface GenericService { 10 | 11 | /** 12 | * 需要等待返回值,或者同步的调用 13 | * @param service 14 | * @param version 15 | * @param method 16 | * @param argtype 17 | * @param args 18 | * @return 19 | */ 20 | public Object invoke(String group,String service,String version,String method,String[] argtype,Object[] args); 21 | 22 | /** 23 | * 不需要等待返回值的调用 24 | * @param service 25 | * @param version 26 | * @param method 27 | * @param argtype 28 | * @param args 29 | */ 30 | public void oneway(String group,String service,String version,String method,String[] argtype,Object[] args); 31 | 32 | } 33 | -------------------------------------------------------------------------------- /hasting-rpc/src/main/java/com/lindzh/hasting/rpc/monitor/RpcMonitorService.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.rpc.monitor; 2 | 3 | import java.util.List; 4 | 5 | import com.lindzh.hasting.rpc.RpcService; 6 | 7 | /** 8 | * 服务提供者性能监控,provider内置 9 | * @author lindezhi 10 | * 2014年6月13日 下午4:48:32 11 | */ 12 | public interface RpcMonitorService extends StatMonitor{ 13 | 14 | /** 15 | * 获取服务列表 16 | * @return 17 | */ 18 | public List getRpcServices(); 19 | 20 | /** 21 | * 检测服务是否正常 22 | * @return 23 | */ 24 | public String ping(); 25 | 26 | } 27 | -------------------------------------------------------------------------------- /hasting-rpc/src/main/java/com/lindzh/hasting/rpc/monitor/StatMonitor.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.rpc.monitor; 2 | 3 | import java.util.Map; 4 | 5 | /** 6 | * 统计监控值 7 | * @author lindezhi 8 | * 2016年6月13日 下午4:38:04 9 | */ 10 | public interface StatMonitor { 11 | 12 | public Map getRpcStat(); 13 | 14 | } 15 | -------------------------------------------------------------------------------- /hasting-rpc/src/main/java/com/lindzh/hasting/rpc/net/AbstractRpcAcceptor.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.rpc.net; 2 | 3 | import com.lindzh.hasting.rpc.Service; 4 | import com.lindzh.hasting.rpc.exception.RpcException; 5 | 6 | 7 | public abstract class AbstractRpcAcceptor extends RpcNetBase implements Service { 8 | 9 | protected boolean stop = false; 10 | 11 | @Override 12 | public void startService() { 13 | super.startService(); 14 | this.setExecutorSharable(false); 15 | } 16 | 17 | @Override 18 | public void stopService() { 19 | this.fireCloseNetListeners(new RpcException("acceptor close")); 20 | super.stopService(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /hasting-rpc/src/main/java/com/lindzh/hasting/rpc/net/AbstractRpcNetworkBase.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.rpc.net; 2 | 3 | import javax.net.ssl.SSLContext; 4 | 5 | import com.lindzh.hasting.rpc.Service; 6 | 7 | /** 8 | * 网络父类,服务端和客户端都需要继承 9 | * @author lindezhi 10 | * 2015年6月14日 上午10:24:26 11 | */ 12 | public abstract class AbstractRpcNetworkBase implements Service{ 13 | /** 14 | * ip服务端表示绑定ip,客户端表示连接到服务器的监听ip 15 | */ 16 | private String host; 17 | 18 | /** 19 | * 端口服务端表示绑定端口,客户端表示连接到服务端的监听端口 20 | */ 21 | private int port; 22 | 23 | /** 24 | * 启用SSL的选项,一般不用 25 | */ 26 | protected SSLContext sslContext; 27 | 28 | protected int sslMode; 29 | 30 | public String getHost() { 31 | return host; 32 | } 33 | 34 | public void setHost(String host) { 35 | this.host = host; 36 | } 37 | 38 | public int getPort() { 39 | return port; 40 | } 41 | 42 | public void setPort(int port) { 43 | this.port = port; 44 | } 45 | 46 | public SSLContext getSslContext() { 47 | return sslContext; 48 | } 49 | 50 | public void setSslContext(SSLContext sslContext) { 51 | this.sslContext = sslContext; 52 | } 53 | 54 | public int getSslMode() { 55 | return sslMode; 56 | } 57 | 58 | public void setSslMode(int sslMode) { 59 | this.sslMode = sslMode; 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /hasting-rpc/src/main/java/com/lindzh/hasting/rpc/net/RpcCallListener.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.rpc.net; 2 | 3 | import com.lindzh.hasting.rpc.RpcObject; 4 | 5 | 6 | public interface RpcCallListener { 7 | 8 | public void onRpcMessage(RpcObject rpc,RpcSender sender); 9 | 10 | } 11 | -------------------------------------------------------------------------------- /hasting-rpc/src/main/java/com/lindzh/hasting/rpc/net/RpcNetListener.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.rpc.net; 2 | 3 | /** 4 | * 网络异常监听器,用于通知集群更新状态 5 | * @author Administrator 6 | * 7 | */ 8 | public interface RpcNetListener { 9 | 10 | public void onClose(RpcNetBase network,Exception e); 11 | 12 | public void onStart(RpcNetBase network); 13 | 14 | } 15 | -------------------------------------------------------------------------------- /hasting-rpc/src/main/java/com/lindzh/hasting/rpc/net/RpcOutputNofity.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.rpc.net; 2 | 3 | public interface RpcOutputNofity { 4 | 5 | public void notifySend(AbstractRpcConnector connector); 6 | 7 | } 8 | -------------------------------------------------------------------------------- /hasting-rpc/src/main/java/com/lindzh/hasting/rpc/net/RpcSender.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.rpc.net; 2 | 3 | import com.lindzh.hasting.rpc.RpcObject; 4 | 5 | public interface RpcSender { 6 | 7 | public boolean sendRpcObject(RpcObject rpc, int timeout); 8 | 9 | } 10 | -------------------------------------------------------------------------------- /hasting-rpc/src/main/java/com/lindzh/hasting/rpc/nio/AbstractRpcNioSelector.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.rpc.nio; 2 | 3 | import java.util.LinkedList; 4 | import java.util.List; 5 | 6 | import com.lindzh.hasting.rpc.Service; 7 | import com.lindzh.hasting.rpc.exception.RpcNetExceptionHandler; 8 | import com.lindzh.hasting.rpc.net.RpcNetBase; 9 | import com.lindzh.hasting.rpc.net.RpcNetListener; 10 | import com.lindzh.hasting.rpc.net.RpcOutputNofity; 11 | 12 | public abstract class AbstractRpcNioSelector implements Service,RpcOutputNofity,RpcNetExceptionHandler{ 13 | 14 | public abstract void register(RpcNioAcceptor acceptor); 15 | 16 | public abstract void unRegister(RpcNioAcceptor acceptor); 17 | 18 | public abstract void register(RpcNioConnector connector); 19 | 20 | public abstract void unRegister(RpcNioConnector connector); 21 | 22 | public AbstractRpcNioSelector(){ 23 | netListeners = new LinkedList(); 24 | } 25 | 26 | protected List netListeners; 27 | 28 | public void addRpcNetListener(RpcNetListener listener){ 29 | netListeners.add(listener); 30 | } 31 | 32 | public void fireNetListeners(RpcNetBase network,Exception e){ 33 | for(RpcNetListener listener:netListeners){ 34 | listener.onClose(network,e); 35 | } 36 | } 37 | 38 | 39 | } 40 | -------------------------------------------------------------------------------- /hasting-rpc/src/main/java/com/lindzh/hasting/rpc/oio/AbstractRpcOioWriter.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.rpc.oio; 2 | 3 | import java.io.DataOutputStream; 4 | 5 | import com.lindzh.hasting.rpc.RpcObject; 6 | import com.lindzh.hasting.rpc.net.AbstractRpcConnector; 7 | import com.lindzh.hasting.rpc.net.AbstractRpcWriter; 8 | import com.lindzh.hasting.rpc.utils.RpcUtils; 9 | 10 | public abstract class AbstractRpcOioWriter extends AbstractRpcWriter{ 11 | 12 | public AbstractRpcOioWriter(){ 13 | super(); 14 | } 15 | 16 | public boolean exeSend(AbstractRpcConnector con){ 17 | boolean hasSend = false; 18 | RpcOioConnector connector = (RpcOioConnector)con; 19 | DataOutputStream dos = connector.getOutputStream(); 20 | while(connector.isNeedToSend()){ 21 | RpcObject rpc = connector.getToSend(); 22 | RpcUtils.writeDataRpc(rpc, dos,connector); 23 | hasSend = true; 24 | } 25 | return hasSend; 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /hasting-rpc/src/main/java/com/lindzh/hasting/rpc/oio/PooledRpcOioWriter.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.rpc.oio; 2 | 3 | import java.util.concurrent.ExecutorService; 4 | import java.util.concurrent.Executors; 5 | 6 | import com.lindzh.hasting.rpc.net.AbstractRpcConnector; 7 | 8 | public class PooledRpcOioWriter extends AbstractRpcOioWriter{ 9 | 10 | private int threadCount = 2; 11 | private ExecutorService executorService; 12 | 13 | public int getThreadCount() { 14 | return threadCount; 15 | } 16 | 17 | public void setThreadCount(int threadCount) { 18 | this.threadCount = threadCount; 19 | } 20 | 21 | @Override 22 | public void startService() { 23 | executorService = Executors.newFixedThreadPool(threadCount); 24 | super.startService(); 25 | } 26 | 27 | @Override 28 | public void stopService() { 29 | super.stopService(); 30 | executorService.shutdown(); 31 | } 32 | 33 | @Override 34 | public boolean doSend(final AbstractRpcConnector connector) { 35 | executorService.execute(new Runnable(){ 36 | public void run() { 37 | PooledRpcOioWriter.this.exeSend(connector); 38 | } 39 | }); 40 | return true; 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /hasting-rpc/src/main/java/com/lindzh/hasting/rpc/oio/SimpleRpcOioWriter.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.rpc.oio; 2 | 3 | import com.lindzh.hasting.rpc.net.AbstractRpcConnector; 4 | 5 | public class SimpleRpcOioWriter extends AbstractRpcOioWriter{ 6 | 7 | @Override 8 | public boolean doSend(AbstractRpcConnector connector) { 9 | return super.exeSend(connector); 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /hasting-rpc/src/main/java/com/lindzh/hasting/rpc/serializer/JdkSerializer.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.rpc.serializer; 2 | 3 | import java.io.ByteArrayInputStream; 4 | import java.io.ByteArrayOutputStream; 5 | import java.io.ObjectInputStream; 6 | import java.io.ObjectOutputStream; 7 | 8 | import com.lindzh.hasting.rpc.exception.RpcException; 9 | import com.lindzh.hasting.rpc.utils.NioUtils; 10 | 11 | /** 12 | * 使用jdk自带序列化 13 | * @author lindezhi 14 | * 2016年6月13日 下午4:25:03 15 | */ 16 | public class JdkSerializer implements RpcSerializer { 17 | 18 | /** 19 | * 先序列化再执行压缩,减少网络流量 20 | */ 21 | @Override 22 | public byte[] serialize(Object obj) { 23 | try { 24 | ByteArrayOutputStream bis = new ByteArrayOutputStream(); 25 | ObjectOutputStream stream = new ObjectOutputStream(bis); 26 | stream.writeObject(obj); 27 | stream.close(); 28 | byte[] bytes = bis.toByteArray(); 29 | //使用zip压缩,缩小网络包 30 | return NioUtils.zip(bytes); 31 | } catch (Exception e) { 32 | throw new RpcException(e); 33 | } 34 | } 35 | 36 | /** 37 | * 先解压缩,再反序列化 38 | */ 39 | @Override 40 | public Object deserialize(byte[] bytes) { 41 | try { 42 | //使用zip解压缩 43 | byte[] unzip = NioUtils.unzip(bytes); 44 | ByteArrayInputStream bis = new ByteArrayInputStream(unzip); 45 | ObjectInputStream stream = new ObjectInputStream(bis); 46 | return stream.readObject(); 47 | } catch (Exception e) { 48 | throw new RpcException(e); 49 | } 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /hasting-rpc/src/main/java/com/lindzh/hasting/rpc/serializer/RpcSerializer.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.rpc.serializer; 2 | 3 | /** 4 | * 对象,参数序列化 5 | * @author lindezhi 6 | * 2016年6月13日 下午4:24:26 7 | */ 8 | public interface RpcSerializer { 9 | 10 | /** 11 | * 序列化 12 | * @param obj 13 | * @return 14 | */ 15 | public byte[] serialize(Object obj); 16 | 17 | /** 18 | * 反序列化 19 | * @param bytes 20 | * @return 21 | */ 22 | public Object deserialize(byte[] bytes); 23 | 24 | } 25 | -------------------------------------------------------------------------------- /hasting-rpc/src/main/java/com/lindzh/hasting/rpc/server/ConcurrentRpcServer.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.rpc.server; 2 | 3 | import com.lindzh.hasting.rpc.nio.AbstractRpcNioSelector; 4 | import com.lindzh.hasting.rpc.nio.ConcurrentRpcNioSelector; 5 | 6 | /** 7 | * 可以使用多个连接的rpcserver 8 | * @author lindezhi 9 | * 2016年6月14日 上午10:35:25 10 | */ 11 | public class ConcurrentRpcServer extends AbstractRpcServer{ 12 | 13 | private AbstractRpcNioSelector nioSelector; 14 | 15 | @Override 16 | public AbstractRpcNioSelector getNioSelector() { 17 | if(nioSelector==null){ 18 | nioSelector = new ConcurrentRpcNioSelector(); 19 | } 20 | return nioSelector; 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /hasting-rpc/src/main/java/com/lindzh/hasting/rpc/server/RpcServicesHolder.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.rpc.server; 2 | 3 | import java.util.List; 4 | 5 | import com.lindzh.hasting.rpc.RpcServiceBean; 6 | 7 | /** 8 | * provider提供的api列表 9 | * @author lindezhi 10 | * 2016年6月14日 上午10:23:33 11 | */ 12 | public interface RpcServicesHolder { 13 | 14 | public List getRpcServices(); 15 | 16 | } 17 | -------------------------------------------------------------------------------- /hasting-rpc/src/main/java/com/lindzh/hasting/rpc/server/SimpleRpcServer.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.rpc.server; 2 | 3 | import com.lindzh.hasting.rpc.nio.AbstractRpcNioSelector; 4 | import com.lindzh.hasting.rpc.nio.SimpleRpcNioSelector; 5 | 6 | /** 7 | * 8 | * @author lindezhi 9 | * 2015年6月14日 上午10:35:03 10 | */ 11 | public class SimpleRpcServer extends AbstractRpcServer{ 12 | 13 | private AbstractRpcNioSelector nioSelector; 14 | 15 | /** 16 | * nio的selector 17 | */ 18 | @Override 19 | public AbstractRpcNioSelector getNioSelector() { 20 | if(nioSelector==null){ 21 | nioSelector = new SimpleRpcNioSelector(); 22 | } 23 | return nioSelector; 24 | } 25 | 26 | 27 | } 28 | -------------------------------------------------------------------------------- /hasting-rpc/src/main/java/com/lindzh/hasting/rpc/sync/RpcSync.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.rpc.sync; 2 | 3 | import com.lindzh.hasting.rpc.RpcCallSync; 4 | import com.lindzh.hasting.rpc.RpcObject; 5 | 6 | /** 7 | * 同步抽象类 8 | * @author lindezhi 9 | * 2016年3月9日 上午11:32:50 10 | */ 11 | public interface RpcSync { 12 | 13 | /** 14 | * 同步等待执行结果 15 | * @param time 16 | * @param sync 17 | */ 18 | public void waitForResult(int time,RpcCallSync sync); 19 | 20 | /** 21 | * 通知结果返回 22 | * @param sync 23 | * @param rpc 返回值 24 | */ 25 | public void notifyResult(RpcCallSync sync,RpcObject rpc); 26 | } 27 | -------------------------------------------------------------------------------- /hasting-rpc/src/main/java/com/lindzh/hasting/rpc/sync/SimpleFutureRpcSync.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.rpc.sync; 2 | 3 | import com.lindzh.hasting.rpc.RpcCallSync; 4 | import com.lindzh.hasting.rpc.RpcObject; 5 | import com.lindzh.hasting.rpc.exception.RpcException; 6 | 7 | /** 8 | * 使用不断检查 9 | * @author lindezhi 10 | * 2016年3月9日 上午11:33:53 11 | */ 12 | public class SimpleFutureRpcSync implements RpcSync{ 13 | 14 | @Override 15 | public void waitForResult(int time, RpcCallSync sync) { 16 | int timeAll = 0; 17 | while(!sync.isDone()){ 18 | try { 19 | Thread.currentThread().sleep(5); 20 | timeAll+=5; 21 | if(timeAll>time){ 22 | throw new RpcException("request time out"); 23 | } 24 | } catch (InterruptedException e) { 25 | throw new RpcException(e); 26 | } 27 | } 28 | } 29 | 30 | @Override 31 | public void notifyResult(RpcCallSync sync, RpcObject rpc) { 32 | if(sync!=null){ 33 | sync.setResponse(rpc); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /hasting-rpc/src/main/java/com/lindzh/hasting/rpc/sync/SimpleJdkRpcSync.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.rpc.sync; 2 | 3 | import com.lindzh.hasting.rpc.RpcCallSync; 4 | import com.lindzh.hasting.rpc.RpcObject; 5 | import com.lindzh.hasting.rpc.exception.RpcException; 6 | 7 | /** 8 | * 使用object wait notify 9 | * @author lindezhi 10 | * 2016年3月9日 上午11:35:31 11 | */ 12 | public class SimpleJdkRpcSync implements RpcSync { 13 | 14 | @Override 15 | public void waitForResult(int time, RpcCallSync sync) { 16 | synchronized(sync){ 17 | try { 18 | sync.wait(time); 19 | if(sync.getResponse()==null){ 20 | throw new RpcException("rpc request time out"); 21 | } 22 | } catch (InterruptedException e) { 23 | throw new RpcException(e); 24 | } 25 | } 26 | } 27 | 28 | @Override 29 | public void notifyResult(RpcCallSync sync, RpcObject rpc) { 30 | if(sync!=null){ 31 | synchronized(sync){ 32 | sync.setResponse(rpc); 33 | sync.notify(); 34 | } 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /hasting-rpc/src/main/java/com/lindzh/hasting/rpc/utils/XName.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.rpc.utils; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * Created by lin on 2016/12/27. 10 | */ 11 | @Target(ElementType.FIELD) 12 | @Retention(RetentionPolicy.RUNTIME) 13 | public @interface XName { 14 | String value() default ""; 15 | } 16 | -------------------------------------------------------------------------------- /hasting-rpc/src/main/java/com/lindzh/hasting/rpc/utils/XNamespace.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.rpc.utils; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * Created by lin on 2016/12/27. 10 | */ 11 | @Target(ElementType.TYPE) 12 | @Retention(RetentionPolicy.RUNTIME) 13 | public @interface XNamespace { 14 | String value() default ""; 15 | } 16 | -------------------------------------------------------------------------------- /hasting-rpc/src/main/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | log4j.rootLogger=INFO,stdout,store 2 | 3 | log4j.appender.stdout=org.apache.log4j.ConsoleAppender 4 | log4j.appender.stdout.Target=System.out 5 | log4j.appender.stdout.layout=org.apache.log4j.PatternLayout 6 | log4j.appender.stdout.layout.ConversionPattern=%d %-4r [%t] (%F:%L) %-5p - %m%n 7 | 8 | log4j.appender.store=org.apache.log4j.DailyRollingFileAppender 9 | log4j.appender.store.File=D:\\rpc\\client\\log 10 | log4j.appender.store.Append=true 11 | log4j.appender.store.DatePattern ='_'yyyy-MM-dd'.log' 12 | log4j.appender.store.layout=org.apache.log4j.PatternLayout 13 | log4j.appender.store.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-4r [%t] (%F:%L) %-5p - %m%n -------------------------------------------------------------------------------- /hasting-rpc/src/main/script/client.sh: -------------------------------------------------------------------------------- 1 | java -Xmx9000m -Xss1m -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCDateStamps -Xloggc:/styx/home/hzlindzh/rpc-client/gc.log -XX:+UseParallelGC -XX:+UseParallelOldGC -jar rpc-client.jar -h10.120.47.41 -p44444 -t300000 -th200 -c25000 -s1000 & 2 | -------------------------------------------------------------------------------- /hasting-rpc/src/main/script/log4j.properties: -------------------------------------------------------------------------------- 1 | log4j.rootLogger=INFO,stdout,store 2 | 3 | log4j.appender.stdout=org.apache.log4j.ConsoleAppender 4 | log4j.appender.stdout.Target=System.out 5 | log4j.appender.stdout.layout=org.apache.log4j.PatternLayout 6 | log4j.appender.stdout.layout.ConversionPattern=%d %-4r [%t] (%F:%L) %-5p - %m%n 7 | 8 | 9 | log4j.appender.store=org.apache.log4j.DailyRollingFileAppender 10 | log4j.appender.store.File=/styx/home/hzlindzh/rpc-server/rpc.log 11 | log4j.appender.store.Append=true 12 | log4j.appender.store.DatePattern ='_'yyyy-MM-dd'.log' 13 | log4j.appender.store.layout=org.apache.log4j.PatternLayout 14 | log4j.appender.store.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-4r [%t] (%F:%L) %-5p - %m%n 15 | 16 | 17 | log4j.logger.rpcstream = INFO, rpcStreamRolling 18 | log4j.appender.rpcStreamRolling = org.apache.log4j.RollingFileAppender 19 | log4j.appender.rpcStreamRolling.Append = true 20 | log4j.appender.rpcStreamRolling.BufferedIO = false 21 | log4j.appender.rpcStreamRolling.File = /styx/home/hzlindzh/rpc-server/rpcstream.log 22 | log4j.appender.rpcStreamRolling.Encoding = UTF-8 23 | log4j.appender.rpcStreamRolling.layout = org.apache.log4j.PatternLayout 24 | log4j.appender.rpcStreamRolling.layout.ConversionPattern = [%-5p]%d{ISO8601}, [Class]%-c{1}, %m%n 25 | log4j.appender.rpcStreamRolling.MaxBackupIndex = 3 26 | log4j.appender.rpcStreamRolling.MaxFileSize = 1024MB 27 | -------------------------------------------------------------------------------- /hasting-rpc/src/main/script/server.sh: -------------------------------------------------------------------------------- 1 | java -Xmx9000m -Xss1m -verbose:gc -Xloggc:/styx/home/hzlindzh/rpc-server/gc.log -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+UseParallelGC -XX:+UseParallelOldGC -XX:SurvivorRatio=3 -XX:NewSize=2g -jar rpc-server.jar -h0.0.0.0 -p44444 -th200 -t600000 2 | -------------------------------------------------------------------------------- /hasting-rpc/src/test/java/com/lindzh/hasting/cluster/SimpleClientTest.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.cluster; 2 | 3 | import java.util.HashMap; 4 | 5 | import com.lindzh.hasting.rpc.HelloRpcService; 6 | import com.lindzh.hasting.rpc.cluster1.RpcClusterClient; 7 | import com.lindzh.hasting.rpc.generic.GenericService; 8 | import com.lindzh.hasting.rpc.utils.RpcUtils; 9 | 10 | public class SimpleClientTest { 11 | 12 | public static void main(String[] args) { 13 | RpcClusterClient client = new RpcClusterClient(); 14 | client.setRemoteExecutor(new SimpleClusterExecutor()); 15 | client.startService(); 16 | HelloRpcService service = client.register(HelloRpcService.class); 17 | service.sayHello("this is linda", 32); 18 | GenericService genService = client.register(GenericService.class); 19 | 20 | String[] getBeanTypes = new String[]{"TestBean","int"}; 21 | HashMap map = new HashMap(); 22 | map.put("limit", 111); 23 | map.put("offset", 322); 24 | map.put("order", "trtr"); 25 | map.put("message", "this is a test"); 26 | Object[] getBeanArgs = new Object[]{map,543543}; 27 | Object hh = genService.invoke(null,"HelloRpcService", RpcUtils.DEFAULT_VERSION, "getBean", getBeanTypes, getBeanArgs); 28 | System.out.println(hh); 29 | client.stopService(); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /hasting-rpc/src/test/java/com/lindzh/hasting/rpc/HelloRpcService.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.rpc; 2 | 3 | public interface HelloRpcService { 4 | 5 | public void sayHello(String message,int tt); 6 | 7 | public String getHello(); 8 | 9 | public TestRemoteBean getBean(TestBean bean,int id); 10 | 11 | public int callException(boolean exception); 12 | 13 | } 14 | -------------------------------------------------------------------------------- /hasting-rpc/src/test/java/com/lindzh/hasting/rpc/HelloRpcServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.rpc; 2 | 3 | import org.apache.log4j.Logger; 4 | 5 | public class HelloRpcServiceImpl implements HelloRpcService{ 6 | 7 | private Logger logger = Logger.getLogger(HelloRpcServiceImpl.class); 8 | 9 | @Override 10 | public void sayHello(String message,int tt) { 11 | Object attachment = RpcContext.getContext().getAttachment("myattachment"); 12 | System.out.println("my attachment:"+attachment); 13 | System.out.println("sayHello:"+message+" intValue:"+tt); 14 | } 15 | 16 | @Override 17 | public TestRemoteBean getBean(TestBean bean, int id) { 18 | Object attachment = RpcContext.getContext().getAttachment("myhaha"); 19 | System.out.println("my attachment:"+attachment); 20 | //logger.info("id:"+id+" bean:"+bean.toString()); 21 | TestRemoteBean remoteBean = new TestRemoteBean(); 22 | remoteBean.setAction("fff-"+id); 23 | remoteBean.setAge(id*2); 24 | remoteBean.setName("serviceBean"); 25 | return remoteBean; 26 | } 27 | 28 | @Override 29 | public String getHello() { 30 | return "this is hello service"; 31 | } 32 | 33 | 34 | 35 | @Override 36 | public int callException(boolean exception) { 37 | if(exception){ 38 | throw new RuntimeException("happen"); 39 | } 40 | return 1; 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /hasting-rpc/src/test/java/com/lindzh/hasting/rpc/HelloRpcTestService.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.rpc; 2 | 3 | public interface HelloRpcTestService { 4 | 5 | public String index(int index,String key); 6 | 7 | } 8 | -------------------------------------------------------------------------------- /hasting-rpc/src/test/java/com/lindzh/hasting/rpc/HelloRpcTestServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.rpc; 2 | 3 | import org.apache.log4j.Logger; 4 | 5 | public class HelloRpcTestServiceImpl implements HelloRpcTestService{ 6 | 7 | private Logger logger = Logger.getLogger(HelloRpcTestServiceImpl.class); 8 | 9 | @Override 10 | public String index(int index, String key) { 11 | //logger.info("index:"+index+" key:"+key); 12 | return "HelloRpcTestServiceImpl-"+index+" key:"+key; 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /hasting-rpc/src/test/java/com/lindzh/hasting/rpc/HostTest.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.rpc; 2 | 3 | import java.util.List; 4 | 5 | import com.lindzh.hasting.rpc.utils.RpcUtils; 6 | 7 | public class HostTest { 8 | 9 | public static void main(String[] args) { 10 | List ips = RpcUtils.getLocalV4IPs(); 11 | String chooseIP = RpcUtils.chooseIP(ips); 12 | for(String ip:ips){ 13 | System.out.print(ip); 14 | System.out.println(","); 15 | } 16 | System.out.println(); 17 | System.out.println(chooseIP); 18 | 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /hasting-rpc/src/test/java/com/lindzh/hasting/rpc/LoginRpcService.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.rpc; 2 | 3 | public interface LoginRpcService { 4 | 5 | public boolean login(String username,String password); 6 | 7 | } 8 | -------------------------------------------------------------------------------- /hasting-rpc/src/test/java/com/lindzh/hasting/rpc/LoginRpcServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.rpc; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | import org.apache.log4j.Logger; 7 | 8 | public class LoginRpcServiceImpl implements LoginRpcService{ 9 | 10 | private Logger logger = Logger.getLogger(LoginRpcServiceImpl.class); 11 | 12 | private Map cache = new HashMap(); 13 | 14 | @Override 15 | public boolean login(String username, String password) { 16 | //获取上下文附件 17 | String haha = (String)RpcContext.getContext().getAttachment("haha"); 18 | System.out.println("login:user:"+username+" pass:"+password+" attach haha:"+haha); 19 | String pass = cache.get(username); 20 | //清除上下文附件 21 | RpcContext.getContext().clear(); 22 | return pass!=null&&pass.equals(password); 23 | } 24 | 25 | public LoginRpcServiceImpl(){ 26 | cache.put("linda", "123456"); 27 | cache.put("test", "123456"); 28 | cache.put("admin", "123456"); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /hasting-rpc/src/test/java/com/lindzh/hasting/rpc/MyTestRpcFilter.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.rpc; 2 | 3 | import com.lindzh.hasting.rpc.filter.RpcFilter; 4 | import com.lindzh.hasting.rpc.filter.RpcFilterChain; 5 | import com.lindzh.hasting.rpc.net.RpcSender; 6 | import org.apache.log4j.Logger; 7 | 8 | public class MyTestRpcFilter implements RpcFilter { 9 | private Logger logger = Logger.getLogger(MyTestRpcFilter.class); 10 | @Override 11 | public void doFilter(RpcObject rpc, RemoteCall call, RpcSender sender, 12 | RpcFilterChain chain) { 13 | logger.info("request ip:"+rpc.getHost()+" port:"+rpc.getPort()); 14 | chain.nextFilter(rpc, call, sender); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /hasting-rpc/src/test/java/com/lindzh/hasting/rpc/RpcLoginCheckFilter.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.rpc; 2 | 3 | import java.util.Map; 4 | 5 | import com.lindzh.hasting.rpc.exception.RpcException; 6 | import com.lindzh.hasting.rpc.filter.RpcFilter; 7 | import com.lindzh.hasting.rpc.filter.RpcFilterChain; 8 | import com.lindzh.hasting.rpc.net.RpcSender; 9 | import org.apache.log4j.Logger; 10 | 11 | public class RpcLoginCheckFilter implements RpcFilter { 12 | 13 | private Logger logger = Logger.getLogger(RpcLoginCheckFilter.class); 14 | 15 | @Override 16 | public void doFilter(RpcObject rpc, RemoteCall call, RpcSender sender, RpcFilterChain chain) { 17 | String service = call.getService(); 18 | if(service.equals(LoginRpcService.class.getName())){ 19 | logger.info("----------user login---------------"); 20 | try{ 21 | chain.nextFilter(rpc, call, sender); 22 | rpc.getRpcContext().put("logined", true); 23 | rpc.getRpcContext().put("user", call.getArgs()); 24 | }catch(RpcException e){ 25 | throw e; 26 | } 27 | return; 28 | }else{ 29 | Map context = rpc.getRpcContext(); 30 | if(context.get("logined")==null){ 31 | throw new RpcException("user not login"); 32 | }else{ 33 | chain.nextFilter(rpc, call, sender); 34 | } 35 | } 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /hasting-rpc/src/test/java/com/lindzh/hasting/rpc/TestBean.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.rpc; 2 | 3 | import java.io.Serializable; 4 | 5 | public class TestBean implements Serializable { 6 | 7 | private static final long serialVersionUID = -6778119358481557931L; 8 | private int limit; 9 | private int offset; 10 | private String order; 11 | private String message; 12 | 13 | public int getLimit() { 14 | return limit; 15 | } 16 | 17 | public void setLimit(int limit) { 18 | this.limit = limit; 19 | } 20 | 21 | public int getOffset() { 22 | return offset; 23 | } 24 | 25 | public void setOffset(int offset) { 26 | this.offset = offset; 27 | } 28 | 29 | public String getOrder() { 30 | return order; 31 | } 32 | 33 | public void setOrder(String order) { 34 | this.order = order; 35 | } 36 | 37 | public String getMessage() { 38 | return message; 39 | } 40 | 41 | public void setMessage(String message) { 42 | this.message = message; 43 | } 44 | 45 | @Override 46 | public String toString() { 47 | return "TestBean [limit=" + limit + ", offset=" + offset + ", order=" 48 | + order + ", message=" + message + "]"; 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /hasting-rpc/src/test/java/com/lindzh/hasting/rpc/TestRemoteBean.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.rpc; 2 | 3 | import java.io.Serializable; 4 | 5 | public class TestRemoteBean implements Serializable { 6 | 7 | private static final long serialVersionUID = 2448105590901413899L; 8 | private String name; 9 | private String action; 10 | private int age; 11 | 12 | public String getName() { 13 | return name; 14 | } 15 | 16 | public void setName(String name) { 17 | this.name = name; 18 | } 19 | 20 | public String getAction() { 21 | return action; 22 | } 23 | 24 | public void setAction(String action) { 25 | this.action = action; 26 | } 27 | 28 | public int getAge() { 29 | return age; 30 | } 31 | 32 | public void setAge(int age) { 33 | this.age = age; 34 | } 35 | 36 | @Override 37 | public String toString() { 38 | return "TestRemoteBean [name=" + name + ", action=" + action + ", age=" 39 | + age + "]"; 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /hasting-rpc/src/test/java/com/lindzh/hasting/rpc/aio/ClientTest.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.rpc.aio; 2 | 3 | import java.io.IOException; 4 | import java.net.InetSocketAddress; 5 | import java.nio.ByteBuffer; 6 | import java.nio.channels.AsynchronousSocketChannel; 7 | import java.nio.channels.CompletionHandler; 8 | import java.util.concurrent.Future; 9 | 10 | public class ClientTest { 11 | public static void main(String[] args) throws Exception { 12 | final AsynchronousSocketChannel client = AsynchronousSocketChannel 13 | .open(); 14 | Future future = client.connect(new InetSocketAddress("127.0.0.1", 15 | 8013)); 16 | future.get(); 17 | final ByteBuffer buffer = ByteBuffer.allocate(100); 18 | client.read(buffer, null, new CompletionHandler() { 19 | @Override 20 | public void completed(Integer result, Void attachment) { 21 | System.out.println("client received: " 22 | + new String(buffer.array())); 23 | } 24 | 25 | @Override 26 | public void failed(Throwable exc, Void attachment) { 27 | exc.printStackTrace(); 28 | try { 29 | client.close(); 30 | } catch (IOException e) { 31 | e.printStackTrace(); 32 | } 33 | } 34 | }); 35 | Thread.sleep(10000); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /hasting-rpc/src/test/java/com/lindzh/hasting/rpc/aio/Sender.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.rpc.aio; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.DataInputStream; 5 | import java.io.DataOutputStream; 6 | import java.io.IOException; 7 | import java.io.InputStreamReader; 8 | import java.net.InetSocketAddress; 9 | import java.net.Socket; 10 | 11 | import com.lindzh.hasting.rpc.utils.SSLUtils; 12 | 13 | public class Sender { 14 | 15 | public static void main(String[] args) throws IOException { 16 | Socket socket = SSLUtils.getSocketInstance(null, 1); 17 | socket.connect(new InetSocketAddress("127.0.0.1",4321)); 18 | 19 | DataInputStream dis = new DataInputStream(socket.getInputStream()); 20 | DataOutputStream dos = new DataOutputStream(socket.getOutputStream()); 21 | 22 | BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); 23 | String line = null; 24 | System.out.print("input->"); 25 | while((line=reader.readLine())!=null){ 26 | dos.writeUTF(line); 27 | System.out.println("send:"+line); 28 | String utf = dis.readUTF(); 29 | System.out.println("read:"+utf); 30 | System.out.print("input->"); 31 | } 32 | reader.close(); 33 | dis.close(); 34 | dos.close(); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /hasting-rpc/src/test/java/com/lindzh/hasting/rpc/aio/SocketAcceptHandler.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.rpc.aio; 2 | 3 | import java.nio.channels.CompletionHandler; 4 | 5 | public class SocketAcceptHandler implements CompletionHandler{ 6 | 7 | @Override 8 | public void completed(V result, A attachment) { 9 | 10 | } 11 | 12 | @Override 13 | public void failed(Throwable exc, A attachment) { 14 | 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /hasting-rpc/src/test/java/com/lindzh/hasting/rpc/aio/SocketReadHandler.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.rpc.aio; 2 | 3 | import java.nio.channels.CompletionHandler; 4 | 5 | public class SocketReadHandler implements CompletionHandler{ 6 | 7 | @Override 8 | public void completed(Integer result, A attachment) { 9 | SimpleAioConnector connector = (SimpleAioConnector)attachment; 10 | connector.fireRead(result); 11 | // connector.getChannel().read(connector.getReadBuf(), attachment, connector.getReadHandler()); 12 | } 13 | 14 | @Override 15 | public void failed(Throwable exc, A attachment) { 16 | SimpleAioConnector connector = (SimpleAioConnector)attachment; 17 | connector.fireFailed(exc); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /hasting-rpc/src/test/java/com/lindzh/hasting/rpc/aio/SocketWriteHandler.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.rpc.aio; 2 | 3 | import java.nio.channels.CompletionHandler; 4 | 5 | public class SocketWriteHandler implements CompletionHandler { 6 | 7 | @Override 8 | public void completed(Integer result, A attachment) { 9 | SimpleAioConnector connector = (SimpleAioConnector)attachment; 10 | connector.fireWrite(result); 11 | // connector.getChannel().write(connector.getWriteBuf(), attachment, connector.getWriteHandler()); 12 | } 13 | 14 | @Override 15 | public void failed(Throwable exc, A attachment) { 16 | SimpleAioConnector connector = (SimpleAioConnector)attachment; 17 | connector.fireFailed(exc); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /hasting-rpc/src/test/java/com/lindzh/hasting/rpc/aiorpc/AioClientTest.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.rpc.aiorpc; 2 | 3 | import com.lindzh.hasting.rpc.HelloRpcService; 4 | import com.lindzh.hasting.rpc.HelloRpcTestService; 5 | import com.lindzh.hasting.rpc.aio.RpcAioConnector; 6 | import com.lindzh.hasting.rpc.client.SimpleRpcClient; 7 | 8 | public class AioClientTest { 9 | 10 | public static void main(String[] args) { 11 | 12 | SimpleRpcClient client = new SimpleRpcClient(); 13 | client.setHost("127.0.0.1"); 14 | client.setPort(4321); 15 | 16 | client.setConnectorClass(RpcAioConnector.class); 17 | 18 | client.startService(); 19 | 20 | HelloRpcService helloRpcService = client.register(HelloRpcService.class); 21 | 22 | helloRpcService.sayHello("this is a test", 123); 23 | 24 | HelloRpcTestService testService = client.register(HelloRpcTestService.class); 25 | String index = testService.index(12345, "haha"); 26 | System.out.println("resp:"+index); 27 | 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /hasting-rpc/src/test/java/com/lindzh/hasting/rpc/aiorpc/AioServerTest.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.rpc.aiorpc; 2 | 3 | import com.lindzh.hasting.rpc.HelloRpcService; 4 | import com.lindzh.hasting.rpc.HelloRpcServiceImpl; 5 | import com.lindzh.hasting.rpc.HelloRpcTestService; 6 | import com.lindzh.hasting.rpc.HelloRpcTestServiceImpl; 7 | import com.lindzh.hasting.rpc.aio.RpcAioAcceptor; 8 | import com.lindzh.hasting.rpc.server.SimpleRpcServer; 9 | 10 | public class AioServerTest { 11 | 12 | public static void main(String[] args) { 13 | SimpleRpcServer server = new SimpleRpcServer(); 14 | server.setHost("127.0.0.1"); 15 | server.setPort(4321); 16 | server.setAcceptor(new RpcAioAcceptor()); 17 | 18 | server.register(HelloRpcService.class, new HelloRpcServiceImpl()); 19 | server.register(HelloRpcTestService.class, new HelloRpcTestServiceImpl()); 20 | 21 | server.startService(); 22 | 23 | System.out.println("server started"); 24 | } 25 | 26 | 27 | } 28 | -------------------------------------------------------------------------------- /hasting-rpc/src/test/java/com/lindzh/hasting/rpc/generic/GenericParserTest.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.rpc.generic; 2 | 3 | import java.util.ArrayList; 4 | import java.util.HashMap; 5 | import java.util.Map; 6 | 7 | public class GenericParserTest { 8 | 9 | public static void main(String[] as) { 10 | SimpleArgsParser parser = new SimpleArgsParser(); 11 | String[] types = new String[]{"int","int[]","java.util.List"}; 12 | HashMap map = new HashMap(); 13 | map.put("limit", 111); 14 | map.put("offset", 322); 15 | map.put("order", "trtr"); 16 | map.put("message", "this is a test"); 17 | ArrayList> list = new ArrayList>(); 18 | list.add(map); 19 | list.add(map); 20 | Object[] args = new Object[]{222,new int[]{44,3333},list}; 21 | Object[] args2 = parser.parseArgs(types, args); 22 | System.out.println(args2); 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /hasting-rpc/src/test/java/com/lindzh/hasting/rpc/generic/GenericServerTest.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.rpc.generic; 2 | 3 | import com.lindzh.hasting.rpc.HelloRpcService; 4 | import com.lindzh.hasting.rpc.HelloRpcServiceImpl; 5 | import com.lindzh.hasting.rpc.oio.RpcOioAcceptor; 6 | import com.lindzh.hasting.rpc.server.SimpleRpcServer; 7 | import com.lindzh.hasting.rpc.utils.RpcUtils; 8 | 9 | public class GenericServerTest { 10 | 11 | public static void main(String[] args) { 12 | SimpleRpcServer server = new SimpleRpcServer(); 13 | server.addRpcFilter(new RpcContextClearFilter()); 14 | server.setAcceptor(new RpcOioAcceptor()); 15 | server.setHost("127.0.0.1"); 16 | server.setPort(4445); 17 | 18 | HelloRpcService helloService = new HelloRpcServiceImpl(); 19 | 20 | server.register(HelloRpcService.class, new HelloRpcServiceImpl(), RpcUtils.DEFAULT_VERSION,"aapp"); 21 | server.startService(); 22 | System.out.println("server startup"); 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /hasting-rpc/src/test/java/com/lindzh/hasting/rpc/generic/RpcContextClearFilter.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.rpc.generic; 2 | 3 | import com.lindzh.hasting.rpc.RemoteCall; 4 | import com.lindzh.hasting.rpc.RpcContext; 5 | import com.lindzh.hasting.rpc.RpcObject; 6 | import com.lindzh.hasting.rpc.filter.RpcFilter; 7 | import com.lindzh.hasting.rpc.filter.RpcFilterChain; 8 | import com.lindzh.hasting.rpc.net.RpcSender; 9 | 10 | public class RpcContextClearFilter implements RpcFilter { 11 | @Override 12 | public void doFilter(RpcObject rpc, RemoteCall call, RpcSender sender, 13 | RpcFilterChain chain) { 14 | try{ 15 | chain.nextFilter(rpc, call, sender); 16 | }finally{ 17 | System.out.println("clean rpc context"); 18 | RpcContext.getContext().clear(); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /hasting-rpc/src/test/java/com/lindzh/hasting/rpc/nio/MyBuftest.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.rpc.nio; 2 | 3 | import java.io.ByteArrayOutputStream; 4 | import java.io.DataOutputStream; 5 | import java.io.IOException; 6 | 7 | public class MyBuftest { 8 | 9 | public static void main(String[] args) throws IOException { 10 | RpcNioBuffer buf = new RpcNioBuffer(); 11 | buf.writeInt(23); 12 | buf.writeLong(543534534); 13 | String str = "this is a test"; 14 | byte[] bytes = str.getBytes(); 15 | buf.write(bytes); 16 | buf.compact(); 17 | int readInt = buf.readInt(); 18 | long readLong = buf.readLong(); 19 | 20 | byte[] readBytes = buf.readBytes(); 21 | ByteArrayOutputStream bos = new ByteArrayOutputStream(); 22 | DataOutputStream dos = new DataOutputStream(bos); 23 | dos.writeInt(23); 24 | dos.writeLong(543534534); 25 | dos.write(bytes); 26 | byte[] byteArray = bos.toByteArray(); 27 | System.out.println("buf:"+readBytes.length+" "+byteArray.length); 28 | 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /hasting-rpc/src/test/java/com/lindzh/hasting/rpc/serialize/SerializeTest.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.rpc.serialize; 2 | 3 | import com.lindzh.hasting.rpc.HelloRpcService; 4 | import com.lindzh.hasting.rpc.RemoteCall; 5 | import com.lindzh.hasting.rpc.TestBean; 6 | import com.lindzh.hasting.rpc.serializer.JdkSerializer; 7 | 8 | public class SerializeTest { 9 | 10 | public static void main(String[] args) { 11 | String service = HelloRpcService.class.getName(); 12 | String method = "getBean"; 13 | String version = "534543"; 14 | TestBean testBean = new TestBean(); 15 | testBean.setLimit(4); 16 | testBean.setMessage("ggggggggggggggggggggggggggggggggggggggggggggg"); 17 | testBean.setOffset(43432); 18 | testBean.setOrder("645gdfghdfghdf"); 19 | RemoteCall call = new RemoteCall(service, method); 20 | call.setArgs(new Object[]{testBean,654645}); 21 | call.setVersion(version); 22 | JdkSerializer serializer = new JdkSerializer(); 23 | byte[] bs = serializer.serialize(call); 24 | System.out.println(bs.length); 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /hasting-rpc/src/test/java/com/lindzh/hasting/rpc/serialize/ZipSerializeTest.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.rpc.serialize; 2 | 3 | import java.io.ByteArrayOutputStream; 4 | import java.io.IOException; 5 | import java.io.ObjectOutputStream; 6 | import java.util.zip.GZIPOutputStream; 7 | 8 | import com.lindzh.hasting.rpc.TestBean; 9 | import com.lindzh.hasting.rpc.serializer.JdkSerializer; 10 | 11 | public class ZipSerializeTest { 12 | 13 | public static void main(String[] args) throws IOException { 14 | TestBean testBean = new TestBean(); 15 | testBean.setLimit(4); 16 | testBean.setMessage("ggggggggggggggggggggggggggggggggggggggggggggg"); 17 | testBean.setOffset(43432); 18 | testBean.setOrder("645gdfghdfghdf"); 19 | 20 | JdkSerializer serializer = new JdkSerializer(); 21 | byte[] bs = serializer.serialize(testBean); 22 | 23 | ByteArrayOutputStream bos = new ByteArrayOutputStream(); 24 | GZIPOutputStream zos = new GZIPOutputStream(bos); 25 | 26 | ObjectOutputStream oos = new ObjectOutputStream(zos); 27 | 28 | oos.writeObject(testBean); 29 | 30 | oos.close(); 31 | 32 | // zis.close(); 33 | // bos.close(); 34 | 35 | byte[] os = bos.toByteArray(); 36 | System.out.println(bs.length+" dest---:"+os.length); 37 | //187 dest---:161 38 | 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /hasting-rpc/src/test/java/com/lindzh/hasting/rpc/service/StatisticsFilter.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.rpc.service; 2 | 3 | import java.util.concurrent.atomic.AtomicLong; 4 | 5 | import com.lindzh.hasting.rpc.RemoteCall; 6 | import com.lindzh.hasting.rpc.RpcObject; 7 | import com.lindzh.hasting.rpc.Service; 8 | import com.lindzh.hasting.rpc.filter.RpcFilter; 9 | import com.lindzh.hasting.rpc.filter.RpcFilterChain; 10 | import com.lindzh.hasting.rpc.net.RpcSender; 11 | 12 | public class StatisticsFilter implements RpcFilter,Service{ 13 | 14 | private long start = 0; 15 | private long end = 0; 16 | private AtomicLong call = new AtomicLong(0); 17 | 18 | public void reset(){ 19 | this.call.set(0); 20 | this.start = 0; 21 | this.end = 0; 22 | } 23 | 24 | @Override 25 | public void doFilter(RpcObject rpc, RemoteCall call, RpcSender sender, 26 | RpcFilterChain chain) { 27 | this.call.incrementAndGet(); 28 | chain.nextFilter(rpc, call, sender); 29 | } 30 | 31 | @Override 32 | public void startService() { 33 | this.start = System.currentTimeMillis(); 34 | } 35 | 36 | @Override 37 | public void stopService() { 38 | this.end = System.currentTimeMillis(); 39 | } 40 | 41 | public long getTime(){ 42 | return this.end-this.start; 43 | } 44 | 45 | public long getCall(){ 46 | return this.call.get(); 47 | } 48 | 49 | public long getTps(){ 50 | long time = this.getTime(); 51 | long cc = this.getCall(); 52 | if(time>0){ 53 | return cc*1000/time; 54 | }else{ 55 | return 0; 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /hasting-spring/README.md: -------------------------------------------------------------------------------- 1 | #### spring 配置支持 -------------------------------------------------------------------------------- /hasting-spring/src/main/java/com/lindzh/hasting/spring/annotation/RpcInvokerService.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.spring.annotation; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * 客户端rpc bean依赖注入 10 | * @author linda 11 | * 12 | */ 13 | @Target(ElementType.TYPE) 14 | @Retention(RetentionPolicy.RUNTIME) 15 | public @interface RpcInvokerService { 16 | 17 | String rpcServer() default "defaultRpcServer"; 18 | 19 | String name() default ""; 20 | 21 | String version() default "0.0"; 22 | } 23 | -------------------------------------------------------------------------------- /hasting-spring/src/main/java/com/lindzh/hasting/spring/annotation/RpcProviderFilter.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.spring.annotation; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | import org.springframework.stereotype.Component; 9 | 10 | @Component 11 | @Target(ElementType.TYPE) 12 | @Retention(RetentionPolicy.RUNTIME) 13 | public @interface RpcProviderFilter { 14 | 15 | String rpcServer() default "defaultRpcServer"; 16 | 17 | } 18 | -------------------------------------------------------------------------------- /hasting-spring/src/main/java/com/lindzh/hasting/spring/annotation/RpcProviderService.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.spring.annotation; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * 服务端提供端bean依赖注入 10 | * @author linda 11 | * 12 | */ 13 | @Target(ElementType.TYPE) 14 | @Retention(RetentionPolicy.RUNTIME) 15 | public @interface RpcProviderService { 16 | 17 | String rpcServer() default "defaultRpcServer"; 18 | 19 | String version() default "0.0"; 20 | 21 | } 22 | -------------------------------------------------------------------------------- /hasting-spring/src/main/java/com/lindzh/hasting/spring/invoker/RpcAnnotationInvokerClassFilter.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.spring.invoker; 2 | 3 | import com.lindzh.hasting.spring.annotation.RpcInvokerService; 4 | 5 | public class RpcAnnotationInvokerClassFilter implements RpcInvokerClassFilter{ 6 | 7 | @Override 8 | public boolean accept(Class clazz) { 9 | if(clazz.getAnnotation(RpcInvokerService.class)!=null){ 10 | return true; 11 | } 12 | return false; 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /hasting-spring/src/main/java/com/lindzh/hasting/spring/invoker/RpcInvokerClassFilter.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.spring.invoker; 2 | 3 | public interface RpcInvokerClassFilter { 4 | 5 | public boolean accept(Class clazz); 6 | 7 | } 8 | -------------------------------------------------------------------------------- /hasting-spring/src/main/resources/rpc-invoker-config.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | com.lindzh.hasting.spring.test 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /hasting-spring/src/main/resources/rpc-provider-config.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /hasting-spring/src/test/java/com/lindzh/hasting/spring/RpcInvokerTestCase.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.spring; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import javax.annotation.Resource; 7 | 8 | import com.lindzh.hasting.cluster.JSONUtils; 9 | import com.lindzh.hasting.spring.test.TestBean; 10 | import com.lindzh.hasting.spring.test.TestRemoteBean; 11 | import org.junit.Test; 12 | 13 | import com.lindzh.hasting.spring.test.CallService; 14 | 15 | public class RpcInvokerTestCase extends AbstractTestCase{ 16 | 17 | @Resource 18 | private CallService callService; 19 | 20 | @Override 21 | public List getLocations() { 22 | ArrayList list = new ArrayList(); 23 | list.add("classpath*:rpc-invoker-config.xml"); 24 | return list; 25 | } 26 | 27 | @Test 28 | public void test(){ 29 | callService.callLogin("linda", "123456"); 30 | callService.callHello("lindzgh", 50); 31 | callService.callHelloTestIndex(100, "543565-fwegfer"); 32 | TestBean testBean = new TestBean(); 33 | testBean.setLimit(1600); 34 | testBean.setMessage("this is spring support test"); 35 | testBean.setOffset(200); 36 | testBean.setOrder("order 9876"); 37 | TestRemoteBean result = callService.getBean(testBean, 1000); 38 | System.out.println(JSONUtils.toJSON(result)); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /hasting-spring/src/test/java/com/lindzh/hasting/spring/RpcProviderTestCase.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.spring; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import javax.annotation.Resource; 7 | 8 | import com.lindzh.hasting.spring.test.CallService; 9 | import org.junit.Test; 10 | 11 | public class RpcProviderTestCase extends AbstractTestCase{ 12 | 13 | @Resource 14 | private CallService callService; 15 | 16 | @Override 17 | public List getLocations() { 18 | ArrayList list = new ArrayList(); 19 | list.add("classpath*:rpc-provider-config.xml"); 20 | return list; 21 | } 22 | 23 | @Test 24 | public void startService(){ 25 | callService.callHello("this is provider call", 564356); 26 | try { 27 | Thread.currentThread().sleep(1000000L); 28 | } catch (InterruptedException e) { 29 | e.printStackTrace(); 30 | } 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /hasting-spring/src/test/java/com/lindzh/hasting/spring/filter/RpcTestFilter.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.spring.filter; 2 | 3 | import com.lindzh.hasting.spring.annotation.RpcProviderFilter; 4 | import org.apache.log4j.Logger; 5 | 6 | import com.lindzh.hasting.rpc.RemoteCall; 7 | import com.lindzh.hasting.rpc.RpcObject; 8 | import com.lindzh.hasting.rpc.filter.RpcFilter; 9 | import com.lindzh.hasting.rpc.filter.RpcFilterChain; 10 | import com.lindzh.hasting.rpc.net.RpcSender; 11 | 12 | @RpcProviderFilter(rpcServer="simpleRpcServer") 13 | public class RpcTestFilter implements RpcFilter{ 14 | 15 | private Logger logger = Logger.getLogger(RpcTestFilter.class); 16 | 17 | @Override 18 | public void doFilter(RpcObject rpc, RemoteCall call, RpcSender sender, 19 | RpcFilterChain chain) { 20 | logger.info(rpc.getHost()+":"+rpc.getPort()+" service:"+call.getService()+"."+call.getVersion()); 21 | chain.nextFilter(rpc, call, sender); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /hasting-spring/src/test/java/com/lindzh/hasting/spring/impl/HelloRpcServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.spring.impl; 2 | 3 | import com.lindzh.hasting.spring.test.TestRemoteBean; 4 | import org.apache.log4j.Logger; 5 | import org.springframework.stereotype.Service; 6 | 7 | import com.lindzh.hasting.spring.annotation.RpcProviderService; 8 | import com.lindzh.hasting.spring.test.HelloRpcService; 9 | import com.lindzh.hasting.spring.test.TestBean; 10 | 11 | @Service 12 | @RpcProviderService(rpcServer="simpleRpcServer",version="1.0") 13 | public class HelloRpcServiceImpl implements HelloRpcService{ 14 | 15 | private Logger logger = Logger.getLogger(HelloRpcServiceImpl.class); 16 | 17 | @Override 18 | public void sayHello(String message,int tt) { 19 | logger.info("sayHello:"+message+" intValue:"+tt); 20 | } 21 | 22 | @Override 23 | public String getHello() { 24 | return "this is hello service"; 25 | } 26 | 27 | @Override 28 | public TestRemoteBean getBean(TestBean bean, int id) { 29 | logger.info("id:"+id+" bean:"+bean.toString()); 30 | TestRemoteBean remoteBean = new TestRemoteBean(); 31 | remoteBean.setAction("fff-"+id); 32 | remoteBean.setAge(id*2); 33 | remoteBean.setName("serviceBean"); 34 | return remoteBean; 35 | } 36 | 37 | @Override 38 | public int callException(boolean exception) { 39 | if(exception){ 40 | throw new RuntimeException("happen"); 41 | } 42 | return 1; 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /hasting-spring/src/test/java/com/lindzh/hasting/spring/impl/HelloRpcTestServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.spring.impl; 2 | 3 | import com.lindzh.hasting.spring.annotation.RpcProviderService; 4 | import org.apache.log4j.Logger; 5 | import org.springframework.stereotype.Service; 6 | 7 | import com.lindzh.hasting.spring.test.HelloRpcTestService; 8 | 9 | @Service 10 | @RpcProviderService(rpcServer="simpleRpcServer") 11 | public class HelloRpcTestServiceImpl implements HelloRpcTestService{ 12 | 13 | private Logger logger = Logger.getLogger(HelloRpcTestServiceImpl.class); 14 | 15 | @Override 16 | public String index(int index, String key) { 17 | logger.info("index:"+index+" key:"+key); 18 | return "HelloRpcTestServiceImpl-"+index; 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /hasting-spring/src/test/java/com/lindzh/hasting/spring/impl/LoginRpcServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.spring.impl; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | import com.lindzh.hasting.spring.annotation.RpcProviderService; 7 | import org.apache.log4j.Logger; 8 | import org.springframework.stereotype.Service; 9 | 10 | import com.lindzh.hasting.spring.test.LoginRpcService; 11 | 12 | @Service 13 | @RpcProviderService(rpcServer="simpleRpcServer") 14 | public class LoginRpcServiceImpl implements LoginRpcService{ 15 | 16 | private Logger logger = Logger.getLogger(LoginRpcServiceImpl.class); 17 | 18 | private Map cache = new HashMap(); 19 | 20 | @Override 21 | public boolean login(String username, String password) { 22 | logger.info("login user:"+username+" password:"+password); 23 | String pass = cache.get(username); 24 | return pass!=null&&pass.equals(password); 25 | } 26 | 27 | public LoginRpcServiceImpl(){ 28 | cache.put("linda", "123456"); 29 | cache.put("test", "123456"); 30 | cache.put("admin", "123456"); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /hasting-spring/src/test/java/com/lindzh/hasting/spring/test/CallService.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.spring.test; 2 | 3 | import javax.annotation.Resource; 4 | 5 | import org.springframework.stereotype.Service; 6 | 7 | @Service 8 | public class CallService { 9 | @Resource 10 | private HelloRpcService helloService; 11 | @Resource 12 | private HelloRpcTestService helloRpcTestService; 13 | @Resource 14 | private LoginRpcService loginRpcService; 15 | 16 | public void callHello(String msg,int tt){ 17 | helloService.sayHello(msg, tt); 18 | } 19 | 20 | public void callLogin(String user,String pass){ 21 | loginRpcService.login(user, pass); 22 | } 23 | 24 | public void callHelloTestIndex(int index,String key){ 25 | helloRpcTestService.index(index, key); 26 | } 27 | 28 | public TestRemoteBean getBean(TestBean bean,int id){ 29 | return helloService.getBean(bean, id); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /hasting-spring/src/test/java/com/lindzh/hasting/spring/test/HelloRpcService.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.spring.test; 2 | 3 | import com.lindzh.hasting.spring.annotation.RpcInvokerService; 4 | 5 | @RpcInvokerService(rpcServer="simpleRpcClient",version = "1.0") 6 | public interface HelloRpcService { 7 | 8 | public void sayHello(String message,int tt); 9 | 10 | public String getHello(); 11 | 12 | public TestRemoteBean getBean(TestBean bean,int id); 13 | 14 | public int callException(boolean exception); 15 | 16 | } 17 | -------------------------------------------------------------------------------- /hasting-spring/src/test/java/com/lindzh/hasting/spring/test/HelloRpcTestService.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.spring.test; 2 | 3 | import com.lindzh.hasting.spring.annotation.RpcInvokerService; 4 | 5 | @RpcInvokerService(rpcServer="simpleRpcClient") 6 | public interface HelloRpcTestService { 7 | 8 | public String index(int index,String key); 9 | 10 | } 11 | -------------------------------------------------------------------------------- /hasting-spring/src/test/java/com/lindzh/hasting/spring/test/LoginRpcService.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.spring.test; 2 | 3 | import com.lindzh.hasting.spring.annotation.RpcInvokerService; 4 | 5 | @RpcInvokerService(rpcServer="simpleRpcClient") 6 | public interface LoginRpcService { 7 | 8 | public boolean login(String username,String password); 9 | 10 | } 11 | -------------------------------------------------------------------------------- /hasting-spring/src/test/java/com/lindzh/hasting/spring/test/TestBean.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.spring.test; 2 | 3 | import java.io.Serializable; 4 | 5 | public class TestBean implements Serializable { 6 | 7 | private static final long serialVersionUID = -6778119358481557931L; 8 | private int limit; 9 | private int offset; 10 | private String order; 11 | private String message; 12 | 13 | public int getLimit() { 14 | return limit; 15 | } 16 | 17 | public void setLimit(int limit) { 18 | this.limit = limit; 19 | } 20 | 21 | public int getOffset() { 22 | return offset; 23 | } 24 | 25 | public void setOffset(int offset) { 26 | this.offset = offset; 27 | } 28 | 29 | public String getOrder() { 30 | return order; 31 | } 32 | 33 | public void setOrder(String order) { 34 | this.order = order; 35 | } 36 | 37 | public String getMessage() { 38 | return message; 39 | } 40 | 41 | public void setMessage(String message) { 42 | this.message = message; 43 | } 44 | 45 | @Override 46 | public String toString() { 47 | return "TestBean [limit=" + limit + ", offset=" + offset + ", order=" 48 | + order + ", message=" + message + "]"; 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /hasting-spring/src/test/java/com/lindzh/hasting/spring/test/TestRemoteBean.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.spring.test; 2 | 3 | import java.io.Serializable; 4 | 5 | public class TestRemoteBean implements Serializable { 6 | 7 | private static final long serialVersionUID = 2448105590901413899L; 8 | private String name; 9 | private String action; 10 | private int age; 11 | 12 | public String getName() { 13 | return name; 14 | } 15 | 16 | public void setName(String name) { 17 | this.name = name; 18 | } 19 | 20 | public String getAction() { 21 | return action; 22 | } 23 | 24 | public void setAction(String action) { 25 | this.action = action; 26 | } 27 | 28 | public int getAge() { 29 | return age; 30 | } 31 | 32 | public void setAge(int age) { 33 | this.age = age; 34 | } 35 | 36 | @Override 37 | public String toString() { 38 | return "TestRemoteBean [name=" + name + ", action=" + action + ", age=" 39 | + age + "]"; 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /hasting-spring/src/test/resources/rpc-invoker-config-backup.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | -------------------------------------------------------------------------------- /hasting-spring/src/test/resources/rpc-provider-config-backup.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | -------------------------------------------------------------------------------- /hasting-webui/src/main/java/com/lindzh/hasting/webui/controller/BasicController.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.webui.controller; 2 | 3 | import com.lindzh.hasting.webui.biz.AppService; 4 | import com.lindzh.hasting.webui.pojo.AppInfo; 5 | import org.springframework.stereotype.Controller; 6 | import org.springframework.ui.ModelMap; 7 | 8 | import javax.annotation.Resource; 9 | import java.util.List; 10 | 11 | /** 12 | * Created by lin on 2016/12/23. 13 | */ 14 | @Controller 15 | public class BasicController { 16 | 17 | @Resource 18 | private AppService appService; 19 | 20 | 21 | public void setApps(ModelMap model){ 22 | List appList = appService.getAppList(); 23 | model.put("apps",appList); 24 | } 25 | 26 | public void setApp(long appId, ModelMap model){ 27 | AppInfo app = appService.getById(appId); 28 | if(app==null){ 29 | app = new AppInfo(); 30 | app.setId(0); 31 | app.setName("全部"); 32 | } 33 | model.put("app",app); 34 | } 35 | 36 | 37 | } 38 | -------------------------------------------------------------------------------- /hasting-webui/src/main/java/com/lindzh/hasting/webui/controller/HealthServlet.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.webui.controller; 2 | 3 | import javax.servlet.ServletException; 4 | import javax.servlet.http.HttpServlet; 5 | import javax.servlet.http.HttpServletRequest; 6 | import javax.servlet.http.HttpServletResponse; 7 | import java.io.IOException; 8 | 9 | /** 10 | * Created by lin on 2016/12/24. 11 | */ 12 | public class HealthServlet extends HttpServlet{ 13 | 14 | private static final long serialVersionUID = -6257404250129290575L; 15 | 16 | @Override 17 | protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException { 18 | 19 | String content = "{\"code\":200,\"message\":\"success\",\"data\":"+System.currentTimeMillis()+"}"; 20 | this.print(req, resp, content); 21 | } 22 | 23 | private void print(HttpServletRequest req,HttpServletResponse response, String content) { 24 | //添加js调用支持 25 | try { 26 | response.getWriter().print(content); 27 | response.getWriter().flush(); 28 | } catch (IOException e) { 29 | 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /hasting-webui/src/main/java/com/lindzh/hasting/webui/controller/StaticController.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.webui.controller; 2 | 3 | import org.springframework.stereotype.Controller; 4 | import org.springframework.ui.ModelMap; 5 | import org.springframework.web.bind.annotation.PathVariable; 6 | import org.springframework.web.bind.annotation.RequestMapping; 7 | import org.springframework.web.bind.annotation.RequestMethod; 8 | 9 | /** 10 | * Created by lin on 2016/12/24. 11 | */ 12 | @Controller 13 | public class StaticController { 14 | 15 | @RequestMapping(value="/{class1}/{file}.htm",method= RequestMethod.GET) 16 | public String getClassifiedResource(@PathVariable("class1")String class1, 17 | @PathVariable("file")String file,ModelMap model){ 18 | return "static/"+class1+"/"+file; 19 | } 20 | 21 | @RequestMapping(value="/{file}.htm",method=RequestMethod.GET) 22 | public String getStaticResource(@PathVariable("file")String file,ModelMap model){ 23 | return "static/"+file; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /hasting-webui/src/main/java/com/lindzh/hasting/webui/dao/AppInfoDao.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.webui.dao; 2 | 3 | import java.util.List; 4 | import org.apache.ibatis.annotations.Param; 5 | import com.lindzh.hasting.webui.pojo.AppInfo; 6 | 7 | /** 8 | * @author AutoGenerated by lindzh 9 | * 2016年12月15日 16:52 10 | */ 11 | public interface AppInfoDao { 12 | 13 | public int addAppInfo(AppInfo obj); 14 | 15 | public AppInfo getById(@Param("id")long id); 16 | 17 | public int updateById(@Param("obj")AppInfo obj); 18 | 19 | public int deleteById(@Param("id")long id); 20 | 21 | 22 | public AppInfo getByName(@Param("name")String name); 23 | 24 | public List getListByAppName(@Param("name")String name,@Param("limit")int limit,@Param("offset") int offset); 25 | 26 | public long getCountByAppName(@Param("name")String name); 27 | 28 | public List getList(); 29 | 30 | public List getConsumerApps(@Param("appId")long appId); 31 | 32 | public List getListByLimitSyncStatus(@Param("limit_sync_status")int syncStatus); 33 | 34 | } 35 | -------------------------------------------------------------------------------- /hasting-webui/src/main/java/com/lindzh/hasting/webui/dao/LimitInfoDao.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.webui.dao; 2 | 3 | import java.util.List; 4 | import org.apache.ibatis.annotations.Param; 5 | import com.lindzh.hasting.webui.pojo.LimitInfo; 6 | 7 | /** 8 | * @author AutoGenerated by lindzh 9 | * 2017年02月15日 14:27 10 | */ 11 | public interface LimitInfoDao { 12 | 13 | public int addLimitInfo(LimitInfo obj); 14 | 15 | public LimitInfo getById(@Param("id")long id); 16 | 17 | public int updateById(@Param("obj")LimitInfo obj); 18 | 19 | public int deleteById(@Param("id")long id); 20 | 21 | 22 | public List getListByAppId(@Param("appId")long appId,@Param("limit")int limit,@Param("offset") int offset); 23 | 24 | public long getCountByAppId(@Param("appId")long appId); 25 | 26 | 27 | 28 | public int deleteByAppId(@Param("appId")long appId); 29 | 30 | public int batchAdd(@Param("limits")List limits); 31 | 32 | } 33 | -------------------------------------------------------------------------------- /hasting-webui/src/main/java/com/lindzh/hasting/webui/dao/ServiceProviderInfoDao.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.webui.dao; 2 | 3 | import com.lindzh.hasting.webui.pojo.ServiceProviderInfo; 4 | import org.apache.ibatis.annotations.Param; 5 | 6 | /** 7 | * @author AutoGenerated by lindzh 8 | * 2016年12月15日 16:55 9 | */ 10 | public interface ServiceProviderInfoDao { 11 | 12 | public int addServiceProviderInfo(ServiceProviderInfo obj); 13 | 14 | public ServiceProviderInfo getById(@Param("id")long id); 15 | 16 | public int updateById(@Param("obj")ServiceProviderInfo obj); 17 | 18 | public int deleteById(@Param("id")long id); 19 | 20 | 21 | 22 | public int deleteByAppIdAndHostId(@Param("appId") long appId,@Param("hostId") long hostId); 23 | 24 | public ServiceProviderInfo getByAppHostAndServiceId(@Param("appId")long appId,@Param("hostId")long hostId,@Param("serviceId")long serviceId); 25 | 26 | public int getServiceProviderCount(@Param("appId")long appId,@Param("serviceId") long ServiceId); 27 | 28 | } 29 | -------------------------------------------------------------------------------- /hasting-webui/src/main/java/com/lindzh/hasting/webui/pojo/ServiceConsumerInfo.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.webui.pojo; 2 | 3 | import com.lindzh.mybatis.generator.annotation.Column; 4 | import com.lindzh.mybatis.generator.annotation.Index; 5 | import com.lindzh.mybatis.generator.annotation.PrimaryKey; 6 | import com.lindzh.mybatis.generator.annotation.Table; 7 | import lombok.Data; 8 | 9 | /** 10 | * Created by lin on 2016/12/15. 11 | */ 12 | @Data 13 | @Table(name = "service_consumer_info",autoGeneratePrimaryKey = true) 14 | public class ServiceConsumerInfo { 15 | 16 | /** 17 | * id 18 | */ 19 | @PrimaryKey 20 | private long id; 21 | 22 | /** 23 | * 服务 24 | */ 25 | @Column(column = "service_id") 26 | @Index(name="ServiceId") 27 | private long serviceId; 28 | 29 | /** 30 | * 服务所属appid 31 | */ 32 | @Column(column = "service_app_id") 33 | @Index(name="ServiceAppId") 34 | private long serviceAppId; 35 | 36 | /** 37 | * 依赖机器所属appid 38 | */ 39 | @Column(column = "consumer_app_id") 40 | @Index(name="ConsumerAppId") 41 | private long consumerAppId; 42 | 43 | /** 44 | * 应用主机 45 | */ 46 | @Column(column = "consumer_host_id") 47 | @Index(name="ConsumerHostId") 48 | private long comsumerHostId; 49 | 50 | /** 51 | * 消费者上线时间 52 | */ 53 | @Column(column = "consumer_host_uptime") 54 | private long time; 55 | } 56 | -------------------------------------------------------------------------------- /hasting-webui/src/main/java/com/lindzh/hasting/webui/pojo/ServiceProviderInfo.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.webui.pojo; 2 | 3 | import com.lindzh.mybatis.generator.annotation.Column; 4 | import com.lindzh.mybatis.generator.annotation.PrimaryKey; 5 | import com.lindzh.mybatis.generator.annotation.Table; 6 | import lombok.Data; 7 | 8 | /** 9 | * Created by lin on 2016/12/15. 10 | */ 11 | @Data 12 | @Table(name="service_provider_info",autoGeneratePrimaryKey = true) 13 | public class ServiceProviderInfo { 14 | 15 | /** 16 | * id 17 | */ 18 | @PrimaryKey 19 | private long id; 20 | 21 | /** 22 | * 服务 23 | */ 24 | @Column(column = "service_id") 25 | private long serviceId; 26 | 27 | /** 28 | * 应用,服务提供者的app和service app一致 29 | */ 30 | @Column(column = "app_id") 31 | private long appId; 32 | 33 | /** 34 | * 应用主机 35 | */ 36 | @Column(column = "host_id") 37 | private long hostId; 38 | 39 | 40 | /** 41 | * 时间 42 | */ 43 | @Column(column = "provider_host_uptime") 44 | private long time; 45 | } 46 | -------------------------------------------------------------------------------- /hasting-webui/src/main/java/com/lindzh/hasting/webui/service/RpcInfoListener.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.webui.service; 2 | 3 | import java.util.List; 4 | import java.util.Map; 5 | 6 | import com.lindzh.hasting.rpc.RpcService; 7 | import com.lindzh.hasting.rpc.cluster1.RpcHostAndPort; 8 | 9 | public interface RpcInfoListener { 10 | 11 | public void onServers(RpcConfig config,List host); 12 | 13 | public void onServices(RpcConfig config,Map> hostServices); 14 | 15 | } 16 | -------------------------------------------------------------------------------- /hasting-webui/src/main/java/com/lindzh/hasting/webui/service/RpcWebuiService.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.webui.service; 2 | 3 | import java.util.List; 4 | 5 | import com.lindzh.hasting.rpc.RpcService; 6 | import com.lindzh.hasting.rpc.cluster1.RpcHostAndPort; 7 | 8 | public interface RpcWebuiService { 9 | 10 | public RpcConfig getNamespaceConfig(String namespace); 11 | 12 | public List search(String namespace,String keyword); 13 | 14 | public List getServicesByHost(String namespace,String hostAndPort); 15 | 16 | public List getNamespaces(); 17 | 18 | public List getRpcConfigs(); 19 | 20 | public List getHostsByNamespace(String namespace); 21 | 22 | public List getRpcHostsByRpc(String namespace,String serviceName,String serviceVersion); 23 | 24 | } 25 | -------------------------------------------------------------------------------- /hasting-webui/src/main/java/com/lindzh/hasting/webui/servlet/EncodingFilter.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.webui.servlet; 2 | 3 | import java.io.IOException; 4 | import java.nio.charset.Charset; 5 | 6 | import javax.servlet.Filter; 7 | import javax.servlet.FilterChain; 8 | import javax.servlet.FilterConfig; 9 | import javax.servlet.ServletException; 10 | import javax.servlet.ServletRequest; 11 | import javax.servlet.ServletResponse; 12 | 13 | import org.apache.log4j.Logger; 14 | 15 | public class EncodingFilter implements Filter{ 16 | 17 | private String characterEncoding = "utf-8"; 18 | 19 | private Logger logger = Logger.getLogger(EncodingFilter.class); 20 | 21 | @Override 22 | public void destroy() { 23 | 24 | } 25 | 26 | @Override 27 | public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { 28 | request.setCharacterEncoding(characterEncoding); 29 | response.setCharacterEncoding(characterEncoding); 30 | chain.doFilter(request, response); 31 | } 32 | 33 | @Override 34 | public void init(FilterConfig config) throws ServletException { 35 | String encoding = config.getInitParameter("encoding"); 36 | if(encoding!=null){ 37 | Charset charset = Charset.forName(encoding); 38 | if(charset==null){ 39 | throw new RuntimeException("not support encoding:"+encoding); 40 | } 41 | this.characterEncoding = encoding; 42 | } 43 | logger.info("set servlet encoding:"+this.characterEncoding); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /hasting-webui/src/main/java/com/lindzh/hasting/webui/servlet/FtlDateParser.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.webui.servlet; 2 | 3 | import java.text.SimpleDateFormat; 4 | import java.util.Date; 5 | import java.util.List; 6 | 7 | import freemarker.template.SimpleNumber; 8 | import freemarker.template.TemplateMethodModelEx; 9 | import freemarker.template.TemplateModelException; 10 | 11 | public class FtlDateParser implements TemplateMethodModelEx{ 12 | @Override 13 | public Object exec(List args) throws TemplateModelException { 14 | SimpleNumber num = (SimpleNumber)args.get(0); 15 | long time = num.getAsNumber().longValue(); 16 | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm"); 17 | return format.format(new Date(time)); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /hasting-webui/src/main/java/com/lindzh/hasting/webui/servlet/ServletExceptionHandler.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.webui.servlet; 2 | 3 | import javax.servlet.http.HttpServletRequest; 4 | import javax.servlet.http.HttpServletResponse; 5 | 6 | public interface ServletExceptionHandler { 7 | 8 | public void handleException(HttpServletRequest request,HttpServletResponse response,Exception e); 9 | 10 | } 11 | -------------------------------------------------------------------------------- /hasting-webui/src/main/java/com/lindzh/hasting/webui/servlet/ServletUtils.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.webui.servlet; 2 | 3 | import java.io.IOException; 4 | import java.io.PrintWriter; 5 | 6 | import javax.servlet.http.HttpServletResponse; 7 | 8 | import org.apache.log4j.Logger; 9 | 10 | public class ServletUtils { 11 | 12 | private static Logger logger = Logger.getLogger(ServletUtils.class); 13 | 14 | public static void write(String content,HttpServletResponse response){ 15 | try { 16 | PrintWriter writer = response.getWriter(); 17 | writer.print(content); 18 | writer.flush(); 19 | } catch (IOException e) { 20 | logger.error("write content error ",e); 21 | } 22 | } 23 | 24 | public static void write(int code,HttpServletResponse response){ 25 | response.setStatus(code); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /hasting-webui/src/main/java/com/lindzh/hasting/webui/servlet/SimpleServletExceptionHandler.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.webui.servlet; 2 | 3 | import javax.servlet.http.HttpServletRequest; 4 | import javax.servlet.http.HttpServletResponse; 5 | 6 | import org.apache.log4j.Logger; 7 | 8 | public class SimpleServletExceptionHandler implements ServletExceptionHandler{ 9 | 10 | private Logger logger = Logger.getLogger(SimpleServletExceptionHandler.class); 11 | 12 | @Override 13 | public void handleException(HttpServletRequest request, HttpServletResponse response, Exception e) { 14 | StringBuffer url = request.getRequestURL(); 15 | logger.error(url.toString(),e); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /hasting-webui/src/main/java/com/lindzh/hasting/webui/utils/BizException.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.webui.utils; 2 | 3 | /** 4 | * Created by lin on 2016/12/24. 5 | */ 6 | public class BizException extends RuntimeException { 7 | 8 | public BizException() { 9 | } 10 | 11 | public BizException(String message) { 12 | super(message); 13 | } 14 | 15 | public BizException(String message, Throwable cause) { 16 | super(message, cause); 17 | } 18 | 19 | public BizException(Throwable cause) { 20 | super(cause); 21 | } 22 | 23 | public BizException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { 24 | super(message, cause, enableSuppression, writableStackTrace); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /hasting-webui/src/main/java/com/lindzh/hasting/webui/utils/Const.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.webui.utils; 2 | 3 | /** 4 | * Created by lin on 2016/12/16. 5 | */ 6 | public class Const { 7 | 8 | public static final int HOST_STATUS_ON = 1; 9 | 10 | public static final int HOST_STATUS_OFF = 0; 11 | 12 | public static final int HOST_STATUS_ALL = -1; 13 | 14 | 15 | 16 | public static final int SERVICE_OK = 1; 17 | 18 | public static final int SERVICE_ERR = 0; 19 | 20 | public static final int SERVICE_ALL = -1; 21 | 22 | 23 | public static final int CODE_SUCCESS = 200; 24 | 25 | public static final int CODE_PARAM_ERROR = 309; 26 | 27 | /** 28 | * 全局限流 29 | */ 30 | public static final int LIMIT_ALL = 0; 31 | 32 | /** 33 | * service限流 34 | */ 35 | public static final int LIMIT_SERVICE = 1; 36 | 37 | /** 38 | * 方法限流 39 | */ 40 | public static final int LIMIT_METHOD = 2; 41 | 42 | 43 | /** 44 | * 指定应用限流 45 | */ 46 | public static final int LIMIT_APP_ALL = 10; 47 | 48 | /** 49 | * 指定应用限流 50 | */ 51 | public static final int LIMIT_APP_SERVICE = 11; 52 | 53 | /** 54 | * 指定应用限流 55 | */ 56 | public static final int LIMIT_APP_METHOD = 12; 57 | 58 | /** 59 | * 应用限流状态 已经同步 60 | */ 61 | public static final int APP_LIMIT_SYNCED = 1; 62 | 63 | /** 64 | * 应用限流状态 未同步 65 | */ 66 | public static final int APP_LIMIT_SYNCED_NO = 0; 67 | } 68 | -------------------------------------------------------------------------------- /hasting-webui/src/main/java/com/lindzh/hasting/webui/utils/RpcTransaction.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.webui.utils; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * Created by lin on 2016/12/17. 10 | */ 11 | @Target(ElementType.METHOD) 12 | @Retention(RetentionPolicy.RUNTIME) 13 | public @interface RpcTransaction { 14 | 15 | } 16 | 17 | -------------------------------------------------------------------------------- /hasting-webui/src/main/resources/conf.properties: -------------------------------------------------------------------------------- 1 | mysql.url=jdbc:mysql://127.0.0.1:3306/webui?autoReconnect=true&useUnicode=true&characterEncoding=utf-8 2 | mysql.username=lindezhi 3 | mysql.password=123456 4 | 5 | rpc.namespace=myrpc 6 | rpc.zkurl=127.0.0.1:2181 7 | rpc.etcdurl=http://127.0.0.1:2379 -------------------------------------------------------------------------------- /hasting-webui/src/main/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | log4j.rootLogger=INFO,stdout,store 2 | 3 | log4j.appender.stdout=org.apache.log4j.ConsoleAppender 4 | log4j.appender.stdout.Target=System.out 5 | log4j.appender.stdout.layout=org.apache.log4j.PatternLayout 6 | log4j.appender.stdout.layout.ConversionPattern=%d %-4r [%t] (%F:%L) %-5p - %m%n 7 | 8 | log4j.appender.store=org.apache.log4j.DailyRollingFileAppender 9 | log4j.appender.store.File=D:\\koplogs\\webui\\system.log 10 | log4j.appender.store.Append=true 11 | log4j.appender.store.DatePattern ='_'yyyy-MM-dd'.log' 12 | log4j.appender.store.layout=org.apache.log4j.PatternLayout 13 | log4j.appender.store.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-4r [%t] (%F:%L) %-5p - %m%n -------------------------------------------------------------------------------- /hasting-webui/src/main/resources/webui.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "namespace": "default", 4 | "protocol": "redis", 5 | "etcdUrl": null, 6 | "redisHost": "192.168.139.129", 7 | "redisPort": 7770, 8 | "sentinelMaster": null, 9 | "sentinels": null, 10 | "providerHost": null, 11 | "providerPort": 0, 12 | "zkConnectionString": null 13 | } 14 | ] -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/biz/AppService.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/biz/AppService.class -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/biz/ConsumerService.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/biz/ConsumerService.class -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/biz/HostService.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/biz/HostService.class -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/biz/LimitService.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/biz/LimitService.class -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/biz/ProviderService.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/biz/ProviderService.class -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/biz/ServiceInfoService.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/biz/ServiceInfoService.class -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/controller/AppController.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/controller/AppController.class -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/controller/BasicController.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/controller/BasicController.class -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/controller/HealthServlet.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/controller/HealthServlet.class -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/controller/HostController.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/controller/HostController.class -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/controller/LimitController$1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/controller/LimitController$1.class -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/controller/LimitController.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/controller/LimitController.class -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/controller/ServiceController.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/controller/ServiceController.class -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/controller/StaticController.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/controller/StaticController.class -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/controller/WeightController$1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/controller/WeightController$1.class -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/controller/WeightController.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/controller/WeightController.class -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/dao/AppInfoDao.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/dao/AppInfoDao.class -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/dao/HostInfoDao.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/dao/HostInfoDao.class -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/dao/LimitInfoDao.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/dao/LimitInfoDao.class -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/dao/ServiceConsumerInfoDao.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/dao/ServiceConsumerInfoDao.class -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/dao/ServiceInfoDao.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/dao/ServiceInfoDao.class -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/dao/ServiceProviderInfoDao.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/dao/ServiceProviderInfoDao.class -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/manager/ManagerService.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/manager/ManagerService.class -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/pojo/AppInfo.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/pojo/AppInfo.class -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/pojo/HostInfo.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/pojo/HostInfo.class -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/pojo/LimitInfo.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/pojo/LimitInfo.class -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/pojo/ServiceConsumerInfo.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/pojo/ServiceConsumerInfo.class -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/pojo/ServiceInfo.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/pojo/ServiceInfo.class -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/pojo/ServiceProviderInfo.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/pojo/ServiceProviderInfo.class -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/service/RpcConfig$RpcProtocol.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/service/RpcConfig$RpcProtocol.class -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/service/RpcConfig.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/service/RpcConfig.class -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/service/RpcFetchService$1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/service/RpcFetchService$1.class -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/service/RpcFetchService$2.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/service/RpcFetchService$2.class -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/service/RpcFetchService.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/service/RpcFetchService.class -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/service/RpcInfoListener.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/service/RpcInfoListener.class -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/service/RpcWebuiService.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/service/RpcWebuiService.class -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/service/RpcWebuiServiceImpl.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/service/RpcWebuiServiceImpl.class -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/servlet/EncodingFilter.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/servlet/EncodingFilter.class -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/servlet/FreemarkerService.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/servlet/FreemarkerService.class -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/servlet/FtlDateParser.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/servlet/FtlDateParser.class -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/servlet/RpcWebuiController.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/servlet/RpcWebuiController.class -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/servlet/ServletExceptionHandler.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/servlet/ServletExceptionHandler.class -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/servlet/ServletUtils.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/servlet/ServletUtils.class -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/servlet/SimpleServletExceptionHandler.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/servlet/SimpleServletExceptionHandler.class -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/servlet/WebuiServlet$1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/servlet/WebuiServlet$1.class -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/servlet/WebuiServlet.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/servlet/WebuiServlet.class -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/utils/BizException.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/utils/BizException.class -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/utils/CollectionUtils.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/utils/CollectionUtils.class -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/utils/ConUtils.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/utils/ConUtils.class -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/utils/Const.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/utils/Const.class -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/utils/DTOUtils.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/utils/DTOUtils.class -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/utils/PackUtils.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/utils/PackUtils.class -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/utils/RpcTransaction.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/classes/com/linda/rpc/webui/utils/RpcTransaction.class -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/classes/conf.properties: -------------------------------------------------------------------------------- 1 | mysql.url=jdbc:mysql://127.0.0.1:3306/webui?autoReconnect=true&useUnicode=true&characterEncoding=utf-8 2 | mysql.username=lindezhi 3 | mysql.password=123456 4 | 5 | rpc.namespace=myrpc 6 | rpc.zkurl=127.0.0.1:2181 7 | rpc.etcdurl=http://127.0.0.1:2379 -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/classes/log4j.properties: -------------------------------------------------------------------------------- 1 | log4j.rootLogger=INFO,stdout,store 2 | 3 | log4j.appender.stdout=org.apache.log4j.ConsoleAppender 4 | log4j.appender.stdout.Target=System.out 5 | log4j.appender.stdout.layout=org.apache.log4j.PatternLayout 6 | log4j.appender.stdout.layout.ConversionPattern=%d %-4r [%t] (%F:%L) %-5p - %m%n 7 | 8 | log4j.appender.store=org.apache.log4j.DailyRollingFileAppender 9 | log4j.appender.store.File=D:\\koplogs\\webui\\system.log 10 | log4j.appender.store.Append=true 11 | log4j.appender.store.DatePattern ='_'yyyy-MM-dd'.log' 12 | log4j.appender.store.layout=org.apache.log4j.PatternLayout 13 | log4j.appender.store.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-4r [%t] (%F:%L) %-5p - %m%n -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/classes/webui.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "namespace": "default", 4 | "protocol": "redis", 5 | "etcdUrl": null, 6 | "redisHost": "192.168.139.129", 7 | "redisPort": 7770, 8 | "sentinelMaster": null, 9 | "sentinels": null, 10 | "providerHost": null, 11 | "providerPort": 0, 12 | "zkConnectionString": null 13 | } 14 | ] -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/lib/aopalliance-1.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/lib/aopalliance-1.0.jar -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/lib/aspectjweaver-1.8.4.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/lib/aspectjweaver-1.8.4.jar -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/lib/commons-codec-1.6.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/lib/commons-codec-1.6.jar -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/lib/commons-fileupload-1.3.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/lib/commons-fileupload-1.3.1.jar -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/lib/commons-io-2.4.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/lib/commons-io-2.4.jar -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/lib/commons-lang-2.6.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/lib/commons-lang-2.6.jar -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/lib/commons-lang3-3.3.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/lib/commons-lang3-3.3.2.jar -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/lib/commons-logging-1.1.3.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/lib/commons-logging-1.1.3.jar -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/lib/commons-pool2-2.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/lib/commons-pool2-2.0.jar -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/lib/curator-client-2.7.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/lib/curator-client-2.7.1.jar -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/lib/curator-framework-2.7.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/lib/curator-framework-2.7.1.jar -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/lib/druid-1.0.12.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/lib/druid-1.0.12.jar -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/lib/framework-rpc-0.1.2-SNAPSHOT.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/lib/framework-rpc-0.1.2-SNAPSHOT.jar -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/lib/framework-rpc-cluster-0.0.2-SNAPSHOT.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/lib/framework-rpc-cluster-0.0.2-SNAPSHOT.jar -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/lib/freemarker-2.3.20.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/lib/freemarker-2.3.20.jar -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/lib/guava-14.0.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/lib/guava-14.0.1.jar -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/lib/httpasyncclient-4.0-beta4.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/lib/httpasyncclient-4.0-beta4.jar -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/lib/httpclient-4.3-beta1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/lib/httpclient-4.3-beta1.jar -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/lib/httpcore-4.3-beta2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/lib/httpcore-4.3-beta2.jar -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/lib/httpcore-nio-4.3-beta2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/lib/httpcore-nio-4.3-beta2.jar -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/lib/jackson-annotations-2.2.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/lib/jackson-annotations-2.2.0.jar -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/lib/jackson-core-2.2.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/lib/jackson-core-2.2.0.jar -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/lib/jackson-databind-2.2.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/lib/jackson-databind-2.2.0.jar -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/lib/javax.servlet-api-3.1.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/lib/javax.servlet-api-3.1.0.jar -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/lib/jedis-2.5.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/lib/jedis-2.5.2.jar -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/lib/jetcd-0.0.1-SNAPSHOT.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/lib/jetcd-0.0.1-SNAPSHOT.jar -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/lib/jline-0.9.94.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/lib/jline-0.9.94.jar -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/lib/log4j-1.2.16.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/lib/log4j-1.2.16.jar -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/lib/lombok-1.16.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/lib/lombok-1.16.2.jar -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/lib/mybatis-3.2.8.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/lib/mybatis-3.2.8.jar -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/lib/mybatis-generator-1.0.3.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/lib/mybatis-generator-1.0.3.jar -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/lib/mybatis-spring-1.2.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/lib/mybatis-spring-1.2.2.jar -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/lib/mysql-connector-java-5.1.34.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/lib/mysql-connector-java-5.1.34.jar -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/lib/netty-3.7.0.Final.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/lib/netty-3.7.0.Final.jar -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/lib/objenesis-2.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/lib/objenesis-2.1.jar -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/lib/ognl-2.6.9.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/lib/ognl-2.6.9.jar -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/lib/protostuff-api-1.0.8.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/lib/protostuff-api-1.0.8.jar -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/lib/protostuff-collectionschema-1.0.8.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/lib/protostuff-collectionschema-1.0.8.jar -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/lib/protostuff-core-1.0.8.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/lib/protostuff-core-1.0.8.jar -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/lib/protostuff-runtime-1.0.8.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/lib/protostuff-runtime-1.0.8.jar -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/lib/quartz-1.8.6.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/lib/quartz-1.8.6.jar -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/lib/slf4j-api-1.6.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/lib/slf4j-api-1.6.0.jar -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/lib/spring-aop-3.2.15.RELEASE.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/lib/spring-aop-3.2.15.RELEASE.jar -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/lib/spring-beans-3.2.15.RELEASE.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/lib/spring-beans-3.2.15.RELEASE.jar -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/lib/spring-context-3.2.15.RELEASE.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/lib/spring-context-3.2.15.RELEASE.jar -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/lib/spring-context-support-3.2.15.RELEASE.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/lib/spring-context-support-3.2.15.RELEASE.jar -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/lib/spring-core-3.2.15.RELEASE.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/lib/spring-core-3.2.15.RELEASE.jar -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/lib/spring-expression-3.2.15.RELEASE.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/lib/spring-expression-3.2.15.RELEASE.jar -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/lib/spring-jdbc-3.2.15.RELEASE.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/lib/spring-jdbc-3.2.15.RELEASE.jar -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/lib/spring-oxm-3.2.15.RELEASE.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/lib/spring-oxm-3.2.15.RELEASE.jar -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/lib/spring-tx-3.2.15.RELEASE.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/lib/spring-tx-3.2.15.RELEASE.jar -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/lib/spring-web-3.2.15.RELEASE.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/lib/spring-web-3.2.15.RELEASE.jar -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/lib/spring-webmvc-3.2.15.RELEASE.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/lib/spring-webmvc-3.2.15.RELEASE.jar -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/lib/xpp3_min-1.1.4c.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/lib/xpp3_min-1.1.4c.jar -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/lib/xstream-1.3.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/lib/xstream-1.3.1.jar -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/lib/zookeeper-3.4.6.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/WEB-INF/lib/zookeeper-3.4.6.jar -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/template/404.ftl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | rpc admin 5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | <#assign page='index'/> 13 | <#include 'navbar.ftl'/> 14 |
15 |
16 |

404 resource not found

17 |
18 |
19 |
20 | 21 | -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/template/configs.ftl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | rpc admin 5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | <#assign page='configs'/> 13 | <#include 'navbar.ftl'/> 14 | 15 |
16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | <#list configs as config> 29 | 30 | 31 | 32 | 33 | 34 | 39 | 40 | 41 |
md5namespaceprotocolinfooperations
${config.md5}${config.namespace}${config.protocol}${config.info} 35 | services 36 |   37 | hosts 38 |
42 |
43 |
44 |
45 | 46 | -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/template/navbar.ftl: -------------------------------------------------------------------------------- 1 | 2 |
29 |



-------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/WEB-INF/web2.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | Archetype Created Web Application 6 | 7 | 8 | EncodingFilter 9 | com.lindzh.hasting.webui.servlet.EncodingFilter 10 | 11 | encoding 12 | utf-8 13 | 14 | 15 | 16 | EncodingFilter 17 | WebuiServlet 18 | 19 | 20 | 21 | WebuiServlet 22 | rpc webui 23 | com.lindzh.hasting.webui.servlet.WebuiServlet 24 | 1 25 | 26 | rpcConfig 27 | webui.json 28 | 29 | 30 | templateLocation 31 | /WEB-INF/template 32 | 33 | 34 | templateSuffix 35 | ftl 36 | 37 | 38 | 39 | WebuiServlet 40 | /webui/* 41 | 42 | 43 | -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/bootstrap/css/tt.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/bootstrap/css/tt.css -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/bootstrap/fonts/glyphicons-halflings-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/bootstrap/fonts/glyphicons-halflings-regular.eot -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/bootstrap/fonts/glyphicons-halflings-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/bootstrap/fonts/glyphicons-halflings-regular.ttf -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/bootstrap/fonts/glyphicons-halflings-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/bootstrap/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/bootstrap/fonts/glyphicons-halflings-regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/bootstrap/fonts/glyphicons-halflings-regular.woff2 -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/bootstrap/js/npm.js: -------------------------------------------------------------------------------- 1 | // This file is autogenerated via the `commonjs` Grunt task. You can require() this file in a CommonJS environment. 2 | require('../../js/transition.js') 3 | require('../../js/alert.js') 4 | require('../../js/button.js') 5 | require('../../js/carousel.js') 6 | require('../../js/collapse.js') 7 | require('../../js/dropdown.js') 8 | require('../../js/modal.js') 9 | require('../../js/tooltip.js') 10 | require('../../js/popover.js') 11 | require('../../js/scrollspy.js') 12 | require('../../js/tab.js') 13 | require('../../js/affix.js') -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/css/webui.css: -------------------------------------------------------------------------------- 1 | .kop-login-form{ 2 | width: 300px; 3 | margin: 200px auto; 4 | } 5 | 6 | .kop-list-select{ 7 | display: online; 8 | } 9 | 10 | .kop-list-select-left{ 11 | float:left; 12 | width:700px; 13 | display: online; 14 | } 15 | 16 | .kop-list-select-right{ 17 | float:right; 18 | display: online; 19 | } 20 | 21 | .kop-no-display{ 22 | display: none; 23 | } 24 | 25 | .kop-display{ 26 | display: block; 27 | } 28 | 29 | .error{ 30 | font-weight:normal; 31 | font-style:normal; 32 | font-size:12px; 33 | color:red; 34 | } 35 | 36 | .modal-dialog{ 37 | width:1000px; 38 | } 39 | 40 | .pannel-magin0{ 41 | margin-bottom:0px; 42 | } 43 | 44 | .searchIpt{ 45 | width:300px; 46 | } 47 | 48 | .rightSpan{ 49 | float:right; 50 | } 51 | 52 | .limit-service{ 53 | width:200; 54 | } 55 | 56 | .limit-method{ 57 | width:50; 58 | } 59 | 60 | .limit-num{ 61 | width:20; 62 | } -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/images/github.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lindzh/hasting/efed0dabcc5181b9f81bb54514048b38adfd7177/hasting-webui/src/main/webapp/images/github.jpg -------------------------------------------------------------------------------- /hasting-webui/src/main/webapp/js/weight.js: -------------------------------------------------------------------------------- 1 | function weightSubmmit(){ 2 | var paramList = new Array(); 3 | var inputs = $('.form-control'); 4 | $.each(inputs,function(index,input){ 5 | var hostId = input.name; 6 | var value = input.value; 7 | var hostWeight = {}; 8 | hostWeight.id = hostId; 9 | hostWeight.wantWeight = value.trim(); 10 | paramList.push(hostWeight); 11 | }); 12 | var content = JSON.stringify(paramList); 13 | 14 | $('#weightData').val(content); 15 | $('#weightForm').submit(); 16 | } 17 | -------------------------------------------------------------------------------- /hasting-webui/src/test/java/com/lindzh/hasting/webui/AbstractTestCase.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.webui; 2 | 3 | /** 4 | * Created by lin on 2016/12/17. 5 | */ 6 | 7 | import org.junit.runner.RunWith; 8 | import org.springframework.test.context.ContextConfiguration; 9 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 10 | 11 | @RunWith(SpringJUnit4ClassRunner.class) 12 | @ContextConfiguration(locations={"classpath:mybatis-config.xml","classpath:spring-admin.xml"}) 13 | public abstract class AbstractTestCase { 14 | 15 | } 16 | -------------------------------------------------------------------------------- /hasting-webui/src/test/java/com/lindzh/hasting/webui/AppTest.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.webui; 2 | 3 | import junit.framework.Test; 4 | import junit.framework.TestCase; 5 | import junit.framework.TestSuite; 6 | 7 | /** 8 | * Unit test for simple App. 9 | */ 10 | public class AppTest 11 | extends TestCase 12 | { 13 | /** 14 | * Create the test case 15 | * 16 | * @param testName name of the test case 17 | */ 18 | public AppTest( String testName ) 19 | { 20 | super( testName ); 21 | } 22 | 23 | /** 24 | * @return the suite of tests being tested 25 | */ 26 | public static Test suite() 27 | { 28 | return new TestSuite( AppTest.class ); 29 | } 30 | 31 | /** 32 | * Rigourous Test :-) 33 | */ 34 | public void testApp() 35 | { 36 | assertTrue( true ); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /hasting-webui/src/test/java/com/lindzh/hasting/webui/AtoGenDao.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.webui; 2 | 3 | import com.lindzh.mybatis.generator.bean.MybatisPojo; 4 | import com.lindzh.mybatis.generator.processor.DefaultMybatisGenerator; 5 | import com.lindzh.hasting.webui.pojo.LimitInfo; 6 | 7 | /** 8 | * Created by lin on 2016/12/15. 9 | */ 10 | public class AtoGenDao { 11 | 12 | public static void main(String[] args) { 13 | DefaultMybatisGenerator generator = new DefaultMybatisGenerator(); 14 | generator.startService(); 15 | MybatisPojo code = generator.genCode(LimitInfo.class, "com.linda.rpc.webui.dao", "D:\\Work\\java\\rpc-webui\\src\\main\\resources\\sqlmap\\", "D:\\Work\\java\\rpc-webui\\src\\main\\java\\com\\linda\\rpc\\webui\\dao\\"); 16 | System.out.println("===========gen finished=================="); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /hasting-webui/src/test/java/com/lindzh/hasting/webui/RpcConfigGen.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.webui; 2 | 3 | import java.util.ArrayList; 4 | 5 | import com.lindzh.hasting.cluster.JSONUtils; 6 | import com.lindzh.hasting.webui.service.RpcConfig; 7 | 8 | public class RpcConfigGen { 9 | 10 | public static void main(String[] args) { 11 | ArrayList configs = new ArrayList(); 12 | configs.add(new RpcConfig()); 13 | System.out.println(JSONUtils.toJSON(configs)); 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /hasting-webui/src/test/java/com/lindzh/hasting/webui/SimpleTest.java: -------------------------------------------------------------------------------- 1 | package com.lindzh.hasting.webui; 2 | 3 | import org.junit.Test; 4 | 5 | /** 6 | * Created by lin on 2016/12/17. 7 | */ 8 | public class SimpleTest extends AbstractTestCase { 9 | 10 | @Test 11 | public void startup() throws InterruptedException { 12 | System.out.println("started------"); 13 | Thread.currentThread().sleep(1000000000); 14 | } 15 | } 16 | --------------------------------------------------------------------------------