org.apache.accumulo.core.client.Instance.getZooKeepersSessionTimeOut()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(10.1k)|赞(0)|评价(0)|浏览(123)

本文整理了Java中org.apache.accumulo.core.client.Instance.getZooKeepersSessionTimeOut()方法的一些代码示例,展示了Instance.getZooKeepersSessionTimeOut()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Instance.getZooKeepersSessionTimeOut()方法的具体详情如下:
包路径:org.apache.accumulo.core.client.Instance
类名称:Instance
方法名:getZooKeepersSessionTimeOut

Instance.getZooKeepersSessionTimeOut介绍

[英]Returns the zookeeper connection timeout.
[中]返回zookeeper连接超时。

代码示例

代码示例来源:origin: org.apache.accumulo/accumulo-core

private static ZooCache getZooCache(Instance instance) {
 SecurityManager sm = System.getSecurityManager();
 if (sm != null) {
  sm.checkPermission(TABLES_PERMISSION);
 }
 return new ZooCacheFactory().getZooCache(instance.getZooKeepers(),
   instance.getZooKeepersSessionTimeOut());
}

代码示例来源:origin: org.apache.accumulo/accumulo-test

private Map<String,Boolean> _getWals(Connector c) throws Exception {
 Map<String,Boolean> result = new HashMap<>();
 Instance i = c.getInstance();
 ZooReaderWriter zk = new ZooReaderWriter(i.getZooKeepers(), i.getZooKeepersSessionTimeOut(),
   "");
 WalStateManager wals = new WalStateManager(c.getInstance(), zk);
 for (Entry<Path,WalState> entry : wals.getAllState().entrySet()) {
  // WALs are in use if they are not unreferenced
  result.put(entry.getKey().toString(), entry.getValue() != WalState.UNREFERENCED);
 }
 return result;
}

代码示例来源:origin: org.apache.accumulo/accumulo-server-base

private static void verifyAccumuloIsDown(Instance inst, String oldPassword) throws Exception {
 ZooReader zooReader = new ZooReaderWriter(inst.getZooKeepers(),
   inst.getZooKeepersSessionTimeOut(), oldPassword);
 String root = ZooUtil.getRoot(inst);
 final List<String> ephemerals = new ArrayList<>();
 recurse(zooReader, root, new Visitor() {
  @Override
  public void visit(ZooReader zoo, String path) throws Exception {
   Stat stat = zoo.getStatus(path);
   if (stat.getEphemeralOwner() != 0)
    ephemerals.add(path);
  }
 });
 if (ephemerals.size() > 0) {
  System.err.println("The following ephemeral nodes exist, something is still running:");
  for (String path : ephemerals) {
   System.err.println(path);
  }
  throw new Exception("Accumulo must be shut down in order to run this tool.");
 }
}

代码示例来源:origin: org.apache.accumulo/accumulo-core

@Override
 public ZooCache call() {
  final String zks = instance.getZooKeepers();
  final int timeOut = instance.getZooKeepersSessionTimeOut();
  return new ZooCacheFactory().getZooCache(zks, timeOut, new Watcher() {
   @Override
   public void process(WatchedEvent watchedEvent) {
    instanceToMapCache.invalidate(uuid);
   }
  });
 }
});

代码示例来源:origin: org.apache.accumulo/accumulo-server

private static boolean verifyAccumuloIsDown(Instance inst, String oldPassword) {
 ZooReader zooReader = new ZooReaderWriter(inst.getZooKeepers(), inst.getZooKeepersSessionTimeOut(), oldPassword);
 String root = ZooUtil.getRoot(inst);
 final List<String> ephemerals = new ArrayList<String>();
 recurse(zooReader, root, new Visitor() {
  public void visit(ZooReader zoo, String path) throws Exception {
   Stat stat = zoo.getStatus(path);
   if (stat.getEphemeralOwner() != 0)
    ephemerals.add(path);
  }
 });
 if (ephemerals.size() == 0) {
  return true;
 }
 System.err.println("The following ephemeral nodes exist, something is still running:");
 for (String path : ephemerals) {
  System.err.println(path);
 }
 return false;
}

