• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java TraceScope类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



TraceScope类属于org.apache.htrace包,在下文中一共展示了TraceScope类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: newStreamForAppend

import org.apache.htrace.TraceScope; //导入依赖的package包/类
static DFSOutputStream newStreamForAppend(DFSClient dfsClient, String src,
    EnumSet<CreateFlag> flags, int bufferSize, Progressable progress,
    LocatedBlock lastBlock, HdfsFileStatus stat, DataChecksum checksum,
    String[] favoredNodes) throws IOException {
  TraceScope scope =
      dfsClient.getPathTraceScope("newStreamForAppend", src);
  try {
    final DFSOutputStream out = new DFSOutputStream(dfsClient, src, flags,
        progress, lastBlock, stat, checksum);
    if (favoredNodes != null && favoredNodes.length != 0) {
      out.streamer.setFavoredNodes(favoredNodes);
    }
    out.start();
    return out;
  } finally {
    scope.close();
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:19,代码来源:DFSOutputStream.java


示例2: getFromOneDataNode

import org.apache.htrace.TraceScope; //导入依赖的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


示例3: testTimed

import org.apache.htrace.TraceScope; //导入依赖的package包/类
/**
 * Provides an extension point for tests that don't want a per row invocation.
 */
void testTimed() throws IOException, InterruptedException {
  int startRow = getStartRow();
  int lastRow = getLastRow();
  // Report on completion of 1/10th of total.
  for (int i = 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(startRow, i, lastRow));
    }
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:23,代码来源:PerformanceEvaluation.java


示例4: fillBuffer

import org.apache.htrace.TraceScope; //导入依赖的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:naver,项目名称:hadoop,代码行数:27,代码来源:BlockReaderLocalLegacy.java


示例5: opRequestShortCircuitFds

import org.apache.htrace.TraceScope; //导入依赖的package包/类
/** Receive {@link Op#REQUEST_SHORT_CIRCUIT_FDS} */
private void opRequestShortCircuitFds(DataInputStream in) throws IOException {
  final OpRequestShortCircuitAccessProto proto =
    OpRequestShortCircuitAccessProto.parseFrom(vintPrefixed(in));
  SlotId slotId = (proto.hasSlotId()) ? 
      PBHelper.convert(proto.getSlotId()) : null;
  TraceScope traceScope = continueTraceSpan(proto.getHeader(),
      proto.getClass().getSimpleName());
  try {
    requestShortCircuitFds(PBHelper.convert(proto.getHeader().getBlock()),
        PBHelper.convert(proto.getHeader().getToken()),
        slotId, proto.getMaxVersion(),
        proto.getSupportsReceiptVerification());
  } finally {
    if (traceScope != null) traceScope.close();
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:18,代码来源:Receiver.java


示例6: getBlockLocations

import org.apache.htrace.TraceScope; //导入依赖的package包/类
/**
 * Get block location info about file
 * 
 * getBlockLocations() returns a list of hostnames that store 
 * data for a specific file region.  It returns a set of hostnames
 * for every block within the indicated region.
 *
 * This function is very useful when writing code that considers
 * data-placement when performing operations.  For example, the
 * MapReduce system tries to schedule tasks on the same machines
 * as the data-block the task processes. 
 */
public BlockLocation[] getBlockLocations(String src, long start, 
      long length) throws IOException, UnresolvedLinkException {
  TraceScope scope = getPathTraceScope("getBlockLocations", src);
  try {
    LocatedBlocks blocks = getLocatedBlocks(src, start, length);
    BlockLocation[] locations =  DFSUtil.locatedBlocks2Locations(blocks);
    HdfsBlockLocation[] hdfsLocations = new HdfsBlockLocation[locations.length];
    for (int i = 0; i < locations.length; i++) {
      hdfsLocations[i] = new HdfsBlockLocation(locations[i], blocks.get(i));
    }
    return hdfsLocations;
  } finally {
    scope.close();
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:28,代码来源:DFSClient.java


示例7: createSymlink

import org.apache.htrace.TraceScope; //导入依赖的package包/类
/**
 * Creates a symbolic link.
 * 
 * @see ClientProtocol#createSymlink(String, String,FsPermission, boolean) 
 */
public void createSymlink(String target, String link, boolean createParent)
    throws IOException {
  TraceScope scope = getPathTraceScope("createSymlink", target);
  try {
    FsPermission dirPerm = 
        FsPermission.getDefault().applyUMask(dfsClientConf.uMask); 
    namenode.createSymlink(target, link, dirPerm, createParent);
  } catch (RemoteException re) {
    throw re.unwrapRemoteException(AccessControlException.class,
                                   FileAlreadyExistsException.class, 
                                   FileNotFoundException.class,
                                   ParentNotDirectoryException.class,
                                   NSQuotaExceededException.class, 
                                   DSQuotaExceededException.class,
                                   UnresolvedPathException.class,
                                   SnapshotAccessControlException.class);
  } finally {
    scope.close();
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:26,代码来源:DFSClient.java


示例8: call

import org.apache.htrace.TraceScope; //导入依赖的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:naver,项目名称:hadoop,代码行数:23,代码来源:BlockStorageLocationUtil.java


示例9: setStoragePolicy

import org.apache.htrace.TraceScope; //导入依赖的package包/类
/**
 * Set storage policy for an existing file/directory
 * @param src file/directory name
 * @param policyName name of the storage policy
 */
public void setStoragePolicy(String src, String policyName)
    throws IOException {
  TraceScope scope = getPathTraceScope("setStoragePolicy", src);
  try {
    namenode.setStoragePolicy(src, policyName);
  } catch (RemoteException e) {
    throw e.unwrapRemoteException(AccessControlException.class,
                                  FileNotFoundException.class,
                                  SafeModeException.class,
                                  NSQuotaExceededException.class,
                                  UnresolvedPathException.class,
                                  SnapshotAccessControlException.class);
  } finally {
    scope.close();
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:22,代码来源:DFSClient.java


示例10: rename

import org.apache.htrace.TraceScope; //导入依赖的package包/类
/**
 * Rename file or directory.
 * @see ClientProtocol#rename(String, String)
 * @deprecated Use {@link #rename(String, String, Options.Rename...)} instead.
 */
@Deprecated
public boolean rename(String src, String dst) throws IOException {
  checkOpen();
  TraceScope scope = getSrcDstTraceScope("rename", src, dst);
  try {
    return namenode.rename(src, dst);
  } catch(RemoteException re) {
    throw re.unwrapRemoteException(AccessControlException.class,
                                   NSQuotaExceededException.class,
                                   DSQuotaExceededException.class,
                                   UnresolvedPathException.class,
                                   SnapshotAccessControlException.class);
  } finally {
    scope.close();
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:22,代码来源:DFSClient.java


示例11: delete

import org.apache.htrace.TraceScope; //导入依赖的package包/类
/**
 * delete file or directory.
 * delete contents of the directory if non empty and recursive 
 * set to true
 *
 * @see ClientProtocol#delete(String, boolean)
 */
public boolean delete(String src, boolean recursive) throws IOException {
  checkOpen();
  TraceScope scope = getPathTraceScope("delete", src);
  try {
    return namenode.delete(src, recursive);
  } catch(RemoteException re) {
    throw re.unwrapRemoteException(AccessControlException.class,
                                   FileNotFoundException.class,
                                   SafeModeException.class,
                                   UnresolvedPathException.class,
                                   SnapshotAccessControlException.class);
  } finally {
    scope.close();
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:23,代码来源:DFSClient.java


示例12: setPermission

import org.apache.htrace.TraceScope; //导入依赖的package包/类
/**
 * Set permissions to a file or directory.
 * @param src path name.
 * @param permission permission to set to
 * 
 * @see ClientProtocol#setPermission(String, FsPermission)
 */
public void setPermission(String src, FsPermission permission)
    throws IOException {
  checkOpen();
  TraceScope scope = getPathTraceScope("setPermission", src);
  try {
    namenode.setPermission(src, permission);
  } catch(RemoteException re) {
    throw re.unwrapRemoteException(AccessControlException.class,
                                   FileNotFoundException.class,
                                   SafeModeException.class,
                                   UnresolvedPathException.class,
                                   SnapshotAccessControlException.class);
  } finally {
    scope.close();
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:24,代码来源:DFSClient.java


示例13: invoke

import org.apache.htrace.TraceScope; //导入依赖的package包/类
@Override
public Object invoke(Object proxy, Method method, Object[] args)
  throws Throwable {
  long startTime = 0;
  if (LOG.isDebugEnabled()) {
    startTime = Time.now();
  }
  TraceScope traceScope = null;
  if (Trace.isTracing()) {
    traceScope = Trace.startSpan(RpcClientUtil.methodToTraceString(method));
  }
  ObjectWritable value;
  try {
    value = (ObjectWritable)
      client.call(RPC.RpcKind.RPC_WRITABLE, new Invocation(method, args),
        remoteId, fallbackToSimpleAuth);
  } finally {
    if (traceScope != null) traceScope.close();
  }
  if (LOG.isDebugEnabled()) {
    long callTime = Time.now() - startTime;
    LOG.debug("Call: " + method.getName() + " " + callTime);
  }
  return value.get();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:26,代码来源:WritableRpcEngine.java


示例14: create

import org.apache.htrace.TraceScope; //导入依赖的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:fengchen8086,项目名称:ditb,代码行数:40,代码来源:RecoverableZooKeeper.java


示例15: modifyAclEntries

import org.apache.htrace.TraceScope; //导入依赖的package包/类
public void modifyAclEntries(String src, List<AclEntry> aclSpec)
    throws IOException {
  checkOpen();
  TraceScope scope = getPathTraceScope("modifyAclEntries", src);
  try {
    namenode.modifyAclEntries(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,代码行数:19,代码来源:DFSClient.java


示例16: removeAclEntries

import org.apache.htrace.TraceScope; //导入依赖的package包/类
public void removeAclEntries(String src, List<AclEntry> aclSpec)
    throws IOException {
  checkOpen();
  TraceScope scope = Trace.startSpan("removeAclEntries", traceSampler);
  try {
    namenode.removeAclEntries(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,代码行数:19,代码来源:DFSClient.java


示例17: removeDefaultAcl

import org.apache.htrace.TraceScope; //导入依赖的package包/类
public void removeDefaultAcl(String src) throws IOException {
  checkOpen();
  TraceScope scope = Trace.startSpan("removeDefaultAcl", traceSampler);
  try {
    namenode.removeDefaultAcl(src);
  } 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


示例18: removeAcl

import org.apache.htrace.TraceScope; //导入依赖的package包/类
public void removeAcl(String src) throws IOException {
  checkOpen();
  TraceScope scope = Trace.startSpan("removeAcl", traceSampler);
  try {
    namenode.removeAcl(src);
  } 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


示例19: setXAttr

import org.apache.htrace.TraceScope; //导入依赖的package包/类
public void setXAttr(String src, String name, byte[] value, 
    EnumSet<XAttrSetFlag> flag) throws IOException {
  checkOpen();
  TraceScope scope = getPathTraceScope("setXAttr", src);
  try {
    namenode.setXAttr(src, XAttrHelper.buildXAttr(name, value), flag);
  } catch (RemoteException re) {
    throw re.unwrapRemoteException(AccessControlException.class,
                                   FileNotFoundException.class,
                                   NSQuotaExceededException.class,
                                   SafeModeException.class,
                                   SnapshotAccessControlException.class,
                                   UnresolvedPathException.class);
  } finally {
    scope.close();
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:18,代码来源:DFSClient.java


示例20: removeXAttr

import org.apache.htrace.TraceScope; //导入依赖的package包/类
public void removeXAttr(String src, String name) throws IOException {
  checkOpen();
  TraceScope scope = getPathTraceScope("removeXAttr", src);
  try {
    namenode.removeXAttr(src, XAttrHelper.buildXAttr(name));
  } catch(RemoteException re) {
    throw re.unwrapRemoteException(AccessControlException.class,
                                   FileNotFoundException.class,
                                   NSQuotaExceededException.class,
                                   SafeModeException.class,
                                   SnapshotAccessControlException.class,
                                   UnresolvedPathException.class);
  } finally {
    scope.close();
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:17,代码来源:DFSClient.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java BindingMap类代码示例发布时间:2022-05-22
下一篇:
Java EMVideoMessageBody类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap