Search in sources :

Example 6 with OpTimer

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;
}
Also used : OpTimer(org.apache.accumulo.core.util.OpTimer)

Example 7 with OpTimer

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;
}
Also used : TreeSet(java.util.TreeSet) OpTimer(org.apache.accumulo.core.util.OpTimer)

Example 8 with OpTimer

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;
}
Also used : Instance(org.apache.accumulo.core.client.Instance) OpTimer(org.apache.accumulo.core.util.OpTimer) Logger(org.slf4j.Logger) ZooCache(org.apache.accumulo.fate.zookeeper.ZooCache)

Example 9 with OpTimer

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));
}
Also used : OpTimer(org.apache.accumulo.core.util.OpTimer)

Example 10 with OpTimer

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];
}
Also used : OpTimer(org.apache.accumulo.core.util.OpTimer)

Aggregations

OpTimer (org.apache.accumulo.core.util.OpTimer)17 ArrayList (java.util.ArrayList)5 Key (org.apache.accumulo.core.data.Key)4 Range (org.apache.accumulo.core.data.Range)4 AccumuloSecurityException (org.apache.accumulo.core.client.AccumuloSecurityException)3 ThriftSecurityException (org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException)3 Value (org.apache.accumulo.core.data.Value)3 TabletClientService (org.apache.accumulo.core.tabletserver.thrift.TabletClientService)3 HostAndPort (org.apache.accumulo.core.util.HostAndPort)3 Text (org.apache.hadoop.io.Text)3 Entry (java.util.Map.Entry)2 TreeSet (java.util.TreeSet)2 AtomicLong (java.util.concurrent.atomic.AtomicLong)2 PartialKey (org.apache.accumulo.core.data.PartialKey)2 TKeyValue (org.apache.accumulo.core.data.thrift.TKeyValue)2 NotServingTabletException (org.apache.accumulo.core.tabletserver.thrift.NotServingTabletException)2 TApplicationException (org.apache.thrift.TApplicationException)2 TException (org.apache.thrift.TException)2 TTransportException (org.apache.thrift.transport.TTransportException)2 IOException (java.io.IOException)1