org.apache.hadoop.hbase.zookeeper.MiniZooKeeperCluster Java Examples

The following examples show how to use org.apache.hadoop.hbase.zookeeper.MiniZooKeeperCluster. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HBaseTestClusterUtil.java    From tajo with Apache License 2.0 6 votes vote down vote up
/**
 * Start a mini ZK cluster. If the property "test.hbase.zookeeper.property.clientPort" is set
 *  the port mentionned is used as the default port for ZooKeeper.
 */
public MiniZooKeeperCluster startMiniZKCluster()
    throws Exception {
  File zkDataPath = new File(testBaseDir, "zk");
  if (this.zkCluster != null) {
    throw new IOException("Cluster already running at " + zkDataPath);
  }
  this.zkCluster = new MiniZooKeeperCluster(conf);
  final int defPort = this.conf.getInt("test.hbase.zookeeper.property.clientPort", 0);
  if (defPort > 0){
    // If there is a port in the config file, we use it.
    this.zkCluster.setDefaultClientPort(defPort);
  }
  int clientPort =  this.zkCluster.startup(zkDataPath, 1);
  this.conf.set(HConstants.ZOOKEEPER_CLIENT_PORT, Integer.toString(clientPort));
  LOG.info("MiniZooKeeperCluster started");

  return this.zkCluster;
}
 
Example #2
Source File: ResultToSolrMapperFactoryTest.java    From hbase-indexer with Apache License 2.0 6 votes vote down vote up
@BeforeClass
public static void setUpBeforeClass() throws Exception {

    ZK_DIR = new File(System.getProperty("java.io.tmpdir") + File.separator + "resulttosolrmapperfactory.zktest");
    ZK_CLIENT_PORT = getFreePort();

    ZK_CLUSTER = new MiniZooKeeperCluster();
    ZK_CLUSTER.setDefaultClientPort(ZK_CLIENT_PORT);
    ZK_CLUSTER.startup(ZK_DIR);

    SOLR_TEST_UTILITY = new SolrTestingUtility(ZK_CLIENT_PORT, NetUtils.getFreePort());
    SOLR_TEST_UTILITY.start();
    SOLR_TEST_UTILITY.uploadConfig("config1",
            Resources.toByteArray(Resources.getResource(ResultToSolrMapperFactoryTest.class, "schema.xml")),
            Resources.toByteArray(Resources.getResource(ResultToSolrMapperFactoryTest.class, "solrconfig.xml")));
    SOLR_TEST_UTILITY.createCore("collection1_core1", "collection1", "config1", 1);

    COLLECTION1 = new CloudSolrClient.Builder().withZkHost(SOLR_TEST_UTILITY.getZkConnectString()).build();
    COLLECTION1.setDefaultCollection("collection1");
}
 
Example #3
Source File: TestReplicationStateBasic.java    From hbase with Apache License 2.0 6 votes vote down vote up
protected void populateQueues() throws ReplicationException {
  rqs.addWAL(server1, "trash", "trash");
  rqs.removeQueue(server1, "trash");

  rqs.addWAL(server2, "qId1", "trash");
  rqs.removeWAL(server2, "qId1", "trash");

  for (int i = 1; i < 6; i++) {
    for (int j = 0; j < i; j++) {
      rqs.addWAL(server3, "qId" + i, "filename" + j);
    }
    // Add peers for the corresponding queues so they are not orphans
    rp.getPeerStorage().addPeer("qId" + i,
      ReplicationPeerConfig.newBuilder().
        setClusterKey(MiniZooKeeperCluster.HOST + ":2818:/bogus" + i).build(),
      true, SyncReplicationState.NONE);
  }
}
 
Example #4
Source File: TestSeparateClientZKCluster.java    From hbase with Apache License 2.0 6 votes vote down vote up
@BeforeClass
public static void beforeAllTests() throws Exception {
  int clientZkPort = 21828;
  clientZkCluster = new MiniZooKeeperCluster(TEST_UTIL.getConfiguration());
  clientZkCluster.setDefaultClientPort(clientZkPort);
  clientZkCluster.startup(clientZkDir);
  // reduce the retry number and start log counter
  TEST_UTIL.getConfiguration().setInt(HConstants.HBASE_CLIENT_RETRIES_NUMBER, 2);
  TEST_UTIL.getConfiguration().setInt("hbase.client.start.log.errors.counter", -1);
  TEST_UTIL.getConfiguration().setInt("zookeeper.recovery.retry", 1);
  // core settings for testing client ZK cluster
  TEST_UTIL.getConfiguration().set(HConstants.CLIENT_ZOOKEEPER_QUORUM, HConstants.LOCALHOST);
  TEST_UTIL.getConfiguration().setInt(HConstants.CLIENT_ZOOKEEPER_CLIENT_PORT, clientZkPort);
  // reduce zk session timeout to easier trigger session expiration
  TEST_UTIL.getConfiguration().setInt(HConstants.ZK_SESSION_TIMEOUT, ZK_SESSION_TIMEOUT);
  // Start a cluster with 2 masters and 3 regionservers.
  StartMiniClusterOption option = StartMiniClusterOption.builder()
      .numMasters(2).numRegionServers(3).numDataNodes(3).build();
  TEST_UTIL.startMiniCluster(option);
}
 
Example #5
Source File: TestZKConnectionRegistry.java    From hbase with Apache License 2.0 6 votes vote down vote up
@Test
public void testIndependentZKConnections() throws IOException {
  try (ReadOnlyZKClient zk1 = REGISTRY.getZKClient()) {
    Configuration otherConf = new Configuration(TEST_UTIL.getConfiguration());
    otherConf.set(HConstants.ZOOKEEPER_QUORUM, MiniZooKeeperCluster.HOST);
    try (ZKConnectionRegistry otherRegistry = new ZKConnectionRegistry(otherConf)) {
      ReadOnlyZKClient zk2 = otherRegistry.getZKClient();
      assertNotSame("Using a different configuration / quorum should result in different " +
        "backing zk connection.", zk1, zk2);
      assertNotEquals(
        "Using a different configrution / quorum should be reflected in the zk connection.",
        zk1.getConnectString(), zk2.getConnectString());
    }
  } finally {
    LOG.info("DONE!");
  }
}
 
Example #6
Source File: HBaseZKTestingUtility.java    From hbase with Apache License 2.0 6 votes vote down vote up
/**
 * Start a mini ZK cluster. If the property "test.hbase.zookeeper.property.clientPort" is set the
 * port mentioned is used as the default port for ZooKeeper.
 */
