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


Java ZooKeeperConnectionException類代碼示例

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


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

示例1: loadDisabledTables

import org.apache.hadoop.hbase.ZooKeeperConnectionException; //導入依賴的package包/類
/**
 * Load the list of disabled tables in ZK into local set.
 * @throws ZooKeeperConnectionException
 * @throws IOException
 */
private void loadDisabledTables()
throws ZooKeeperConnectionException, IOException {
  HConnectionManager.execute(new HConnectable<Void>(getConf()) {
    @Override
    public Void connect(HConnection connection) throws IOException {
      ZooKeeperWatcher zkw = createZooKeeperWatcher();
      try {
        for (TableName tableName :
            ZKTableStateClientSideReader.getDisabledOrDisablingTables(zkw)) {
          disabledTables.add(tableName);
        }
      } catch (KeeperException ke) {
        throw new IOException(ke);
      } catch (InterruptedException e) {
        throw new InterruptedIOException();
      } finally {
        zkw.close();
      }
      return null;
    }
  });
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:28,代碼來源:HBaseFsck.java

示例2: moveRegionAndWait

import org.apache.hadoop.hbase.ZooKeeperConnectionException; //導入依賴的package包/類
private void moveRegionAndWait(HRegionInfo destRegion, ServerName destServer)
    throws InterruptedException, MasterNotRunningException,
    ZooKeeperConnectionException, IOException {
  HMaster master = TEST_UTIL.getMiniHBaseCluster().getMaster();
  TEST_UTIL.getHBaseAdmin().move(
      destRegion.getEncodedNameAsBytes(),
      Bytes.toBytes(destServer.getServerName()));
  while (true) {
    ServerName serverName = master.getAssignmentManager()
        .getRegionStates().getRegionServerOfRegion(destRegion);
    if (serverName != null && serverName.equals(destServer)) {
      TEST_UTIL.assertRegionOnServer(
          destRegion, serverName, 200);
      break;
    }
    Thread.sleep(10);
  }
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:19,代碼來源:TestAdmin1.java

示例3: getMockedConnection

import org.apache.hadoop.hbase.ZooKeeperConnectionException; //導入依賴的package包/類
/**
 * Get a Mocked {@link HConnection} that goes with the passed <code>conf</code>
 * configuration instance.  Minimally the mock will return
 * <code>conf</conf> when {@link ClusterConnection#getConfiguration()} is invoked.
 * Be sure to shutdown the connection when done by calling
 * {@link HConnectionManager#deleteConnection(Configuration)} else it
 * will stick around; this is probably not what you want.
 * @param conf configuration
 * @return HConnection object for <code>conf</code>
 * @throws ZooKeeperConnectionException
 */
public static ClusterConnection getMockedConnection(final Configuration conf)
throws ZooKeeperConnectionException {
  HConnectionKey connectionKey = new HConnectionKey(conf);
  synchronized (ConnectionManager.CONNECTION_INSTANCES) {
    HConnectionImplementation connection =
        ConnectionManager.CONNECTION_INSTANCES.get(connectionKey);
    if (connection == null) {
      connection = Mockito.mock(HConnectionImplementation.class);
      Mockito.when(connection.getConfiguration()).thenReturn(conf);
      Mockito.when(connection.getRpcControllerFactory()).thenReturn(
      Mockito.mock(RpcControllerFactory.class));
      // we need a real retrying caller
      RpcRetryingCallerFactory callerFactory = new RpcRetryingCallerFactory(conf);
      Mockito.when(connection.getRpcRetryingCallerFactory()).thenReturn(callerFactory);
      ConnectionManager.CONNECTION_INSTANCES.put(connectionKey, connection);
    }
    return connection;
  }
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:31,代碼來源:HConnectionTestingUtility.java

示例4: tearDown

import org.apache.hadoop.hbase.ZooKeeperConnectionException; //導入依賴的package包/類
@After
public void tearDown()
throws KeeperException, ZooKeeperConnectionException, IOException {
  // Make sure zk is clean before we run the next test.
  ZooKeeperWatcher zkw = new ZooKeeperWatcher(TESTUTIL.getConfiguration(),
      "@Before", new Abortable() {
    @Override
    public void abort(String why, Throwable e) {
      throw new RuntimeException(why, e);
    }

    @Override
    public boolean isAborted() {
      return false;
    }
  });
  ZKUtil.deleteNodeRecursively(zkw, zkw.baseZNode);
  zkw.close();
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:20,代碼來源:TestMasterNoCluster.java

示例5: moveRegionAndWait

import org.apache.hadoop.hbase.ZooKeeperConnectionException; //導入依賴的package包/類
private void moveRegionAndWait(Region destRegion, HRegionServer destServer)
    throws InterruptedException, MasterNotRunningException,
    ZooKeeperConnectionException, IOException {
  HMaster master = TEST_UTIL.getMiniHBaseCluster().getMaster();
  TEST_UTIL.getHBaseAdmin().move(
      destRegion.getRegionInfo().getEncodedNameAsBytes(),
      Bytes.toBytes(destServer.getServerName().getServerName()));
  while (true) {
    ServerName serverName = master.getAssignmentManager()
      .getRegionStates().getRegionServerOfRegion(destRegion.getRegionInfo());
    if (serverName != null && serverName.equals(destServer.getServerName())) {
      TEST_UTIL.assertRegionOnServer(
        destRegion.getRegionInfo(), serverName, 200);
      break;
    }
    Thread.sleep(10);
  }
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:19,代碼來源:TestWALReplay.java

示例6: assign

import org.apache.hadoop.hbase.ZooKeeperConnectionException; //導入依賴的package包/類
/**
 * @param regionName
 *          Region name to assign.
 * @throws MasterNotRunningException
 * @throws ZooKeeperConnectionException
 * @throws IOException
 */
@Override
public void assign(final byte[] regionName) throws MasterNotRunningException,
    ZooKeeperConnectionException, IOException {
  final byte[] toBeAssigned = getRegionName(regionName);
  executeCallable(new MasterCallable<Void>(getConnection()) {
    @Override
    public Void call(int callTimeout) throws ServiceException {
      PayloadCarryingRpcController controller = rpcControllerFactory.newController();
      controller.setCallTimeout(callTimeout);
      // Hard to know the table name, at least check if meta
      if (isMetaRegion(regionName)) {
        controller.setPriority(TableName.META_TABLE_NAME);
      }

      AssignRegionRequest request =
        RequestConverter.buildAssignRegionRequest(toBeAssigned);
      master.assignRegion(controller,request);
      return null;
    }
  });
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:29,代碼來源:HBaseAdmin.java

示例7: unassign

import org.apache.hadoop.hbase.ZooKeeperConnectionException; //導入依賴的package包/類
/**
 * Unassign a region from current hosting regionserver.  Region will then be
 * assigned to a regionserver chosen at random.  Region could be reassigned
 * back to the same server.  Use {@link #move(byte[], byte[])} if you want
 * to control the region movement.
 * @param regionName Region to unassign. Will clear any existing RegionPlan
 * if one found.
 * @param force If true, force unassign (Will remove region from
 * regions-in-transition too if present. If results in double assignment
 * use hbck -fix to resolve. To be used by experts).
 * @throws MasterNotRunningException
 * @throws ZooKeeperConnectionException
 * @throws IOException
 */
@Override
public void unassign(final byte [] regionName, final boolean force)
throws MasterNotRunningException, ZooKeeperConnectionException, IOException {
  final byte[] toBeUnassigned = getRegionName(regionName);
  executeCallable(new MasterCallable<Void>(getConnection()) {
    @Override
    public Void call(int callTimeout) throws ServiceException {
      PayloadCarryingRpcController controller = rpcControllerFactory.newController();
      controller.setCallTimeout(callTimeout);
      // Hard to know the table name, at least check if meta
      if (isMetaRegion(regionName)) {
        controller.setPriority(TableName.META_TABLE_NAME);
      }
      UnassignRegionRequest request =
        RequestConverter.buildUnassignRegionRequest(toBeUnassigned, force);
      master.unassignRegion(controller, request);
      return null;
    }
  });
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:35,代碼來源:HBaseAdmin.java

示例8: ZooKeeperWatcher

import org.apache.hadoop.hbase.ZooKeeperConnectionException; //導入依賴的package包/類
/**
 * Instantiate a ZooKeeper connection and watcher.
 * @param conf
 * @param identifier string that is passed to RecoverableZookeeper to be used as identifier for
 *          this instance. Use null for default.
 * @param abortable Can be null if there is on error there is no host to abort: e.g. client
 *          context.
 * @param canCreateBaseZNode
 * @throws IOException
 * @throws ZooKeeperConnectionException
 */
public ZooKeeperWatcher(Configuration conf, String identifier,
    Abortable abortable, boolean canCreateBaseZNode)
throws IOException, ZooKeeperConnectionException {
  this.conf = conf;
  // Capture a stack trace now.  Will print it out later if problem so we can
  // distingush amongst the myriad ZKWs.
  try {
    throw new Exception("ZKW CONSTRUCTOR STACK TRACE FOR DEBUGGING");
  } catch (Exception e) {
    this.constructorCaller = e;
  }
  this.quorum = ZKConfig.getZKQuorumServersString(conf);
  this.prefix = identifier;
  // Identifier will get the sessionid appended later below down when we
  // handle the syncconnect event.
  this.identifier = identifier + "0x0";
  this.abortable = abortable;
  setNodeNames(conf);
  this.recoverableZooKeeper = ZKUtil.connect(conf, quorum, this, identifier);
  if (canCreateBaseZNode) {
    createBaseZNodes();
  }
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:35,代碼來源:ZooKeeperWatcher.java

示例9: createBaseZNodes

import org.apache.hadoop.hbase.ZooKeeperConnectionException; //導入依賴的package包/類
private void createBaseZNodes() throws ZooKeeperConnectionException {
  try {
    // Create all the necessary "directories" of znodes
    ZKUtil.createWithParents(this, baseZNode);
    if (conf.getBoolean("hbase.assignment.usezk", true)) {
      ZKUtil.createAndFailSilent(this, assignmentZNode);
    }
    ZKUtil.createAndFailSilent(this, rsZNode);
    ZKUtil.createAndFailSilent(this, drainingZNode);
    ZKUtil.createAndFailSilent(this, tableZNode);
    ZKUtil.createAndFailSilent(this, splitLogZNode);
    ZKUtil.createAndFailSilent(this, backupMasterAddressesZNode);
    ZKUtil.createAndFailSilent(this, tableLockZNode);
    ZKUtil.createAndFailSilent(this, recoveringRegionsZNode);
  } catch (KeeperException e) {
    throw new ZooKeeperConnectionException(
        prefix("Unexpected KeeperException creating base node"), e);
  }
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:20,代碼來源:ZooKeeperWatcher.java

示例10: testIsClientReadable

import org.apache.hadoop.hbase.ZooKeeperConnectionException; //導入依賴的package包/類
@Test
public void testIsClientReadable() throws ZooKeeperConnectionException, IOException {
  ZooKeeperWatcher watcher = new ZooKeeperWatcher(HBaseConfiguration.create(),
    "testIsClientReadable", null, false);

  assertTrue(watcher.isClientReadable(watcher.baseZNode));
  assertTrue(watcher.isClientReadable(watcher.getZNodeForReplica(0)));
  assertTrue(watcher.isClientReadable(watcher.getMasterAddressZNode()));
  assertTrue(watcher.isClientReadable(watcher.clusterIdZNode));
  assertTrue(watcher.isClientReadable(watcher.tableZNode));
  assertTrue(watcher.isClientReadable(ZKUtil.joinZNode(watcher.tableZNode, "foo")));
  assertTrue(watcher.isClientReadable(watcher.rsZNode));


  assertFalse(watcher.isClientReadable(watcher.tableLockZNode));
  assertFalse(watcher.isClientReadable(watcher.balancerZNode));
  assertFalse(watcher.isClientReadable(watcher.getRegionNormalizerZNode()));
  assertFalse(watcher.isClientReadable(watcher.clusterStateZNode));
  assertFalse(watcher.isClientReadable(watcher.drainingZNode));
  assertFalse(watcher.isClientReadable(watcher.recoveringRegionsZNode));
  assertFalse(watcher.isClientReadable(watcher.splitLogZNode));
  assertFalse(watcher.isClientReadable(watcher.backupMasterAddressesZNode));

  watcher.close();
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:26,代碼來源:TestZooKeeperWatcher.java

示例11: HBaseAdminMultiCluster

import org.apache.hadoop.hbase.ZooKeeperConnectionException; //導入依賴的package包/類
public HBaseAdminMultiCluster(Configuration c)
    throws MasterNotRunningException, ZooKeeperConnectionException,
    IOException {
  super(HBaseMultiClusterConfigUtil.splitMultiConfigFile(c).get(
      HBaseMultiClusterConfigUtil.PRIMARY_NAME));

  Map<String, Configuration> configs = HBaseMultiClusterConfigUtil
      .splitMultiConfigFile(c);

  for (Entry<String, Configuration> entry : configs.entrySet()) {

    if (!entry.getKey().equals(HBaseMultiClusterConfigUtil.PRIMARY_NAME)) {
      HBaseAdmin admin = new HBaseAdmin(entry.getValue());
      LOG.info("creating HBaseAdmin for : " + entry.getKey());
      failoverAdminMap.put(entry.getKey(), admin);
      LOG.info(" - successfully creating HBaseAdmin for : " + entry.getKey());
    }
  }
  LOG.info("Successful loaded all HBaseAdmins");

}
 
開發者ID:cloudera-labs,項目名稱:hbase.mcc,代碼行數:22,代碼來源:HBaseAdminMultiCluster.java

示例12: setBalancerRunning

import org.apache.hadoop.hbase.ZooKeeperConnectionException; //導入依賴的package包/類
/**
 * Turn the load balancer on or off.
 * @param on If true, enable balancer. If false, disable balancer.
 * @param synchronous If true, it waits until current balance() call, if outstanding, to return.
 * @return Previous balancer value
 */
public boolean setBalancerRunning(final boolean on, final boolean synchronous)
    throws MasterNotRunningException, ZooKeeperConnectionException {
  if (synchronous && synchronousBalanceSwitchSupported) {
    try {
      return getMaster().synchronousBalanceSwitch(on);
    } catch (UndeclaredThrowableException ute) {
      String error = ute.getCause().getMessage();
      if (error != null
          && error.matches("(?s).+NoSuchMethodException:.+synchronousBalanceSwitch.+")) {
        LOG.info("HMaster doesn't support synchronousBalanceSwitch");
        synchronousBalanceSwitchSupported = false;
      } else {
        throw ute;
      }
    }
  }
  return balanceSwitch(on);
}
 
開發者ID:fengchen8086,項目名稱:LCIndex-HBase-0.94.16,代碼行數:25,代碼來源:HBaseAdmin.java

示例13: getConnection

import org.apache.hadoop.hbase.ZooKeeperConnectionException; //導入依賴的package包/類
/**
 * Get the connection that goes with the passed <code>conf</code>
 * configuration instance.
 * If no current connection exists, method creates a new connection for the
 * passed <code>conf</code> instance.
 * @param conf configuration
 * @return HConnection object for <code>conf</code>
 * @throws ZooKeeperConnectionException
 */
public static HConnection getConnection(Configuration conf)
throws ZooKeeperConnectionException {
  HConnectionKey connectionKey = new HConnectionKey(conf);
  synchronized (HBASE_INSTANCES) {
    HConnectionImplementation connection = HBASE_INSTANCES.get(connectionKey);
    if (connection == null) {
      connection = new HConnectionImplementation(conf, true, null);
      HBASE_INSTANCES.put(connectionKey, connection);
    } else if (connection.isClosed()) {
      HConnectionManager.deleteConnection(connectionKey, true);
      connection = new HConnectionImplementation(conf, true, null);
      HBASE_INSTANCES.put(connectionKey, connection);
    }
    connection.incCount();
    return connection;
  }
}
 
開發者ID:fengchen8086,項目名稱:LCIndex-HBase-0.94.16,代碼行數:27,代碼來源:HConnectionManager.java

示例14: getZooKeeperWatcher

import org.apache.hadoop.hbase.ZooKeeperConnectionException; //導入依賴的package包/類
/**
 * Get the ZooKeeper instance for this TableServers instance.
 *
 * If ZK has not been initialized yet, this will connect to ZK.
 * @returns zookeeper reference
 * @throws ZooKeeperConnectionException if there's a problem connecting to zk
 */
@Deprecated
public synchronized ZooKeeperWatcher getZooKeeperWatcher()
    throws ZooKeeperConnectionException {
  if(zooKeeper == null) {
    try {
      if (this.closed) {
        throw new IOException(toString() + " closed");
      }
      this.zooKeeper = new ZooKeeperWatcher(conf, "hconnection", this);
    } catch(ZooKeeperConnectionException zce) {
      throw zce;
    } catch (IOException e) {
      throw new ZooKeeperConnectionException("An error is preventing" +
          " HBase from connecting to ZooKeeper", e);
    }
  }
  return zooKeeper;
}
 
開發者ID:fengchen8086,項目名稱:LCIndex-HBase-0.94.16,代碼行數:26,代碼來源:HConnectionManager.java

示例15: createNewConfigurations

import org.apache.hadoop.hbase.ZooKeeperConnectionException; //導入依賴的package包/類
public static void createNewConfigurations() throws SecurityException,
IllegalArgumentException, NoSuchFieldException,
IllegalAccessException, InterruptedException, ZooKeeperConnectionException {
  HConnection last = null;
  for (int i = 0; i <= (HConnectionManager.MAX_CACHED_HBASE_INSTANCES * 2); i++) {
    // set random key to differentiate the connection from previous ones
    Configuration configuration = HBaseConfiguration.create();
    configuration.set("somekey", String.valueOf(_randy.nextInt()));
    System.out.println("Hash Code: " + configuration.hashCode());
    HConnection connection = HConnectionManager.getConnection(configuration);
    if (last != null) {
      if (last == connection) {
        System.out.println("!! Got same connection for once !!");
      }
    }
    // change the configuration once, and the cached connection is lost forever:
    //      the hashtable holding the cache won't be able to find its own keys
    //      to remove them, so the LRU strategy does not work.
    configuration.set("someotherkey", String.valueOf(_randy.nextInt()));
    last = connection;
    LOG.info("Cache Size: " + getHConnectionManagerCacheSize());
    Thread.sleep(100);
  }
  Assert.assertEquals(1,
    getHConnectionManagerCacheSize());
}
 
開發者ID:fengchen8086,項目名稱:LCIndex-HBase-0.94.16,代碼行數:27,代碼來源:TestHCM.java


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