当前位置: 首页>>代码示例>>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;未经允许,请勿转载。