Search in sources :

Example 51 with TraceScope

use of org.apache.htrace.core.TraceScope in project hadoop by apache.

the class Receiver method opReleaseShortCircuitFds.

/** Receive {@link Op#RELEASE_SHORT_CIRCUIT_FDS} */
private void opReleaseShortCircuitFds(DataInputStream in) throws IOException {
    final ReleaseShortCircuitAccessRequestProto proto = ReleaseShortCircuitAccessRequestProto.parseFrom(vintPrefixed(in));
    TraceScope traceScope = continueTraceSpan(proto.getTraceInfo(), proto.getClass().getSimpleName());
    try {
        releaseShortCircuitFds(PBHelperClient.convert(proto.getSlotId()));
    } finally {
        if (traceScope != null)
            traceScope.close();
    }
}
Also used : TraceScope(org.apache.htrace.core.TraceScope) ReleaseShortCircuitAccessRequestProto(org.apache.hadoop.hdfs.protocol.proto.DataTransferProtos.ReleaseShortCircuitAccessRequestProto)

Example 52 with TraceScope

use of org.apache.htrace.core.TraceScope in project hadoop by apache.

the class Receiver method opReplaceBlock.

/** Receive OP_REPLACE_BLOCK */
private void opReplaceBlock(DataInputStream in) throws IOException {
    OpReplaceBlockProto proto = OpReplaceBlockProto.parseFrom(vintPrefixed(in));
    TraceScope traceScope = continueTraceSpan(proto.getHeader(), proto.getClass().getSimpleName());
    try {
        replaceBlock(PBHelperClient.convert(proto.getHeader().getBlock()), PBHelperClient.convertStorageType(proto.getStorageType()), PBHelperClient.convert(proto.getHeader().getToken()), proto.getDelHint(), PBHelperClient.convert(proto.getSource()));
    } finally {
        if (traceScope != null)
            traceScope.close();
    }
}
Also used : OpReplaceBlockProto(org.apache.hadoop.hdfs.protocol.proto.DataTransferProtos.OpReplaceBlockProto) TraceScope(org.apache.htrace.core.TraceScope)

Example 53 with TraceScope

use of org.apache.htrace.core.TraceScope in project hadoop by apache.

the class Receiver method opWriteBlock.

/** Receive OP_WRITE_BLOCK */
private void opWriteBlock(DataInputStream in) throws IOException {
    final OpWriteBlockProto proto = OpWriteBlockProto.parseFrom(vintPrefixed(in));
    final DatanodeInfo[] targets = PBHelperClient.convert(proto.getTargetsList());
    TraceScope traceScope = continueTraceSpan(proto.getHeader(), proto.getClass().getSimpleName());
    try {
        writeBlock(PBHelperClient.convert(proto.getHeader().getBaseHeader().getBlock()), PBHelperClient.convertStorageType(proto.getStorageType()), PBHelperClient.convert(proto.getHeader().getBaseHeader().getToken()), proto.getHeader().getClientName(), targets, PBHelperClient.convertStorageTypes(proto.getTargetStorageTypesList(), targets.length), PBHelperClient.convert(proto.getSource()), fromProto(proto.getStage()), proto.getPipelineSize(), proto.getMinBytesRcvd(), proto.getMaxBytesRcvd(), proto.getLatestGenerationStamp(), fromProto(proto.getRequestedChecksum()), (proto.hasCachingStrategy() ? getCachingStrategy(proto.getCachingStrategy()) : CachingStrategy.newDefaultStrategy()), (proto.hasAllowLazyPersist() ? proto.getAllowLazyPersist() : false), (proto.hasPinning() ? proto.getPinning() : false), (PBHelperClient.convertBooleanList(proto.getTargetPinningsList())));
    } finally {
        if (traceScope != null)
            traceScope.close();
    }
}
Also used : DatanodeInfo(org.apache.hadoop.hdfs.protocol.DatanodeInfo) TraceScope(org.apache.htrace.core.TraceScope) OpWriteBlockProto(org.apache.hadoop.hdfs.protocol.proto.DataTransferProtos.OpWriteBlockProto)

Example 54 with TraceScope

use of org.apache.htrace.core.TraceScope in project hadoop by apache.

the class TestTracing method readWithTracing.

private void readWithTracing(Tracer tracer) throws Exception {
    long startTime = System.currentTimeMillis();
    TraceScope ts = tracer.newScope("testReadTraceHooks");
    readTestFile("testReadTraceHooks.dat");
    ts.close();
    long endTime = System.currentTimeMillis();
    String[] expectedSpanNames = { "testReadTraceHooks", "ClientProtocol#getBlockLocations", "ClientNamenodeProtocol#getBlockLocations", "OpReadBlockProto" };
    SetSpanReceiver.assertSpanNamesFound(expectedSpanNames);
    // The trace should last about the same amount of time as the test
    Map<String, List<Span>> map = SetSpanReceiver.getMap();
    Span s = map.get("testReadTraceHooks").get(0);
    Assert.assertNotNull(s);
    long spanStart = s.getStartTimeMillis();
    long spanEnd = s.getStopTimeMillis();
    Assert.assertTrue(spanStart - startTime < 100);
    Assert.assertTrue(spanEnd - endTime < 100);
    // top trace.
    for (Span span : SetSpanReceiver.getSpans()) {
        System.out.println(span.toJson());
    }
    for (Span span : SetSpanReceiver.getSpans()) {
        Assert.assertEquals(ts.getSpan().getSpanId().getHigh(), span.getSpanId().getHigh());
    }
    SetSpanReceiver.clear();
}
Also used : TraceScope(org.apache.htrace.core.TraceScope) List(java.util.List) Span(org.apache.htrace.core.Span)

Aggregations

TraceScope (org.apache.htrace.core.TraceScope)54 IOException (java.io.IOException)11 InterruptedIOException (java.io.InterruptedIOException)7 MultipleIOException (org.apache.hadoop.io.MultipleIOException)6 RemoteException (org.apache.hadoop.ipc.RemoteException)5 FileNotFoundException (java.io.FileNotFoundException)4 SnapshotAccessControlException (org.apache.hadoop.hdfs.protocol.SnapshotAccessControlException)4 UnresolvedPathException (org.apache.hadoop.hdfs.protocol.UnresolvedPathException)4 AccessControlException (org.apache.hadoop.security.AccessControlException)4 ClosedChannelException (java.nio.channels.ClosedChannelException)3 FileAlreadyExistsException (org.apache.hadoop.fs.FileAlreadyExistsException)3 ParentNotDirectoryException (org.apache.hadoop.fs.ParentNotDirectoryException)3 DSQuotaExceededException (org.apache.hadoop.hdfs.protocol.DSQuotaExceededException)3 NSQuotaExceededException (org.apache.hadoop.hdfs.protocol.NSQuotaExceededException)3 QuotaByStorageTypeExceededException (org.apache.hadoop.hdfs.protocol.QuotaByStorageTypeExceededException)3 Tracer (org.apache.htrace.core.Tracer)3 ByteBuffer (java.nio.ByteBuffer)2 List (java.util.List)2 EventBatch (org.apache.hadoop.hdfs.inotify.EventBatch)2 DatanodeInfo (org.apache.hadoop.hdfs.protocol.DatanodeInfo)2