private MiniZooKeeperCluster startMiniZKCluster(File dir, int zooKeeperServerNum,
    int[] clientPortList) throws Exception {
  if (this.zkCluster != null) {
    throw new IOException("Cluster already running at " + dir);
  }
  this.passedZkCluster = false;
  this.zkCluster = new MiniZooKeeperCluster(this.getConfiguration());
  int defPort = this.conf.getInt("test.hbase.zookeeper.property.clientPort", 0);
  if (defPort > 0) {
    // If there is a port in the config file, we use it.
    this.zkCluster.setDefaultClientPort(defPort);
  }

  if (clientPortList != null) {
    // Ignore extra client ports
    int clientPortListSize = Math.min(clientPortList.length, zooKeeperServerNum);
    for (int i = 0; i < clientPortListSize; i++) {
      this.zkCluster.addClientPort(clientPortList[i]);
    }
  }
  int clientPort = this.zkCluster.startup(dir, zooKeeperServerNum);
  this.conf.set(HConstants.ZOOKEEPER_CLIENT_PORT, Integer.toString(clientPort));
  return this.zkCluster;
}
 
Example #7
Source File: TestReplicationStuckWithDeletedTableCFs.java    From hbase with Apache License 2.0 6 votes vote down vote up
@BeforeClass
public static void setUpBeforeClass() throws Exception {
  conf1.set(HConstants.ZOOKEEPER_ZNODE_PARENT, "/1");
  conf1.setInt("replication.source.nb.capacity", 1);
  utility1 = new HBaseTestingUtility(conf1);
  utility1.startMiniZKCluster();
  MiniZooKeeperCluster miniZK = utility1.getZkCluster();
  conf1 = utility1.getConfiguration();

  conf2 = HBaseConfiguration.create(conf1);
  conf2.set(HConstants.ZOOKEEPER_ZNODE_PARENT, "/2");
  utility2 = new HBaseTestingUtility(conf2);
  utility2.setZkCluster(miniZK);

  utility1.startMiniCluster(1);
  utility2.startMiniCluster(1);

  admin1 = utility1.getAdmin();
  admin2 = utility2.getAdmin();
}
 
Example #8
Source File: TestReplicationEditsDroppedWithDeletedTableCFs.java    From hbase with Apache License 2.0 6 votes vote down vote up
@BeforeClass
public static void setUpBeforeClass() throws Exception {
  // Set true to filter replication edits for dropped table
  conf1.setBoolean(REPLICATION_DROP_ON_DELETED_COLUMN_FAMILY_KEY, true);
  conf1.set(ZOOKEEPER_ZNODE_PARENT, "/1");
  conf1.setInt("replication.source.nb.capacity", 1);
  utility1 = new HBaseTestingUtility(conf1);
  utility1.startMiniZKCluster();
  MiniZooKeeperCluster miniZK = utility1.getZkCluster();
  conf1 = utility1.getConfiguration();

  conf2 = HBaseConfiguration.create(conf1);
  conf2.set(ZOOKEEPER_ZNODE_PARENT, "/2");
  utility2 = new HBaseTestingUtility(conf2);
  utility2.setZkCluster(miniZK);

  utility1.startMiniCluster(1);
  utility2.startMiniCluster(1);

  admin1 = utility1.getAdmin();
  admin2 = utility2.getAdmin();
}
 
Example #9
Source File: TestReplicationStuckWithDroppedTable.java    From hbase with Apache License 2.0 6 votes vote down vote up
@BeforeClass
public static void setUpBeforeClass() throws Exception {
  conf1.set(ZOOKEEPER_ZNODE_PARENT, "/1");
  conf1.setInt("replication.source.nb.capacity", 1);
  utility1 = new HBaseTestingUtility(conf1);
  utility1.startMiniZKCluster();
  MiniZooKeeperCluster miniZK = utility1.getZkCluster();
  conf1 = utility1.getConfiguration();

  conf2 = HBaseConfiguration.create(conf1);
  conf2.set(ZOOKEEPER_ZNODE_PARENT, "/2");
  utility2 = new HBaseTestingUtility(conf2);
  utility2.setZkCluster(miniZK);

  utility1.startMiniCluster(1);
  utility2.startMiniCluster(1);

  admin1 = utility1.getAdmin();
  admin2 = utility2.getAdmin();
}
 
Example #10
Source File: TestVerifyReplicationCrossDiffHdfs.java    From hbase with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void setUpBeforeClass() throws Exception {
  conf1.set(HConstants.ZOOKEEPER_ZNODE_PARENT, "/1");
  util1 = new HBaseTestingUtility(conf1);
  util1.startMiniZKCluster();
  MiniZooKeeperCluster miniZK = util1.getZkCluster();
  conf1 = util1.getConfiguration();

  conf2 = HBaseConfiguration.create(conf1);
  conf2.set(HConstants.ZOOKEEPER_ZNODE_PARENT, "/2");
  util2 = new HBaseTestingUtility(conf2);
  util2.setZkCluster(miniZK);

  util1.startMiniCluster();
  util2.startMiniCluster();

  createTestingTable(util1.getAdmin());
  createTestingTable(util2.getAdmin());
  addTestingPeer();

  LOG.info("Start to load some data to source cluster.");
  loadSomeData();

  LOG.info("Start mini MapReduce cluster.");
  mapReduceUtil.setZkCluster(miniZK);
  mapReduceUtil.startMiniMapReduceCluster();
}
 
Example #11
Source File: TestHBaseTestingUtility.java    From hbase with Apache License 2.0 5 votes vote down vote up
@Test
public void testMiniZooKeeperWithOneServer() throws Exception {
  HBaseTestingUtility hbt = new HBaseTestingUtility();
  MiniZooKeeperCluster cluster1 = hbt.startMiniZKCluster();
  try {
    assertEquals(0, cluster1.getBackupZooKeeperServerNum());
    assertTrue((cluster1.killCurrentActiveZooKeeperServer() == -1));
  } finally {
    hbt.shutdownMiniZKCluster();
  }
}
 
