1 Star 0 Fork 15

北却 / eyer

forked from 青木 / eyer 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README

一个简单的服务 (单机版)

    public class TestServer {
        public static void main(String[] args) throws IOException {

            NioConfig.registered(new KryoSerializer());
            final ServerHandler handler = new ServerHandler();
            NioConfig.registered(handler);
            NioConfig.initSessionHandler();
            //需要导出的服务接口 以及对应的实现类
            handler.services.put(UserService.class, new RemoteUserService());
            Server server = new Server(new InetSocketAddress("0.0.0.0",6161),new Acceptor("acceptor-1",new ReactorPool(1)));

        }
    }

服务引用

    public class ProxyClientTest {
        public static void main(String[] args) throws Exception {
                  NioConfig.registered(new KryoSerializer());
                  final Handler invocationHandler = new ClientHandler();
                  NioConfig.registered(invocationHandler);
                  NioConfig.registered(new Connector("connector",new ReactorPool(1)));
                  NioConfig.initSessionHandler();

                  URL url = new URL();
                  url.setHost("localhost");
                  url.setPort(6161);
                  Invoker invoker = new SimpleInvoker(url,50);

                  ProxyClient proxyClient = new ProxyClient(invoker);
                  final AtomicLong counter = new AtomicLong(0);
                  UserService userService = proxyClient.refService(UserService.class);
                  userService.save(new User());
            clientProxy.close();
        }
    }

一个简单的服务 (zookeeper注册中心集群版)

集群版本采用和dubbo一样的基于注册中心无状态的模式。可以说是精简版的dubbo
    public class ZookeeperServer {

        public static void main(String[] args) throws IOException {

            NioConfig.registered(new KryoSerializer());
            final ServerHandler handler = new ServerHandler();
            NioConfig.registered(handler);
            NioConfig.initSessionHandler();

            handler.services.put(UserService.class, new RemoteUserService());
            Server server = new Server(new InetSocketAddress("0.0.0.0", 6161), new Acceptor("acceptor-1", new ReactorPool(1)));

            ZooKeeperClient zooKeeperClient = new DefaultZookeeperClient("192.168.1.66:2181");
            String format = "/eyer/" + URLEncoder.encode(String.format("rpc/%s:%s/Services", "localhost", 6161), "UTF-8");
            zooKeeperClient.create(format, true);
        }
    }

服务引用

    public class ZookeeperClient {
        public static void main(String[] args) throws Exception {
                  NioConfig.registered(new KryoSerializer());
                   final Handler invocationHandler = new ClientHandler();
                   NioConfig.registered(invocationHandler);
                   NioConfig.registered(new Connector("ZookeeperProxyServicePerf-connector-1",new ReactorPool(1)));
                   NioConfig.initSessionHandler();


                   Invoker invoker = new ZookeeperInvoker("192.168.1.66:2181",new PollingBalance(),50);

                   ProxyClient proxyClient = new ProxyClient(invoker);


                   UserService userService = proxyClient.refService(UserService.class);
            System.out.println(save);
            clientProxy.close();
        }
    }

空文件

简介

使用java nio包 书写的RPC 展开 收起
Java
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Java
1
https://gitee.com/bealone/eyer.git
git@gitee.com:bealone/eyer.git
bealone
eyer
eyer
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891