Examples of TraceScope


Examples of org.cloudera.htrace.TraceScope

      if (createScope != null) createScope.close();
    }
  }

  private void deleteTable() throws IOException {
    TraceScope deleteScope = null;

    try {
      if (admin.tableExists(tableName)) {
        deleteScope = Trace.startSpan("deleteTable", Sampler.ALWAYS);
        util.deleteTable(tableName);
      }
    } finally {
      if (deleteScope != null) deleteScope.close();
    }
  }
View Full Code Here

Examples of org.cloudera.htrace.TraceScope

  private LinkedBlockingQueue<Long> insertData() throws IOException, InterruptedException {
    LinkedBlockingQueue<Long> rowKeys = new LinkedBlockingQueue<Long>(25000);
    HTable ht = new HTable(util.getConfiguration(), this.tableName);
    byte[] value = new byte[300];
    for (int x = 0; x < 5000; x++) {
      TraceScope traceScope = Trace.startSpan("insertData", Sampler.ALWAYS);
      try {
        ht.setAutoFlush(false, true);
        for (int i = 0; i < 5; i++) {
          long rk = random.nextLong();
          rowKeys.add(rk);
          Put p = new Put(Bytes.toBytes(rk));
          for (int y = 0; y < 10; y++) {
            random.nextBytes(value);
            p.add(Bytes.toBytes(familyName),
                Bytes.toBytes(random.nextLong()),
                value);
          }
          ht.put(p);
        }
        if ((x % 1000) == 0) {
          admin.flush(Bytes.toBytes(tableName));
        }
      } finally {
        traceScope.close();
      }
    }
    admin.flush(Bytes.toBytes(tableName));
    return rowKeys;
  }
View Full Code Here

Examples of org.cloudera.htrace.TraceScope

          }
          Throwable errorThrowable = null;
          String error = null;
          Pair<Message, CellScanner> resultPair = null;
          CurCall.set(call);
          TraceScope traceScope = null;
          try {
            if (!started) {
              throw new ServerNotRunningYetException("Server is not running yet");
            }
            if (call.tinfo != null) {
              traceScope = Trace.startSpan(call.toTraceString(), call.tinfo);
            }

            // make the call
          RequestContext.set(userProvider.create(call.connection.user), getRemoteIp(),
            call.connection.service);
          // make the call
          resultPair = call(call.service, call.md, call.param, call.cellScanner, call.timestamp,
              status);
          } catch (Throwable e) {
            LOG.debug(getName() + ": " + call.toShortString(), e);
            errorThrowable = e;
            error = StringUtils.stringifyException(e);
          } finally {
            if (traceScope != null) {
              traceScope.close();
            }
            // Must always clear the request context to avoid leaking
            // credentials between requests.
            RequestContext.clear();
          }
View Full Code Here

Examples of org.cloudera.htrace.TraceScope

   * This function will not throw NoNodeException if the path does not
   * exist.
   */
  public void delete(String path, int version)
  throws InterruptedException, KeeperException {
    TraceScope traceScope = null;
    try {
      traceScope = Trace.startSpan("RecoverableZookeeper.delete");
      RetryCounter retryCounter = retryCounterFactory.create();
      boolean isRetry = false; // False for first attempt, true for all retries.
      while (true) {
        try {
          zk.delete(path, version);
          return;
        } catch (KeeperException e) {
          switch (e.code()) {
            case NONODE:
              if (isRetry) {
                LOG.info("Node " + path + " already deleted. Assuming a " +
                    "previous attempt succeeded.");
                return;
              }
              LOG.warn("Node " + path + " already deleted, retry=" + isRetry);
              throw e;

            case CONNECTIONLOSS:
            case SESSIONEXPIRED:
            case OPERATIONTIMEOUT:
              retryOrThrow(retryCounter, e, "delete");
              break;

            default:
              throw e;
          }
        }
        retryCounter.sleepUntilNextRetry();
        retryCounter.useRetry();
        isRetry = true;
      }
    } finally {
      if (traceScope != null) traceScope.close();
    }
  }
View Full Code Here

Examples of org.cloudera.htrace.TraceScope

   * exists is an idempotent operation. Retry before throwing exception
   * @return A Stat instance
   */
  public Stat exists(String path, Watcher watcher)
  throws KeeperException, InterruptedException {
    TraceScope traceScope = null;
    try {
      traceScope = Trace.startSpan("RecoverableZookeeper.exists");
      RetryCounter retryCounter = retryCounterFactory.create();
      while (true) {
        try {
          return zk.exists(path, watcher);
        } catch (KeeperException e) {
          switch (e.code()) {
            case CONNECTIONLOSS:
            case SESSIONEXPIRED:
            case OPERATIONTIMEOUT:
              retryOrThrow(retryCounter, e, "exists");
              break;

            default:
              throw e;
          }
        }
        retryCounter.sleepUntilNextRetry();
        retryCounter.useRetry();
      }
    } finally {
      if (traceScope != null) traceScope.close();
    }
  }
