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


Java SplitLogTask.Unassigned方法代码示例

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


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

示例1: createNode

import org.apache.hadoop.hbase.SplitLogTask; //导入方法依赖的package包/类
private void createNode(String path, Long retry_count) {
  SplitLogTask slt = new SplitLogTask.Unassigned(details.getServerName(), getRecoveryMode());
  ZKUtil.asyncCreate(this.watcher, path, slt.toByteArray(), new CreateAsyncCallback(),
    retry_count);
  SplitLogCounters.tot_mgr_node_create_queued.incrementAndGet();
  return;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:8,代码来源:ZKSplitLogManagerCoordination.java

示例2: testUnassignedOrphan

import org.apache.hadoop.hbase.SplitLogTask; //导入方法依赖的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

示例3: testUnassignedOrphan

import org.apache.hadoop.hbase.SplitLogTask; //导入方法依赖的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

示例4: testUnassignedOrphan

import org.apache.hadoop.hbase.SplitLogTask; //导入方法依赖的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

示例5: createNode

import org.apache.hadoop.hbase.SplitLogTask; //导入方法依赖的package包/类
private void createNode(String path, Long retry_count) {
  SplitLogTask slt = new SplitLogTask.Unassigned(details.getServerName());
  ZKUtil.asyncCreate(this.watcher, path, slt.toByteArray(), new CreateAsyncCallback(),
    retry_count);
  SplitLogCounters.tot_mgr_node_create_queued.increment();
  return;
}
 
开发者ID:apache,项目名称:hbase,代码行数:8,代码来源:ZKSplitLogManagerCoordination.java

示例6: testUnassignedOrphan

import org.apache.hadoop.hbase.SplitLogTask; //导入方法依赖的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(master.getServerName());
  zkw.getRecoverableZooKeeper().create(tasknode, slt.toByteArray(), Ids.OPEN_ACL_UNSAFE,
      CreateMode.PERSISTENT);
  int version = ZKUtil.checkExists(zkw, tasknode);

  slm = new SplitLogManager(master, conf);
  waitForCounter(tot_mgr_orphan_task_acquired, 0, 1, to/2);
  Task task = 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 = findOrCreateOrphanTask(tasknode);
  assertTrue(task == task2);
  LOG.debug("task = " + task);
  assertEquals(1L, tot_mgr_resubmit.sum());
  assertEquals(1, task.incarnation.get());
  assertEquals(0, task.unforcedResubmits.get());
  assertTrue(task.isOrphan());
  assertTrue(task.isUnassigned());
  assertTrue(ZKUtil.checkExists(zkw, tasknode) > version);
}
 
开发者ID:apache,项目名称:hbase,代码行数:29,代码来源:TestSplitLogManager.java

示例7: testUnassignedOrphan

import org.apache.hadoop.hbase.SplitLogTask; //导入方法依赖的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);
  assertTrue(task.isOrphan());
  assertTrue(task.isUnassigned());
  assertTrue(ZKUtil.checkExists(zkw, tasknode) > version);
}
 
开发者ID:cloud-software-foundation,项目名称:c5,代码行数:29,代码来源:TestSplitLogManager.java

示例8: testPreemptTask

import org.apache.hadoop.hbase.SplitLogTask; //导入方法依赖的package包/类
@Test
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, 5000);

    // 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, 8000);
    assertEquals(1, slw.taskReadySeq);
    byte [] bytes = ZKUtil.getData(zkw, PATH);
    SplitLogTask slt = SplitLogTask.parseFrom(bytes);
    assertTrue(slt.isOwned(SRV));
    slt = new SplitLogTask.Unassigned(MANAGER);
    ZKUtil.setData(zkw, PATH, slt.toByteArray());
    waitForCounter(SplitLogCounters.tot_wkr_preempt_task, 0, 1, 1500);
  } finally {
    stopSplitLogWorker(slw);
  }
}
 
开发者ID:cloud-software-foundation,项目名称:c5,代码行数:33,代码来源:TestSplitLogWorker.java

示例9: testUnassignedOrphan

import org.apache.hadoop.hbase.SplitLogTask; //导入方法依赖的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, 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:daidong,项目名称:DominoHBase,代码行数:30,代码来源:TestSplitLogManager.java

示例10: testPreemptTask

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

    // 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, 1000);
    assertEquals(1, slw.taskReadySeq);
    byte [] bytes = ZKUtil.getData(zkw, PATH);
    SplitLogTask slt = SplitLogTask.parseFrom(bytes);
    assertTrue(slt.isOwned(SRV));
    slt = new SplitLogTask.Unassigned(MANAGER);
    ZKUtil.setData(zkw, PATH, slt.toByteArray());
    waitForCounter(SplitLogCounters.tot_wkr_preempt_task, 0, 1, 1000);
  } finally {
    stopSplitLogWorker(slw);
  }
}
 