Example #12
Source File: TestingPhoenixServer.java    From presto with Apache License 2.0 5 votes vote down vote up
private TestingPhoenixServer()
{
    // keep references to prevent GC from resetting the log levels
    apacheLogger = java.util.logging.Logger.getLogger("org.apache");
    apacheLogger.setLevel(Level.SEVERE);
    zookeeperLogger = java.util.logging.Logger.getLogger(ZooKeeperServer.class.getName());
    zookeeperLogger.setLevel(Level.OFF);
    securityLogger = java.util.logging.Logger.getLogger("SecurityLogger.org.apache");
    securityLogger.setLevel(Level.SEVERE);
    // to squelch the SecurityLogger,
    // instantiate logger with config above before config is overriden again in HBase test franework
    org.apache.commons.logging.LogFactory.getLog("SecurityLogger.org.apache.hadoop.hbase.server");
    this.conf.set("hbase.security.logger", "ERROR");
    this.conf.setInt(MASTER_INFO_PORT, -1);
    this.conf.setInt(REGIONSERVER_INFO_PORT, -1);
    this.conf.setInt(HBASE_CLIENT_RETRIES_NUMBER, 1);
    this.conf.setBoolean("phoenix.schema.isNamespaceMappingEnabled", true);
    this.conf.set("hbase.regionserver.wal.codec", "org.apache.hadoop.hbase.regionserver.wal.IndexedWALEditCodec");
    this.hbaseTestingUtility = new HBaseTestingUtility(conf);

    try {
        MiniZooKeeperCluster zkCluster = this.hbaseTestingUtility.startMiniZKCluster();
        port = zkCluster.getClientPort();

        MiniHBaseCluster hbaseCluster = hbaseTestingUtility.startMiniHBaseCluster(1, 4);
        hbaseCluster.waitForActiveAndReadyMaster();
        LOG.info("Phoenix server ready: %s", getJdbcUrl());
    }
    catch (Exception e) {
        throw new RuntimeException("Can't start phoenix server.", e);
    }
}
 
Example #13
Source File: TestGlobalReplicationThrottler.java    From hbase with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void setUpBeforeClass() throws Exception {
  conf1 = HBaseConfiguration.create();
  conf1.set(HConstants.ZOOKEEPER_ZNODE_PARENT, "/1");
  conf1.setLong("replication.source.sleepforretries", 100);
  // Each WAL is about 120 bytes
  conf1.setInt(HConstants.REPLICATION_SOURCE_TOTAL_BUFFER_KEY, REPLICATION_SOURCE_QUOTA);
  conf1.setLong("replication.source.per.peer.node.bandwidth", 100L);

  utility1 = new HBaseTestingUtility(conf1);
  utility1.startMiniZKCluster();
  MiniZooKeeperCluster miniZK = utility1.getZkCluster();
  new ZKWatcher(conf1, "cluster1", null, true);

  conf2 = new Configuration(conf1);
  conf2.set(HConstants.ZOOKEEPER_ZNODE_PARENT, "/2");

  utility2 = new HBaseTestingUtility(conf2);
  utility2.setZkCluster(miniZK);
  new ZKWatcher(conf2, "cluster2", null, true);

  ReplicationPeerConfig rpc = new ReplicationPeerConfig();
  rpc.setClusterKey(utility2.getClusterKey());

  utility1.startMiniCluster();
  utility2.startMiniCluster();

  Admin admin1 = ConnectionFactory.createConnection(conf1).getAdmin();
  admin1.addReplicationPeer("peer1", rpc);
  admin1.addReplicationPeer("peer2", rpc);
  admin1.addReplicationPeer("peer3", rpc);
  numOfPeer = admin1.listReplicationPeers().size();
}
 
Example #14
Source File: TestReplicationBase.java    From hbase with Apache License 2.0 5 votes vote down vote up
private static void startClusters() throws Exception {
  UTIL1.startMiniZKCluster();
  MiniZooKeeperCluster miniZK = UTIL1.getZkCluster();
  LOG.info("Setup first Zk");

  UTIL2.setZkCluster(miniZK);
  LOG.info("Setup second Zk");

  CONF_WITH_LOCALFS = HBaseConfiguration.create(CONF1);
  UTIL1.startMiniCluster(NUM_SLAVES1);
  // Have a bunch of slave servers, because inter-cluster shipping logic uses number of sinks
  // as a component in deciding maximum number of parallel batches to send to the peer cluster.
  UTIL2.startMiniCluster(NUM_SLAVES2);

  hbaseAdmin = ConnectionFactory.createConnection(CONF1).getAdmin();

  TableDescriptor table = TableDescriptorBuilder.newBuilder(tableName)
      .setColumnFamily(ColumnFamilyDescriptorBuilder.newBuilder(famName).setMaxVersions(100)
          .setScope(HConstants.REPLICATION_SCOPE_GLOBAL).build())
      .setColumnFamily(ColumnFamilyDescriptorBuilder.of(noRepfamName)).build();

  Connection connection1 = ConnectionFactory.createConnection(CONF1);
  Connection connection2 = ConnectionFactory.createConnection(CONF2);
  try (Admin admin1 = connection1.getAdmin()) {
    admin1.createTable(table, HBaseTestingUtility.KEYS_FOR_HBA_CREATE_TABLE);
  }
  try (Admin admin2 = connection2.getAdmin()) {
    admin2.createTable(table, HBaseTestingUtility.KEYS_FOR_HBA_CREATE_TABLE);
  }
  UTIL1.waitUntilAllRegionsAssigned(tableName);
  UTIL2.waitUntilAllRegionsAssigned(tableName);
  htable1 = connection1.getTable(tableName);
  htable2 = connection2.getTable(tableName);
}
 
Example #15
Source File: TestReplicationEditsDroppedWithDroppedTable.java    From hbase with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void setUpBeforeClass() throws Exception {
  // Set true to filter replication edits for dropped table
  conf1.setBoolean(HBaseInterClusterReplicationEndpoint.REPLICATION_DROP_ON_DELETED_TABLE_KEY,
      true);
  conf1.set(HConstants.ZOOKEEPER_ZNODE_PARENT, "/1");
  conf1.setInt("replication.source.nb.capacity", 1);
  utility1 = new HBaseTestingUtility(conf1);
  utility1.startMiniZKCluster();
  MiniZooKeeperCluster miniZK = utility1.getZkCluster();
  conf1 = utility1.getConfiguration();

  conf2 = HBaseConfiguration.create(conf1);
  conf2.set(HConstants.ZOOKEEPER_ZNODE_PARENT, "/2");
  utility2 = new HBaseTestingUtility(conf2);
  utility2.setZkCluster(miniZK);

  utility1.startMiniCluster(1);
  utility2.startMiniCluster(1);

  admin1 = utility1.getAdmin();
  admin2 = utility2.getAdmin();

  NamespaceDescriptor nsDesc = NamespaceDescriptor.create(namespace).build();
  admin1.createNamespace(nsDesc);
  admin2.createNamespace(nsDesc);
}
 
