当前位置: 首页>>代码示例>>Java>>正文


Java ZKSplitLog.getEncodedNodeName方法代码示例

本文整理汇总了Java中org.apache.hadoop.hbase.zookeeper.ZKSplitLog.getEncodedNodeName方法的典型用法代码示例。如果您正苦于以下问题:Java ZKSplitLog.getEncodedNodeName方法的具体用法?Java ZKSplitLog.getEncodedNodeName怎么用?Java ZKSplitLog.getEncodedNodeName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.hadoop.hbase.zookeeper.ZKSplitLog的用法示例。


在下文中一共展示了ZKSplitLog.getEncodedNodeName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: submitTaskAndWait

import org.apache.hadoop.hbase.zookeeper.ZKSplitLog; //导入方法依赖的package包/类
private String submitTaskAndWait(TaskBatch batch, String name) throws KeeperException,
    InterruptedException {
  String tasknode = ZKSplitLog.getEncodedNodeName(zkw, name);
  NodeCreationListener listener = new NodeCreationListener(zkw, tasknode);
  zkw.registerListener(listener);
  ZKUtil.watchAndCheckExists(zkw, tasknode);

  slm.enqueueSplitTask(name, batch);
  assertEquals(1, batch.installed);
  assertTrue(slm.findOrCreateOrphanTask(tasknode).batch == batch);
  assertEquals(1L, tot_mgr_node_create_queued.get());

  LOG.debug("waiting for task node creation");
  listener.waitForCreation();
  LOG.debug("task created");
  return tasknode;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:18,代码来源:TestSplitLogManager.java

示例2: testOrphanTaskAcquisition

import org.apache.hadoop.hbase.zookeeper.ZKSplitLog; //导入方法依赖的package包/类
@Test (timeout=180000)
public void testOrphanTaskAcquisition() throws Exception {
  LOG.info("TestOrphanTaskAcquisition");

  String tasknode = ZKSplitLog.getEncodedNodeName(zkw, "orphan/test/slash");
  SplitLogTask slt = new SplitLogTask.Owned(DUMMY_MASTER, this.mode);
  zkw.getRecoverableZooKeeper().create(tasknode, slt.toByteArray(), Ids.OPEN_ACL_UNSAFE,
      CreateMode.PERSISTENT);

  slm = new SplitLogManager(ds, conf, stopper, master, DUMMY_MASTER);
  waitForCounter(tot_mgr_orphan_task_acquired, 0, 1, to/2);
  Task task = slm.findOrCreateOrphanTask(tasknode);
  assertTrue(task.isOrphan());
  waitForCounter(tot_mgr_heartbeat, 0, 1, to/2);
  assertFalse(task.isUnassigned());
  long curt = System.currentTimeMillis();
  assertTrue((task.last_update <= curt) &&
      (task.last_update > (curt - 1000)));
  LOG.info("waiting for manager to resubmit the orphan task");
  waitForCounter(tot_mgr_resubmit, 0, 1, to + to/2);
  assertTrue(task.isUnassigned());
  waitForCounter(tot_mgr_rescan, 0, 1, to + to/2);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:24,代码来源:TestSplitLogManager.java

示例3: submitTaskAndWait

import org.apache.hadoop.hbase.zookeeper.ZKSplitLog; //导入方法依赖的package包/类
private String submitTaskAndWait(TaskBatch batch, String name)
throws KeeperException, InterruptedException {
  String tasknode = ZKSplitLog.getEncodedNodeName(zkw, name);
  NodeCreationListener listener = new NodeCreationListener(zkw, tasknode);
  zkw.registerListener(listener);
  ZKUtil.watchAndCheckExists(zkw, tasknode);

  slm.enqueueSplitTask(name, batch);
  assertEquals(1, batch.installed);
  assertTrue(slm.findOrCreateOrphanTask(tasknode).batch == batch);
  assertEquals(1L, tot_mgr_node_create_queued.get());

  LOG.debug("waiting for task node creation");
  listener.waitForCreation();
  LOG.debug("task created");
  return tasknode;
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:18,代码来源:TestSplitLogManager.java

示例4: testOrphanTaskAcquisition

import org.apache.hadoop.hbase.zookeeper.ZKSplitLog; //导入方法依赖的package包/类
@Test
public void testOrphanTaskAcquisition() throws Exception {
  LOG.info("TestOrphanTaskAcquisition");

  String tasknode = ZKSplitLog.getEncodedNodeName(zkw, "orphan/test/slash");
  SplitLogTask slt = new SplitLogTask.Owned(DUMMY_MASTER);
  zkw.getRecoverableZooKeeper().create(tasknode, slt.toByteArray(), Ids.OPEN_ACL_UNSAFE,
      CreateMode.PERSISTENT);

  slm = new SplitLogManager(zkw, conf, stopper, master, DUMMY_MASTER);
  waitForCounter(tot_mgr_orphan_task_acquired, 0, 1, to/2);
  Task task = slm.findOrCreateOrphanTask(tasknode);
  assertTrue(task.isOrphan());
  waitForCounter(tot_mgr_heartbeat, 0, 1, to/2);
  assertFalse(task.isUnassigned());
  long curt = System.currentTimeMillis();
  assertTrue((task.last_update <= curt) &&
      (task.last_update > (curt - 1000)));
  LOG.info("waiting for manager to resubmit the orphan task");
  waitForCounter(tot_mgr_resubmit, 0, 1, to + to/2);
  assertTrue(task.isUnassigned());
  waitForCounter(tot_mgr_rescan, 0, 1, to + to/2);
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:24,代码来源:TestSplitLogManager.java

示例5: testOrphanTaskAcquisition

import org.apache.hadoop.hbase.zookeeper.ZKSplitLog; //导入方法依赖的package包/类
@Test
public void testOrphanTaskAcquisition() throws Exception {
  LOG.info("TestOrphanTaskAcquisition");

  String tasknode = ZKSplitLog.getEncodedNodeName(zkw, "orphan/test/slash");
  zkw.getRecoverableZooKeeper().create(tasknode,
      TaskState.TASK_OWNED.get("dummy-worker"), Ids.OPEN_ACL_UNSAFE,
      CreateMode.PERSISTENT);

  slm = new SplitLogManager(zkw, conf, stopper, master, "dummy-master", null);
  slm.finishInitialization();
  waitForCounter(tot_mgr_orphan_task_acquired, 0, 1, to/2);
  Task task = slm.findOrCreateOrphanTask(tasknode);
  assertTrue(task.isOrphan());
  waitForCounter(tot_mgr_heartbeat, 0, 1, to/2);
  assertFalse(task.isUnassigned());
  long curt = System.currentTimeMillis();
  assertTrue((task.last_update <= curt) &&
      (task.last_update > (curt - 1000)));
  LOG.info("waiting for manager to resubmit the orphan task");
  waitForCounter(tot_mgr_resubmit, 0, 1, to + to/2);
  assertTrue(task.isUnassigned());
  waitForCounter(tot_mgr_rescan, 0, 1, to + to/2);
}
 
开发者ID:wanhao,项目名称:IRIndex,代码行数:25,代码来源:TestSplitLogManager.java

示例6: testUnassignedOrphan

import org.apache.hadoop.hbase.zookeeper.ZKSplitLog; //导入方法依赖的package包/类
@Test (timeout=180000)
public void testUnassignedOrphan() throws Exception {
  LOG.info("TestUnassignedOrphan - an unassigned task is resubmitted at" +
      " startup");
  String tasknode = ZKSplitLog.getEncodedNodeName(zkw, "orphan/test/slash");
  //create an unassigned orphan task
  SplitLogTask slt = new SplitLogTask.Unassigned(DUMMY_MASTER, this.mode);
  zkw.getRecoverableZooKeeper().create(tasknode, slt.toByteArray(), Ids.OPEN_ACL_UNSAFE,
      CreateMode.PERSISTENT);
  int version = ZKUtil.checkExists(zkw, tasknode);

  slm = new SplitLogManager(ds, conf, stopper, master, DUMMY_MASTER);
  waitForCounter(tot_mgr_orphan_task_acquired, 0, 1, to/2);
  Task task = slm.findOrCreateOrphanTask(tasknode);
  assertTrue(task.isOrphan());
  assertTrue(task.isUnassigned());
  // wait for RESCAN node to be created
  waitForCounter(tot_mgr_rescan, 0, 1, to/2);
  Task task2 = slm.findOrCreateOrphanTask(tasknode);
  assertTrue(task == task2);
  LOG.debug("task = " + task);
  assertEquals(1L, tot_mgr_resubmit.get());
  assertEquals(1, task.incarnation.get());
  assertEquals(0, task.unforcedResubmits.get());
  assertTrue(task.isOrphan());
  assertTrue(task.isUnassigned());
  assertTrue(ZKUtil.checkExists(zkw, tasknode) > version);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:29,代码来源:TestSplitLogManager.java

示例7: testUnassignedTimeout

import org.apache.hadoop.hbase.zookeeper.ZKSplitLog; //导入方法依赖的package包/类
@Test (timeout=180000)
public void testUnassignedTimeout() throws Exception {
  LOG.info("TestUnassignedTimeout - iff all tasks are unassigned then" +
      " resubmit");

  // create an orphan task in OWNED state
  String tasknode1 = ZKSplitLog.getEncodedNodeName(zkw, "orphan/1");
  final ServerName worker1 = ServerName.valueOf("worker1,1,1");
  SplitLogTask slt = new SplitLogTask.Owned(worker1, this.mode);
  zkw.getRecoverableZooKeeper().create(tasknode1, slt.toByteArray(), Ids.OPEN_ACL_UNSAFE,
      CreateMode.PERSISTENT);

  slm = new SplitLogManager(ds, conf, stopper, master, DUMMY_MASTER);
  waitForCounter(tot_mgr_orphan_task_acquired, 0, 1, to/2);

  // submit another task which will stay in unassigned mode
  TaskBatch batch = new TaskBatch();
  submitTaskAndWait(batch, "foo/1");

  // keep updating the orphan owned node every to/2 seconds
  for (int i = 0; i < (3 * to)/100; i++) {
    Thread.sleep(100);
    final ServerName worker2 = ServerName.valueOf("worker1,1,1");
    slt = new SplitLogTask.Owned(worker2, this.mode);
    ZKUtil.setData(zkw, tasknode1, slt.toByteArray());
  }

  // since we have stopped heartbeating the owned node therefore it should
  // get resubmitted
  LOG.info("waiting for manager to resubmit the orphan task");
  waitForCounter(tot_mgr_resubmit, 0, 1, to + to/2);

  // now all the nodes are unassigned. manager should post another rescan
  waitForCounter(tot_mgr_resubmit_unassigned, 0, 1, 2 * to + to/2);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:36,代码来源:TestSplitLogManager.java

示例8: testPreemptTask

import org.apache.hadoop.hbase.zookeeper.ZKSplitLog; //导入方法依赖的package包/类
@Test(timeout=60000)
public void testPreemptTask() throws Exception {
  LOG.info("testPreemptTask");
  SplitLogCounters.resetCounters();
  final ServerName SRV = ServerName.valueOf("tpt_svr,1,1");
  final String PATH = ZKSplitLog.getEncodedNodeName(zkw, "tpt_task");
  RegionServerServices mockedRS = getRegionServer(SRV);
  SplitLogWorker slw =
      new SplitLogWorker(ds, TEST_UTIL.getConfiguration(), mockedRS, neverEndingTask);
  slw.start();
  try {
    Thread.yield(); // let the worker start
    Thread.sleep(1000);
    waitForCounter(SplitLogCounters.tot_wkr_task_grabing, 0, 1, WAIT_TIME);

    // this time create a task node after starting the splitLogWorker
    zkw.getRecoverableZooKeeper().create(PATH,
      new SplitLogTask.Unassigned(MANAGER, this.mode).toByteArray(),
      Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);

    waitForCounter(SplitLogCounters.tot_wkr_task_acquired, 0, 1, WAIT_TIME);
    assertEquals(1, slw.getTaskReadySeq());
    byte [] bytes = ZKUtil.getData(zkw, PATH);
    SplitLogTask slt = SplitLogTask.parseFrom(bytes);
    assertTrue(slt.isOwned(SRV));
    slt = new SplitLogTask.Owned(MANAGER, this.mode);
    ZKUtil.setData(zkw, PATH, slt.toByteArray());
    waitForCounter(SplitLogCounters.tot_wkr_preempt_task, 0, 1, WAIT_TIME);
  } finally {
    stopSplitLogWorker(slw);
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:33,代码来源:TestSplitLogWorker.java

示例9: enqueueSplitTask

import org.apache.hadoop.hbase.zookeeper.ZKSplitLog; //导入方法依赖的package包/类
/**
 * Add a task entry to splitlog znode if it is not already there.
 * 
 * @param taskname the path of the log to be split
 * @param batch the batch this task belongs to
 * @return true if a new entry is created, false if it is already there.
 */
boolean enqueueSplitTask(String taskname, TaskBatch batch) {
  tot_mgr_log_split_start.incrementAndGet();
  String path = ZKSplitLog.getEncodedNodeName(watcher, taskname);
  Task oldtask = createTaskIfAbsent(path, batch);
  if (oldtask == null) {
    // publish the task in zk
    createNode(path, zkretries);
    return true;
  }
  return false;
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:19,代码来源:SplitLogManager.java

示例10: testPreemptTask

import org.apache.hadoop.hbase.zookeeper.ZKSplitLog; //导入方法依赖的package包/类
@Test(timeout=60000)
public void testPreemptTask() throws Exception {
  LOG.info("testPreemptTask");
  SplitLogCounters.resetCounters();
  final ServerName SRV = ServerName.valueOf("tpt_svr,1,1");
  final String PATH = ZKSplitLog.getEncodedNodeName(zkw, "tpt_task");
  RegionServerServices mockedRS = getRegionServer(SRV);
  SplitLogWorker slw =
      new SplitLogWorker(zkw, TEST_UTIL.getConfiguration(), mockedRS, neverEndingTask);
  slw.start();
  try {
    Thread.yield(); // let the worker start
    Thread.sleep(1000);
    waitForCounter(SplitLogCounters.tot_wkr_task_grabing, 0, 1, WAIT_TIME);

    // this time create a task node after starting the splitLogWorker
    zkw.getRecoverableZooKeeper().create(PATH,
      new SplitLogTask.Unassigned(MANAGER).toByteArray(), Ids.OPEN_ACL_UNSAFE,
      CreateMode.PERSISTENT);

    waitForCounter(SplitLogCounters.tot_wkr_task_acquired, 0, 1, WAIT_TIME);
    assertEquals(1, slw.taskReadySeq);
    byte [] bytes = ZKUtil.getData(zkw, PATH);
    SplitLogTask slt = SplitLogTask.parseFrom(bytes);
    assertTrue(slt.isOwned(SRV));
    slt = new SplitLogTask.Owned(MANAGER);
    ZKUtil.setData(zkw, PATH, slt.toByteArray());
    waitForCounter(SplitLogCounters.tot_wkr_preempt_task, 0, 1, WAIT_TIME);
  } finally {
    stopSplitLogWorker(slw);
  }
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:33,代码来源:TestSplitLogWorker.java

示例11: testUnassignedOrphan

import org.apache.hadoop.hbase.zookeeper.ZKSplitLog; //导入方法依赖的package包/类
@Test
public void testUnassignedOrphan() throws Exception {
  LOG.info("TestUnassignedOrphan - an unassigned task is resubmitted at" +
      " startup");
  String tasknode = ZKSplitLog.getEncodedNodeName(zkw, "orphan/test/slash");
  //create an unassigned orphan task
  zkw.getRecoverableZooKeeper().create(tasknode,
      TaskState.TASK_UNASSIGNED.get("dummy-worker"), Ids.OPEN_ACL_UNSAFE,
      CreateMode.PERSISTENT);
  int version = ZKUtil.checkExists(zkw, tasknode);

  slm = new SplitLogManager(zkw, conf, stopper, master, "dummy-master", null);
  slm.finishInitialization();
  waitForCounter(tot_mgr_orphan_task_acquired, 0, 1, to/2);
  Task task = slm.findOrCreateOrphanTask(tasknode);
  assertTrue(task.isOrphan());
  assertTrue(task.isUnassigned());
  // wait for RESCAN node to be created
  waitForCounter(tot_mgr_rescan, 0, 1, to/2);
  Task task2 = slm.findOrCreateOrphanTask(tasknode);
  assertTrue(task == task2);
  LOG.debug("task = " + task);
  assertEquals(1L, tot_mgr_resubmit.get());
  assertEquals(1, task.incarnation);
  assertEquals(0, task.unforcedResubmits);
  assertTrue(task.isOrphan());
  assertTrue(task.isUnassigned());
  assertTrue(ZKUtil.checkExists(zkw, tasknode) > version);
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:30,代码来源:TestSplitLogManager.java

示例12: testUnassignedTimeout

import org.apache.hadoop.hbase.zookeeper.ZKSplitLog; //导入方法依赖的package包/类
@Test
public void testUnassignedTimeout() throws Exception {
  LOG.info("TestUnassignedTimeout - iff all tasks are unassigned then" +
      " resubmit");

  // create an orphan task in OWNED state
  String tasknode1 = ZKSplitLog.getEncodedNodeName(zkw, "orphan/1");
  zkw.getRecoverableZooKeeper().create(tasknode1,
      TaskState.TASK_OWNED.get("dummy-worker"), Ids.OPEN_ACL_UNSAFE,
      CreateMode.PERSISTENT);

  slm = new SplitLogManager(zkw, conf, stopper, master, "dummy-master", null);
  slm.finishInitialization();
  waitForCounter(tot_mgr_orphan_task_acquired, 0, 1, to/2);


  // submit another task which will stay in unassigned mode
  TaskBatch batch = new TaskBatch();
  submitTaskAndWait(batch, "foo/1");

  // keep updating the orphan owned node every to/2 seconds
  for (int i = 0; i < (3 * to)/100; i++) {
    Thread.sleep(100);
    ZKUtil.setData(zkw, tasknode1,
        TaskState.TASK_OWNED.get("dummy-worker"));
  }

  // since we have stopped heartbeating the owned node therefore it should
  // get resubmitted
  LOG.info("waiting for manager to resubmit the orphan task");
  waitForCounter(tot_mgr_resubmit, 0, 1, to + to/2);

  // now all the nodes are unassigned. manager should post another rescan
  waitForCounter(tot_mgr_resubmit_unassigned, 0, 1, 2 * to + to/2);
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:36,代码来源:TestSplitLogManager.java

示例13: testUnassignedOrphan

import org.apache.hadoop.hbase.zookeeper.ZKSplitLog; //导入方法依赖的package包/类
@Test (timeout=180000)
public void testUnassignedOrphan() throws Exception {
  LOG.info("TestUnassignedOrphan - an unassigned task is resubmitted at" +
      " startup");
  String tasknode = ZKSplitLog.getEncodedNodeName(zkw, "orphan/test/slash");
  //create an unassigned orphan task
  SplitLogTask slt = new SplitLogTask.Unassigned(DUMMY_MASTER, this.mode);
  zkw.getRecoverableZooKeeper().create(tasknode, slt.toByteArray(), Ids.OPEN_ACL_UNSAFE,
      CreateMode.PERSISTENT);
  int version = ZKUtil.checkExists(zkw, tasknode);

  slm = new SplitLogManager(ds, conf, stopper, master, DUMMY_MASTER);
  waitForCounter(tot_mgr_orphan_task_acquired, 0, 1, to/2);
  Task task = slm.findOrCreateOrphanTask(tasknode);
  assertTrue(task.isOrphan());
  assertTrue(task.isUnassigned());
  // wait for RESCAN node to be created
  waitForCounter(tot_mgr_rescan, 0, 1, to/2);
  Task task2 = slm.findOrCreateOrphanTask(tasknode);
  assertTrue(task == task2);
  LOG.debug("task = " + task);
  assertEquals(1L, tot_mgr_resubmit.get());
  assertEquals(1, task.incarnation);
  assertEquals(0, task.unforcedResubmits.get());
  assertTrue(task.isOrphan());
  assertTrue(task.isUnassigned());
  assertTrue(ZKUtil.checkExists(zkw, tasknode) > version);
}
 
开发者ID:grokcoder,项目名称:pbase,代码行数:29,代码来源:TestSplitLogManager.java

示例14: enqueueSplitTask

import org.apache.hadoop.hbase.zookeeper.ZKSplitLog; //导入方法依赖的package包/类
/**
 * Add a task entry to splitlog znode if it is not already there.
 *
 * @param taskname the path of the log to be split
 * @param batch the batch this task belongs to
 * @return true if a new entry is created, false if it is already there.
 */
boolean enqueueSplitTask(String taskname, TaskBatch batch) {
  SplitLogCounters.tot_mgr_log_split_start.incrementAndGet();
  // This is a znode path under the splitlog dir with the rest of the path made up of an
  // url encoding of the passed in log to split.
  String path = ZKSplitLog.getEncodedNodeName(watcher, taskname);
  lastTaskCreateTime = EnvironmentEdgeManager.currentTimeMillis();
  Task oldtask = createTaskIfAbsent(path, batch);
  if (oldtask == null) {
    // publish the task in zk
    createNode(path, zkretries);
    return true;
  }
  return false;
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:22,代码来源:SplitLogManager.java

示例15: testUnassignedOrphan

import org.apache.hadoop.hbase.zookeeper.ZKSplitLog; //导入方法依赖的package包/类
@Test
public void testUnassignedOrphan() throws Exception {
  LOG.info("TestUnassignedOrphan - an unassigned task is resubmitted at" +
      " startup");
  String tasknode = ZKSplitLog.getEncodedNodeName(zkw, "orphan/test/slash");
  //create an unassigned orphan task
  SplitLogTask slt = new SplitLogTask.Unassigned(DUMMY_MASTER);
  zkw.getRecoverableZooKeeper().create(tasknode, slt.toByteArray(), Ids.OPEN_ACL_UNSAFE,
      CreateMode.PERSISTENT);
  int version = ZKUtil.checkExists(zkw, tasknode);

  slm = new SplitLogManager(zkw, conf, stopper, master, DUMMY_MASTER);
  waitForCounter(tot_mgr_orphan_task_acquired, 0, 1, to/2);
  Task task = slm.findOrCreateOrphanTask(tasknode);
  assertTrue(task.isOrphan());
  assertTrue(task.isUnassigned());
  // wait for RESCAN node to be created
  waitForCounter(tot_mgr_rescan, 0, 1, to/2);
  Task task2 = slm.findOrCreateOrphanTask(tasknode);
  assertTrue(task == task2);
  LOG.debug("task = " + task);
  assertEquals(1L, tot_mgr_resubmit.get());
  assertEquals(1, task.incarnation);
  assertEquals(0, task.unforcedResubmits.get());
  assertTrue(task.isOrphan());
  assertTrue(task.isUnassigned());
  assertTrue(ZKUtil.checkExists(zkw, tasknode) > version);
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:29,代码来源:TestSplitLogManager.java


注:本文中的org.apache.hadoop.hbase.zookeeper.ZKSplitLog.getEncodedNodeName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。