当前位置: 首页>>代码示例>>Java>>正文


Java Stopwatch.stop方法代码示例

本文整理汇总了Java中com.netflix.servo.monitor.Stopwatch.stop方法的典型用法代码示例。如果您正苦于以下问题:Java Stopwatch.stop方法的具体用法?Java Stopwatch.stop怎么用?Java Stopwatch.stop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.netflix.servo.monitor.Stopwatch的用法示例。


在下文中一共展示了Stopwatch.stop方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: sendNow

import com.netflix.servo.monitor.Stopwatch; //导入方法依赖的package包/类
private void sendNow(UpdateTasks updateTasks) {
    if (updateTasks.numMetrics == 0) {
        return;
    }
    pushSizeCount.increment();
    pushSizeTotal.increment(updateTasks.numMetrics);

    final Stopwatch s = updateTimer.start();
    int totalSent = 0;
    try {
        totalSent = RxHttp.sendAll(updateTasks.tasks, updateTasks.numMetrics, sendTimeoutMs);
        LOGGER.debug("Sent {}/{} metrics to atlas", totalSent, updateTasks.numMetrics);
    } finally {
        s.stop();
        int dropped = updateTasks.numMetrics - totalSent;
        numMetricsDroppedSendTimeout.increment(dropped);
    }
}
 
开发者ID:dmuino,项目名称:atlas-oss-plugin,代码行数:19,代码来源:BaseAtlasMetricObserver.java

示例2: execute

import com.netflix.servo.monitor.Stopwatch; //导入方法依赖的package包/类
@Override
public <T> T execute(
		final HttpHost target,
		final HttpRequest request,
		final ResponseHandler<? extends T> responseHandler,
		final HttpContext context)
				throws IOException, ClientProtocolException {
    Stopwatch sw = tracer.start();
	try{
		// TODO: replaced method.getQueryString() with request.getRequestLine().getUri()
		LOGGER.debug("Executing HTTP method: {}, uri: {}", request.getRequestLine().getMethod(), request.getRequestLine().getUri());
		return super.execute(target, request, responseHandler, context);
	}finally{
		sw.stop();
	}
}
 
开发者ID:Netflix,项目名称:ribbon,代码行数:17,代码来源:NFHttpClient.java

示例3: createEntry

import com.netflix.servo.monitor.Stopwatch; //导入方法依赖的package包/类
@Override
protected BasicPoolEntry createEntry(RouteSpecificPool rospl,
        ClientConnectionOperator op) {
    createEntryCounter.increment();
    Stopwatch stopWatch = creationTimer.start();
    try {
        return super.createEntry(rospl, op);
    } finally {
        stopWatch.stop();
    }
}
 
开发者ID:Netflix,项目名称:ribbon,代码行数:12,代码来源:NamedConnectionPool.java

示例4: getEntryBlocking

import com.netflix.servo.monitor.Stopwatch; //导入方法依赖的package包/类
@Override
protected BasicPoolEntry getEntryBlocking(HttpRoute route, Object state,
        long timeout, TimeUnit tunit, WaitingThreadAborter aborter)
        throws ConnectionPoolTimeoutException, InterruptedException {
    Stopwatch stopWatch = requestTimer.start();
    try {
        return super.getEntryBlocking(route, state, timeout, tunit, aborter);
    } finally {
        stopWatch.stop();
    }
}
 
开发者ID:Netflix,项目名称:ribbon,代码行数:12,代码来源:NamedConnectionPool.java

示例5: primeConnections

import com.netflix.servo.monitor.Stopwatch; //导入方法依赖的package包/类
/**
 * Prime connections, blocking until configured percentage (default is 100%) of target servers are primed 
 * or max time is reached.
 * 
 * @see CommonClientConfigKey#MinPrimeConnectionsRatio
 * @see CommonClientConfigKey#MaxTotalTimeToPrimeConnections
 * 
 */
public void primeConnections(List<Server> servers) {
    if (servers == null || servers.size() == 0) {
        logger.debug("No server to prime");
        return;
    }
    for (Server server: servers) {
        server.setReadyToServe(false);
    }
    int totalCount = (int) (servers.size() * primeRatio); 
    final CountDownLatch latch = new CountDownLatch(totalCount);
    final AtomicInteger successCount = new AtomicInteger(0);
    final AtomicInteger failureCount= new AtomicInteger(0);
    primeConnectionsAsync(servers, new PrimeConnectionListener()  {            
        @Override
        public void primeCompleted(Server s, Throwable lastException) {
            if (lastException == null) {
                successCount.incrementAndGet();
                s.setReadyToServe(true);
            } else {
                failureCount.incrementAndGet();
            }
            latch.countDown();
        }
    }); 
            
    Stopwatch stopWatch = initialPrimeTimer.start();
    try {
        latch.await(maxTotalTimeToPrimeConnections, TimeUnit.MILLISECONDS);
    } catch (InterruptedException e) {
        logger.error("Priming connection interrupted", e);
    } finally {
        stopWatch.stop();
    }

    stats = new PrimeConnectionEndStats(totalCount, successCount.get(), failureCount.get(), stopWatch.getDuration(TimeUnit.MILLISECONDS));

    printStats(stats);
}
 
开发者ID:Netflix,项目名称:ribbon,代码行数:47,代码来源:PrimeConnections.java

示例6: delete

