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


Java Waiter.waitFor方法代码示例

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


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

示例1: testWALEntryFilterFromReplicationEndpoint

import org.apache.hadoop.hbase.Waiter; //导入方法依赖的package包/类
@Test (timeout=120000)
public void testWALEntryFilterFromReplicationEndpoint() throws Exception {
  admin.addPeer("testWALEntryFilterFromReplicationEndpoint",
    new ReplicationPeerConfig().setClusterKey(ZKConfig.getZooKeeperClusterKey(conf1))
      .setReplicationEndpointImpl(ReplicationEndpointWithWALEntryFilter.class.getName()), null);
  // now replicate some data.
  try (Connection connection = ConnectionFactory.createConnection(conf1)) {
    doPut(connection, Bytes.toBytes("row1"));
    doPut(connection, row);
    doPut(connection, Bytes.toBytes("row2"));
  }

  Waiter.waitFor(conf1, 60000, new Waiter.Predicate<Exception>() {
    @Override
    public boolean evaluate() throws Exception {
      return ReplicationEndpointForTest.replicateCount.get() >= 1;
    }
  });

  Assert.assertNull(ReplicationEndpointWithWALEntryFilter.ex.get());
  admin.removePeer("testWALEntryFilterFromReplicationEndpoint");
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:23,代码来源:TestReplicationEndpoint.java

示例2: testWALEntryFilterFromReplicationEndpoint

import org.apache.hadoop.hbase.Waiter; //导入方法依赖的package包/类
@Test (timeout=120000)
public void testWALEntryFilterFromReplicationEndpoint() throws Exception {
  admin.addPeer("testWALEntryFilterFromReplicationEndpoint",
    new ReplicationPeerConfig().setClusterKey(ZKUtil.getZooKeeperClusterKey(conf1))
      .setReplicationEndpointImpl(ReplicationEndpointWithWALEntryFilter.class.getName()), null);
  // now replicate some data.
  try (Connection connection = ConnectionFactory.createConnection(conf1)) {
    doPut(connection, Bytes.toBytes("row1"));
    doPut(connection, row);
    doPut(connection, Bytes.toBytes("row2"));
  }

  Waiter.waitFor(conf1, 60000, new Waiter.Predicate<Exception>() {
    @Override
    public boolean evaluate() throws Exception {
      return ReplicationEndpointForTest.replicateCount.get() >= 1;
    }
  });

  Assert.assertNull(ReplicationEndpointWithWALEntryFilter.ex.get());
  admin.removePeer("testWALEntryFilterFromReplicationEndpoint");
}
 
开发者ID:grokcoder,项目名称:pbase,代码行数:23,代码来源:TestReplicationEndpoint.java

示例3: waitForLogAdvance

import org.apache.hadoop.hbase.Waiter; //导入方法依赖的package包/类
/**
 * Waits until there is only one log(the current writing one) in the replication queue
 * @param numRs number of regionservers
 */
private void waitForLogAdvance(int numRs) throws Exception {
  Waiter.waitFor(conf1, 10000, new Waiter.Predicate<Exception>() {
    @Override
    public boolean evaluate() throws Exception {
      for (int i = 0; i < numRs; i++) {
        HRegionServer hrs = utility1.getHBaseCluster().getRegionServer(i);
        RegionInfo regionInfo =
            utility1.getHBaseCluster().getRegions(htable1.getName()).get(0).getRegionInfo();
        WAL wal = hrs.getWAL(regionInfo);
        Path currentFile = ((AbstractFSWAL<?>) wal).getCurrentFileName();
        Replication replicationService = (Replication) utility1.getHBaseCluster()
            .getRegionServer(i).getReplicationSourceService();
        for (ReplicationSourceInterface rsi : replicationService.getReplicationManager()
            .getSources()) {
          ReplicationSource source = (ReplicationSource) rsi;
          if (!currentFile.equals(source.getCurrentPath())) {
            return false;
          }
        }
      }
      return true;
    }
  });
}
 
开发者ID:apache,项目名称:hbase,代码行数:29,代码来源:TestReplicationEmptyWALRecovery.java

示例4: waitPeer

import org.apache.hadoop.hbase.Waiter; //导入方法依赖的package包/类
private static void waitPeer(final String peerId,
    ReplicationSourceManager manager, final boolean waitForSource) {
  ReplicationPeers rp = manager.getReplicationPeers();
  Waiter.waitFor(conf, 20000, () -> {
    if (waitForSource) {
      ReplicationSourceInterface rs = manager.getSource(peerId);
      if (rs == null) {
        return false;
      }
      if (rs instanceof ReplicationSourceDummy) {
        return ((ReplicationSourceDummy)rs).isStartup();
      }
      return true;
    } else {
      return (rp.getPeer(peerId) != null);
    }
  });
}
 
开发者ID:apache,项目名称:hbase,代码行数:19,代码来源:TestReplicationSourceManager.java

示例5: removePeerAndWait

import org.apache.hadoop.hbase.Waiter; //导入方法依赖的package包/类
/**
 * Remove a peer and wait for it to get cleaned up
 * @param peerId
 * @throws Exception
 */
private void removePeerAndWait(final String peerId) throws Exception {
  final ReplicationPeers rp = manager.getReplicationPeers();
  if (rp.getPeerStorage().listPeerIds().contains(peerId)) {
    rp.getPeerStorage().removePeer(peerId);
    try {
      manager.removePeer(peerId);
    } catch (Exception e) {
      // ignore the failed exception and continue.
    }
  }
  Waiter.waitFor(conf, 20000, new Waiter.Predicate<Exception>() {
    @Override
    public boolean evaluate() throws Exception {
      Collection<String> peers = rp.getPeerStorage().listPeerIds();
      return (!manager.getAllQueues().contains(peerId)) && (rp.getPeer(peerId) == null)
          && (!peers.contains(peerId)) && manager.getSource(peerId) == null;
    }
  });
}
 
开发者ID:apache,项目名称:hbase,代码行数:25,代码来源:TestReplicationSourceManager.java

示例6: waitForTableToEnterQuotaViolation

import org.apache.hadoop.hbase.Waiter; //导入方法依赖的package包/类
private void waitForTableToEnterQuotaViolation(TableName tn) throws Exception {
  // Verify that the RegionServer has the quota in violation
  final HRegionServer rs = TEST_UTIL.getHBaseCluster().getRegionServer(0);
  Waiter.waitFor(TEST_UTIL.getConfiguration(), 30 * 1000, 1000, new Predicate<Exception>() {
    @Override
    public boolean evaluate() throws Exception {
      Map<TableName,SpaceQuotaSnapshot> snapshots =
          rs.getRegionServerSpaceQuotaManager().copyQuotaSnapshots();
      SpaceQuotaSnapshot snapshot = snapshots.get(tn);
      if (snapshot == null) {
        LOG.info("Found no snapshot for " + tn);
        return false;
      }
      LOG.info("Found snapshot " + snapshot);
      return snapshot.getQuotaStatus().isInViolation();
    }
  });
}
 
开发者ID:apache,项目名称:hbase,代码行数:19,代码来源:TestSuperUserQuotaPermissions.java

示例7: testRegionSizesFromMaster

import org.apache.hadoop.hbase.Waiter; //导入方法依赖的package包/类
@Test
public void testRegionSizesFromMaster() throws Exception {
  final long tableSize = 1024L * 10L; // 10KB
  final int numRegions = 10;
  final TableName tn = helper.createTableWithRegions(numRegions);
  // Will write at least `tableSize` data
  helper.writeData(tn, tableSize);

  final HMaster master = TEST_UTIL.getMiniHBaseCluster().getMaster();
  final MasterQuotaManager quotaManager = master.getMasterQuotaManager();
  // Make sure the master has all of the reports
  Waiter.waitFor(TEST_UTIL.getConfiguration(), 30 * 1000, new Predicate<Exception>() {
    @Override
    public boolean evaluate() throws Exception {
      Map<RegionInfo,Long> regionSizes = quotaManager.snapshotRegionSizes();
      LOG.trace("Region sizes=" + regionSizes);
      return numRegions == countRegionsForTable(tn, regionSizes) &&
          tableSize <= getTableSize(tn, regionSizes);
    }
  });

  Map<TableName,Long> sizes = QuotaTableUtil.getMasterReportedTableSizes(TEST_UTIL.getConnection());
  Long size = sizes.get(tn);
  assertNotNull("No reported size for " + tn, size);
  assertTrue("Reported table size was " + size, size.longValue() >= tableSize);
}
 
开发者ID:apache,项目名称:hbase,代码行数:27,代码来源:TestQuotaStatusRPCs.java

示例8: testCustomReplicationEndpoint

import org.apache.hadoop.hbase.Waiter; //导入方法依赖的package包/类
@Test (timeout=120000)
public void testCustomReplicationEndpoint() throws Exception {
  // test installing a custom replication endpoint other than the default one.
  admin.addPeer("testCustomReplicationEndpoint",
    new ReplicationPeerConfig().setClusterKey(ZKConfig.getZooKeeperClusterKey(conf1))
      .setReplicationEndpointImpl(ReplicationEndpointForTest.class.getName()), null);

  // check whether the class has been constructed and started
  Waiter.waitFor(conf1, 60000, new Waiter.Predicate<Exception>() {
    @Override
    public boolean evaluate() throws Exception {
      return ReplicationEndpointForTest.contructedCount.get() >= numRegionServers;
    }
  });

  Waiter.waitFor(conf1, 60000, new Waiter.Predicate<Exception>() {
    @Override
    public boolean evaluate() throws Exception {
      return ReplicationEndpointForTest.startedCount.get() >= numRegionServers;
    }
  });

  Assert.assertEquals(0, ReplicationEndpointForTest.replicateCount.get());

  // now replicate some data.
  doPut(Bytes.toBytes("row42"));

  Waiter.waitFor(conf1, 60000, new Waiter.Predicate<Exception>() {
    @Override
    public boolean evaluate() throws Exception {
      return ReplicationEndpointForTest.replicateCount.get() >= 1;
    }
  });

  doAssert(Bytes.toBytes("row42"));

  admin.removePeer("testCustomReplicationEndpoint");
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:39,代码来源:TestReplicationEndpoint.java

示例9: testReplicationEndpointReturnsFalseOnReplicate

import org.apache.hadoop.hbase.Waiter; //导入方法依赖的package包/类
@Test (timeout=120000)
public void testReplicationEndpointReturnsFalseOnReplicate() throws Exception {
  Assert.assertEquals(0, ReplicationEndpointForTest.replicateCount.get());
  Assert.assertTrue(!ReplicationEndpointReturningFalse.replicated.get());
  int peerCount = admin.getPeersCount();
  final String id = "testReplicationEndpointReturnsFalseOnReplicate";
  admin.addPeer(id,
    new ReplicationPeerConfig().setClusterKey(ZKConfig.getZooKeeperClusterKey(conf1))
      .setReplicationEndpointImpl(ReplicationEndpointReturningFalse.class.getName()), null);
  // This test is flakey and then there is so much stuff flying around in here its, hard to
  // debug.  Peer needs to be up for the edit to make it across. This wait on
  // peer count seems to be a hack that has us not progress till peer is up.
  if (admin.getPeersCount() <= peerCount) {
    LOG.info("Waiting on peercount to go up from " + peerCount);
    Threads.sleep(100);
  }
  // now replicate some data
  doPut(row);

  Waiter.waitFor(conf1, 60000, new Waiter.Predicate<Exception>() {
    @Override
    public boolean evaluate() throws Exception {
      // Looks like replication endpoint returns false unless we put more than 10 edits. We
      // only send over one edit.
      int count = ReplicationEndpointForTest.replicateCount.get();
      LOG.info("count=" + count);
      return ReplicationEndpointReturningFalse.replicated.get();
    }
  });
  if (ReplicationEndpointReturningFalse.ex.get() != null) {
    throw ReplicationEndpointReturningFalse.ex.get();
  }

  admin.removePeer("testReplicationEndpointReturnsFalseOnReplicate");
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:36,代码来源:TestReplicationEndpoint.java

示例10: testCustomReplicationEndpoint

import org.apache.hadoop.hbase.Waiter; //导入方法依赖的package包/类
@Test (timeout=120000)
public void testCustomReplicationEndpoint() throws Exception {
  // test installing a custom replication endpoint other than the default one.
  admin.addPeer("testCustomReplicationEndpoint",
    new ReplicationPeerConfig().setClusterKey(ZKUtil.getZooKeeperClusterKey(conf1))
      .setReplicationEndpointImpl(ReplicationEndpointForTest.class.getName()), null);

  // check whether the class has been constructed and started
  Waiter.waitFor(conf1, 60000, new Waiter.Predicate<Exception>() {
    @Override
    public boolean evaluate() throws Exception {
      return ReplicationEndpointForTest.contructedCount.get() >= numRegionServers;
    }
  });

  Waiter.waitFor(conf1, 60000, new Waiter.Predicate<Exception>() {
    @Override
    public boolean evaluate() throws Exception {
      return ReplicationEndpointForTest.startedCount.get() >= numRegionServers;
    }
  });

  Assert.assertEquals(0, ReplicationEndpointForTest.replicateCount.get());

  // now replicate some data.
  doPut(Bytes.toBytes("row42"));

  Waiter.waitFor(conf1, 60000, new Waiter.Predicate<Exception>() {
    @Override
    public boolean evaluate() throws Exception {
      return ReplicationEndpointForTest.replicateCount.get() >= 1;
    }
  });

  doAssert(Bytes.toBytes("row42"));

  admin.removePeer("testCustomReplicationEndpoint");
}
 
开发者ID:grokcoder,项目名称:pbase,代码行数:39,代码来源:TestReplicationEndpoint.java

示例11: testReplicationEndpointReturnsFalseOnReplicate

import org.apache.hadoop.hbase.Waiter; //导入方法依赖的package包/类
@Test (timeout=120000)
public void testReplicationEndpointReturnsFalseOnReplicate() throws Exception {
  Assert.assertEquals(0, ReplicationEndpointForTest.replicateCount.get());
  Assert.assertTrue(!ReplicationEndpointReturningFalse.replicated.get());
  int peerCount = admin.getPeersCount();
  final String id = "testReplicationEndpointReturnsFalseOnReplicate";
  admin.addPeer(id,
    new ReplicationPeerConfig().setClusterKey(ZKUtil.getZooKeeperClusterKey(conf1))
      .setReplicationEndpointImpl(ReplicationEndpointReturningFalse.class.getName()), null);
  // This test is flakey and then there is so much stuff flying around in here its, hard to
  // debug.  Peer needs to be up for the edit to make it across. This wait on
  // peer count seems to be a hack that has us not progress till peer is up.
  if (admin.getPeersCount() <= peerCount) {
    LOG.info("Waiting on peercount to go up from " + peerCount);
    Threads.sleep(100);
  }
  // now replicate some data
  doPut(row);

  Waiter.waitFor(conf1, 60000, new Waiter.Predicate<Exception>() {
    @Override
    public boolean evaluate() throws Exception {
      // Looks like replication endpoint returns false unless we put more than 10 edits. We
      // only send over one edit.
      int count = ReplicationEndpointForTest.replicateCount.get();
      LOG.info("count=" + count);
      return ReplicationEndpointReturningFalse.replicated.get();
    }
  });
  if (ReplicationEndpointReturningFalse.ex.get() != null) {
    throw ReplicationEndpointReturningFalse.ex.get();
  }

  admin.removePeer("testReplicationEndpointReturnsFalseOnReplicate");
}
 
开发者ID:grokcoder,项目名称:pbase,代码行数:36,代码来源:TestReplicationEndpoint.java

示例12: testLoopedReplication

import org.apache.hadoop.hbase.Waiter; //导入方法依赖的package包/类
/**
 * Tests the replication scenario 0 -> 0. By default
 * {@link BaseReplicationEndpoint#canReplicateToSameCluster()} returns false, so the
 * ReplicationSource should terminate, and no further logs should get enqueued
 */
@Test(timeout = 300000)
public void testLoopedReplication() throws Exception {
  LOG.info("testLoopedReplication");
  startMiniClusters(1);
  createTableOnClusters(table);
  addPeer("1", 0, 0);
  Thread.sleep(SLEEP_TIME);

  // wait for source to terminate
  final ServerName rsName = utilities[0].getHBaseCluster().getRegionServer(0).getServerName();
  Waiter.waitFor(baseConfiguration, 10000, new Waiter.Predicate<Exception>() {
    @Override
    public boolean evaluate() throws Exception {
      ClusterMetrics clusterStatus = utilities[0].getAdmin()
          .getClusterMetrics(EnumSet.of(ClusterMetrics.Option.LIVE_SERVERS));
      ServerMetrics serverLoad = clusterStatus.getLiveServerMetrics().get(rsName);
      List<ReplicationLoadSource> replicationLoadSourceList =
          serverLoad.getReplicationLoadSourceList();
      return replicationLoadSourceList.isEmpty();
    }
  });

  Table[] htables = getHTablesOnClusters(tableName);
  putAndWait(row, famName, htables[0], htables[0]);
  rollWALAndWait(utilities[0], table.getTableName(), row);
  ZKWatcher zkw = utilities[0].getZooKeeperWatcher();
  String queuesZnode = ZNodePaths.joinZNode(zkw.getZNodePaths().baseZNode,
    ZNodePaths.joinZNode("replication", "rs"));
  List<String> listChildrenNoWatch =
      ZKUtil.listChildrenNoWatch(zkw, ZNodePaths.joinZNode(queuesZnode, rsName.toString()));
  assertEquals(0, listChildrenNoWatch.size());
}
 
开发者ID:apache,项目名称:hbase,代码行数:38,代码来源:TestMasterReplication.java

示例13: testCustomReplicationEndpoint

import org.apache.hadoop.hbase.Waiter; //导入方法依赖的package包/类
@Test (timeout=120000)
public void testCustomReplicationEndpoint() throws Exception {
  // test installing a custom replication endpoint other than the default one.
  admin.addPeer("testCustomReplicationEndpoint",
      new ReplicationPeerConfig().setClusterKey(ZKConfig.getZooKeeperClusterKey(conf1))
          .setReplicationEndpointImpl(ReplicationEndpointForTest.class.getName()), null);

  // check whether the class has been constructed and started
  Waiter.waitFor(conf1, 60000, new Waiter.Predicate<Exception>() {
    @Override
    public boolean evaluate() throws Exception {
      return ReplicationEndpointForTest.contructedCount.get() >= numRegionServers;
    }
  });

  Waiter.waitFor(conf1, 60000, new Waiter.Predicate<Exception>() {
    @Override
    public boolean evaluate() throws Exception {
      return ReplicationEndpointForTest.startedCount.get() >= numRegionServers;
    }
  });

  Assert.assertEquals(0, ReplicationEndpointForTest.replicateCount.get());

  // now replicate some data.
  doPut(Bytes.toBytes("row42"));

  Waiter.waitFor(conf1, 60000, new Waiter.Predicate<Exception>() {
    @Override
    public boolean evaluate() throws Exception {
      return ReplicationEndpointForTest.replicateCount.get() >= 1;
    }
  });

  doAssert(Bytes.toBytes("row42"));

  admin.removePeer("testCustomReplicationEndpoint");
}
 
开发者ID:apache,项目名称:hbase,代码行数:39,代码来源:TestReplicationEndpoint.java

示例14: testWALEntryFilterFromReplicationEndpoint

import org.apache.hadoop.hbase.Waiter; //导入方法依赖的package包/类
@Test (timeout=120000)
public void testWALEntryFilterFromReplicationEndpoint() throws Exception {
  ReplicationPeerConfig rpc =  new ReplicationPeerConfig().setClusterKey(ZKConfig.getZooKeeperClusterKey(conf1))
      .setReplicationEndpointImpl(ReplicationEndpointWithWALEntryFilter.class.getName());
  //test that we can create mutliple WALFilters reflectively
  rpc.getConfiguration().put(BaseReplicationEndpoint.REPLICATION_WALENTRYFILTER_CONFIG_KEY,
      EverythingPassesWALEntryFilter.class.getName() +
          "," + EverythingPassesWALEntryFilterSubclass.class.getName());
  admin.addPeer("testWALEntryFilterFromReplicationEndpoint", rpc);
  // now replicate some data.
  try (Connection connection = ConnectionFactory.createConnection(conf1)) {
    doPut(connection, Bytes.toBytes("row1"));
    doPut(connection, row);
    doPut(connection, Bytes.toBytes("row2"));
  }

  Waiter.waitFor(conf1, 60000, new Waiter.Predicate<Exception>() {
    @Override
    public boolean evaluate() throws Exception {
      return ReplicationEndpointForTest.replicateCount.get() >= 1;
    }
  });

  Assert.assertNull(ReplicationEndpointWithWALEntryFilter.ex.get());
  //make sure our reflectively created filter is in the filter chain
  Assert.assertTrue(EverythingPassesWALEntryFilter.hasPassedAnEntry());
  admin.removePeer("testWALEntryFilterFromReplicationEndpoint");
}
 
开发者ID:apache,项目名称:hbase,代码行数:29,代码来源:TestReplicationEndpoint.java

示例15: testAborting

import org.apache.hadoop.hbase.Waiter; //导入方法依赖的package包/类
@Test
public void testAborting() throws Exception {
  final Configuration conf = HBaseConfiguration.create();
  final Server server = mock(Server.class);
  when(server.getConfiguration()).thenReturn(conf);

  ExecutorService executorService = new ExecutorService("unit_test");
  executorService.startExecutorService(
    ExecutorType.MASTER_SERVER_OPERATIONS, 1);


  executorService.submit(new EventHandler(server, EventType.M_SERVER_SHUTDOWN) {
    @Override
    public void process() throws IOException {
      throw new RuntimeException("Should cause abort");
    }
  });

  Waiter.waitFor(conf, 30000, new Predicate<Exception>() {
    @Override
    public boolean evaluate() throws Exception {
      try {
        verify(server, times(1)).abort(anyString(), (Throwable) anyObject());
        return true;
      } catch (Throwable t) {
        return false;
      }
    }
  });

  executorService.shutdown();
}
 
开发者ID:apache,项目名称:hbase,代码行数:33,代码来源:TestExecutorService.java


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