Refine search
@Override public Entity create( UUID importId, String entityType, Map<String, Object> properties ) throws Exception { //Adding graphite metrics Timer.Context timeCassCreation = entCreateTimer.time(); Entity entity = batchCreate( entityType, null, properties, importId); timeCassCreation.stop(); return entity; }
private <T> T runWithMetrics(String opName, Function<Void,T> impl) { Preconditions.checkNotNull(opName); Preconditions.checkNotNull(impl); final MetricManager mgr = MetricManager.INSTANCE; mgr.getCounter(metricsPrefix, opName, M_CALLS).inc(); final Timer.Context tc = mgr.getTimer(metricsPrefix, opName, M_TIME).time(); try { return impl.apply(null); } catch (RuntimeException e) { mgr.getCounter(metricsPrefix, opName, M_EXCEPTIONS).inc(); throw e; } finally { tc.stop(); } } }
private List<byte[]> getQueuesToPersist(GetOperation getOperation) { Timer.Context timer = getQueuesTimer.time(); try { long maxTime = System.currentTimeMillis() - delayTimeUnit.toMillis(delayTime); return getOperation.getQueues(Key.getUserMessageQueueIndex(), maxTime, 100); } finally { timer.stop(); } }
public final RP sendRequest(RQ request) throws IOException { final Timer.Context context = sendTimer.time(); try { if (limiter.acquirePermits(1) != null) { log.debug ("Acquired permits successfully"); return sendRequestImpl (request); } else { throw new IOException ("Acquired permits return null"); } } catch (InterruptedException e) { throw new IOException("Throttling is interrupted"); } finally { context.stop(); } }
public final void sendAsyncRequest(RQ request, Callback<RP> callback) throws IOException { final Timer.Context context = sendTimer.time(); try { if (limiter.acquirePermits(1) != null) { log.debug ("Acquired permits successfully"); sendAsyncRequestImpl (request, callback); } else { throw new IOException ("Acquired permits return null"); } } catch (InterruptedException e) { throw new IOException("Throttling is interrupted"); } finally { context.stop(); } }
private void offerBatch(final List operations, AsyncEventQueueType queueType){ final Timer.Context timer = this.writeTimer.time(); try { //signal to SQS getQueue(queueType).sendMessages(operations); } catch (IOException e) { throw new RuntimeException("Unable to queue message", e); } finally { timer.stop(); } }
private void offerTopic(final Serializable operation, AsyncEventQueueType queueType) { final Timer.Context timer = this.writeTimer.time(); try { //signal to SQS getQueue(queueType).sendMessageToAllRegions(operation,null); } catch ( IOException e ) { throw new RuntimeException( "Unable to queue message", e ); } finally { timer.stop(); } }
public Optional<OutgoingMessageEntity> remove(String destination, long destinationDevice, String sender, long timestamp) { Timer.Context timer = removeByNameTimer.time(); try { byte[] serialized = removeOperation.remove(destination, destinationDevice, sender, timestamp); if (serialized != null) { Envelope envelope = Envelope.parseFrom(serialized); return Optional.of(constructEntityFromEnvelope(0, envelope)); } } catch (InvalidProtocolBufferException e) { logger.warn("Failed to parse envelope", e); } finally { timer.stop(); } return Optional.empty(); }
public Optional<OutgoingMessageEntity> remove(String destination, long destinationDevice, UUID guid) { Timer.Context timer = removeByGuidTimer.time(); try { byte[] serialized = removeOperation.remove(destination, destinationDevice, guid); if (serialized != null) { Envelope envelope = Envelope.parseFrom(serialized); return Optional.of(constructEntityFromEnvelope(0, envelope)); } } catch (InvalidProtocolBufferException e) { logger.warn("Failed to parse envelope", e); } finally { timer.stop(); } return Optional.empty(); }
@Override public void writeTo(View t, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream) throws IOException { final Timer.Context context = metricRegistry.timer(name(t.getClass(), "rendering")).time(); try { for (ViewRenderer renderer : renderers) { if (renderer.isRenderable(t)) { renderer.render(t, detectLocale(requireNonNull(headers)), entityStream); return; } } throw new ViewRenderException("Unable to find a renderer for " + t.getTemplateName()); } catch (ViewRenderException e) { throw new WebApplicationException(e); } finally { context.stop(); } }