List of usage examples for org.joda.time DateTime now
public static DateTime now()
ISOChronology
in the default time zone. From source file:com.facebook.presto.execution.SqlTaskManager.java
License:Apache License
public void failAbandonedTasks() { DateTime now = DateTime.now(); DateTime oldestAllowedHeartbeat = now.minus(clientTimeout.toMillis()); for (TaskExecution taskExecution : tasks.values()) { try {//from www . j a v a 2 s.c o m TaskInfo taskInfo = taskExecution.getTaskInfo(); if (taskInfo.getState().isDone()) { continue; } DateTime lastHeartbeat = taskInfo.getLastHeartbeat(); if (lastHeartbeat != null && lastHeartbeat.isBefore(oldestAllowedHeartbeat)) { log.info("Failing abandoned task %s", taskExecution.getTaskId()); taskExecution.fail(new AbandonedException("Task " + taskInfo.getTaskId(), lastHeartbeat, now)); // trigger caching getTaskInfo(taskExecution); } } catch (RuntimeException e) { log.warn(e, "Error while inspecting age of task %s", taskExecution.getTaskId()); } } }
From source file:com.facebook.presto.execution.StageStateMachine.java
License:Apache License
public synchronized boolean transitionToScheduled() { schedulingComplete.compareAndSet(null, DateTime.now()); return stageState.setIf(SCHEDULED, currentState -> currentState == PLANNED || currentState == SCHEDULING || currentState == SCHEDULING_SPLITS); }
From source file:com.facebook.presto.operator.DriverContext.java
License:Apache License
public void start() { if (!startNanos.compareAndSet(0, System.nanoTime())) { // already started return;// w w w .j av a 2s .co m } pipelineContext.start(); executionStartTime.set(DateTime.now()); }
From source file:com.facebook.presto.operator.DriverContext.java
License:Apache License
public void finished() { if (!finished.compareAndSet(false, true)) { // already finished return;//from ww w . j av a 2s.c om } executionEndTime.set(DateTime.now()); endNanos.set(System.nanoTime()); pipelineContext.driverFinished(this); }
From source file:com.facebook.presto.operator.DriverStats.java
License:Apache License
public DriverStats() { this.createTime = DateTime.now(); this.startTime = null; this.endTime = null; this.queuedTime = new Duration(0, MILLISECONDS); this.elapsedTime = new Duration(0, MILLISECONDS); this.memoryReservation = new DataSize(0, BYTE); this.totalScheduledTime = new Duration(0, MILLISECONDS); this.totalCpuTime = new Duration(0, MILLISECONDS); this.totalUserTime = new Duration(0, MILLISECONDS); this.totalBlockedTime = new Duration(0, MILLISECONDS); this.rawInputDataSize = new DataSize(0, BYTE); this.rawInputPositions = 0; this.rawInputReadTime = new Duration(0, MILLISECONDS); this.processedInputDataSize = new DataSize(0, BYTE); this.processedInputPositions = 0; this.outputDataSize = new DataSize(0, BYTE); this.outputPositions = 0; this.operatorStats = ImmutableList.of(); }
From source file:com.facebook.presto.operator.HttpPageBufferClient.java
License:Apache License
@Override public void close() { boolean shouldSendDelete; Future<?> future;/* w w w .j ava 2s .com*/ synchronized (this) { shouldSendDelete = !closed; closed = true; future = this.future; this.future = null; lastUpdate = DateTime.now(); } if (future != null) { future.cancel(true); } // abort the output buffer on the remote node; response of delete is ignored if (shouldSendDelete) { httpClient.executeAsync(prepareDelete().setUri(location).build(), createStatusResponseHandler()); } }
From source file:com.facebook.presto.operator.HttpPageBufferClient.java
License:Apache License
public synchronized void scheduleRequest() { if (closed || (future != null) || scheduled) { return;// w w w . java2 s . c o m } scheduled = true; // start before scheduling to include error delay errorStopwatch.start(); executor.schedule(new Runnable() { @Override public void run() { try { initiateRequest(); } catch (Throwable t) { // should not happen, but be safe and fail the operator clientCallback.clientFailed(HttpPageBufferClient.this, t); } } }, errorDelayMillis, TimeUnit.MILLISECONDS); lastUpdate = DateTime.now(); requestsScheduled.incrementAndGet(); }
From source file:com.facebook.presto.operator.HttpPageBufferClient.java
License:Apache License
private synchronized void initiateRequest() { scheduled = false;/*from www. j ava 2s . co m*/ if (closed || (future != null)) { return; } final URI uri = HttpUriBuilder.uriBuilderFrom(location).appendPath(String.valueOf(token)).build(); future = httpClient.executeAsync( prepareGet().setHeader(PRESTO_MAX_SIZE, maxResponseSize.toString()).setUri(uri).build(), new PageResponseHandler(blockEncodingSerde)); Futures.addCallback(future, new FutureCallback<PagesResponse>() { @Override public void onSuccess(PagesResponse result) { if (Thread.holdsLock(HttpPageBufferClient.this)) { log.error("Can not handle callback while holding a lock on this"); } resetErrors(); requestsCompleted.incrementAndGet(); List<Page> pages; synchronized (HttpPageBufferClient.this) { if (result.getToken() == token) { pages = result.getPages(); token = result.getNextToken(); } else { pages = ImmutableList.of(); } } // add pages for (Page page : pages) { pagesReceived.incrementAndGet(); clientCallback.addPage(HttpPageBufferClient.this, page); } // complete request or close client if (result.isClientClosed()) { synchronized (HttpPageBufferClient.this) { closed = true; future = null; lastUpdate = DateTime.now(); } clientCallback.clientFinished(HttpPageBufferClient.this); } else { synchronized (HttpPageBufferClient.this) { future = null; lastUpdate = DateTime.now(); } clientCallback.requestComplete(HttpPageBufferClient.this); } } @Override public void onFailure(Throwable t) { log.debug("Request to %s failed %s", uri, t); if (Thread.holdsLock(HttpPageBufferClient.this)) { log.error("Can not handle callback while holding a lock on this"); } t = rewriteException(t); if (t instanceof PrestoException) { clientCallback.clientFailed(HttpPageBufferClient.this, t); } Duration errorDuration = elapsedErrorDuration(); if (errorDuration.compareTo(minErrorDuration) > 0) { String message = format("Requests to %s failed for %s", uri, errorDuration); clientCallback.clientFailed(HttpPageBufferClient.this, new PageTransportTimeoutException(message, t)); } increaseErrorDelay(); requestsFailed.incrementAndGet(); requestsCompleted.incrementAndGet(); synchronized (HttpPageBufferClient.this) { future = null; lastUpdate = DateTime.now(); } clientCallback.requestComplete(HttpPageBufferClient.this); } }, executor); lastUpdate = DateTime.now(); }
From source file:com.facebook.presto.operator.PipelineContext.java
License:Apache License
public void driverFinished(DriverContext driverContext) { requireNonNull(driverContext, "driverContext is null"); if (!drivers.remove(driverContext)) { throw new IllegalArgumentException("Unknown driver " + driverContext); }// w ww .j ava2 s.c om // always update last execution end time lastExecutionEndTime.set(DateTime.now()); DriverStats driverStats = driverContext.getDriverStats(); completedDrivers.getAndIncrement(); queuedTime.add(driverStats.getQueuedTime().roundTo(NANOSECONDS)); elapsedTime.add(driverStats.getElapsedTime().roundTo(NANOSECONDS)); totalScheduledTime.getAndAdd(driverStats.getTotalScheduledTime().roundTo(NANOSECONDS)); totalCpuTime.getAndAdd(driverStats.getTotalCpuTime().roundTo(NANOSECONDS)); totalUserTime.getAndAdd(driverStats.getTotalUserTime().roundTo(NANOSECONDS)); totalBlockedTime.getAndAdd(driverStats.getTotalBlockedTime().roundTo(NANOSECONDS)); // merge the operator stats into the operator summary List<OperatorStats> operators = driverStats.getOperatorStats(); for (OperatorStats operator : operators) { // TODO: replace with ConcurrentMap.compute() when we migrate to java 8 OperatorStats updated; OperatorStats current; do { current = operatorSummaries.get(operator.getOperatorId()); if (current != null) { updated = current.add(operator); } else { updated = operator; } } while (!compareAndSet(operatorSummaries, operator.getOperatorId(), current, updated)); } rawInputDataSize.update(driverStats.getRawInputDataSize().toBytes()); rawInputPositions.update(driverStats.getRawInputPositions()); processedInputDataSize.update(driverStats.getProcessedInputDataSize().toBytes()); processedInputPositions.update(driverStats.getProcessedInputPositions()); outputDataSize.update(driverStats.getOutputDataSize().toBytes()); outputPositions.update(driverStats.getOutputPositions()); }
From source file:com.facebook.presto.operator.PipelineContext.java
License:Apache License
public void start() { DateTime now = DateTime.now(); executionStartTime.compareAndSet(null, now); // always update last execution start time lastExecutionStartTime.set(now);/*from w w w.j a v a 2s . c om*/ taskContext.start(); }