Examples of ZooCache


Examples of org.apache.accumulo.fate.zookeeper.ZooCache

    });
  }

  @Override
  public List<String> getTabletServers() {
    ZooCache cache = new ZooCacheFactory().getZooCache(instance.getZooKeepers(), instance.getZooKeepersSessionTimeOut());
    String path = ZooUtil.getRoot(instance) + Constants.ZTSERVERS;
    List<String> results = new ArrayList<String>();
    for (String candidate : cache.getChildren(path)) {
      List<String> children = cache.getChildren(path + "/" + candidate);
      if (children != null && children.size() > 0) {
        List<String> copy = new ArrayList<String>(children);
        Collections.sort(copy);
        byte[] data = cache.get(path + "/" + candidate + "/" + copy.get(0));
        if (data != null && !"master".equals(new String(data, Constants.UTF8))) {
          results.add(candidate);
        }
      }
    }
View Full Code Here

Examples of org.apache.accumulo.fate.zookeeper.ZooCache

  private synchronized ZooCachePropertyAccessor getPropCacheAccessor() {
    if (propCacheAccessor == null) {
      synchronized (propCaches) {
        PropCacheKey key = new PropCacheKey(inst.getInstanceID(), namespaceId);
        ZooCache propCache = propCaches.get(key);
        if (propCache == null) {
          propCache = zcf.getZooCache(inst.getZooKeepers(), inst.getZooKeepersSessionTimeOut(), new NamespaceConfWatcher(inst));
          propCaches.put(key, propCache);
        }
        propCacheAccessor = new ZooCachePropertyAccessor(propCache);
View Full Code Here

Examples of org.apache.accumulo.fate.zookeeper.ZooCache

    ZooConfiguration config;
    synchronized (instances) {
      config = instances.get(instanceId);
      if (config == null) {
        ZooCache propCache;
        if (inst == null) {
          propCache = zcf.getZooCache(parent.get(Property.INSTANCE_ZK_HOST), (int) parent.getTimeInMillis(Property.INSTANCE_ZK_TIMEOUT));
        } else {
          propCache = zcf.getZooCache(inst.getZooKeepers(), inst.getZooKeepersSessionTimeOut());
        }
View Full Code Here

Examples of org.apache.accumulo.fate.zookeeper.ZooCache

    }
    return new ZooCacheFactory().getZooCache(instance.getZooKeepers(), instance.getZooKeepersSessionTimeOut());
  }

  private static SortedMap<String,String> getMap(Instance instance, boolean nameAsKey) {
    ZooCache zc = getZooCache(instance);

    List<String> namespaceIds = zc.getChildren(ZooUtil.getRoot(instance) + Constants.ZNAMESPACES);

    TreeMap<String,String> namespaceMap = new TreeMap<String,String>();

    for (String id : namespaceIds) {
      byte[] path = zc.get(ZooUtil.getRoot(instance) + Constants.ZNAMESPACES + "/" + id + Constants.ZNAMESPACE_NAME);
      if (path != null) {
        if (nameAsKey)
          namespaceMap.put(new String(path, Constants.UTF8), id);
        else
          namespaceMap.put(id, new String(path, Constants.UTF8));
View Full Code Here

Examples of org.apache.accumulo.fate.zookeeper.ZooCache

    }
    return namespaceMap;
  }

  public static boolean exists(Instance instance, String namespaceId) {
    ZooCache zc = getZooCache(instance);
    List<String> namespaceIds = zc.getChildren(ZooUtil.getRoot(instance) + Constants.ZNAMESPACES);
    return namespaceIds.contains(namespaceId);
  }
View Full Code Here

Examples of org.apache.accumulo.fate.zookeeper.ZooCache

    }
    return new ZooCacheFactory().getZooCache(instance.getZooKeepers(), instance.getZooKeepersSessionTimeOut());
  }

  private static SortedMap<String,String> getMap(Instance instance, boolean nameAsKey) {
    ZooCache zc = getZooCache(instance);

    List<String> tableIds = zc.getChildren(ZooUtil.getRoot(instance) + Constants.ZTABLES);
    TreeMap<String,String> tableMap = new TreeMap<String,String>();
    Map<String,String> namespaceIdToNameMap = new HashMap<String,String>();

    for (String tableId : tableIds) {
      byte[] tableName = zc.get(ZooUtil.getRoot(instance) + Constants.ZTABLES + "/" + tableId + Constants.ZTABLE_NAME);
      byte[] nId = zc.get(ZooUtil.getRoot(instance) + Constants.ZTABLES + "/" + tableId + Constants.ZTABLE_NAMESPACE);
      String namespaceName = Namespaces.DEFAULT_NAMESPACE;
      // create fully qualified table name
      if (nId == null) {
        namespaceName = null;
      } else {
View Full Code Here

Examples of org.apache.accumulo.fate.zookeeper.ZooCache

  public static SortedMap<String,String> getIdToNameMap(Instance instance) {
    return getMap(instance, false);
  }

  public static boolean exists(Instance instance, String tableId) {
    ZooCache zc = getZooCache(instance);
    List<String> tableIds = zc.getChildren(ZooUtil.getRoot(instance) + Constants.ZTABLES);
    return tableIds.contains(tableId);
  }
View Full Code Here

Examples of org.apache.accumulo.fate.zookeeper.ZooCache

    return tableId == null ? String.format("%s(?)", tableName) : String.format("%s(ID:%s)", tableName, tableId);
  }

  public static TableState getTableState(Instance instance, String tableId) {
    String statePath = ZooUtil.getRoot(instance) + Constants.ZTABLES + "/" + tableId + Constants.ZTABLE_STATE;
    ZooCache zc = getZooCache(instance);
    byte[] state = zc.get(statePath);
    if (state == null)
      return TableState.UNKNOWN;

    return TableState.valueOf(new String(state, Constants.UTF8));
  }
View Full Code Here

Examples of org.apache.accumulo.fate.zookeeper.ZooCache

   *           if the table doesn't exist in ZooKeeper
   */
  public static String getNamespaceId(Instance instance, String tableId) throws IllegalArgumentException {
    ArgumentChecker.notNull(instance, tableId);

    ZooCache zc = getZooCache(instance);
    byte[] n = zc.get(ZooUtil.getRoot(instance) + Constants.ZTABLES + "/" + tableId + Constants.ZTABLE_NAMESPACE);

    // We might get null out of ZooCache if this tableID doesn't exist
    if (null == n) {
      throw new IllegalArgumentException("Table with id " + tableId + " does not exist");
    }
View Full Code Here

Examples of org.apache.accumulo.fate.zookeeper.ZooCache

    }
    return ZooCache.getInstance(instance.getZooKeepers(), instance.getZooKeepersSessionTimeOut());
  }
 
  private static SortedMap<String,String> getMap(Instance instance, boolean nameAsKey) {
    ZooCache zc = getZooCache(instance);
   
    List<String> tableIds = zc.getChildren(ZooUtil.getRoot(instance) + Constants.ZTABLES);
   
    TreeMap<String,String> tableMap = new TreeMap<String,String>();
   
    for (String tableId : tableIds) {
      byte[] tblPath = zc.get(ZooUtil.getRoot(instance) + Constants.ZTABLES + "/" + tableId + Constants.ZTABLE_NAME);
      if (tblPath != null) {
        if (nameAsKey)
          tableMap.put(new String(tblPath, Constants.UTF8), tableId);
        else
          tableMap.put(tableId, new String(tblPath, Constants.UTF8));
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.