List of usage examples for org.springframework.util StopWatch shortSummary
public String shortSummary()
From source file:org.axonframework.samples.trader.infra.util.ProfilingAspect.java
@Around("methodsToBeProfiled()") public Object profile(ProceedingJoinPoint pjp) throws Throwable { StopWatch sw = new StopWatch(getClass().getSimpleName()); try {/*ww w . ja va2 s.c o m*/ sw.start(pjp.getSignature().getName()); return pjp.proceed(); } finally { sw.stop(); System.out.println(sw.getLastTaskName() + sw.shortSummary()); } }
From source file:com.si.xe.trader.infra.util.ProfilingAspect.java
@Around("methodsToBeProfiled()") public Object profile(ProceedingJoinPoint pjp) throws Throwable { StopWatch sw = new StopWatch(getClass().getSimpleName()); try {/*from ww w . j a v a2 s.c o m*/ sw.start(pjp.getSignature().getName()); return pjp.proceed(); } finally { sw.stop(); System.out.println(sw.getLastTaskName() + sw.shortSummary()); } }
From source file:com.create.aop.LoggingAspect.java
private Object logPerformance(ProceedingJoinPoint joinPoint, Logger logger, String watchId) throws Throwable { final StopWatch stopWatch = new StopWatch(watchId); stopWatch.start(watchId);//ww w . ja v a2 s.com try { return joinPoint.proceed(); } finally { stopWatch.stop(); logger.trace(stopWatch.shortSummary()); } }
From source file:com.emc.smartcomm.UregApplication.java
/** * @param register A SmartRegister instance *//*from w ww .ja v a 2s . com*/ public void uregApplication(SmartRegister register) { logger.info("Processing UREG Tranasctional Flow:"); GrsiRequest greq = PopulateData.setGrsiRequest(); GrsiResponse grsiResponse = PopulateData.setGrsiResponse(); BabProtocolRequest breq = PopulateData.setBabRequest(); BabProtocolResponse bres = PopulateData.setBabResponse(); ValidateRegRequest vreg = PopulateData.setValidateRegRequest(); ValidateRegResponse vres = PopulateData.setValidateRegResponse(); greq.setSvcFlag(register.getChannel()); String msg = register.toString(); String path = "/appl/LogTransaction.txt"; Timestamp txStartTime = PrepareLog.getCurrentTimeStamp(); StopWatch sw = new StopWatch("UREG Transaction"); sw.start("UREG Transaction"); logger.debug("UREG Transaction Initiated:{}", txStartTime); StopWatch sw0 = new StopWatch("UREG REQUEST"); sw0.start("UREG REQUEST"); uregTemplate.convertAndSend(msg); sw0.stop(); logger.debug(sw0.prettyPrint()); logger.debug(sw0.shortSummary()); StopWatch sw1 = new StopWatch("GRSI Request"); sw1.start("GRSI Request"); grsiTemplate.convertAndSend(greq); sw1.stop(); logger.debug(sw1.prettyPrint()); logger.debug(sw1.shortSummary()); if ("PVS".equals(grsiResponse.getsx12())) // || "BAB".equals(grsiResponse.getsx13())) { StopWatch sw2 = new StopWatch("Validate Request:"); sw2.start("Validate Request:"); String validateRegText = vreg.toString(); validateRegTemplate.convertAndSend(validateRegText); sw2.stop(); logger.debug(sw2.prettyPrint()); logger.debug(sw2.shortSummary()); } if ("PPC".equals(grsiResponse.getsx03())) { StopWatch sw3 = new StopWatch("BAB Request"); sw3.start("BAB Request:"); babTemplate.convertAndSend("bab.Request", breq.toString()); sw3.stop(); logger.debug(sw3.prettyPrint()); logger.debug(sw3.shortSummary()); } grsiResponse.setsx03("NSN"); if ("NSN".equals(grsiResponse.getsx03())) { InputStream is = getClass().getResourceAsStream("/mock/SOAPProtocolRecharge.txt"); String message = FileReader.readFile(is); StopWatch sw4 = new StopWatch("SOAP Recharge Request: "); sw4.start("SOAP Recharge Request:"); soapRechargeTemplate.convertAndSend(message); sw4.stop(); logger.debug(sw4.prettyPrint()); logger.debug(sw4.shortSummary()); } Timestamp txEndTime = PrepareLog.getCurrentTimeStamp(); logger.debug("Persisting Transaction log in gemxd and oracle"); LogTransaction logTransaction = PrepareLog.prepareLog(greq, grsiResponse, breq, bres, vreg, vres); logTransaction.setTxnStartTime(txStartTime); logTransaction.setTxnEndTime(txEndTime); StopWatch sw5 = new StopWatch("Transaction Persistence: "); sw5.start("Transaction Persistence:"); logTransactionService.logTransaction(logTransaction); sw5.stop(); logger.debug(sw5.prettyPrint()); logger.debug(sw5.shortSummary()); ExternalFileWriter.writeToFile(path, PopulateData.populateLog()); sw.stop(); logger.debug(sw.prettyPrint()); logger.debug(sw.shortSummary()); logger.debug("UREG Transaction is Completed:{}", txEndTime); logger.info("UREG Transaction TimeSpan:{}", (txEndTime.getTime() - txStartTime.getTime())); }
From source file:my.adam.smo.client.Client.java
public BlockingRpcChannel blockingConnect(final InetSocketAddress sa) { return new BlockingRpcChannel() { private int countDownCallTimesToRelease = 1; private RpcChannel rpc = connect(sa); @Override// www . ja v a 2 s . co m public Message callBlockingMethod(Descriptors.MethodDescriptor method, RpcController controller, Message request, Message responsePrototype) throws ServiceException { StopWatch stopWatch = new StopWatch("callBlockingMethod"); stopWatch.start(); final CountDownLatch callbackLatch = new CountDownLatch(countDownCallTimesToRelease); final AtomicReference<Message> result = new AtomicReference<Message>(); RpcCallback<Message> done = new RpcCallback<Message>() { @Override public void run(Message parameter) { result.set(parameter); callbackLatch.countDown(); } }; rpc.callMethod(method, controller, request, responsePrototype, done); try { boolean succeededBeforeTimeout = callbackLatch.await(blocking_method_call_timeout, TimeUnit.SECONDS); if (!succeededBeforeTimeout) { throw new ServiceException( "blocking method timeout reached for method:" + method.getFullName()); } } catch (InterruptedException e) { getLogger().error("call failed", e); stopWatch.stop(); } stopWatch.stop(); getLogger().trace(stopWatch.shortSummary()); return result.get(); } }; }
From source file:edu.isistan.carcha.lsa.TraceabilityComparator.java
/** * Run./*from ww w . j a v a 2 s. c o m*/ * * @param builder the Vector builder to construct vector using the sspace * @param reqConcerns the requirement concerns * @param archConcerns the architectural concerns */ @SuppressWarnings("unused") private void run(DocumentVectorBuilder builder, List<String> reqConcerns, List<String> archConcerns) { StopWatch sw = new StopWatch(); sw.start("Start the traceability comparation"); init(); int i = 0; int count = reqConcerns.size(); this.untracedCount = 0; for (String lineForVector1 : reqConcerns) { Entity req = Entity.buildFromString(lineForVector1, NodeType.CC); addNode(req); //create vector 1 DoubleVector vector1 = new CompactSparseVector(); vector1 = builder.buildVector(new BufferedReader(new StringReader(req.getFormattedLabel())), vector1); boolean hasTrace = false; for (String lineForVector2 : archConcerns) { Entity arch = Entity.buildFromString(lineForVector2, NodeType.DD); addNode(arch); //create vector 2 DoubleVector vector2 = new CompactSparseVector(); vector2 = builder.buildVector(new BufferedReader(new StringReader(arch.getFormattedLabel())), vector2); //Math round is WAY faster than DoubleFormat Double linkWeight = ((double) Math.round(Similarity.cosineSimilarity(vector1, vector2) * 1000) / 1000); //add the edge between the two nodes including the calculated weight if (linkWeight > threshold) { addEdge(req, arch, linkWeight); hasTrace = true; } } if (!hasTrace) { this.untracedCount++; } } sw.stop(); logger.info(sw.shortSummary()); String filename = saveGraph(); }
From source file:my.adam.smo.client.SocketClient.java
@Override public RpcChannel connect(final InetSocketAddress sa) { RpcChannel rpcChannel = new RpcChannel() { private Channel c = bootstrap.connect(sa).awaitUninterruptibly().getChannel(); @Override//from w w w . j a v a2s . c o m public void callMethod(Descriptors.MethodDescriptor method, RpcController controller, Message request, Message responsePrototype, RpcCallback<Message> done) { StopWatch stopWatch = new StopWatch("callMethod"); stopWatch.start(); long id = seqNum.addAndGet(1); logger.trace("calling method: " + method.getFullName()); //infinit reconnection loop while (reconnect && !c.isOpen()) { logger.debug("channel closed " + sa); logger.debug("trying to reconnect"); c.disconnect().awaitUninterruptibly(); c.unbind().awaitUninterruptibly(); c = bootstrap.connect(sa).awaitUninterruptibly().getChannel(); try { Thread.sleep(reconnect_delay * 1000); } catch (InterruptedException e) { logger.error("error while sleeping", e); } } RPCommunication.Request protoRequest = RPCommunication.Request.newBuilder() .setServiceName(method.getService().getFullName()).setMethodName(method.getName()) .setMethodArgument(request.toByteString()).setRequestId(id).build(); logger.trace("request built: " + request.toString()); if (enableSymmetricEncryption) { protoRequest = getEncryptedRequest(protoRequest); logger.trace("symmetric encryption enabled, encrypted request: " + protoRequest.toString()); } if (enableAsymmetricEncryption) { protoRequest = getAsymEncryptedRequest(protoRequest); logger.trace("asymmetric encryption enabled, encrypted request: " + protoRequest.toString()); } callbackMap.put(id, done); descriptorProtoMap.put(id, responsePrototype); c.write(protoRequest); logger.trace("request sent: " + protoRequest.toString()); stopWatch.stop(); logger.trace(stopWatch.shortSummary()); } }; logger.trace("connected to address: " + sa.toString()); return rpcChannel; }
From source file:my.adam.smo.client.HTTPClient.java
@Override public RpcChannel connect(final InetSocketAddress sa) { RpcChannel rpcChannel = new RpcChannel() { private Channel c = bootstrap.connect(sa).awaitUninterruptibly().getChannel(); @Override//from ww w . j av a2 s . c om public void callMethod(Descriptors.MethodDescriptor method, RpcController controller, Message request, Message responsePrototype, RpcCallback<Message> done) { StopWatch stopWatch = new StopWatch("callMethod"); stopWatch.start(); long id = seqNum.addAndGet(1); logger.trace("calling method: " + method.getFullName()); HttpRequest httpRequest = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, "http://" + sa.getHostName() + ":" + sa.getPort()); httpRequest.setHeader(HttpHeaders.Names.CONNECTION, HttpHeaders.Values.CLOSE); httpRequest.setHeader(HttpHeaders.Names.ACCEPT_ENCODING, HttpHeaders.Values.GZIP); httpRequest.setHeader(HttpHeaders.Names.CONTENT_TYPE, HttpHeaders.Values.APPLICATION_X_WWW_FORM_URLENCODED); RPCommunication.Request protoRequest = RPCommunication.Request.newBuilder() .setServiceName(method.getService().getFullName()).setMethodName(method.getName()) .setMethodArgument(request.toByteString()).setRequestId(id).build(); logger.trace("request built: " + request.toString()); if (enableSymmetricEncryption) { protoRequest = getEncryptedRequest(protoRequest); logger.trace("symmetric encryption enabled, encrypted request: " + protoRequest.toString()); } if (enableAsymmetricEncryption) { protoRequest = getAsymEncryptedRequest(protoRequest); logger.trace("asymmetric encryption enabled, encrypted request: " + protoRequest.toString()); } byte[] arr = protoRequest.toByteArray(); ChannelBuffer s = Base64.encode(ChannelBuffers.copiedBuffer(arr), Base64Dialect.STANDARD); httpRequest.setContent(s); httpRequest.addHeader(HttpHeaders.Names.CONTENT_LENGTH, s.readableBytes()); httpRequest.setChunked(false); callbackMap.put(id, done); descriptorProtoMap.put(id, responsePrototype); c.write(httpRequest); logger.trace("request sent: " + protoRequest.toString()); stopWatch.stop(); logger.trace(stopWatch.shortSummary()); } }; logger.trace("connected to address: " + sa.toString()); return rpcChannel; }
From source file:my.adam.smo.client.SocketClient.java
@Inject public SocketClient(@Value("${client_worker_threads:10}") int workerThreads) { bootstrap.setFactory(new NioClientSocketChannelFactory(Executors.newCachedThreadPool(), Executors.newCachedThreadPool(), workerThreads)); bootstrap.setPipelineFactory(new ChannelPipelineFactory() { @Override//from ww w . ja va2 s. com public ChannelPipeline getPipeline() throws Exception { StopWatch stopWatch = new StopWatch("getPipeline"); stopWatch.start(); ChannelPipeline p = Channels.pipeline(); if (enableTrafficLogging) { InternalLoggerFactory.setDefaultFactory(new Slf4JLoggerFactory()); p.addLast("logger", new LoggingHandler(InternalLogLevel.DEBUG)); } p.addLast("frameEncoder", new LengthFieldPrepender(4));//DownstreamHandler p.addLast("protobufEncoder", new ProtobufEncoder());//DownstreamHandler p.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(MAX_FRAME_BYTES_LENGTH, 0, 4, 0, 4));//UpstreamHandler p.addLast("protobufDecoder", new ProtobufDecoder(RPCommunication.Response.getDefaultInstance()));//UpstreamHandler p.addLast("handler", new SimpleChannelUpstreamHandler() { @Override public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception { StopWatch stopWatch = new StopWatch("messageReceived"); stopWatch.start(); RPCommunication.Response response = (RPCommunication.Response) e.getMessage(); logger.trace("received response:" + response); //encryption if (enableAsymmetricEncryption) { response = getAsymDecryptedResponse(response); logger.trace( "asymmetric encryption enabled, encrypted request: " + response.toString()); } if (enableSymmetricEncryption) { response = getDecryptedResponse(response); logger.trace("symmetric encryption enabled, encrypted request: " + response.toString()); } Message msg = descriptorProtoMap.remove(response.getRequestId()); Message m = msg.getParserForType().parseFrom(response.getResponse()); callbackMap.remove(response.getRequestId()).run(m); super.messageReceived(ctx, e); stopWatch.stop(); logger.trace(stopWatch.shortSummary()); } @Override public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception { if (!standardExceptionHandling(ctx, e)) { super.exceptionCaught(ctx, e); } } }); stopWatch.stop(); logger.trace(stopWatch.shortSummary()); return p; } }); }
From source file:my.adam.smo.client.HTTPClient.java
@Inject public HTTPClient(@Value("${client_worker_threads:10}") int workerThreads) { bootstrap.setFactory(new NioClientSocketChannelFactory(Executors.newCachedThreadPool(), Executors.newCachedThreadPool(), workerThreads)); bootstrap.setPipelineFactory(new ChannelPipelineFactory() { @Override//from w w w . jav a 2s . c om public ChannelPipeline getPipeline() throws Exception { StopWatch stopWatch = new StopWatch("getPipeline"); stopWatch.start(); ChannelPipeline p = Channels.pipeline(); if (enableTrafficLogging) { InternalLoggerFactory.setDefaultFactory(new Slf4JLoggerFactory()); p.addLast("logger", new LoggingHandler(InternalLogLevel.DEBUG)); } p.addLast("codec", new HttpClientCodec()); p.addLast("chunkAggregator", new HttpChunkAggregator(MAX_CONTENT_LENGTH)); p.addLast("chunkedWriter", new ChunkedWriteHandler()); p.addLast("decompressor", new HttpContentDecompressor()); p.addLast("handler", new SimpleChannelUpstreamHandler() { @Override public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception { StopWatch stopWatch = new StopWatch("messageReceived"); stopWatch.start(); HttpResponse httpResponse = (HttpResponse) e.getMessage(); ChannelBuffer cb = Base64.decode(httpResponse.getContent(), Base64Dialect.STANDARD); RPCommunication.Response response = RPCommunication.Response .parseFrom(CodedInputStream.newInstance(cb.copy(0, cb.readableBytes()).array())); logger.trace("received response:" + response); //encryption if (enableAsymmetricEncryption) { response = getAsymDecryptedResponse(response); logger.trace( "asymmetric encryption enabled, encrypted request: " + response.toString()); } if (enableSymmetricEncryption) { response = getDecryptedResponse(response); logger.trace("symmetric encryption enabled, encrypted request: " + response.toString()); } Message msg = descriptorProtoMap.remove(response.getRequestId()); Message m = msg.getParserForType().parseFrom(response.getResponse()); callbackMap.remove(response.getRequestId()).run(m); super.messageReceived(ctx, e); stopWatch.stop(); logger.trace(stopWatch.shortSummary()); } @Override public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception { if (!standardExceptionHandling(ctx, e)) { super.exceptionCaught(ctx, e); } } }); stopWatch.stop(); logger.trace(stopWatch.shortSummary()); return p; } }); }