Example #16
Source File: HBaseIndexingOptionsTest.java    From hbase-indexer with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void setUpBeforeClass() throws Exception {
    ZK_DIR = new File(System.getProperty("java.io.tmpdir") + File.separator + "hbaseindexer.zktest");
    ZK_CLIENT_PORT = getFreePort();

    ZK_CLUSTER = new MiniZooKeeperCluster();
    ZK_CLUSTER.setDefaultClientPort(ZK_CLIENT_PORT);
    ZK_CLUSTER.startup(ZK_DIR);
    
    ZK = ZkUtil.connect("localhost:" + ZK_CLIENT_PORT, 15000);
    INDEXER_MODEL = new IndexerModelImpl(ZK, "/ngdata/hbaseindexer");
}
 
Example #17
Source File: IndexerModelImplTest.java    From hbase-indexer with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void setUpBeforeClass() throws Exception {
    ZK_DIR = new File(System.getProperty("java.io.tmpdir") + File.separator + "hbaseindexer.zklocktest");
    FileUtils.deleteDirectory(ZK_DIR);
    ZK_CLIENT_PORT = getFreePort();

    ZK_CLUSTER = new MiniZooKeeperCluster();
    ZK_CLUSTER.setDefaultClientPort(ZK_CLIENT_PORT);
    ZK_CLUSTER.startup(ZK_DIR);
}
 
Example #18
Source File: HbaseServiceImpl.java    From searchanalytics-bigdata with MIT License 4 votes vote down vote up
@Override
public void setup() {
	try {
		LOG.info("Setting up Hbase mini cluster!");
		File clusterTestDirRoot = new File("target/zookeeper");
		clusterTestDirRoot.delete();
		File clusterTestDir = new File(clusterTestDirRoot, "/dfscluster_"
				+ UUID.randomUUID().toString()).getAbsoluteFile();

		LOG.info("Setting up Hbase zookeeper mini cluster!");
		int clientPort = 10235;
		miniZooKeeperCluster = new MiniZooKeeperCluster();
		miniZooKeeperCluster.setDefaultClientPort(clientPort);
		miniZooKeeperCluster.startup(clusterTestDir);
		LOG.info("Setting up Hbase zookeeper mini cluster done!");

		LOG.info("Setting up Hbase mini cluster master!");
		Configuration config = HBaseConfiguration.create();
		config.set("hbase.tmp.dir",
				new File("target/hbasetom").getAbsolutePath());
		config.set("hbase.rootdir", hadoopClusterService.getHDFSUri()
				+ "/hbase");
		config.set("hbase.master.port", "44335");
		config.set("hbase.master.info.port", "44345");
		config.set("hbase.regionserver.port", "44435");
		config.set("hbase.regionserver.info.port", "44445");
		config.set("hbase.master.distributed.log.replay", "false");
		config.set("hbase.cluster.distributed", "false");
		config.set("hbase.master.distributed.log.splitting", "false");
		// hbase.zookeeper.peerport
		// hbase.zookeeper.leaderport
		config.set("hbase.zookeeper.property.clientPort",
				Integer.toString(clientPort));
		config.set("zookeeper.znode.parent", "/hbase");
		
		miniHBaseCluster = new MiniHBaseCluster(config, 1);
		miniHBaseCluster.startMaster();

		LOG.info("Setting up Hbase mini cluster done!");
	} catch (IOException | InterruptedException e) {
		String errMsg = "Error occured starting Mini Hbase cluster";
		LOG.error(errMsg);
		throw new RuntimeException(errMsg, e);
	}

	setupSearchEventsTable();
}
 
Example #19
Source File: HBaseZKTestingUtility.java    From hbase with Apache License 2.0 4 votes vote down vote up
public void setZkCluster(MiniZooKeeperCluster zkCluster) {
  this.passedZkCluster = true;
  this.zkCluster = zkCluster;
  conf.setInt(HConstants.ZOOKEEPER_CLIENT_PORT, zkCluster.getClientPort());
}
 
Example #20
Source File: HBaseZKTestingUtility.java    From hbase with Apache License 2.0 4 votes vote down vote up
public MiniZooKeeperCluster getZkCluster() {
  return zkCluster;
}
 
Example #21
Source File: MutableIndexReplicationIT.java    From phoenix with Apache License 2.0 4 votes vote down vote up
private static void setupConfigsAndStartCluster() throws Exception {
        // cluster-1 lives at regular HBase home, so we don't need to change how phoenix handles
        // lookups
//        conf1.set(HConstants.ZOOKEEPER_ZNODE_PARENT, "/1");
        // smaller log roll size to trigger more events
        setUpConfigForMiniCluster(conf1);
        conf1.setFloat("hbase.regionserver.logroll.multiplier", 0.0003f);
        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);

        utility1 = new HBaseTestingUtility(conf1);
        utility1.startMiniZKCluster();
        MiniZooKeeperCluster miniZK = utility1.getZkCluster();
        // Have to reset conf1 in case zk cluster location different
        // than default
        conf1 = utility1.getConfiguration();
        zkw1 = new ZKWatcher(conf1, "cluster1", null, true);
        admin=ConnectionFactory.createConnection(conf1).getAdmin();
        LOGGER.info("Setup first Zk");

        // Base conf2 on conf1 so it gets the right zk cluster, and general cluster configs
        conf2 = HBaseConfiguration.create(conf1);
        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);

        utility2 = new HBaseTestingUtility(conf2);
        utility2.setZkCluster(miniZK);
        zkw2 = new ZKWatcher(conf2, "cluster2", null, true);

        LOGGER.info("Setup second Zk");
        utility1.startMiniCluster(2);
        utility2.startMiniCluster(2);
      //replicate from cluster 1 -> cluster 2, but not back again
        admin.addReplicationPeer("1", new ReplicationPeerConfig().setClusterKey(utility2.getClusterKey()));
    }
 
Example #22
Source File: HBaseZKTestingUtility.java    From hbase with Apache License 2.0 4 votes vote down vote up
/**
 * Call this if you only want a zk cluster.
 * @see #shutdownMiniZKCluster()
 * @return zk cluster started.
 */
public MiniZooKeeperCluster startMiniZKCluster(int zooKeeperServerNum, int... clientPortList)
    throws Exception {
  setupClusterTestDir();
  return startMiniZKCluster(clusterTestDir, zooKeeperServerNum, clientPortList);
}
 
Example #23
Source File: TestVisibilityLabelsReplication.java    From hbase with Apache License 2.0 4 votes vote down vote up
@Before
public void setup() throws Exception {
  // setup configuration
  conf = HBaseConfiguration.create();
  conf.setInt("hfile.format.version", 3);
  conf.set(HConstants.ZOOKEEPER_ZNODE_PARENT, "/1");
  conf.setInt("replication.source.size.capacity", 10240);
  conf.setLong("replication.source.sleepforretries", 100);
  conf.setInt("hbase.regionserver.maxlogs", 10);
  conf.setLong("hbase.master.logcleaner.ttl", 10);
  conf.setInt("zookeeper.recovery.retry", 1);
  conf.setInt("zookeeper.recovery.retry.intervalmill", 10);
  conf.setLong(HConstants.THREAD_WAKE_FREQUENCY, 100);
  conf.setInt("replication.stats.thread.period.seconds", 5);
  conf.setBoolean("hbase.tests.use.shortcircuit.reads", false);
  setVisibilityLabelServiceImpl(conf);
  conf.setStrings(HConstants.REPLICATION_CODEC_CONF_KEY, KeyValueCodecWithTags.class.getName());
  VisibilityTestUtil.enableVisiblityLabels(conf);
  conf.set(CoprocessorHost.REGIONSERVER_COPROCESSOR_CONF_KEY,
      VisibilityReplication.class.getName());
  conf.setStrings(CoprocessorHost.USER_REGION_COPROCESSOR_CONF_KEY,
      SimpleCP.class.getName());
  // Have to reset conf1 in case zk cluster location different
  // than default
  conf.setClass(VisibilityUtils.VISIBILITY_LABEL_GENERATOR_CLASS, SimpleScanLabelGenerator.class,
      ScanLabelGenerator.class);
  conf.set("hbase.superuser", User.getCurrent().getShortName());
  SUPERUSER = User.createUserForTesting(conf, User.getCurrent().getShortName(),
      new String[] { "supergroup" });
  // User.createUserForTesting(conf, User.getCurrent().getShortName(), new
  // String[] { "supergroup" });
  USER1 = User.createUserForTesting(conf, "user1", new String[] {});
  TEST_UTIL = new HBaseTestingUtility(conf);
  TEST_UTIL.startMiniZKCluster();
  MiniZooKeeperCluster miniZK = TEST_UTIL.getZkCluster();
  zkw1 = new ZKWatcher(conf, "cluster1", null, true);

  // Base conf2 on conf1 so it gets the right zk cluster.
  conf1 = HBaseConfiguration.create(conf);
  conf1.setInt("hfile.format.version", 3);
  conf1.set(HConstants.ZOOKEEPER_ZNODE_PARENT, "/2");
  conf1.setInt(HConstants.HBASE_CLIENT_RETRIES_NUMBER, 6);
  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,
      TestCoprocessorForTagsAtSink.class.getName());
  // setVisibilityLabelServiceImpl(conf1);
  USER1 = User.createUserForTesting(conf1, "user1", new String[] {});
  TEST_UTIL1 = new HBaseTestingUtility(conf1);
  TEST_UTIL1.setZkCluster(miniZK);
  zkw2 = new ZKWatcher(conf1, "cluster2", null, true);

  TEST_UTIL.startMiniCluster(1);
  // Wait for the labels table to become available
  TEST_UTIL.waitTableEnabled(LABELS_TABLE_NAME.getName(), 50000);
  TEST_UTIL1.startMiniCluster(1);

  admin = TEST_UTIL.getAdmin();
  ReplicationPeerConfig rpc = new ReplicationPeerConfig();
  rpc.setClusterKey(TEST_UTIL1.getClusterKey());
  admin.addReplicationPeer("2", rpc);

  Admin hBaseAdmin = TEST_UTIL.getAdmin();
  TableDescriptorBuilder.ModifyableTableDescriptor tableDescriptor =
    new TableDescriptorBuilder.ModifyableTableDescriptor(TABLE_NAME);
  ColumnFamilyDescriptorBuilder.ModifyableColumnFamilyDescriptor familyDescriptor =
    new ColumnFamilyDescriptorBuilder.ModifyableColumnFamilyDescriptor(fam);
  familyDescriptor.setScope(HConstants.REPLICATION_SCOPE_GLOBAL);
  tableDescriptor.setColumnFamily(familyDescriptor);
  try {
    hBaseAdmin.createTable(tableDescriptor);
  } finally {
    if (hBaseAdmin != null) {
      hBaseAdmin.close();
    }
  }
  Admin hBaseAdmin1 = TEST_UTIL1.getAdmin();
  try {
    hBaseAdmin1.createTable(tableDescriptor);
  } finally {
    if (hBaseAdmin1 != null) {
      hBaseAdmin1.close();
    }
  }
  addLabels();
  setAuths(conf);
  setAuths(conf1);
}
 
Example #24
Source File: TestHBaseTestingUtility.java    From hbase with Apache License 2.0 4 votes vote down vote up
@Test
public void testMiniZooKeeperWithMultipleServers() throws Exception {
  HBaseTestingUtility hbt = new HBaseTestingUtility();
  // set up zookeeper cluster with 5 zk servers
  MiniZooKeeperCluster cluster2 = hbt.startMiniZKCluster(5);
  int defaultClientPort = 21818;
  cluster2.setDefaultClientPort(defaultClientPort);
  try {
    assertEquals(4, cluster2.getBackupZooKeeperServerNum());

    // killing the current active zk server
    int currentActivePort = cluster2.killCurrentActiveZooKeeperServer();
    assertTrue(currentActivePort >= defaultClientPort);
    // Check if the client port is returning a proper value
    assertTrue(cluster2.getClientPort() == currentActivePort);

    // kill another active zk server
    currentActivePort = cluster2.killCurrentActiveZooKeeperServer();
    assertTrue(currentActivePort >= defaultClientPort);
    assertTrue(cluster2.getClientPort() == currentActivePort);
    assertEquals(2, cluster2.getBackupZooKeeperServerNum());
    assertEquals(3, cluster2.getZooKeeperServerNum());

    // killing the backup zk servers
    cluster2.killOneBackupZooKeeperServer();
    cluster2.killOneBackupZooKeeperServer();
    assertEquals(0, cluster2.getBackupZooKeeperServerNum());
    assertEquals(1, cluster2.getZooKeeperServerNum());

    // killing the last zk server
    currentActivePort = cluster2.killCurrentActiveZooKeeperServer();
    assertTrue(currentActivePort == -1);
    assertTrue(cluster2.getClientPort() == currentActivePort);
    // this should do nothing.
    cluster2.killOneBackupZooKeeperServer();
    assertEquals(-1, cluster2.getBackupZooKeeperServerNum());
    assertEquals(0, cluster2.getZooKeeperServerNum());
  } finally {
    hbt.shutdownMiniZKCluster();
  }
}
 