代码示例来源:origin: org.apache.accumulo/accumulo-shell

protected synchronized IZooReaderWriter getZooReaderWriter(Instance instance, String secret) {
 if (secret == null) {
  AccumuloConfiguration conf = SiteConfiguration.getInstance();
  secret = conf.get(Property.INSTANCE_SECRET);
 }
 return new ZooReaderWriter(instance.getZooKeepers(), instance.getZooKeepersSessionTimeOut(),
   SCHEME, (USER + ":" + secret).getBytes());
}

代码示例来源:origin: org.apache.accumulo/accumulo-core

ZookeeperLockChecker(Instance instance, ZooCacheFactory zcf) {
 zc = zcf.getZooCache(instance.getZooKeepers(), instance.getZooKeepersSessionTimeOut());
 this.root = ZooUtil.getRoot(instance) + Constants.ZTSERVERS;
}

代码示例来源:origin: org.apache.accumulo/accumulo-core

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

代码示例来源:origin: org.apache.accumulo/accumulo-test

/**
 * Fetch all of the WALs referenced by tablets in the metadata table for this table
 */
private Set<String> getWalsForTable(String tableName) throws Exception {
 final Connector conn = getConnector();
 final String tableId = conn.tableOperations().tableIdMap().get(tableName);
 Assert.assertNotNull("Could not determine table ID for " + tableName, tableId);
 Instance i = conn.getInstance();
 ZooReaderWriter zk = new ZooReaderWriter(i.getZooKeepers(), i.getZooKeepersSessionTimeOut(),
   "");
 WalStateManager wals = new WalStateManager(conn.getInstance(), zk);
 Set<String> result = new HashSet<>();
 for (Entry<Path,WalState> entry : wals.getAllState().entrySet()) {
  log.debug("Reading WALs: {}={}", entry.getKey(), entry.getValue());
  result.add(entry.getKey().toString());
 }
 return result;
}

代码示例来源:origin: org.apache.accumulo/accumulo-server

private static void deleteInstance(Instance origInstance, String oldPass) throws Exception {
  IZooReaderWriter orig = new ZooReaderWriter(origInstance.getZooKeepers(), origInstance.getZooKeepersSessionTimeOut(), oldPass);
  orig.recursiveDelete("/accumulo/" + origInstance.getInstanceID(), NodeMissingPolicy.SKIP);
 }
}

代码示例来源:origin: org.apache.accumulo/accumulo-core

@Override
public void invalidateCache(Instance instance, String server) {
 ZooCache zooCache = zcf.getZooCache(instance.getZooKeepers(),
   instance.getZooKeepersSessionTimeOut());
 String root = ZooUtil.getRoot(instance) + Constants.ZTSERVERS;
 zooCache.clear(root + "/" + server);
}

代码示例来源:origin: org.apache.accumulo/accumulo-server

private void initializeZooCache() {
 synchronized (initLock) {
  if (null == tablePropCache) {
   tablePropCache = new ZooCache(instance.getZooKeepers(), instance.getZooKeepersSessionTimeOut(), new TableConfWatcher(instance));
  }
 }
}

代码示例来源:origin: org.apache.accumulo/accumulo-server

synchronized public static ZooConfiguration getInstance(Instance inst, AccumuloConfiguration parent) {
 if (instance == null) {
  propCache = new ZooCache(inst.getZooKeepers(), inst.getZooKeepersSessionTimeOut());
  instance = new ZooConfiguration(parent);
  instanceId = inst.getInstanceID();
 }
 return instance;
}

代码示例来源:origin: org.apache.accumulo/accumulo-server-base

