コード例 #1
0
 /** Given a zooCache and instanceId, look up the instance name. */
 public static String lookupInstanceName(ZooCache zooCache, UUID instanceId) {
   ArgumentChecker.notNull(zooCache, instanceId);
   for (String name : zooCache.getChildren(Constants.ZROOT + Constants.ZINSTANCES)) {
     String instanceNamePath = Constants.ZROOT + Constants.ZINSTANCES + "/" + name;
     byte[] bytes = zooCache.get(instanceNamePath);
     UUID iid = UUID.fromString(new String(bytes, Constants.UTF8));
     if (iid.equals(instanceId)) {
       return name;
     }
   }
   return null;
 }
コード例 #2
0
 /**
  * @param config Client configuration for specifying connection options. See {@link
  *     ClientConfiguration} which extends Configuration with convenience methods specific to
  *     Accumulo.
  * @since 1.6.0
  */
 public ZooKeeperInstance(Configuration config) {
   ArgumentChecker.notNull(config);
   if (config instanceof ClientConfiguration) {
     this.clientConf = (ClientConfiguration) config;
   } else {
     this.clientConf = new ClientConfiguration(config);
   }
   this.instanceId = clientConf.get(ClientProperty.INSTANCE_ID);
   this.instanceName = clientConf.get(ClientProperty.INSTANCE_NAME);
   if ((instanceId == null) == (instanceName == null))
     throw new IllegalArgumentException(
         "Expected exactly one of instanceName and instanceId to be set");
   this.zooKeepers = clientConf.get(ClientProperty.INSTANCE_ZK_HOST);
   this.zooKeepersSessionTimeOut =
       (int)
           AccumuloConfiguration.getTimeInMillis(
               clientConf.get(ClientProperty.INSTANCE_ZK_TIMEOUT));
   zooCache = ZooCache.getInstance(zooKeepers, zooKeepersSessionTimeOut);
 }