Package org.apache.accumulo.core.zookeeper

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


  }
 
  @SuppressWarnings("deprecation")
  synchronized public static ZooConfiguration getInstance(AccumuloConfiguration parent) {
    if (instance == null) {
      propCache = new ZooCache(parent.get(Property.INSTANCE_ZK_HOST), (int) parent.getTimeInMillis(Property.INSTANCE_ZK_TIMEOUT));
      instance = new ZooConfiguration(parent);
      instanceId = ZooKeeperInstance.getInstanceIDFromHdfs(ServerConstants.getInstanceIdLocation());
    }
    return instance;
  }
View Full Code Here


  private static ZooCache getTablePropCache() {
    Instance inst = HdfsZooInstance.getInstance();
    if (tablePropCache == null)
      synchronized (TableConfiguration.class) {
        if (tablePropCache == null)
          tablePropCache = new ZooCache(inst.getZooKeepers(), inst.getZooKeepersSessionTimeOut(), new TableConfWatcher(inst.getInstanceID()));
      }
    return tablePropCache;
  }
View Full Code Here

    }
    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), tableId);
        else
          tableMap.put(tableId, new String(tblPath));
View Full Code Here

  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

   *
   * @return
   */
 
  public List<String> getTabletServers() {
    ZooCache cache = ZooCache.getInstance(instance.getZooKeepers(), instance.getZooKeepersSessionTimeOut());
    String path = ZooUtil.getRoot(instance) + Constants.ZTSERVERS;
    List<String> results = new ArrayList<String>();
    for (String candidate : cache.getChildren(path)) {
      try {
        byte[] data = ZooLock.getLockData(cache, path + "/" + candidate);
        if (data != null && !"master".equals(new String(data))) {
          results.add(candidate);
        }
View Full Code Here

      } catch (Exception ex) {
        log.fatal("Programmer error: cannot create a logger strategy.");
        throw new RuntimeException(ex);
      }
    }
    cache = new ZooCache();
   
  }
View Full Code Here

  private static ZooCache getZooCache(Instance instance) {
    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), tableId);
        else
          tableMap.put(tableId, new String(tblPath));
View Full Code Here

    int numData = CacheTestWriter.NUM_DATA;
   
    File myfile = new File(reportDir + "/" + UUID.randomUUID());
    myfile.deleteOnExit();
   
    ZooCache zc = ZooCache.getInstance(keepers, 30000);
   
    while (true) {
      if (myfile.exists())
        myfile.delete();
     
      if (zc.get(rootDir + "/die") != null) {
        return;
      }
     
      Map<String,String> readData = new TreeMap<String,String>();
     
      for (int i = 0; i < numData; i++) {
        byte[] v = zc.get(rootDir + "/data" + i);
        if (v != null)
          readData.put(rootDir + "/data" + i, new String(v));
      }
     
      byte[] v = zc.get(rootDir + "/dataS");
      if (v != null)
        readData.put(rootDir + "/dataS", new String(v));
     
      List<String> children = zc.getChildren(rootDir + "/dir");
      if (children != null)
        for (String child : children) {
          readData.put(rootDir + "/dir/" + child, "");
        }
     
View Full Code Here

public class ServerClient {
  private static final Logger log = Logger.getLogger(ServerClient.class);
  private static final Map<String,ZooCache> zooCaches = new HashMap<String,ZooCache>();
 
  private synchronized static ZooCache getZooCache(Instance instance) {
    ZooCache result = zooCaches.get(instance.getZooKeepers());
    if (result == null) {
      result = new ZooCache(instance.getZooKeepers(), instance.getZooKeepersSessionTimeOut(), null);
      zooCaches.put(instance.getZooKeepers(), result);
    }
    return result;
  }
View Full Code Here

    if (instanceId == null)
      throw new IllegalStateException("Attempt to get per-table properties without an instanceId");
    if (tablePropCache == null)
      synchronized (TableConfiguration.class) {
        if (tablePropCache == null)
          tablePropCache = new ZooCache(new TableConfWatcher(instanceId));
      }
    return tablePropCache;
  }
View Full Code Here

TOP

Related Classes of org.apache.accumulo.core.zookeeper.ZooCache

Copyright © 2018 www.massapicom. 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.