通知下一个minTimestamp数据出队列

@throws InterruptedException
423746
private void single(long timestamp) throws InterruptedException {
        lastTimestamps.add(timestamp);

        if (timestamp < state()) {
            // 针对mysql事务中会出现时间跳跃
            // 例子：
            // 2012-08-08 16:24:26 事务头
            // 2012-08-08 16:24:24 变更记录
            // 2012-08-08 16:24:25 变更记录
            // 2012-08-08 16:24:26　事务尾

            // 针对这种case，一旦发现timestamp有回退的情况，直接更新threshold，强制阻塞其他的操作，等待最小数据优先处理完成
            threshold = timestamp; // 更新为最小值
        }

        if (lastTimestamps.size() >= groupSize) {// 判断队列是否需要触发
            // 触发下一个出队列的数据
            Long minTimestamp = this.lastTimestamps.peek();
            if (minTimestamp != null) {
                threshold = minTimestamp;
                notify(minTimestamp);
            }
        } else {
            threshold = Long.MIN_VALUE;// 如果不满足队列长度，需要阻塞等待
        }
    }
684808
public void awaitTermination() throws InterruptedException {
      lock.lock();
      try {
         while (!isDone) {
            done.await();
         }
      } finally {
         isDone = false;
         lock.unlock();
      }
   }
999472
synchronized public void shutdown() throws InterruptedException, KeeperException {
        m_shutdown = true;
        es.shutdown();
        es.awaitTermination(365, TimeUnit.DAYS);
    }
80332
@Override
    public V poll(long timeout, TimeUnit unit) throws InterruptedException {
        return get(pollAsync(timeout, unit));
    }
811340
private void marshalUpdatedTimestamp() {
    PropertyMetadata updatedTimestampMetadata = entityMetadata.getUpdatedTimestampMetadata();
    if (updatedTimestampMetadata != null) {
      applyAutoTimestamp(updatedTimestampMetadata, System.currentTimeMillis());
    }
  }
196068
private final void sleepTill(long future) throws InterruptedException {
        long milliseconds = future - logicalClockMillis();
        if (milliseconds > 0) {
            Thread.sleep(milliseconds);
        }
    }
1096531
private void sleepUntilAsyncSet() {
    LOG.info("Sleep a while until asynchronously set persistent timestamp");
    while (isAsyncSetPersistentTimestamp) {
      try {
        Thread.sleep(1);
      } catch (InterruptedException e) {
        LOG.fatal("Interrupt when sleep to set persistent timestamp, exit immediately");
        System.exit(0);
      }
    }
  }
732342
public function getCreatedAtTimestamp(): ?int
    {
        if (!$this->hasCreatedAt()) {
            return null;
        }

	    $timestamp = strtotime($this->getCreatedAt() . 'UTC');

	    if ($timestamp === false) {
		    throw new Exception("Unable to get timestamp from \"{$this->getCreatedAt()}\"");
	    }

	    return $timestamp;
    }
1330260
public void stopLeaseMonitor() throws InterruptedException {
    if (lmmonitor != null) {
      lmmonitor.stop();
      InjectionHandler
          .processEvent(InjectionEvent.FSNAMESYSTEM_STOP_LEASEMANAGER);
    }
    if (lmthread != null) {
      // interrupt the lease monitor thread. We need to make sure the
      // interruption does not happen during
      // LeaseManager.checkLeases(), which would possibly interfere with writing
      // to edit log, and hence with clean shutdown. It essential during
      // failover, as it could exclude edit log streams!!!
      writeLock();
      try {
        lmthread.interrupt();
      } finally {
        writeUnlock();
      }
      lmthread.join();
    }
  }
841434
public static void main(String[] args) throws IOException, InterruptedException {
    // Register the view. It is imperative that this step exists,
    // otherwise recorded metrics will be dropped and never exported.
    View view =
        View.create(
            Name.create("task_latency_distribution"),
            "The distribution of the task latencies.",
            LATENCY_MS,
            Aggregation.Distribution.create(LATENCY_BOUNDARIES),
            Collections.<TagKey>emptyList());

    // Create the view manager
    ViewManager viewManager = Stats.getViewManager();

    // Then finally register the views
    viewManager.registerView(view);

    // [START setup_exporter]
    // Enable OpenCensus exporters to export metrics to Stackdriver Monitoring.
    // Exporters use Application Default Credentials to authenticate.
    // See https://developers.google.com/identity/protocols/application-default-credentials
    // for more details.
    StackdriverStatsExporter.createAndRegister();
    // [END setup_exporter]

    // Record 100 fake latency values between 0 and 5 seconds.
    Random rand = new Random();
    for (int i = 0; i < 100; i++) {
      long ms = (long) (TimeUnit.MILLISECONDS.convert(5, TimeUnit.SECONDS) * rand.nextDouble());
      System.out.println(String.format("Latency %d: %d", i, ms));
      STATS_RECORDER.newMeasureMap().put(LATENCY_MS, ms).record();
    }

    // The default export interval is 60 seconds. The thread with the StackdriverStatsExporter must
    // live for at least the interval past any metrics that must be collected, or some risk being
    // lost if they are recorded after the last export.

    System.out.println(
        String.format(
            "Sleeping %d seconds before shutdown to ensure all records are flushed.",
            EXPORT_INTERVAL));
    Thread.sleep(TimeUnit.MILLISECONDS.convert(EXPORT_INTERVAL, TimeUnit.SECONDS));
  }