import com.netflix.servo.monitor.Stopwatch; //导入方法依赖的package包/类
public OperationFuture<Boolean> delete(String key, EVCacheLatch evcacheLatch) {
    final CountDownLatch latch = new CountDownLatch(1);
    final OperationFuture<Boolean> rv = new OperationFuture<Boolean>(key, latch, connectionFactory.getOperationTimeout(), executorService);
    final Stopwatch operationDuration = getTimer(DELETE_STRING).start();
    final DeleteOperation.Callback callback = new DeleteOperation.Callback() {
        @Override
        public void receivedStatus(OperationStatus status) {
            operationDuration.stop();
            rv.set(Boolean.TRUE, status);
            if (status.getStatusCode().equals(StatusCode.SUCCESS)) {
                getCounter(DELETE_OPERATION_SUCCESS_STRING).increment();
            } else {
                getCounter("DeleteOperation-"+ status.getStatusCode().name()).increment();
            }
        }

        @Override
        public void gotData(long cas) {
            rv.setCas(cas);
        }

        @Override
        public void complete() {
            latch.countDown();
            rv.signalComplete();
        }
    };

    final DeleteOperation op = opFact.delete(key, callback);
    rv.setOperation(op);
    if (evcacheLatch != null && evcacheLatch instanceof EVCacheLatchImpl && !client.isInWriteOnly()) ((EVCacheLatchImpl) evcacheLatch).addFuture(rv);
    mconn.enqueueOperation(key, op);
    return rv;
}
 
开发者ID:Netflix,项目名称:EVCache,代码行数:35,代码来源:EVCacheMemcachedClient.java

示例7: incr

import com.netflix.servo.monitor.Stopwatch; //导入方法依赖的package包/类
public long incr(String key, long by, long def, int exp) {
    final Stopwatch operationDuration = getTimer(INCR_OPERATION_STRING).start();
    long val = 0;
    try {
        val = mutate(Mutator.incr, key, by, def, exp);
    } finally {
        operationDuration.stop();
        if (log.isDebugEnabled()) log.debug("Increment Key : " + key + "; by : " + by + "; default : " + def + "; exp : " + exp 
                + "; val : " + val + "; Elapsed Time - " + operationDuration.getDuration(TimeUnit.MILLISECONDS));
    }
    return val;
}
 
开发者ID:Netflix,项目名称:EVCache,代码行数:13,代码来源:EVCacheMemcachedClient.java

示例8: decr

import com.netflix.servo.monitor.Stopwatch; //导入方法依赖的package包/类
public long decr(String key, long by, long def, int exp) {
    final Stopwatch operationDuration = getTimer(DECR_OPERATION_STRING).start();
    long val = 0;
    try {
        val = super.decr(key, by, def, exp);
    } finally {
        operationDuration.stop();
        if (log.isDebugEnabled()) log.debug("decrement Key : " + key + "; by : " + by + "; default : " + def + "; exp : " + exp 
                + "; val : " + val + "; Elapsed Time - " + (operationDuration.getDuration(TimeUnit.MILLISECONDS)));
    }
    return val;
}
 
开发者ID:Netflix,项目名称:EVCache,代码行数:13,代码来源:EVCacheMemcachedClient.java

示例9: pollForTask

import com.netflix.servo.monitor.Stopwatch; //导入方法依赖的package包/类
private void pollForTask(Worker worker) {
	
	if(ec != null && !ec.getInstanceRemoteStatus().equals(InstanceStatus.UP)) {
		logger.debug("Instance is NOT UP in discovery - will not poll");
		return;
	}
	
	if(worker.paused()) {
		WorkflowTaskMetrics.paused(worker.getTaskDefName());
		logger.debug("Worker {} has been paused. Not polling anymore!", worker.getClass());
		return;
	}
	String domain = PropertyFactory.getString(worker.getTaskDefName(), DOMAIN, null);		
	if(domain == null){
		domain = PropertyFactory.getString(ALL_WORKERS, DOMAIN, null);		
	}
	logger.debug("Polling {}, domain={}, count = {} timeout = {} ms", worker.getTaskDefName(), domain, worker.getPollCount(), worker.getLongPollTimeoutInMS());
	
	try{

           // get the remaining capacity of worker queue to prevent queue full exception
           int realPollCount = Math.min(workerQueue.remainingCapacity(), worker.getPollCount());
           if (realPollCount <= 0) {
			logger.warn("All workers are busy, not polling.  queue size {}, max {}", workerQueue.size(), workerQueueSize);
			return;
           }
		String taskType = worker.getTaskDefName();
		Stopwatch sw = WorkflowTaskMetrics.pollTimer(worker.getTaskDefName());
		List<Task> tasks = client.poll(taskType, domain, worker.getIdentity(), realPollCount, worker.getLongPollTimeoutInMS());
           sw.stop();
           logger.debug("Polled {}, for domain {} and received {} tasks", worker.getTaskDefName(), domain, tasks.size());
           for(Task task : tasks) {
			es.submit(() -> {
				try {
					execute(worker, task);
				} catch (Throwable t) {
					task.setStatus(Task.Status.FAILED);
					TaskResult result = new TaskResult(task);
					handleException(t, result, worker, true, task);
				}
			});
		}

	}catch(RejectedExecutionException qfe) {
		WorkflowTaskMetrics.queueFull(worker.getTaskDefName());
		logger.error("Execution queue is full", qfe);
	} catch (Exception e) {
		WorkflowTaskMetrics.pollingException(worker.getTaskDefName(), e);
		logger.error("Error when polling for task " + e.getMessage(), e);
	}
}
 
开发者ID:Netflix,项目名称:conductor,代码行数:52,代码来源:WorkflowTaskCoordinator.java


注:本文中的com.netflix.servo.monitor.Stopwatch.stop方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。