Example #25
Source File: TestVisibilityLabelReplicationWithExpAsString.java    From hbase with Apache License 2.0 4 votes vote down vote up
@Override
@Before
public void setup() throws Exception {
  expected[0] = 4;
  expected[1] = 6;
  expected[2] = 4;
  expected[3] = 0;
  expected[3] = 3;
  expectedVisString[0] = "(\"public\"&\"secret\"&\"topsecret\")|(\"confidential\"&\"topsecret\")";
  expectedVisString[1] = "(\"private\"&\"public\")|(\"private\"&\"topsecret\")|"
      + "(\"confidential\"&\"public\")|(\"confidential\"&\"topsecret\")";
  expectedVisString[2] = "(!\"topsecret\"&\"secret\")|(!\"topsecret\"&\"confidential\")";
  expectedVisString[3] = "(\"secret\"&\"" + COPYRIGHT + "\\\"" + ACCENT + "\\\\" + SECRET
      + "\\\"" + "\u0027&\\\\" + "\")";
  // setup configuration
  conf = HBaseConfiguration.create();
  conf.setInt("hfile.format.version", 3);
  conf.set(HConstants.ZOOKEEPER_ZNODE_PARENT, "/1");
  conf.setInt("replication.source.size.capacity", 10240);
  conf.setLong("replication.source.sleepforretries", 100);
  conf.setInt("hbase.regionserver.maxlogs", 10);
  conf.setLong("hbase.master.logcleaner.ttl", 10);
  conf.setInt("zookeeper.recovery.retry", 1);
  conf.setInt("zookeeper.recovery.retry.intervalmill", 10);
  conf.setLong(HConstants.THREAD_WAKE_FREQUENCY, 100);
  conf.setInt("replication.stats.thread.period.seconds", 5);
  conf.setBoolean("hbase.tests.use.shortcircuit.reads", false);
  setVisibilityLabelServiceImpl(conf, ExpAsStringVisibilityLabelServiceImpl.class);
  conf.setStrings(HConstants.REPLICATION_CODEC_CONF_KEY, KeyValueCodecWithTags.class.getName());
  VisibilityTestUtil.enableVisiblityLabels(conf);
  conf.set(CoprocessorHost.REGIONSERVER_COPROCESSOR_CONF_KEY,
      VisibilityReplication.class.getName());
  conf.setStrings(CoprocessorHost.USER_REGION_COPROCESSOR_CONF_KEY,
      SimpleCP.class.getName());
  // Have to reset conf1 in case zk cluster location different
  // than default
  conf.setClass(VisibilityUtils.VISIBILITY_LABEL_GENERATOR_CLASS, SimpleScanLabelGenerator.class,
          ScanLabelGenerator.class);
  conf.set("hbase.superuser", "admin");
  conf.set("hbase.superuser", User.getCurrent().getShortName());
  SUPERUSER = User.createUserForTesting(conf, User.getCurrent().getShortName(),
      new String[] { "supergroup" });
  User.createUserForTesting(conf,
      User.getCurrent().getShortName(), new String[] { "supergroup" });
  USER1 = User.createUserForTesting(conf, "user1", new String[] {});
  TEST_UTIL = new HBaseTestingUtility(conf);
  TEST_UTIL.startMiniZKCluster();
  MiniZooKeeperCluster miniZK = TEST_UTIL.getZkCluster();
  zkw1 = new ZKWatcher(conf, "cluster1", null, true);

  // Base conf2 on conf1 so it gets the right zk cluster.
  conf1 = HBaseConfiguration.create(conf);
  conf1.setInt("hfile.format.version", 3);
  conf1.set(HConstants.ZOOKEEPER_ZNODE_PARENT, "/2");
  conf1.setInt(HConstants.HBASE_CLIENT_RETRIES_NUMBER, 6);
  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,
          TestCoprocessorForTagsAtSink.class.getName());
  setVisibilityLabelServiceImpl(conf1, ExpAsStringVisibilityLabelServiceImpl.class);
  TEST_UTIL1 = new HBaseTestingUtility(conf1);
  TEST_UTIL1.setZkCluster(miniZK);
  zkw2 = new ZKWatcher(conf1, "cluster2", null, true);

  TEST_UTIL.startMiniCluster(1);
  // Wait for the labels table to become available
  TEST_UTIL.waitTableEnabled(LABELS_TABLE_NAME.getName(), 50000);
  TEST_UTIL1.startMiniCluster(1);

  admin = TEST_UTIL.getAdmin();
  ReplicationPeerConfig rpc = new ReplicationPeerConfig();
  rpc.setClusterKey(TEST_UTIL1.getClusterKey());
  admin.addReplicationPeer("2", rpc);

  TableDescriptorBuilder.ModifyableTableDescriptor tableDescriptor =
    new TableDescriptorBuilder.ModifyableTableDescriptor(TABLE_NAME);
  ColumnFamilyDescriptorBuilder.ModifyableColumnFamilyDescriptor familyDescriptor =
    new ColumnFamilyDescriptorBuilder.ModifyableColumnFamilyDescriptor(fam);
  familyDescriptor.setScope(HConstants.REPLICATION_SCOPE_GLOBAL);
  tableDescriptor.setColumnFamily(familyDescriptor);
  try (Admin hBaseAdmin = TEST_UTIL.getAdmin()) {
    hBaseAdmin.createTable(tableDescriptor);
  }
  try (Admin hBaseAdmin1 = TEST_UTIL1.getAdmin()){
    hBaseAdmin1.createTable(tableDescriptor);
  }
  addLabels();
  setAuths(conf);
  setAuths(conf1);
}
 