开发者ID:daidong,项目名称:DominoHBase,代码行数:30,代码来源:TestSplitLogWorker.java

示例11: testMultipleTasks

import org.apache.hadoop.hbase.SplitLogTask; //导入方法依赖的package包/类
@Test
public void testMultipleTasks() throws Exception {
  LOG.info("testMultipleTasks");
  SplitLogCounters.resetCounters();
  final ServerName SRV = new ServerName("tmt_svr,1,1");
  final String PATH1 = ZKSplitLog.getEncodedNodeName(zkw, "tmt_task");
  SplitLogWorker slw = new SplitLogWorker(zkw, TEST_UTIL.getConfiguration(), SRV, neverEndingTask);
  slw.start();
  try {
    Thread.yield(); // let the worker start
    Thread.sleep(100);
    SplitLogTask unassignedManager = new SplitLogTask.Unassigned(MANAGER);
    zkw.getRecoverableZooKeeper().create(PATH1, unassignedManager.toByteArray(),
      Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);

    waitForCounter(SplitLogCounters.tot_wkr_task_acquired, 0, 1, 1000);
    // now the worker is busy doing the above task

    // create another task
    final String PATH2 = ZKSplitLog.getEncodedNodeName(zkw, "tmt_task_2");
    zkw.getRecoverableZooKeeper().create(PATH2, unassignedManager.toByteArray(),
      Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);

    // preempt the first task, have it owned by another worker
    final ServerName anotherWorker = new ServerName("another-worker,1,1");
    SplitLogTask slt = new SplitLogTask.Owned(anotherWorker);
    ZKUtil.setData(zkw, PATH1, slt.toByteArray());
    waitForCounter(SplitLogCounters.tot_wkr_preempt_task, 0, 1, 1000);

    waitForCounter(SplitLogCounters.tot_wkr_task_acquired, 1, 2, 1000);
    assertEquals(2, slw.taskReadySeq);
    byte [] bytes = ZKUtil.getData(zkw, PATH2);
    slt = SplitLogTask.parseFrom(bytes);
    assertTrue(slt.isOwned(SRV));
  } finally {
    stopSplitLogWorker(slw);
  }
}
 
开发者ID:daidong,项目名称:DominoHBase,代码行数:39,代码来源:TestSplitLogWorker.java

示例12: testMultipleTasks

