当前位置: 首页>>代码示例>>Java>>正文


Java Trace.startSpan方法代码示例

本文整理汇总了Java中org.apache.htrace.Trace.startSpan方法的典型用法代码示例。如果您正苦于以下问题:Java Trace.startSpan方法的具体用法?Java Trace.startSpan怎么用?Java Trace.startSpan使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.htrace.Trace的用法示例。


在下文中一共展示了Trace.startSpan方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getFromOneDataNode

import org.apache.htrace.Trace; //导入方法依赖的package包/类
private Callable<ByteBuffer> getFromOneDataNode(final DNAddrPair datanode,
    final LocatedBlock block, final long start, final long end,
    final ByteBuffer bb,
    final Map<ExtendedBlock, Set<DatanodeInfo>> corruptedBlockMap,
    final int hedgedReadId) {
  final Span parentSpan = Trace.currentSpan();
  return new Callable<ByteBuffer>() {
    @Override
    public ByteBuffer call() throws Exception {
      byte[] buf = bb.array();
      int offset = bb.position();
      TraceScope scope =
          Trace.startSpan("hedgedRead" + hedgedReadId, parentSpan);
      try {
        actualGetFromOneDataNode(datanode, block, start, end, buf, offset,
            corruptedBlockMap);
        return bb;
      } finally {
        scope.close();
      }
    }
  };
}
 
开发者ID:naver,项目名称:hadoop,代码行数:24,代码来源:DFSInputStream.java

示例2: decryptEncryptedDataEncryptionKey

import org.apache.htrace.Trace; //导入方法依赖的package包/类
/**
 * Decrypts a EDEK by consulting the KeyProvider.
 */