Example #26
Source File: TestNamespaceReplicationWithBulkLoadedData.java    From hbase with Apache License 2.0 4 votes vote down vote up
@Test
@Override
public void testBulkLoadReplicationActiveActive() throws Exception {
  Table peer1TestTable = UTIL1.getConnection().getTable(TestReplicationBase.tableName);
  Table peer2TestTable = UTIL2.getConnection().getTable(TestReplicationBase.tableName);
  Table peer3TestTable = UTIL3.getConnection().getTable(TestReplicationBase.tableName);
  Table notPeerTable = UTIL4.getConnection().getTable(TestReplicationBase.tableName);
  Table ns1Table = UTIL4.getConnection().getTable(NS1_TABLE);
  Table ns2Table = UTIL4.getConnection().getTable(NS2_TABLE);

  // case1: The ns1 tables will be replicate to cluster4
  byte[] row = Bytes.toBytes("002_ns_peer");
  byte[] value = Bytes.toBytes("v2");
  bulkLoadOnCluster(ns1Table.getName(), row, value, UTIL1);
  waitForReplication(ns1Table, 1, NB_RETRIES);
  assertTableHasValue(ns1Table, row, value);

  // case2: The ns2:t2_syncup will be replicate to cluster4
  // If it's not fix HBASE-23098 the ns_peer1's hfile-refs(zk) will be backlog
  row = Bytes.toBytes("003_ns_table_peer");
  value = Bytes.toBytes("v2");
  bulkLoadOnCluster(ns2Table.getName(), row, value, UTIL1);
  waitForReplication(ns2Table, 1, NB_RETRIES);
  assertTableHasValue(ns2Table, row, value);

  // case3: The table test will be replicate to cluster1,cluster2,cluster3
  //        not replicate to cluster4, because we not set other peer for that tables.
  row = Bytes.toBytes("001_nopeer");
  value = Bytes.toBytes("v1");
  assertBulkLoadConditions(tableName, row, value, UTIL1, peer1TestTable,
      peer2TestTable, peer3TestTable);
  assertTableNoValue(notPeerTable, row, value); // 1 -> 4, table is empty

  // Verify hfile-refs for 1:ns_peer1, expect is empty
  MiniZooKeeperCluster zkCluster = UTIL1.getZkCluster();
  ZKWatcher watcher = new ZKWatcher(UTIL1.getConfiguration(), "TestZnodeHFiles-refs", null);
  RecoverableZooKeeper zk = ZKUtil.connect(UTIL1.getConfiguration(), watcher);
  ZKReplicationQueueStorage replicationQueueStorage =
      new ZKReplicationQueueStorage(watcher, UTIL1.getConfiguration());
  Set<String> hfiles = replicationQueueStorage.getAllHFileRefs();
  assertTrue(hfiles.isEmpty());
}
 
Example #27
Source File: TestReplicationWithTags.java    From hbase with Apache License 2.0 4 votes vote down vote up
@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.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();
  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("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);

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

  connection1 = ConnectionFactory.createConnection(conf1);
  replicationAdmin = connection1.getAdmin();
  ReplicationPeerConfig rpc = new ReplicationPeerConfig();
  rpc.setClusterKey(utility2.getClusterKey());
  replicationAdmin.addReplicationPeer("2", rpc);

  TableDescriptorBuilder.ModifyableTableDescriptor tableDescriptor =
    new TableDescriptorBuilder.ModifyableTableDescriptor(TABLE_NAME);
  ColumnFamilyDescriptorBuilder.ModifyableColumnFamilyDescriptor familyDescriptor =
    new ColumnFamilyDescriptorBuilder.ModifyableColumnFamilyDescriptor(FAMILY);
  familyDescriptor.setMaxVersions(3);
  familyDescriptor.setScope(HConstants.REPLICATION_SCOPE_GLOBAL);
  tableDescriptor.setColumnFamily(familyDescriptor);
  try (Connection conn = ConnectionFactory.createConnection(conf1);
      Admin admin = conn.getAdmin()) {
    admin.createTable(tableDescriptor, HBaseTestingUtility.KEYS_FOR_HBA_CREATE_TABLE);
  }
  try (Connection conn = ConnectionFactory.createConnection(conf2);
      Admin admin = conn.getAdmin()) {
    admin.createTable(tableDescriptor, HBaseTestingUtility.KEYS_FOR_HBA_CREATE_TABLE);
  }
  htable1 = utility1.getConnection().getTable(TABLE_NAME);
  htable2 = utility2.getConnection().getTable(TABLE_NAME);
}
 
Example #28
Source File: TestMultiSlaveReplication.java    From hbase with Apache License 2.0 4 votes vote down vote up
@BeforeClass
public static void setUpBeforeClass() throws Exception {
  conf1 = HBaseConfiguration.create();
  conf1.set(HConstants.ZOOKEEPER_ZNODE_PARENT, "/1");
  // smaller block size and capacity to trigger more operations
  // and test them
  conf1.setInt("hbase.regionserver.hlog.blocksize", 1024*20);
  conf1.setInt("replication.source.size.capacity", 1024);
  conf1.setLong("replication.source.sleepforretries", 100);
  conf1.setInt("hbase.regionserver.maxlogs", 10);
  conf1.setLong("hbase.master.logcleaner.ttl", 10);
  conf1.setLong(HConstants.THREAD_WAKE_FREQUENCY, 100);
  conf1.setStrings(CoprocessorHost.USER_REGION_COPROCESSOR_CONF_KEY,
      "org.apache.hadoop.hbase.replication.TestMasterReplication$CoprocessorCounter");
  conf1.setInt("hbase.master.cleaner.interval", 5 * 1000);

  utility1 = new HBaseTestingUtility(conf1);
  utility1.startMiniZKCluster();
  MiniZooKeeperCluster miniZK = utility1.getZkCluster();
  utility1.setZkCluster(miniZK);
  new ZKWatcher(conf1, "cluster1", null, true);

  conf2 = new Configuration(conf1);
  conf2.set(HConstants.ZOOKEEPER_ZNODE_PARENT, "/2");

  conf3 = new Configuration(conf1);
  conf3.set(HConstants.ZOOKEEPER_ZNODE_PARENT, "/3");

  utility2 = new HBaseTestingUtility(conf2);
  utility2.setZkCluster(miniZK);
  new ZKWatcher(conf2, "cluster2", null, true);

  utility3 = new HBaseTestingUtility(conf3);
  utility3.setZkCluster(miniZK);
  new ZKWatcher(conf3, "cluster3", null, true);

  table = new TableDescriptorBuilder.ModifyableTableDescriptor(tableName);
  ColumnFamilyDescriptorBuilder.ModifyableColumnFamilyDescriptor familyDescriptor =
    new ColumnFamilyDescriptorBuilder.ModifyableColumnFamilyDescriptor(famName);
  familyDescriptor.setScope(HConstants.REPLICATION_SCOPE_GLOBAL);
  table.setColumnFamily(familyDescriptor);
  familyDescriptor =
    new ColumnFamilyDescriptorBuilder.ModifyableColumnFamilyDescriptor(noRepfamName);
  table.setColumnFamily(familyDescriptor);
}
 
