Examples of LayoutTracker


Examples of org.kiji.schema.layout.impl.ZooKeeperMonitor.LayoutTracker

        new ZooKeeperMonitor(ZooKeeperClient.getZooKeeperClient(getZKAddress()));

    ZooKeeperUtils.setTableLayout(mZKClient, tableURI, layout1);

    BlockingQueue<byte[]> layoutQueue = Queues.newSynchronousQueue();
    LayoutTracker tracker =
        zkMonitor.newTableLayoutTracker(tableURI, new QueueingLayoutUpdateHandler(layoutQueue));
    try {
      tracker.open();
      Assert.assertEquals(layout1, Bytes.toString(layoutQueue.poll(5, TimeUnit.SECONDS)));

      ZooKeeperUtils.setTableLayout(mZKClient, tableURI, layout2);
      Assert.assertEquals(layout2, Bytes.toString(layoutQueue.poll(5, TimeUnit.SECONDS)));
    } finally {
      tracker.close();
    }
  }
View Full Code Here

Examples of org.kiji.schema.layout.impl.ZooKeeperMonitor.LayoutTracker

        monitor.notifyNewTableLayout(tableURI, Bytes.toBytes("layout.v1"), -1);

        final BlockingQueue<String> queue = Queues.newSynchronousQueue();

        final LayoutTracker layoutTracker = monitor.newTableLayoutTracker(
            tableURI,
            new LayoutUpdateHandler() {
              /** {@inheritDoc} */
              @Override
              public void update(byte[] layout) {
                try {
                  queue.put(Bytes.toString(layout));
                } catch (InterruptedException ie) {
                  throw new RuntimeInterruptedException(ie);
                }
              }
            });

        layoutTracker.open();
        final String layout1 = queue.poll(1, TimeUnit.SECONDS);
        Assert.assertEquals("layout.v1", layout1);

        monitor.notifyNewTableLayout(tableURI, Bytes.toBytes("layout.v2"), -1);
        final String layout2 = queue.poll(1, TimeUnit.SECONDS);
View Full Code Here

Examples of org.kiji.schema.layout.impl.ZooKeeperMonitor.LayoutTracker

    final byte[] layout1 = "1".getBytes();

    KijiURI tableURI = getTableURI();
    final BlockingQueue<byte[]> layoutQueue = Queues.newSynchronousQueue();

    LayoutTracker tracker =
        mMonitor.newTableLayoutTracker(tableURI, new QueueingLayoutUpdateHandler(layoutQueue));

    try {
      mMonitor.notifyNewTableLayout(tableURI, layout0, -1);
      tracker.open();
      Assert.assertTrue("No notification for initial layout.",
          Arrays.equals(layout0, layoutQueue.poll(1, TimeUnit.SECONDS)));

      mMonitor.notifyNewTableLayout(tableURI, layout1, -1);
      Assert.assertTrue("No notification for layout update.",
          Arrays.equals(layout1, layoutQueue.poll(1, TimeUnit.SECONDS)));
    } finally {
      tracker.close();
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.