Package client

Examples of client.IService


  public void testGetConfigOK() throws Exception{
    ZooKeeper zk = this.initZK();
   
    CountDownLatch connectedSignal = new CountDownLatch(1);
    TestHandler th = new TestHandler(connectedSignal);
    IService iservice = new IService(TestConf.host,null,null,null,"./src/test/tmp");   
    iservice.setEventHandle(Constants.CONNECT_EVENT, th);
    iservice.init();
    connectedSignal.await();
   
    Config config = iservice.createConfig("/iserviceTest/node1");
    DefaultData data = (DefaultData) config.get("node3", 123);
    Assert.assertEquals("node3", data.getData());
   
    this.clearUpZK(zk);
    this.clearUpFiles(TestConf.tmpPath);
View Full Code Here


 
  public void testSetConfigOK() throws Exception {
    ZooKeeper zk = this.initZK();
   
    CountDownLatch connectedSignal = new CountDownLatch(1);
    IService iservice = new IService(TestConf.host,null,null,null,"./src/test/tmp");   
    iservice.setEventHandle(Constants.CONNECT_EVENT, new TestHandler(connectedSignal));
    iservice.init();
    connectedSignal.await();
   
    Config config = iservice.createConfig("/iserviceTest/node1");
    DefaultData data = (DefaultData) config.get("node3", 123);
    Assert.assertEquals("node3", data.getData());
   
   
    CountDownLatch connectedSignal2 = new CountDownLatch(1);
View Full Code Here

  // change local file before update
  public void testSetConfigOK2() throws Exception{
    ZooKeeper zk = this.initZK();
   
    CountDownLatch connectedSignal = new CountDownLatch(1);
    IService iservice = new IService(TestConf.host,null,null,null,"./src/test/tmp");   
    iservice.setEventHandle(Constants.CONNECT_EVENT, new TestHandler(connectedSignal));
    iservice.init();
    connectedSignal.await();
   
    Config config = iservice.createConfig("/iserviceTest/node1");
    DefaultData data = (DefaultData) config.get("node3", 123);
    Assert.assertEquals("node3", data.getData());
   
    FS.dump(TestConf.tmpPath + "/" + Extends.getPid() + "/iserviceTest/node1/node4.data", "version:1\r\nnew-node4");
   
View Full Code Here

    FS.dump(TestConf.tmpPath + "/234/root/node1.data", "version:1\r\ni'm newer info1");
    FS.dump(TestConf.tmpPath + "/234/root/node2.data", "version:0\r\ni'm older info2");
   
    CountDownLatch connectedSignal = new CountDownLatch(1);
    TestHandler th = new TestHandler(connectedSignal);
    IService iservice = new IService("127.0.0.1:6000",null,null,null,"./src/test/tmp");   
    iservice.setEventHandle(Constants.DISCONNECT_EVENT, th);
    iservice.init();
    connectedSignal.await();
   
    Config config = iservice.createConfig("/root/node1");
    DefaultData data = (DefaultData) config.get("info", 111);
    Assert.assertEquals("i'm in newer node", data.getData());
   
    this.clearUpFiles(TestConf.tmpPath);
  }
View Full Code Here

 
  public static void main(String args[]) throws Exception{
    Main2 m = new Main2();
    m.initZk();
   
    IService client = new IService(DemoConf.host, DemoConf.root, "", "", DemoConf.tmpPath);
    client.setEventHandle(Constants.CONNECT_EVENT, new ConnectHandler());
    client.setEventHandle(Constants.DISCONNECT_EVENT, new DisconnectHandler());
    client.setEventHandle(Constants.EXPIRED_EVENT, new ExpiredHandler());
    client.init();
   
    String key = "app2/key1";
    Config config = client.createConfig("/IserviceDemoTest/group1");
    config.setEventHandle(Constants.DATA_CHANGE_EVENT, new DataChangeHandler(config, key));
   
    Timer timer = new Timer();
    TimerTask task = new Main2().new GetDataTask(config);
   
View Full Code Here

 
  public static void main(String args[]) throws Exception{
    Main m = new Main();
    m.initZk();
   
    IService client = new IService(DemoConf.host, DemoConf.root, "", "", DemoConf.tmpPath);
    client.setEventHandle(Constants.CONNECT_EVENT, new ConnectHandler());
    client.setEventHandle(Constants.DISCONNECT_EVENT, new DisconnectHandler());
    client.setEventHandle(Constants.EXPIRED_EVENT, new ExpiredHandler());
    client.init();
   
    String key = "key1";
    Config config = client.createConfig("/IserviceDemoTest/group1/app2");
    config.setEventHandle(Constants.DATA_CHANGE_EVENT, new DataChangeHandler(config, key));
   
    Timer timer = new Timer();
    TimerTask task = new Main().new GetDataTask(config);
   
View Full Code Here

TOP

Related Classes of client.IService

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.