Example #29
Source File: TestPerTableCFReplication.java    From hbase with Apache License 2.0 4 votes vote down vote up
@BeforeClass
public static void setUpBeforeClass() throws Exception {
  conf1 = HBaseConfiguration.create();
  conf1.set(HConstants.ZOOKEEPER_ZNODE_PARENT, "/1");
  // smaller block size and capacity to trigger more operations
  // and test them
  conf1.setInt("hbase.regionserver.hlog.blocksize", 1024*20);
  conf1.setInt("replication.source.size.capacity", 1024);
  conf1.setLong("replication.source.sleepforretries", 100);
  conf1.setInt("hbase.regionserver.maxlogs", 10);
  conf1.setLong("hbase.master.logcleaner.ttl", 10);
  conf1.setLong(HConstants.THREAD_WAKE_FREQUENCY, 100);
  conf1.setStrings(CoprocessorHost.USER_REGION_COPROCESSOR_CONF_KEY,
      "org.apache.hadoop.hbase.replication.TestMasterReplication$CoprocessorCounter");

  utility1 = new HBaseTestingUtility(conf1);
  utility1.startMiniZKCluster();
  MiniZooKeeperCluster miniZK = utility1.getZkCluster();
  new ZKWatcher(conf1, "cluster1", null, true);

  conf2 = new Configuration(conf1);
  conf2.set(HConstants.ZOOKEEPER_ZNODE_PARENT, "/2");

  conf3 = new Configuration(conf1);
  conf3.set(HConstants.ZOOKEEPER_ZNODE_PARENT, "/3");

  utility2 = new HBaseTestingUtility(conf2);
  utility2.setZkCluster(miniZK);
  new ZKWatcher(conf2, "cluster3", null, true);

  utility3 = new HBaseTestingUtility(conf3);
  utility3.setZkCluster(miniZK);
  new ZKWatcher(conf3, "cluster3", null, true);

  table = new TableDescriptorBuilder.ModifyableTableDescriptor(tableName);
  ColumnFamilyDescriptorBuilder.ModifyableColumnFamilyDescriptor familyDescriptor =
    new ColumnFamilyDescriptorBuilder.ModifyableColumnFamilyDescriptor(famName);
  familyDescriptor.setScope(HConstants.REPLICATION_SCOPE_GLOBAL);
  table.setColumnFamily(familyDescriptor);
  familyDescriptor =
    new ColumnFamilyDescriptorBuilder.ModifyableColumnFamilyDescriptor(noRepfamName);
  table.setColumnFamily(familyDescriptor);

  tabA = new TableDescriptorBuilder.ModifyableTableDescriptor(tabAName);
  familyDescriptor = new ColumnFamilyDescriptorBuilder.ModifyableColumnFamilyDescriptor(f1Name);
  familyDescriptor.setScope(HConstants.REPLICATION_SCOPE_GLOBAL);
  tabA.setColumnFamily(familyDescriptor);
  familyDescriptor = new ColumnFamilyDescriptorBuilder.ModifyableColumnFamilyDescriptor(f2Name);
  familyDescriptor.setScope(HConstants.REPLICATION_SCOPE_GLOBAL);
  tabA.setColumnFamily(familyDescriptor);
  familyDescriptor = new ColumnFamilyDescriptorBuilder.ModifyableColumnFamilyDescriptor(f3Name);
  familyDescriptor.setScope(HConstants.REPLICATION_SCOPE_GLOBAL);
  tabA.setColumnFamily(familyDescriptor);

  tabB = new TableDescriptorBuilder.ModifyableTableDescriptor(tabBName);
  familyDescriptor = new ColumnFamilyDescriptorBuilder.ModifyableColumnFamilyDescriptor(f1Name);
  familyDescriptor.setScope(HConstants.REPLICATION_SCOPE_GLOBAL);
  tabB.setColumnFamily(familyDescriptor);
  familyDescriptor = new ColumnFamilyDescriptorBuilder.ModifyableColumnFamilyDescriptor(f2Name);
  familyDescriptor.setScope(HConstants.REPLICATION_SCOPE_GLOBAL);
  tabB.setColumnFamily(familyDescriptor);
  familyDescriptor = new ColumnFamilyDescriptorBuilder.ModifyableColumnFamilyDescriptor(f3Name);
  familyDescriptor.setScope(HConstants.REPLICATION_SCOPE_GLOBAL);
  tabB.setColumnFamily(familyDescriptor);

  tabC = new TableDescriptorBuilder.ModifyableTableDescriptor(tabCName);
  familyDescriptor = new ColumnFamilyDescriptorBuilder.ModifyableColumnFamilyDescriptor(f1Name);
  familyDescriptor.setScope(HConstants.REPLICATION_SCOPE_GLOBAL);
  tabC.setColumnFamily(familyDescriptor);
  familyDescriptor = new ColumnFamilyDescriptorBuilder.ModifyableColumnFamilyDescriptor(f2Name);
  familyDescriptor.setScope(HConstants.REPLICATION_SCOPE_GLOBAL);
  tabC.setColumnFamily(familyDescriptor);
  familyDescriptor = new ColumnFamilyDescriptorBuilder.ModifyableColumnFamilyDescriptor(f3Name);
  familyDescriptor.setScope(HConstants.REPLICATION_SCOPE_GLOBAL);
  tabC.setColumnFamily(familyDescriptor);

  utility1.startMiniCluster();
  utility2.startMiniCluster();
  utility3.startMiniCluster();
}
 
Example #30
Source File: HMasterCommandLine.java    From hbase with Apache License 2.0 4 votes vote down vote up
void setZKCluster(final MiniZooKeeperCluster zkcluster) {
  this.zkcluster = zkcluster;
}