private synchronized ZooCachePropertyAccessor getPropCacheAccessor() {
 if (propCacheAccessor == null) {
  synchronized (propCaches) {
   PropCacheKey key = new PropCacheKey(instance.getInstanceID(), tableId);
   ZooCache propCache = propCaches.get(key);
   if (propCache == null) {
    propCache = zcf.getZooCache(instance.getZooKeepers(),
      instance.getZooKeepersSessionTimeOut(), new TableConfWatcher(instance));
    propCaches.put(key, propCache);
   }
   propCacheAccessor = new ZooCachePropertyAccessor(propCache);
  }
 }
 return propCacheAccessor;
}

代码示例来源:origin: org.apache.accumulo/accumulo-server-base

private static void deleteInstance(Instance origInstance, String oldPass) throws Exception {
  IZooReaderWriter orig = new ZooReaderWriter(origInstance.getZooKeepers(),
    origInstance.getZooKeepersSessionTimeOut(), oldPass);
  orig.recursiveDelete("/accumulo/" + origInstance.getInstanceID(), NodeMissingPolicy.SKIP);
 }
}

代码示例来源:origin: org.apache.accumulo/accumulo-server-base

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);
  }
 }
 return propCacheAccessor;
}

代码示例来源:origin: org.apache.accumulo/accumulo-master

public MasterReplicationCoordinator(Master master) {
 this(master, new ZooReader(master.getInstance().getZooKeepers(),
   master.getInstance().getZooKeepersSessionTimeOut()));
}

代码示例来源:origin: org.apache.accumulo/accumulo-test

@Override
public Set<TServerInstance> onlineTabletServers() {
 HashSet<TServerInstance> tservers = new HashSet<>();
 for (String tserver : getConnector().instanceOperations().getTabletServers()) {
  try {
   String zPath = ZooUtil.getRoot(getConnector().getInstance()) + Constants.ZTSERVERS + "/"
     + tserver;
   long sessionId = ZooLock.getSessionId(new ZooCache(getCluster().getZooKeepers(),
     getConnector().getInstance().getZooKeepersSessionTimeOut()), zPath);
   tservers.add(new TServerInstance(tserver, sessionId));
  } catch (Exception e) {
   throw new RuntimeException(e);
  }
 }
 return tservers;
}

代码示例来源:origin: org.apache.accumulo/accumulo-test

public static IteratorSetting iteratorSetting(int priority, int sleepAfterFirstWrite,
  long batchWriterTimeout, long batchWriterMaxMemory, int numEntriesToWrite, String tableName,
  Connector connector, AuthenticationToken token, boolean clearCacheAfterFirstWrite,
  boolean splitAfterFirstWrite) {
 return iteratorSetting(priority, sleepAfterFirstWrite, batchWriterTimeout, batchWriterMaxMemory,
   numEntriesToWrite, tableName, connector.getInstance().getZooKeepers(),
   connector.getInstance().getInstanceName(),
   connector.getInstance().getZooKeepersSessionTimeOut(), connector.whoami(), token,
   clearCacheAfterFirstWrite, splitAfterFirstWrite);
}

代码示例来源:origin: org.apache.accumulo/accumulo-test

private static FateStatus getFateStatus(Instance instance, AccumuloCluster cluster) {
  try {
   AdminUtil<String> admin = new AdminUtil<>(false);
   String secret = cluster.getSiteConfiguration().get(Property.INSTANCE_SECRET);
   IZooReaderWriter zk = new ZooReaderWriterFactory().getZooReaderWriter(
     instance.getZooKeepers(), instance.getZooKeepersSessionTimeOut(), secret);
   ZooStore<String> zs = new ZooStore<>(ZooUtil.getRoot(instance) + Constants.ZFATE, zk);
   FateStatus fateStatus = admin.getStatus(zs, zk,
     ZooUtil.getRoot(instance) + Constants.ZTABLE_LOCKS, null, null);
   return fateStatus;
  } catch (KeeperException | InterruptedException e) {
   throw new RuntimeException(e);
  }
 }
}

相关文章