import org.apache.hadoop.hbase.SplitLogTask; //导入方法依赖的package包/类
@Test(timeout=60000)
public void testMultipleTasks() throws Exception {
  LOG.info("testMultipleTasks");
  SplitLogCounters.resetCounters();
  final ServerName SRV = ServerName.valueOf("tmt_svr,1,1");
  final String PATH1 = ZKSplitLog.getEncodedNodeName(zkw, "tmt_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(100);
    waitForCounter(SplitLogCounters.tot_wkr_task_grabing, 0, 1, WAIT_TIME);

    SplitLogTask unassignedManager =
      new SplitLogTask.Unassigned(MANAGER, this.mode);
    zkw.getRecoverableZooKeeper().create(PATH1, unassignedManager.toByteArray(),
      Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);

    waitForCounter(SplitLogCounters.tot_wkr_task_acquired, 0, 1, WAIT_TIME);
    // now the worker is busy doing the above task

    // create another task
    final String PATH2 = ZKSplitLog.getEncodedNodeName(zkw, "tmt_task_2");
    zkw.getRecoverableZooKeeper().create(PATH2, unassignedManager.toByteArray(),
      Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);

    // preempt the first task, have it owned by another worker
    final ServerName anotherWorker = ServerName.valueOf("another-worker,1,1");
    SplitLogTask slt = new SplitLogTask.Owned(anotherWorker, this.mode);
    ZKUtil.setData(zkw, PATH1, slt.toByteArray());
    waitForCounter(SplitLogCounters.tot_wkr_preempt_task, 0, 1, WAIT_TIME);

    waitForCounter(SplitLogCounters.tot_wkr_task_acquired, 1, 2, WAIT_TIME);
    assertEquals(2, slw.getTaskReadySeq());
    byte [] bytes = ZKUtil.getData(zkw, PATH2);
    slt = SplitLogTask.parseFrom(bytes);
    assertTrue(slt.isOwned(SRV));
  } finally {
    stopSplitLogWorker(slw);
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:44,代码来源:TestSplitLogWorker.java

示例13: testRescan

import org.apache.hadoop.hbase.SplitLogTask; //导入方法依赖的package包/类
@Test(timeout=60000)
public void testRescan() throws Exception {
  LOG.info("testRescan");
  SplitLogCounters.resetCounters();
  final ServerName SRV = ServerName.valueOf("svr,1,1");
  RegionServerServices mockedRS = getRegionServer(SRV);
  slw = new SplitLogWorker(ds, TEST_UTIL.getConfiguration(), mockedRS, neverEndingTask);
  slw.start();
  Thread.yield(); // let the worker start
  Thread.sleep(100);

  String task = ZKSplitLog.getEncodedNodeName(zkw, "task");
  SplitLogTask slt = new SplitLogTask.Unassigned(MANAGER, this.mode);
  zkw.getRecoverableZooKeeper().create(task,slt.toByteArray(), Ids.OPEN_ACL_UNSAFE,
    CreateMode.PERSISTENT);

  waitForCounter(SplitLogCounters.tot_wkr_task_acquired, 0, 1, WAIT_TIME);
  // now the worker is busy doing the above task

  // preempt the task, have it owned by another worker
  ZKUtil.setData(zkw, task, slt.toByteArray());
  waitForCounter(SplitLogCounters.tot_wkr_preempt_task, 0, 1, WAIT_TIME);

  // create a RESCAN node
  String rescan = ZKSplitLog.getEncodedNodeName(zkw, "RESCAN");
  rescan = zkw.getRecoverableZooKeeper().create(rescan, slt.toByteArray(), Ids.OPEN_ACL_UNSAFE,
    CreateMode.PERSISTENT_SEQUENTIAL);

  waitForCounter(SplitLogCounters.tot_wkr_task_acquired, 1, 2, WAIT_TIME);
  // RESCAN node might not have been processed if the worker became busy
  // with the above task. preempt the task again so that now the RESCAN
  // node is processed
  ZKUtil.setData(zkw, task, slt.toByteArray());
  waitForCounter(SplitLogCounters.tot_wkr_preempt_task, 1, 2, WAIT_TIME);
  waitForCounter(SplitLogCounters.tot_wkr_task_acquired_rescan, 0, 1, WAIT_TIME);

  List<String> nodes = ZKUtil.listChildrenNoWatch(zkw, zkw.splitLogZNode);
  LOG.debug(nodes);
  int num = 0;
  for (String node : nodes) {
    num++;
    if (node.startsWith("RESCAN")) {
      String name = ZKSplitLog.getEncodedNodeName(zkw, node);
      String fn = ZKSplitLog.getFileName(name);
      byte [] data = ZKUtil.getData(zkw, ZKUtil.joinZNode(zkw.splitLogZNode, fn));
      slt = SplitLogTask.parseFrom(data);
      assertTrue(slt.toString(), slt.isDone(SRV));
    }
  }
  assertEquals(2, num);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:52,代码来源:TestSplitLogWorker.java

示例14: createNode

import org.apache.hadoop.hbase.SplitLogTask; //导入方法依赖的package包/类
private void createNode(String path, Long retry_count) {
  SplitLogTask slt = new SplitLogTask.Unassigned(serverName);
  ZKUtil.asyncCreate(this.watcher, path, slt.toByteArray(), new CreateAsyncCallback(), retry_count);
  SplitLogCounters.tot_mgr_node_create_queued.incrementAndGet();
  return;
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:7,代码来源:SplitLogManager.java

示例15: testMultipleTasks

import org.apache.hadoop.hbase.SplitLogTask; //导入方法依赖的package包/类
@Test(timeout=60000)
public void testMultipleTasks() throws Exception {
  LOG.info("testMultipleTasks");
  SplitLogCounters.resetCounters();
  final ServerName SRV = ServerName.valueOf("tmt_svr,1,1");
  final String PATH1 = ZKSplitLog.getEncodedNodeName(zkw, "tmt_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(100);
    waitForCounter(SplitLogCounters.tot_wkr_task_grabing, 0, 1, WAIT_TIME);

    SplitLogTask unassignedManager = new SplitLogTask.Unassigned(MANAGER);
    zkw.getRecoverableZooKeeper().create(PATH1, unassignedManager.toByteArray(),
      Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);

    waitForCounter(SplitLogCounters.tot_wkr_task_acquired, 0, 1, WAIT_TIME);
    // now the worker is busy doing the above task

    // create another task
    final String PATH2 = ZKSplitLog.getEncodedNodeName(zkw, "tmt_task_2");
    zkw.getRecoverableZooKeeper().create(PATH2, unassignedManager.toByteArray(),
      Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);

    // preempt the first task, have it owned by another worker
    final ServerName anotherWorker = ServerName.valueOf("another-worker,1,1");
    SplitLogTask slt = new SplitLogTask.Owned(anotherWorker);
    ZKUtil.setData(zkw, PATH1, slt.toByteArray());
    waitForCounter(SplitLogCounters.tot_wkr_preempt_task, 0, 1, WAIT_TIME);

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


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