View Full Code Here

Examples of org.cloudera.htrace.TraceScope

   * exists is an idempotent operation. Retry before throwing exception
   * @return A Stat instance
   */
  public Stat exists(String path, boolean watch)
  throws KeeperException, InterruptedException {
    TraceScope traceScope = null;
    try {
      traceScope = Trace.startSpan("RecoverableZookeeper.exists");
      RetryCounter retryCounter = retryCounterFactory.create();
      while (true) {
        try {
          return zk.exists(path, watch);
        } catch (KeeperException e) {
          switch (e.code()) {
            case CONNECTIONLOSS:
            case SESSIONEXPIRED:
            case OPERATIONTIMEOUT:
              retryOrThrow(retryCounter, e, "exists");
              break;

            default:
              throw e;
          }
        }
        retryCounter.sleepUntilNextRetry();
        retryCounter.useRetry();
      }
    } finally {
      if (traceScope != null) traceScope.close();
    }
  }
View Full Code Here

Examples of org.cloudera.htrace.TraceScope

   * getChildren is an idempotent operation. Retry before throwing exception
   * @return List of children znodes
   */
  public List<String> getChildren(String path, Watcher watcher)
    throws KeeperException, InterruptedException {
    TraceScope traceScope = null;
    try {
      traceScope = Trace.startSpan("RecoverableZookeeper.getChildren");
      RetryCounter retryCounter = retryCounterFactory.create();
      while (true) {
        try {
          return zk.getChildren(path, watcher);
        } catch (KeeperException e) {
          switch (e.code()) {
            case CONNECTIONLOSS:
            case SESSIONEXPIRED:
            case OPERATIONTIMEOUT:
              retryOrThrow(retryCounter, e, "getChildren");
              break;

            default:
              throw e;
          }
        }
        retryCounter.sleepUntilNextRetry();
        retryCounter.useRetry();
      }
    } finally {
      if (traceScope != null) traceScope.close();
    }
  }
View Full Code Here

Examples of org.cloudera.htrace.TraceScope

   * getChildren is an idempotent operation. Retry before throwing exception
   * @return List of children znodes
   */
  public List<String> getChildren(String path, boolean watch)
  throws KeeperException, InterruptedException {
    TraceScope traceScope = null;
    try {
      traceScope = Trace.startSpan("RecoverableZookeeper.getChildren");
      RetryCounter retryCounter = retryCounterFactory.create();
      while (true) {
        try {
          return zk.getChildren(path, watch);
        } catch (KeeperException e) {
          switch (e.code()) {
            case CONNECTIONLOSS:
            case SESSIONEXPIRED:
            case OPERATIONTIMEOUT:
              retryOrThrow(retryCounter, e, "getChildren");
              break;

            default:
              throw e;
          }
        }
        retryCounter.sleepUntilNextRetry();
        retryCounter.useRetry();
      }
    } finally {
      if (traceScope != null) traceScope.close();
    }
  }
View Full Code Here

Examples of org.cloudera.htrace.TraceScope

   * getData is an idempotent operation. Retry before throwing exception
   * @return Data
   */
  public byte[] getData(String path, Watcher watcher, Stat stat)
  throws KeeperException, InterruptedException {
    TraceScope traceScope = null;
    try {
      traceScope = Trace.startSpan("RecoverableZookeeper.getData");
      RetryCounter retryCounter = retryCounterFactory.create();
      while (true) {
        try {
          byte[] revData = zk.getData(path, watcher, stat);
          return this.removeMetaData(revData);
        } catch (KeeperException e) {
          switch (e.code()) {
            case CONNECTIONLOSS:
            case SESSIONEXPIRED:
            case OPERATIONTIMEOUT:
              retryOrThrow(retryCounter, e, "getData");
              break;

            default:
              throw e;
          }
        }
        retryCounter.sleepUntilNextRetry();
        retryCounter.useRetry();
      }
    } finally {
      if (traceScope != null) traceScope.close();
    }
  }
View Full Code Here

Examples of org.cloudera.htrace.TraceScope

   * getData is an idemnpotent operation. Retry before throwing exception
   * @return Data
   */
  public byte[] getData(String path, boolean watch, Stat stat)
  throws KeeperException, InterruptedException {
    TraceScope traceScope = null;
    try {
      traceScope = Trace.startSpan("RecoverableZookeeper.getData");
      RetryCounter retryCounter = retryCounterFactory.create();
      while (true) {
        try {
          byte[] revData = zk.getData(path, watch, stat);
          return this.removeMetaData(revData);
        } catch (KeeperException e) {
          switch (e.code()) {
            case CONNECTIONLOSS:
            case SESSIONEXPIRED:
            case OPERATIONTIMEOUT:
              retryOrThrow(retryCounter, e, "getData");
              break;

            default:
              throw e;
          }
        }
        retryCounter.sleepUntilNextRetry();
        retryCounter.useRetry();
      }
    } finally {
      if (traceScope != null) traceScope.close();
    }
  }
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.