Java Code Examples for io.perfmark.PerfMark#linkIn()
The following examples show how to use
io.perfmark.PerfMark#linkIn() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NettyClientHandler.java From grpc-java with Apache License 2.0 | 6 votes |
/** * Cancels this stream. */ private void cancelStream(ChannelHandlerContext ctx, CancelClientStreamCommand cmd, ChannelPromise promise) { NettyClientStream.TransportState stream = cmd.stream(); PerfMark.startTask("NettyClientHandler.cancelStream", stream.tag()); PerfMark.linkIn(cmd.getLink()); try { Status reason = cmd.reason(); if (reason != null) { stream.transportReportStatus(reason, true, new Metadata()); } if (!cmd.stream().isNonExistent()) { encoder().writeRstStream(ctx, stream.id(), Http2Error.CANCEL.code(), promise); } else { promise.setSuccess(); } } finally { PerfMark.stopTask("NettyClientHandler.cancelStream", stream.tag()); } }
Example 2
Source File: BaseZuulFilterRunner.java From zuul with Apache License 2.0 | 6 votes |
@Override public void onNext(O outMesg) { boolean stopped = false; PerfMark.startTask(filter.filterName(), "onNextAsync"); try { PerfMark.linkIn(onNextLinkOut.get()); addPerfMarkTags(inMesg); recordFilterCompletion(SUCCESS, filter, startTime, inMesg, snapshot); if (outMesg == null) { outMesg = filter.getDefaultOutput(inMesg); } stopped = true; PerfMark.stopTask(filter.filterName(), "onNextAsync"); resumeInBindingContext(outMesg, filter.filterName()); } catch (Exception e) { decrementConcurrency(); handleException(inMesg, filter.filterName(), e); } finally { if (!stopped) { PerfMark.stopTask(filter.filterName(), "onNextAsync"); } } }
Example 3
Source File: ServerImpl.java From grpc-java with Apache License 2.0 | 5 votes |
@Override public void onReady() { PerfMark.startTask("ServerStreamListener.onReady", tag); final Link link = PerfMark.linkOut(); final class OnReady extends ContextRunnable { OnReady() { super(context); } @Override public void runInContext() { PerfMark.startTask("ServerCallListener(app).onReady", tag); PerfMark.linkIn(link); try { getListener().onReady(); } catch (Throwable t) { internalClose(t); throw t; } finally { PerfMark.stopTask("ServerCallListener(app).onReady", tag); } } } try { callExecutor.execute(new OnReady()); } finally { PerfMark.stopTask("ServerStreamListener.onReady", tag); } }
Example 4
Source File: BaseZuulFilterRunner.java From zuul with Apache License 2.0 | 5 votes |
private Action0 onCompletedStarted(Link onCompletedLinkIn) { return () -> { PerfMark.startTask(filter.filterName(), "onCompleted"); try { PerfMark.linkIn(onCompletedLinkIn); onCompletedLinkOut.compareAndSet(null, PerfMark.linkOut()); } finally { PerfMark.stopTask(filter.filterName(), "onCompleted"); } }; }
Example 5
Source File: BaseZuulFilterRunner.java From zuul with Apache License 2.0 | 5 votes |
private Action1<Throwable> onErrorStarted(Link onErrorLinkIn) { return t -> { PerfMark.startTask(filter.filterName(), "onError"); try { PerfMark.linkIn(onErrorLinkIn); onErrorLinkOut.compareAndSet(null, PerfMark.linkOut()); } finally { PerfMark.stopTask(filter.filterName(), "onError"); } }; }
Example 6
Source File: BaseZuulFilterRunner.java From zuul with Apache License 2.0 | 5 votes |
private Action1<O> onNextStarted(Link onNextLinkIn) { return o -> { PerfMark.startTask(filter.filterName(), "onNext"); try { PerfMark.linkIn(onNextLinkIn); onNextLinkOut.compareAndSet(null, PerfMark.linkOut()); } finally { PerfMark.stopTask(filter.filterName(), "onNext"); } }; }
Example 7
Source File: BaseZuulFilterRunner.java From zuul with Apache License 2.0 | 5 votes |
@Override public void onCompleted() { PerfMark.startTask(filter.filterName(), "onCompletedAsync"); try { PerfMark.linkIn(onCompletedLinkOut.get( )); decrementConcurrency(); } finally { PerfMark.stopTask(filter.filterName(), "onCompletedAsync"); } }
Example 8
Source File: BaseZuulFilterRunner.java From zuul with Apache License 2.0 | 5 votes |
@Override public void onError(Throwable ex) { PerfMark.startTask(filter.filterName(), "onErrorAsync"); try { PerfMark.linkIn(onErrorLinkOut.get()); decrementConcurrency(); recordFilterCompletion(FAILED, filter, startTime, inMesg, snapshot); final O outMesg = handleFilterException(inMesg, filter, ex); resumeInBindingContext(outMesg, filter.filterName()); } catch (Exception e) { handleException(inMesg, filter.filterName(), e); } finally { PerfMark.stopTask(filter.filterName(), "onErrorAsync"); } }
Example 9
Source File: AbstractStream.java From grpc-java with Apache License 2.0 | 5 votes |
/** * Called to request the given number of messages from the deframer. May be called from any * thread. */ private void requestMessagesFromDeframer(final int numMessages) { if (deframer instanceof ThreadOptimizedDeframer) { PerfMark.startTask("AbstractStream.request"); try { deframer.request(numMessages); } finally { PerfMark.stopTask("AbstractStream.request"); } return; } final Link link = PerfMark.linkOut(); class RequestRunnable implements Runnable { @Override public void run() { PerfMark.startTask("AbstractStream.request"); PerfMark.linkIn(link); try { deframer.request(numMessages); } catch (Throwable t) { deframeFailed(t); } finally { PerfMark.stopTask("AbstractStream.request"); } } } runOnTransportThread(new RequestRunnable()); }
Example 10
Source File: PerfMarkTransformerTest.java From perfmark with Apache License 2.0 | 5 votes |
@Test public void transform_link() throws Exception { PerfMark.setEnabled(true); Storage.resetForTest(); final class ClzLocal { public ClzLocal() { PerfMark.startTask("task"); Link link = PerfMark.linkOut(); PerfMark.linkIn(link); PerfMark.stopTask("task"); } } Class<?> clz = transformAndLoad(ClzLocal.class); Constructor<?> ctor = clz.getConstructor(PerfMarkTransformerTest.class); ctor.setAccessible(true); ctor.newInstance(this); List<Mark> marks = Storage.readForTest(); assertThat(marks).hasSize(4); for (Mark mark : marks) { assertNotNull(mark.getMarker()); StackTraceElement element = Internal.getElement(mark.getMarker()); assertThat(element.getClassName()).isEqualTo(ClzLocal.class.getName()); assertThat(element.getMethodName()).isEqualTo("<init>"); assertThat(element.getFileName()).isEqualTo("PerfMarkTransformerTest.java"); assertThat(element.getLineNumber()).isGreaterThan(0); } }
Example 11
Source File: ServerImpl.java From grpc-java with Apache License 2.0 | 5 votes |
private void closedInternal(final Status status) { // For cancellations, promptly inform any users of the context that their work should be // aborted. Otherwise, we can wait until pending work is done. if (!status.isOk()) { // The callExecutor might be busy doing user work. To avoid waiting, use an executor that // is not serializing. cancelExecutor.execute(new ContextCloser(context, status.getCause())); } final Link link = PerfMark.linkOut(); final class Closed extends ContextRunnable { Closed() { super(context); } @Override public void runInContext() { PerfMark.startTask("ServerCallListener(app).closed", tag); PerfMark.linkIn(link); try { getListener().closed(status); } finally { PerfMark.stopTask("ServerCallListener(app).closed", tag); } } } callExecutor.execute(new Closed()); }
Example 12
Source File: ServerImpl.java From grpc-java with Apache License 2.0 | 5 votes |
@Override public void halfClosed() { PerfMark.startTask("ServerStreamListener.halfClosed", tag); final Link link = PerfMark.linkOut(); final class HalfClosed extends ContextRunnable { HalfClosed() { super(context); } @Override public void runInContext() { PerfMark.startTask("ServerCallListener(app).halfClosed", tag); PerfMark.linkIn(link); try { getListener().halfClosed(); } catch (Throwable t) { internalClose(t); throw t; } finally { PerfMark.stopTask("ServerCallListener(app).halfClosed", tag); } } } try { callExecutor.execute(new HalfClosed()); } finally { PerfMark.stopTask("ServerStreamListener.halfClosed", tag); } }
Example 13
Source File: ServerImpl.java From grpc-java with Apache License 2.0 | 5 votes |
@Override public void messagesAvailable(final MessageProducer producer) { PerfMark.startTask("ServerStreamListener.messagesAvailable", tag); final Link link = PerfMark.linkOut(); final class MessagesAvailable extends ContextRunnable { MessagesAvailable() { super(context); } @Override public void runInContext() { PerfMark.startTask("ServerCallListener(app).messagesAvailable", tag); PerfMark.linkIn(link); try { getListener().messagesAvailable(producer); } catch (Throwable t) { internalClose(t); throw t; } finally { PerfMark.stopTask("ServerCallListener(app).messagesAvailable", tag); } } } try { callExecutor.execute(new MessagesAvailable()); } finally { PerfMark.stopTask("ServerStreamListener.messagesAvailable", tag); } }
Example 14
Source File: NettyClientHandler.java From grpc-java with Apache License 2.0 | 5 votes |
private void sendPingFrame(ChannelHandlerContext ctx, SendPingCommand msg, ChannelPromise promise) { PerfMark.startTask("NettyClientHandler.sendPingFrame"); PerfMark.linkIn(msg.getLink()); try { sendPingFrameTraced(ctx, msg, promise); } finally { PerfMark.stopTask("NettyClientHandler.sendPingFrame"); } }
Example 15
Source File: NettyClientHandler.java From grpc-java with Apache License 2.0 | 5 votes |
/** * Sends the given GRPC frame for the stream. */ private void sendGrpcFrame(ChannelHandlerContext ctx, SendGrpcFrameCommand cmd, ChannelPromise promise) { PerfMark.startTask("NettyClientHandler.sendGrpcFrame", cmd.stream().tag()); PerfMark.linkIn(cmd.getLink()); try { // Call the base class to write the HTTP/2 DATA frame. // Note: no need to flush since this is handled by the outbound flow controller. encoder().writeData(ctx, cmd.stream().id(), cmd.content(), 0, cmd.endStream(), promise); } finally { PerfMark.stopTask("NettyClientHandler.sendGrpcFrame", cmd.stream().tag()); } }
Example 16
Source File: NettyServerHandler.java From grpc-java with Apache License 2.0 | 5 votes |
private void cancelStream(ChannelHandlerContext ctx, CancelServerStreamCommand cmd, ChannelPromise promise) { PerfMark.startTask("NettyServerHandler.cancelStream", cmd.stream().tag()); PerfMark.linkIn(cmd.getLink()); try { // Notify the listener if we haven't already. cmd.stream().transportReportStatus(cmd.reason()); // Terminate the stream. encoder().writeRstStream(ctx, cmd.stream().id(), Http2Error.CANCEL.code(), promise); } finally { PerfMark.stopTask("NettyServerHandler.cancelStream", cmd.stream().tag()); } }
Example 17
Source File: NettyServerHandler.java From grpc-java with Apache License 2.0 | 5 votes |
/** * Sends the given gRPC frame to the client. */ private void sendGrpcFrame(ChannelHandlerContext ctx, SendGrpcFrameCommand cmd, ChannelPromise promise) throws Http2Exception { PerfMark.startTask("NettyServerHandler.sendGrpcFrame", cmd.stream().tag()); PerfMark.linkIn(cmd.getLink()); try { if (cmd.endStream()) { closeStreamWhenDone(promise, cmd.stream().id()); } // Call the base class to write the HTTP/2 DATA frame. encoder().writeData(ctx, cmd.stream().id(), cmd.content(), 0, cmd.endStream(), promise); } finally { PerfMark.stopTask("NettyServerHandler.sendGrpcFrame", cmd.stream().tag()); } }
Example 18
Source File: ClientCallImpl.java From grpc-java with Apache License 2.0 | 4 votes |
@Override public void headersRead(final Metadata headers) { PerfMark.startTask("ClientStreamListener.headersRead", tag); final Link link = PerfMark.linkOut(); final class HeadersRead extends ContextRunnable { HeadersRead() { super(context); } @Override public void runInContext() { PerfMark.startTask("ClientCall$Listener.headersRead", tag); PerfMark.linkIn(link); try { runInternal(); } finally { PerfMark.stopTask("ClientCall$Listener.headersRead", tag); } } private void runInternal() { if (closed) { return; } try { observer.onHeaders(headers); } catch (Throwable t) { Status status = Status.CANCELLED.withCause(t).withDescription("Failed to read headers"); stream.cancel(status); close(status, new Metadata()); } } } try { callExecutor.execute(new HeadersRead()); } finally { PerfMark.stopTask("ClientStreamListener.headersRead", tag); } }
Example 19
Source File: ClientCallImpl.java From grpc-java with Apache License 2.0 | 4 votes |
@Override public void onReady() { if (method.getType().clientSendsOneMessage()) { return; } PerfMark.startTask("ClientStreamListener.onReady", tag); final Link link = PerfMark.linkOut(); final class StreamOnReady extends ContextRunnable { StreamOnReady() { super(context); } @Override public void runInContext() { PerfMark.startTask("ClientCall$Listener.onReady", tag); PerfMark.linkIn(link); try { runInternal(); } finally { PerfMark.stopTask("ClientCall$Listener.onReady", tag); } } private void runInternal() { try { observer.onReady(); } catch (Throwable t) { Status status = Status.CANCELLED.withCause(t).withDescription("Failed to call onReady."); stream.cancel(status); close(status, new Metadata()); } } } try { callExecutor.execute(new StreamOnReady()); } finally { PerfMark.stopTask("ClientStreamListener.onReady", tag); } }