private KeyVersion decryptEncryptedDataEncryptionKey(FileEncryptionInfo
    feInfo) throws IOException {
  TraceScope scope = Trace.startSpan("decryptEDEK", traceSampler);
  try {
    KeyProvider provider = getKeyProvider();
    if (provider == null) {
      throw new IOException("No KeyProvider is configured, cannot access" +
          " an encrypted file");
    }
    EncryptedKeyVersion ekv = EncryptedKeyVersion.createForDecryption(
        feInfo.getKeyName(), feInfo.getEzKeyVersionName(), feInfo.getIV(),
        feInfo.getEncryptedDataEncryptionKey());
    try {
      KeyProviderCryptoExtension cryptoProvider = KeyProviderCryptoExtension
          .createKeyProviderCryptoExtension(provider);
      return cryptoProvider.decryptEncryptedKey(ekv);
    } catch (GeneralSecurityException e) {
      throw new IOException(e);
    }
  } finally {
    scope.close();
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:27,代码来源:DFSClient.java

示例3: take

import org.apache.htrace.Trace; //导入方法依赖的package包/类
/**
 * Returns the next batch of events in the stream, waiting indefinitely if
 * a new batch  is not immediately available.
 *
 * @throws IOException see {@link DFSInotifyEventInputStream#poll()}
 * @throws MissingEventsException see
 * {@link DFSInotifyEventInputStream#poll()}
 * @throws InterruptedException if the calling thread is interrupted
 */
public EventBatch take() throws IOException, InterruptedException,
    MissingEventsException {
  TraceScope scope = Trace.startSpan("inotifyTake", traceSampler);
  EventBatch next = null;
  try {
    int nextWaitMin = INITIAL_WAIT_MS;
    while ((next = poll()) == null) {
      // sleep for a random period between nextWaitMin and nextWaitMin * 2
      // to avoid stampedes at the NN if there are multiple clients
      int sleepTime = nextWaitMin + rng.nextInt(nextWaitMin);
      LOG.debug("take(): poll() returned null, sleeping for {} ms", sleepTime);
      Thread.sleep(sleepTime);
      // the maximum sleep is 2 minutes
      nextWaitMin = Math.min(60000, nextWaitMin * 2);
    }
  } finally {
    scope.close();
  }

  return next;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:31,代码来源:DFSInotifyEventInputStream.java

示例4: setAcl

import org.apache.htrace.Trace; //导入方法依赖的package包/类
public void setAcl(String src, List<AclEntry> aclSpec) throws IOException {
  checkOpen();
  TraceScope scope = Trace.startSpan("setAcl", traceSampler);
  try {
    namenode.setAcl(src, aclSpec);
  } catch(RemoteException re) {
    throw re.unwrapRemoteException(AccessControlException.class,
                                   AclException.class,
                                   FileNotFoundException.class,
                                   NSQuotaExceededException.class,
                                   SafeModeException.class,
                                   SnapshotAccessControlException.class,
                                   UnresolvedPathException.class);
  } finally {
    scope.close();
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:18,代码来源:DFSClient.java

示例5: createEntries

import org.apache.htrace.Trace; //导入方法依赖的package包/类
private void createEntries(Opts opts) throws TableNotFoundException, AccumuloException, AccumuloSecurityException {

    // Trace the write operation. Note, unless you flush the BatchWriter, you will not capture
    // the write operation as it is occurs asynchronously. You can optionally create additional Spans
    // within a given Trace as seen below around the flush
    TraceScope scope = Trace.startSpan("Client Write", Sampler.ALWAYS);

    System.out.println("TraceID: " + Long.toHexString(scope.getSpan().getTraceId()));
    BatchWriter batchWriter = opts.getConnector().createBatchWriter(opts.getTableName(), new BatchWriterConfig());

    Mutation m = new Mutation("row");
    m.put("cf", "cq", "value");

    batchWriter.addMutation(m);
    // You can add timeline annotations to Spans which will be able to be viewed in the Monitor
    scope.getSpan().addTimelineAnnotation("Initiating Flush");
    batchWriter.flush();

    batchWriter.close();
    scope.close();
  }
 
开发者ID:apache,项目名称:accumulo-examples,代码行数:22,代码来源:TracingExample.java

示例6: fillBuffer

import org.apache.htrace.Trace; //导入方法依赖的package包/类
/**
 * Reads bytes into a buffer until EOF or the buffer's limit is reached
 */
private int fillBuffer(FileInputStream stream, ByteBuffer buf)
    throws IOException {
  TraceScope scope = Trace.startSpan("BlockReaderLocalLegacy#fillBuffer(" +
      blockId + ")", Sampler.NEVER);
  try {
    int bytesRead = stream.getChannel().read(buf);
    if (bytesRead < 0) {
      //EOF
      return bytesRead;
    }
    while (buf.remaining() > 0) {
      int n = stream.getChannel().read(buf);
      if (n < 0) {
        //EOF
        return bytesRead;
      }
      bytesRead += n;
    }
    return bytesRead;
  } finally {
    scope.close();
  }
}
 
开发者ID:yncxcw,项目名称:big-c,代码行数:27,代码来源:BlockReaderLocalLegacy.java

示例7: readEntries

import org.apache.htrace.Trace; //导入方法依赖的package包/类
private void readEntries(Opts opts) throws TableNotFoundException, AccumuloException, AccumuloSecurityException {

    Scanner scanner = opts.getConnector().createScanner(opts.getTableName(), opts.auths);

    // Trace the read operation.
    TraceScope readScope = Trace.startSpan("Client Read", Sampler.ALWAYS);
    System.out.println("TraceID: " + Long.toHexString(readScope.getSpan().getTraceId()));

    int numberOfEntriesRead = 0;
    for (Entry<Key,Value> entry : scanner) {
      System.out.println(entry.getKey().toString() + " -> " + entry.getValue().toString());
      ++numberOfEntriesRead;
    }
    // You can add additional metadata (key, values) to Spans which will be able to be viewed in the Monitor
    readScope.getSpan().addKVAnnotation("Number of Entries Read".getBytes(UTF_8), String.valueOf(numberOfEntriesRead).getBytes(UTF_8));

    readScope.close();
  }
 
开发者ID:apache,项目名称:accumulo-examples,代码行数:19,代码来源:TracingExample.java

示例8: call

import org.apache.htrace.Trace; //导入方法依赖的package包/类
@Override
public HdfsBlocksMetadata call() throws Exception {
  HdfsBlocksMetadata metadata = null;
  // Create the RPC proxy and make the RPC
  ClientDatanodeProtocol cdp = null;
  TraceScope scope =
      Trace.startSpan("getHdfsBlocksMetadata", parentSpan);
  try {
    cdp = DFSUtil.createClientDatanodeProtocolProxy(datanode, configuration,
        timeout, connectToDnViaHostname);
    metadata = cdp.getHdfsBlocksMetadata(poolId, blockIds, dnTokens);
  } catch (IOException e) {
    // Bubble this up to the caller, handle with the Future
    throw e;
  } finally {
    scope.close();
    if (cdp != null) {
      RPC.stopProxy(cdp);
    }
  }
  return metadata;
}
 
开发者ID:yncxcw,项目名称:big-c,代码行数:23,代码来源:BlockStorageLocationUtil.java

示例9: testTimed

import org.apache.htrace.Trace; //导入方法依赖的package包/类
/**
 * Provides an extension point for tests that don't want a per row invocation.
 */
void testTimed() throws IOException, InterruptedException {
  int lastRow = opts.startRow + opts.perClientRunRows;
  // Report on completion of 1/10th of total.
  for (int i = opts.startRow; i < lastRow; i++) {
    if (i % everyN != 0) continue;
    long startTime = System.nanoTime();
    TraceScope scope = Trace.startSpan("test row", traceSampler);
    try {
      testRow(i);
    } finally {
      scope.close();
    }
    latency.update((System.nanoTime() - startTime) / 1000);
    if (status != null && i > 0 && (i % getReportingPeriod()) == 0) {
      status.setStatus(generateStatus(opts.startRow, i, lastRow));
    }
  }
}
 
开发者ID:grokcoder,项目名称:pbase,代码行数:22,代码来源:PerformanceEvaluation.java

示例10: create

import org.apache.htrace.Trace; //导入方法依赖的package包/类
/**
 * <p>
 * NONSEQUENTIAL create is idempotent operation.
 * Retry before throwing exceptions.
 * But this function will not throw the NodeExist exception back to the
 * application.
 * </p>
 * <p>
 * But SEQUENTIAL is NOT idempotent operation. It is necessary to add
 * identifier to the path to verify, whether the previous one is successful
 * or not.
 * </p>
 *
 * @return Path
 */
public String create(String path, byte[] data, List<ACL> acl,
    CreateMode createMode)
throws KeeperException, InterruptedException {
  TraceScope traceScope = null;
  try {
    traceScope = Trace.startSpan("RecoverableZookeeper.create");
    byte[] newData = appendMetaData(data);
    switch (createMode) {
      case EPHEMERAL:
      case PERSISTENT:
        return createNonSequential(path, newData, acl, createMode);

      case EPHEMERAL_SEQUENTIAL:
      case PERSISTENT_SEQUENTIAL:
        return createSequential(path, newData, acl, createMode);

      default:
        throw new IllegalArgumentException("Unrecognized CreateMode: " +
            createMode);
    }
  } finally {
    if (traceScope != null) traceScope.close();
  }
}
 
开发者ID:grokcoder,项目名称:pbase,代码行数:40,代码来源:RecoverableZooKeeper.java

示例11: getAcl

import org.apache.htrace.Trace; //导入方法依赖的package包/类
/**
 * getAcl is an idempotent operation. Retry before throwing exception
 * @return list of ACLs
 */
public List<ACL> getAcl(String path, Stat stat)
throws KeeperException, InterruptedException {
  TraceScope traceScope = null;
  try {
    traceScope = Trace.startSpan("RecoverableZookeeper.getAcl");
    RetryCounter retryCounter = retryCounterFactory.create();
    while (true) {
      try {
        return checkZk().getACL(path, stat);
      } catch (KeeperException e) {
        switch (e.code()) {
          case CONNECTIONLOSS:
          case SESSIONEXPIRED:
          case OPERATIONTIMEOUT:
            retryOrThrow(retryCounter, e, "getAcl");
            break;

          default:
            throw e;
        }
      }
      retryCounter.sleepUntilNextRetry();
    }
  } finally {
    if (traceScope != null) traceScope.close();
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:32,代码来源:RecoverableZooKeeper.java

示例12: getPathTraceScope

import org.apache.htrace.Trace; //导入方法依赖的package包/类
TraceScope getPathTraceScope(String description, String path) {
  TraceScope scope = Trace.startSpan(description, traceSampler);
  Span span = scope.getSpan();
  if (span != null) {
    if (path != null) {
      span.addKVAnnotation(PATH,
          path.getBytes(Charset.forName("UTF-8")));
    }
  }
  return scope;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:12,代码来源:DFSClient.java

示例13: getChildren

import org.apache.htrace.Trace; //导入方法依赖的package包/类
/**
 * 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 checkZk().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();
    }
  } finally {
    if (traceScope != null) traceScope.close();
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:32,代码来源:RecoverableZooKeeper.java

示例14: setBalancerBandwidth

import org.apache.htrace.Trace; //导入方法依赖的package包/类
/**
 * Requests the namenode to tell all datanodes to use a new, non-persistent
 * bandwidth value for dfs.balance.bandwidthPerSec.
 * See {@link ClientProtocol#setBalancerBandwidth(long)} 
 * for more details.
 * 
 * @see ClientProtocol#setBalancerBandwidth(long)
 */
public void setBalancerBandwidth(long bandwidth) throws IOException {
  TraceScope scope = Trace.startSpan("setBalancerBandwidth", traceSampler);
  try {
    namenode.setBalancerBandwidth(bandwidth);
  } finally {
    scope.close();
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:17,代码来源:DFSClient.java

示例15: setAcl

import org.apache.htrace.Trace; //导入方法依赖的package包/类
/**
 * setAcl is an idempotent operation. Retry before throwing exception
 * @return list of ACLs
 */
public Stat setAcl(String path, List<ACL> acls, int version)
throws KeeperException, InterruptedException {
  TraceScope traceScope = null;
  try {
    traceScope = Trace.startSpan("RecoverableZookeeper.setAcl");
    RetryCounter retryCounter = retryCounterFactory.create();
    while (true) {
      try {
        return checkZk().setACL(path, acls, version);
      } catch (KeeperException e) {
        switch (e.code()) {
          case CONNECTIONLOSS:
          case SESSIONEXPIRED:
          case OPERATIONTIMEOUT:
            retryOrThrow(retryCounter, e, "setAcl");
            break;

          default:
            throw e;
        }
      }
      retryCounter.sleepUntilNextRetry();
    }
  } finally {
    if (traceScope != null) traceScope.close();
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:32,代码来源:RecoverableZooKeeper.java


注:本文中的org.apache.htrace.Trace.startSpan方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。