749341
public static void sleep(long millis) throws InterruptedException {
        while (millis > 0) {
            // abort if the user kills mlcp in local mode
            String shutdown = System.getProperty("mlcp.shutdown");
            if (shutdown != null) {
                break;
            }
            if (millis > 1000) {
                Thread.sleep(1000);
                millis -= 1000;
            } else {
                Thread.sleep(millis);
                millis = 0;
            }
        }
    }
25528
public static void sleep(int milliseconds) {

        try {
            Thread.sleep(milliseconds);
        } catch (InterruptedException e) {
            QuickUtils.log.e("Interrupted exception", e);
        }
    }
5286
public void runQueryWithTimestampParameters() throws InterruptedException {
    // [START bigquery_query_params_timestamps]
    // BigQuery bigquery = BigQueryOptions.getDefaultInstance().getService();
    ZonedDateTime timestamp = LocalDateTime.of(2016, 12, 7, 8, 0, 0).atZone(ZoneOffset.UTC);
    String query = "SELECT TIMESTAMP_ADD(@ts_value, INTERVAL 1 HOUR);";
    // Note: Standard SQL is required to use query parameters.
    QueryJobConfiguration queryConfig =
        QueryJobConfiguration.newBuilder(query)
            .addNamedParameter(
                "ts_value",
                QueryParameterValue.timestamp(
                    // Timestamp takes microseconds since 1970-01-01T00:00:00 UTC
                    timestamp.toInstant().toEpochMilli() * 1000))
            .build();

    // Print the results.
    DateTimeFormatter formatter = DateTimeFormatter.ISO_INSTANT.withZone(ZoneOffset.UTC);
    for (FieldValueList row : bigquery.query(queryConfig).iterateAll()) {
      System.out.printf(
          "%s\n",
          formatter.format(
              Instant.ofEpochMilli(
                      // Timestamp values are returned in microseconds since 1970-01-01T00:00:00
                      // UTC,
                      // but org.joda.time.DateTime constructor accepts times in milliseconds.
                      row.get(0).getTimestampValue() / 1000)
                  .atOffset(ZoneOffset.UTC)));
      System.out.printf("\n");
    }
    // [END bigquery_query_params_timestamps]
  }
696583
public void shrink()
        throws InterruptedException
    {
        if (_running==0)
            return;

        synchronized(this)
        {
            // If we have a maxIdleTime, then only shrink once per period.
            if (_maxIdleTimeMs>0)
            {
                long now=System.currentTimeMillis();
                if ((now-_lastShrink)<_maxIdleTimeMs)
                    return; // don't shrink
                _lastShrink=now;
            }
            
            // shrink if we are running and have available threads and we are above minimal size
            if (_running>0 && _available>0 && _size>_min)
                stopPondLife(_index[--_available]);
        }
    }
195428
@SuppressWarnings("PMD.GuardLogStatement")
    public W acquire() throws InterruptedException {
        // Stop draining, because we obviously need this kind of buffers
        Optional.ofNullable(idleTimer.getAndSet(null)).ifPresent(
            timer -> timer.cancel());
        if (createdBufs.get() < maximumBufs) {
            // Haven't reached maximum, so if no buffer is queued, create one.
            W buffer = queue.poll();
            if (buffer != null) {
                buffer.lockBuffer();
                return buffer;
            }
            return createBuffer();
        }
        // Wait for buffer to become available.
        if (logger.isLoggable(Level.FINE)) {
            // If configured, log message after waiting some time.
            W buffer = queue.poll(acquireWarningLimit, TimeUnit.MILLISECONDS);
            if (buffer != null) {
                buffer.lockBuffer();
                return buffer;
            }
            logger.log(Level.FINE, new Throwable(),
                () -> Thread.currentThread().getName() + " waiting > "
                    + acquireWarningLimit + "ms for buffer, while executing:");
        }
        W buffer = queue.take();
        buffer.lockBuffer();
        return buffer;
    }
591276
@Override
    public void setTimestamp(int parameterIndex, Timestamp x) throws SQLException {
        internalStmt.setTimestamp(parameterIndex, x);
    }
768978
@Override
    public void waitForData(long timeout, TimeUnit timeUnit) throws CouldNotPerformException, InterruptedException {
        try {
            if (isDataAvailable()) {
                return;
            }
            long startTime = System.currentTimeMillis();
            getDataFuture().get(timeout, timeUnit);
            long partialTimeout = timeUnit.toMillis(timeout) - (System.currentTimeMillis() - startTime);
            if (partialTimeout <= 0) {
                throw new java.util.concurrent.TimeoutException("Data timeout is reached!");
            }
            dataObservable.waitForValue(partialTimeout, TimeUnit.MILLISECONDS);
        } catch (java.util.concurrent.TimeoutException | CouldNotPerformException | ExecutionException | CancellationException ex) {
            if (shutdownInitiated) {
                throw new InterruptedException("Interrupt request because system shutdown was initiated!");
            }
            throw new NotAvailableException("Data is not yet available!", ex);
        }
    }