當前位置: 首頁>>代碼示例>>Java>>正文


Java HBaseTestingUtility.startMiniZKCluster方法代碼示例

本文整理匯總了Java中org.apache.hadoop.hbase.HBaseTestingUtility.startMiniZKCluster方法的典型用法代碼示例。如果您正苦於以下問題:Java HBaseTestingUtility.startMiniZKCluster方法的具體用法?Java HBaseTestingUtility.startMiniZKCluster怎麽用?Java HBaseTestingUtility.startMiniZKCluster使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.hadoop.hbase.HBaseTestingUtility的用法示例。


在下文中一共展示了HBaseTestingUtility.startMiniZKCluster方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: startMiniClusters

import org.apache.hadoop.hbase.HBaseTestingUtility; //導入方法依賴的package包/類
@SuppressWarnings("resource")
private void startMiniClusters(int numClusters) throws Exception {
  Random random = new Random();
  utilities = new HBaseTestingUtility[numClusters];
  configurations = new Configuration[numClusters];
  for (int i = 0; i < numClusters; i++) {
    Configuration conf = new Configuration(baseConfiguration);
    conf.set(HConstants.ZOOKEEPER_ZNODE_PARENT, "/" + i + random.nextInt());
    HBaseTestingUtility utility = new HBaseTestingUtility(conf);
    if (i == 0) {
      utility.startMiniZKCluster();
      miniZK = utility.getZkCluster();
    } else {
      utility.setZkCluster(miniZK);
    }
    utility.startMiniCluster();
    utilities[i] = utility;
    configurations[i] = conf;
    new ZooKeeperWatcher(conf, "cluster" + i, null, true);
  }
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:22,代碼來源:TestMasterReplication.java

示例2: initCluster

import org.apache.hadoop.hbase.HBaseTestingUtility; //導入方法依賴的package包/類
@BeforeClass
public static void initCluster() throws Exception {
  if (initCount.get() == 0) {
    synchronized (HBaseTestsSuite.class) {
      if (initCount.get() == 0) {
        conf = HBaseConfiguration.create();
        conf.set(HConstants.HBASE_CLIENT_INSTANCE_ID, "drill-hbase-unit-tests-client");
        if (IS_DEBUG) {
          conf.set("hbase.regionserver.lease.period","10000000");
        }

        if (manageHBaseCluster) {
          logger.info("Starting HBase mini cluster.");
          UTIL = new HBaseTestingUtility(conf);
          UTIL.startMiniZKCluster();
          String old_home = System.getProperty("user.home");
          System.setProperty("user.home", UTIL.getDataTestDir().toString());
          UTIL.startMiniHBaseCluster(1, 1);
          System.setProperty("user.home", old_home);
          hbaseClusterCreated = true;
          logger.info("HBase mini cluster started. Zookeeper port: '{}'", getZookeeperPort());
        }

        admin = new HBaseAdmin(conf);

        if (createTables || !tablesExist()) {
          createTestTables();
          tablesCreated = true;
        }
        initCount.incrementAndGet();
        return;
      }
    }
  }
  initCount.incrementAndGet();
}
 
開發者ID:skhalifa,項目名稱:QDrill,代碼行數:37,代碼來源:HBaseTestsSuite.java

示例3: initCluster

import org.apache.hadoop.hbase.HBaseTestingUtility; //導入方法依賴的package包/類
@BeforeClass
public static void initCluster() throws Exception {
  assumeNonMaprProfile();
  if (initCount.get() == 0) {
    synchronized (HBaseTestsSuite.class) {
      if (initCount.get() == 0) {
        conf = HBaseConfiguration.create();
        conf.set(HConstants.HBASE_CLIENT_INSTANCE_ID, "dremio-hbase-unit-tests-client");
        if (IS_DEBUG) {
          conf.set("hbase.client.scanner.timeout.period","10000000");
        }

        if (manageHBaseCluster) {
          logger.info("Starting HBase mini cluster.");
          UTIL = new HBaseTestingUtility(conf);
          UTIL.startMiniZKCluster();
          String old_home = System.getProperty("user.home");
          System.setProperty("user.home", UTIL.getDataTestDir().toString());
          UTIL.startMiniHBaseCluster(1, 1);
          System.setProperty("user.home", old_home);
          hbaseClusterCreated = true;
          logger.info("HBase mini cluster started. Zookeeper port: '{}'", getZookeeperPort());
        }

        conn = ConnectionFactory.createConnection(conf);
        admin = conn.getAdmin();

        if (createTables || !tablesExist()) {
          createTestTables();
          tablesCreated = true;
        }
        initCount.incrementAndGet();
        return;
      }
    }
  }
  initCount.incrementAndGet();
}
 
開發者ID:dremio,項目名稱:dremio-oss,代碼行數:39,代碼來源:HBaseTestsSuite.java

示例4: setUpBeforeClass

import org.apache.hadoop.hbase.HBaseTestingUtility; //導入方法依賴的package包/類
@BeforeClass
public static void setUpBeforeClass() throws Exception {
  utility = new HBaseTestingUtility();
  utility.startMiniZKCluster();
  conf = utility.getConfiguration();
  ZooKeeperWatcher zk = HBaseTestingUtility.getZooKeeperWatcher(utility);
  ZKUtil.createWithParents(zk, zk.rsZNode);
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:9,代碼來源:TestReplicationTrackerZKImpl.java

示例5: setUpBeforeClass

import org.apache.hadoop.hbase.HBaseTestingUtility; //導入方法依賴的package包/類
@BeforeClass
public static void setUpBeforeClass() throws Exception {
  utility = new HBaseTestingUtility();
  utility.startMiniZKCluster();
  conf = utility.getConfiguration();
  zkw = HBaseTestingUtility.getZooKeeperWatcher(utility);
  String replicationZNodeName = conf.get("zookeeper.znode.replication", "replication");
  replicationZNode = ZKUtil.joinZNode(zkw.baseZNode, replicationZNodeName);
  KEY_ONE = initPeerClusterState("/hbase1");
  KEY_TWO = initPeerClusterState("/hbase2");
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:12,代碼來源:TestReplicationStateZKImpl.java

示例6: setupBeforeClass

import org.apache.hadoop.hbase.HBaseTestingUtility; //導入方法依賴的package包/類
@BeforeClass
public static void setupBeforeClass() throws Exception {
  TEST_UTIL = new HBaseTestingUtility();
  TEST_UTIL.startMiniZKCluster();
  // register token type for protocol
  SecurityInfo.addInfo(AuthenticationProtos.AuthenticationService.getDescriptor().getName(),
    new SecurityInfo("hbase.test.kerberos.principal",
      AuthenticationProtos.TokenIdentifier.Kind.HBASE_AUTH_TOKEN));
  // security settings only added after startup so that ZK does not require SASL
  Configuration conf = TEST_UTIL.getConfiguration();
  conf.set("hadoop.security.authentication", "kerberos");
  conf.set("hbase.security.authentication", "kerberos");
  conf.setBoolean(HADOOP_SECURITY_AUTHORIZATION, true);
  server = new TokenServer(conf);
  serverThread = new Thread(server);
  Threads.setDaemonThreadRunning(serverThread, "TokenServer:"+server.getServerName().toString());
  // wait for startup
  while (!server.isStarted() && !server.isStopped()) {
    Thread.sleep(10);
  }
  server.rpcServer.refreshAuthManager(new PolicyProvider() {
    @Override
    public Service[] getServices() {
      return new Service [] {
        new Service("security.client.protocol.acl",
          AuthenticationProtos.AuthenticationService.BlockingInterface.class)};
    }
  });
  ZKClusterId.setClusterId(server.getZooKeeper(), clusterId);
  secretManager = (AuthenticationTokenSecretManager)server.getSecretManager();
  while(secretManager.getCurrentKey() == null) {
    Thread.sleep(1);
  }
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:35,代碼來源:TestTokenAuthentication.java

示例7: setupBeforeClass

import org.apache.hadoop.hbase.HBaseTestingUtility; //導入方法依賴的package包/類
@BeforeClass
public static void setupBeforeClass() throws Exception {
  TEST_UTIL = new HBaseTestingUtility();
  TEST_UTIL.startMiniZKCluster();
  Configuration conf = TEST_UTIL.getConfiguration();

  ZooKeeperWatcher zk = newZK(conf, "server1", new MockAbortable());
  AuthenticationTokenSecretManagerForTest[] tmp = new AuthenticationTokenSecretManagerForTest[2];
  tmp[0] = new AuthenticationTokenSecretManagerForTest(
      conf, zk, "server1", 60*60*1000, 60*1000);
  tmp[0].start();

  zk = newZK(conf, "server2", new MockAbortable());
  tmp[1] = new AuthenticationTokenSecretManagerForTest(
      conf, zk, "server2", 60*60*1000, 60*1000);
  tmp[1].start();

  while (KEY_MASTER == null) {
    for (int i=0; i<2; i++) {
      if (tmp[i].isMaster()) {
        KEY_MASTER = tmp[i];
        KEY_SLAVE = tmp[ (i+1) % 2 ];
        break;
      }
    }
    Thread.sleep(500);
  }
  LOG.info("Master is "+KEY_MASTER.getName()+
      ", slave is "+KEY_SLAVE.getName());
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:31,代碼來源:TestZKSecretWatcher.java

示例8: setup

import org.apache.hadoop.hbase.HBaseTestingUtility; //導入方法依賴的package包/類
@Before
public void setup() throws Exception {
  TEST_UTIL = new HBaseTestingUtility();
  TEST_UTIL.startMiniZKCluster();
  conf = TEST_UTIL.getConfiguration();
  // Use a different ZK wrapper instance for each tests.
  zkw =
      new ZooKeeperWatcher(conf, "split-log-manager-tests" + UUID.randomUUID().toString(), null);
  ds = new DummyServer(zkw, conf);

  ZKUtil.deleteChildrenRecursively(zkw, zkw.baseZNode);
  ZKUtil.createAndFailSilent(zkw, zkw.baseZNode);
  assertTrue(ZKUtil.checkExists(zkw, zkw.baseZNode) != -1);
  LOG.debug(zkw.baseZNode + " created");
  ZKUtil.createAndFailSilent(zkw, zkw.splitLogZNode);
  assertTrue(ZKUtil.checkExists(zkw, zkw.splitLogZNode) != -1);
  LOG.debug(zkw.splitLogZNode + " created");

  stopped = false;
  resetCounters();

  // By default, we let the test manage the error as before, so the server
  // does not appear as dead from the master point of view, only from the split log pov.
  Mockito.when(sm.isServerOnline(Mockito.any(ServerName.class))).thenReturn(true);
  Mockito.when(master.getServerManager()).thenReturn(sm);

  to = 12000;
  conf.setInt(HConstants.HBASE_SPLITLOG_MANAGER_TIMEOUT, to);
  conf.setInt("hbase.splitlog.manager.unassigned.timeout", 2 * to);

  conf.setInt("hbase.splitlog.manager.timeoutmonitor.period", 100);
  to = to + 4 * 100;

  this.mode =
      (conf.getBoolean(HConstants.DISTRIBUTED_LOG_REPLAY_KEY, false) ? RecoveryMode.LOG_REPLAY
          : RecoveryMode.LOG_SPLITTING);
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:38,代碼來源:TestSplitLogManager.java

示例9: setUp

import org.apache.hadoop.hbase.HBaseTestingUtility; //導入方法依賴的package包/類
@Before
public void setUp() throws Exception {
  testUtil = new HBaseTestingUtility();
  testUtil.startMiniDFSCluster(1);
  testUtil.startMiniZKCluster(1);
  testUtil.createRootDir();
  cluster = new LocalHBaseCluster(testUtil.getConfiguration(), 0, 0);
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:9,代碼來源:TestRegionServerReportForDuty.java

示例10: setUpBeforeClass

import org.apache.hadoop.hbase.HBaseTestingUtility; //導入方法依賴的package包/類
@BeforeClass
public static void setUpBeforeClass() throws Exception {
  conf1.setInt("hfile.format.version", 3);
  conf1.set(HConstants.ZOOKEEPER_ZNODE_PARENT, "/1");
  conf1.setInt("replication.source.size.capacity", 10240);
  conf1.setLong("replication.source.sleepforretries", 100);
  conf1.setInt("hbase.regionserver.maxlogs", 10);
  conf1.setLong("hbase.master.logcleaner.ttl", 10);
  conf1.setInt("zookeeper.recovery.retry", 1);
  conf1.setInt("zookeeper.recovery.retry.intervalmill", 10);
  conf1.setBoolean("dfs.support.append", true);
  conf1.setLong(HConstants.THREAD_WAKE_FREQUENCY, 100);
  conf1.setInt("replication.stats.thread.period.seconds", 5);
  conf1.setBoolean("hbase.tests.use.shortcircuit.reads", false);
  conf1.setStrings(HConstants.REPLICATION_CODEC_CONF_KEY, KeyValueCodecWithTags.class.getName());
  conf1.setStrings(CoprocessorHost.USER_REGION_COPROCESSOR_CONF_KEY,
      TestCoprocessorForTagsAtSource.class.getName());

  utility1 = new HBaseTestingUtility(conf1);
  utility1.startMiniZKCluster();
  MiniZooKeeperCluster miniZK = utility1.getZkCluster();
  // Have to reget conf1 in case zk cluster location different
  // than default
  conf1 = utility1.getConfiguration();
  replicationAdmin = new ReplicationAdmin(conf1);
  LOG.info("Setup first Zk");

  // Base conf2 on conf1 so it gets the right zk cluster.
  conf2 = HBaseConfiguration.create(conf1);
  conf2.setInt("hfile.format.version", 3);
  conf2.set(HConstants.ZOOKEEPER_ZNODE_PARENT, "/2");
  conf2.setInt(HConstants.HBASE_CLIENT_RETRIES_NUMBER, 6);
  conf2.setBoolean("dfs.support.append", true);
  conf2.setBoolean("hbase.tests.use.shortcircuit.reads", false);
  conf2.setStrings(HConstants.REPLICATION_CODEC_CONF_KEY, KeyValueCodecWithTags.class.getName());
  conf2.setStrings(CoprocessorHost.USER_REGION_COPROCESSOR_CONF_KEY,
      TestCoprocessorForTagsAtSink.class.getName());

  utility2 = new HBaseTestingUtility(conf2);
  utility2.setZkCluster(miniZK);

  replicationAdmin.addPeer("2", utility2.getClusterKey());

  LOG.info("Setup second Zk");
  utility1.startMiniCluster(2);
  utility2.startMiniCluster(2);

  HTableDescriptor table = new HTableDescriptor(TABLE_NAME);
  HColumnDescriptor fam = new HColumnDescriptor(FAMILY);
  fam.setMaxVersions(3);
  fam.setScope(HConstants.REPLICATION_SCOPE_GLOBAL);
  table.addFamily(fam);
  try (Connection conn = ConnectionFactory.createConnection(conf1);
      Admin admin = conn.getAdmin()) {
    admin.createTable(table, HBaseTestingUtility.KEYS_FOR_HBA_CREATE_TABLE);
  }
  try (Connection conn = ConnectionFactory.createConnection(conf2);
      Admin admin = conn.getAdmin()) {
    admin.createTable(table, HBaseTestingUtility.KEYS_FOR_HBA_CREATE_TABLE);
  }
  htable1 = utility1.getConnection().getTable(TABLE_NAME);
  htable2 = utility2.getConnection().getTable(TABLE_NAME);
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:64,代碼來源:TestReplicationWithTags.java

示例11: setupBeforeClass

import org.apache.hadoop.hbase.HBaseTestingUtility; //導入方法依賴的package包/類
@BeforeClass
public static void setupBeforeClass() throws Exception {
  TEST_UTIL = new HBaseTestingUtility();
  TEST_UTIL.startMiniZKCluster();
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:6,代碼來源:TestZKSecretWatcherRefreshKeys.java

示例12: testMasterShutdownBeforeStartingAnyRegionServer

import org.apache.hadoop.hbase.HBaseTestingUtility; //導入方法依賴的package包/類
@Test(timeout = 60000)
public void testMasterShutdownBeforeStartingAnyRegionServer() throws Exception {
  final int NUM_MASTERS = 1;
  final int NUM_RS = 0;

  // Create config to use for this cluster
  Configuration conf = HBaseConfiguration.create();
  conf.setInt("hbase.ipc.client.failed.servers.expiry", 200);
  conf.setInt(ServerManager.WAIT_ON_REGIONSERVERS_MINTOSTART, 1);

  // Start the cluster
  final HBaseTestingUtility util = new HBaseTestingUtility(conf);
  util.startMiniDFSCluster(3);
  util.startMiniZKCluster();
  util.createRootDir();
  final LocalHBaseCluster cluster =
      new LocalHBaseCluster(conf, NUM_MASTERS, NUM_RS, HMaster.class,
          MiniHBaseCluster.MiniHBaseClusterRegionServer.class);
  final int MASTER_INDEX = 0;
  final MasterThread master = cluster.getMasters().get(MASTER_INDEX);
  master.start();
  LOG.info("Called master start on " + master.getName());
  Thread shutdownThread = new Thread() {
    public void run() {
      LOG.info("Before call to shutdown master");
      try {
        try (Connection connection =
            ConnectionFactory.createConnection(util.getConfiguration())) {
          try (Admin admin = connection.getAdmin()) {
            admin.shutdown();
          }
        }
        LOG.info("After call to shutdown master");
        cluster.waitOnMaster(MASTER_INDEX);
      } catch (Exception e) {
      }
    };
  };
  shutdownThread.start();
  LOG.info("Called master join on " + master.getName());
  master.join();
  shutdownThread.join();

  List<MasterThread> masterThreads = cluster.getMasters();
  // make sure all the masters properly shutdown
  assertEquals(0, masterThreads.size());

  util.shutdownMiniZKCluster();
  util.shutdownMiniDFSCluster();
  util.cleanupTestDir();
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:52,代碼來源:TestMasterShutdown.java

示例13: testRSTermnationAfterRegisteringToMasterBeforeCreatingEphemeralNod

import org.apache.hadoop.hbase.HBaseTestingUtility; //導入方法依賴的package包/類
/**
 * Test verifies whether a region server is removing from online servers list in master if it went
 * down after registering with master.
 * @throws Exception
 */
@Test(timeout = 180000)
public void testRSTermnationAfterRegisteringToMasterBeforeCreatingEphemeralNod() throws Exception {

  final int NUM_MASTERS = 1;
  final int NUM_RS = 2;
  firstRS.set(true);
  // Create config to use for this cluster
  Configuration conf = HBaseConfiguration.create();
  conf.setInt(ServerManager.WAIT_ON_REGIONSERVERS_MINTOSTART, 1);

  // Start the cluster
  final HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility(conf);
  TEST_UTIL.startMiniDFSCluster(3);
  TEST_UTIL.startMiniZKCluster();
  TEST_UTIL.createRootDir();
  final LocalHBaseCluster cluster =
      new LocalHBaseCluster(conf, NUM_MASTERS, NUM_RS, HMaster.class, MockedRegionServer.class);
  final MasterThread master = cluster.getMasters().get(0);
  master.start();
  try {
    long startTime = System.currentTimeMillis();
    while (!master.getMaster().isActiveMaster()) {
      try {
        Thread.sleep(100);
      } catch (InterruptedException ignored) {
      }
      if (System.currentTimeMillis() > startTime + 30000) {
        throw new RuntimeException("Master not active after 30 seconds");
      }
    }
    masterActive = true;
    cluster.getRegionServers().get(0).start();
    cluster.getRegionServers().get(1).start();
    Thread.sleep(10000);
    List<ServerName> onlineServersList =
        master.getMaster().getServerManager().getOnlineServersList();
    while (onlineServersList.size() > 1) {
      Thread.sleep(100);
      onlineServersList = master.getMaster().getServerManager().getOnlineServersList();
    }
    assertEquals(onlineServersList.size(), 1);
    cluster.shutdown();
  } finally {
    masterActive = false;
    firstRS.set(true);
    TEST_UTIL.shutdownMiniCluster();
  }
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:54,代碼來源:TestRSKilledWhenInitializing.java


注:本文中的org.apache.hadoop.hbase.HBaseTestingUtility.startMiniZKCluster方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。