use of org.apache.accumulo.core.util.OpTimer in project accumulo by apache.
the class NamespaceOperationsImpl method exists.
@Override
public boolean exists(String namespace) {
checkArgument(namespace != null, "namespace is null");
OpTimer timer = null;
if (log.isTraceEnabled()) {
log.trace("tid={} Checking if namespace {} exists", Thread.currentThread().getId(), namespace);
timer = new OpTimer().start();
}
boolean exists = Namespaces.namespaceNameExists(context.getInstance(), namespace);
if (timer != null) {
timer.stop();
log.trace("tid={} Checked existance of {} in {}", Thread.currentThread().getId(), exists, String.format("%.3f secs", timer.scale(TimeUnit.SECONDS)));
}
return exists;
}
use of org.apache.accumulo.core.util.OpTimer in project accumulo by apache.
the class NamespaceOperationsImpl method list.
@Override
public SortedSet<String> list() {
OpTimer timer = null;
if (log.isTraceEnabled()) {
log.trace("tid={} Fetching list of namespaces...", Thread.currentThread().getId());
timer = new OpTimer().start();
}
TreeSet<String> namespaces = new TreeSet<>(Namespaces.getNameToIdMap(context.getInstance()).keySet());
if (timer != null) {
timer.stop();
log.trace("tid={} Fetched {} namespaces in {}", Thread.currentThread().getId(), namespaces.size(), String.format("%.3f secs", timer.scale(TimeUnit.SECONDS)));
}
return namespaces;
}
use of org.apache.accumulo.core.util.OpTimer in project accumulo by apache.
the class RootTabletLocator method getRootTabletLocation.
protected TabletLocation getRootTabletLocation(ClientContext context) {
Instance instance = context.getInstance();
String zRootLocPath = ZooUtil.getRoot(instance) + RootTable.ZROOT_TABLET_LOCATION;
ZooCache zooCache = zcf.getZooCache(instance.getZooKeepers(), instance.getZooKeepersSessionTimeOut());
Logger log = LoggerFactory.getLogger(this.getClass());
OpTimer timer = null;
if (log.isTraceEnabled()) {
log.trace("tid={} Looking up root tablet location in zookeeper.", Thread.currentThread().getId());
timer = new OpTimer().start();
}
byte[] loc = zooCache.get(zRootLocPath);
if (timer != null) {
timer.stop();
log.trace("tid={} Found root tablet at {} in {}", Thread.currentThread().getId(), (loc == null ? "null" : new String(loc)), String.format("%.3f secs", timer.scale(TimeUnit.SECONDS)));
}
if (loc == null) {
return null;
}
String[] tokens = new String(loc).split("\\|");
if (lockChecker.isLockHeld(tokens[0], tokens[1]))
return new TabletLocation(RootTable.EXTENT, tokens[0], tokens[1]);
else
return null;
}
use of org.apache.accumulo.core.util.OpTimer in project accumulo by apache.
the class ZooKeeperInstance method getMasterLocations.
@Override
public List<String> getMasterLocations() {
String masterLocPath = ZooUtil.getRoot(this) + Constants.ZMASTER_LOCK;
OpTimer timer = null;
if (log.isTraceEnabled()) {
log.trace("tid={} Looking up master location in zookeeper.", Thread.currentThread().getId());
timer = new OpTimer().start();
}
byte[] loc = ZooUtil.getLockData(zooCache, masterLocPath);
if (timer != null) {
timer.stop();
log.trace("tid={} Found master at {} in {}", Thread.currentThread().getId(), (loc == null ? "null" : new String(loc, UTF_8)), String.format("%.3f secs", timer.scale(TimeUnit.SECONDS)));
}
if (loc == null) {
return Collections.emptyList();
}
return Collections.singletonList(new String(loc, UTF_8));
}
use of org.apache.accumulo.core.util.OpTimer in project accumulo by apache.
the class ZooKeeperInstance method getRootTabletLocation.
@Override
public String getRootTabletLocation() {
String zRootLocPath = ZooUtil.getRoot(this) + RootTable.ZROOT_TABLET_LOCATION;
OpTimer timer = null;
if (log.isTraceEnabled()) {
log.trace("tid={} Looking up root tablet location in zookeeper.", Thread.currentThread().getId());
timer = new OpTimer().start();
}
byte[] loc = zooCache.get(zRootLocPath);
if (timer != null) {
timer.stop();
log.trace("tid={} Found root tablet at {} in {}", Thread.currentThread().getId(), (loc == null ? "null" : new String(loc, UTF_8)), String.format("%.3f secs", timer.scale(TimeUnit.SECONDS)));
}
if (loc == null) {
return null;
}
return new String(loc, UTF_8).split("\\|")[0];
}
Aggregations