Package com.google.common.base

Examples of com.google.common.base.Stopwatch.elapsedMillis()


    }

    public void waitForProcessEnd(final String processInstanceId, int timeoutInMilliseconds) throws Exception {
        Stopwatch stopwatch = new Stopwatch().start();
        while (isProcessNotEnded(processInstanceId)) {
            if (stopwatch.elapsedMillis() > timeoutInMilliseconds) {
                throw new TimeoutException(String.format("Process %s not ended in %d milliseconds.",
                    processInstanceId, timeoutInMilliseconds));
            }
            LOG.info(String.format("Process instance %s not ended. Waiting 1s.", processInstanceId));
            TimeUnit.SECONDS.sleep(1);
View Full Code Here


            PoolTemplate.class.getCanonicalName(), null);
        tracker.open(true);

        try {
            Stopwatch stopwatch = new Stopwatch().start();
            while (stopwatch.elapsedMillis() < timeoutInMilliseconds) {
                for (Object candidate : tracker.getServices()) {
                    if (PoolTemplate.class.cast(candidate).getId().equals(templateId)) {
                        return PoolTemplate.class.cast(candidate);
                    }
                }
View Full Code Here

                }
                TimeUnit.MILLISECONDS.sleep(100);
            }

            throw new TimeoutException(String.format("Status check timed out after %d milliseconds",
                stopwatch.elapsedMillis()));

        } finally {
            tracker.close();
        }
    }
View Full Code Here

    txMetricsCollector.gauge("start.short", 1);
    Stopwatch timer = new Stopwatch().start();
    long currentTime = System.currentTimeMillis();
    long expiration = currentTime + 1000L * timeoutInSeconds;
    Transaction tx = startTx(expiration);
    txMetricsCollector.gauge("start.short.latency", (int) timer.elapsedMillis());
    return tx;
  }

  private long getNextWritePointer() {
    // We want to align tx ids with current time. We assume that tx ids are sequential, but not less than
View Full Code Here

   */
  public Transaction startLong() {
    txMetricsCollector.gauge("start.long", 1);
    Stopwatch timer = new Stopwatch().start();
    Transaction tx = startTx(-1);
    txMetricsCollector.gauge("start.long.latency", (int) timer.elapsedMillis());
    return tx;
  }

  private Transaction startTx(long expiration) {
    Transaction tx = null;
View Full Code Here

      }
      appendToLog(TransactionEdit.createCommitting(tx.getWritePointer(), set));
    } finally {
      this.logReadLock.unlock();
    }
    txMetricsCollector.gauge("canCommit.latency", (int) timer.elapsedMillis());
    return true;
  }

  private void addCommittingChangeSet(long writePointer, Set<ChangeId> changes) {
    committingChangeSets.put(writePointer, changes);
View Full Code Here

      }
      appendToLog(TransactionEdit.createCommitted(tx.getWritePointer(), changeSet, commitPointer, addToCommitted));
    } finally {
      this.logReadLock.unlock();
    }
    txMetricsCollector.gauge("commit.latency", (int) timer.elapsedMillis());
    return true;
  }

  private void doCommit(long writePointer, Set<ChangeId> changes, long commitPointer, boolean addToCommitted) {
    // In case this method is called when loading a previous WAL, we need to remove the tx from these sets
View Full Code Here

      synchronized (this) {
        ensureAvailable();
        doAbort(tx.getWritePointer());
      }
      appendToLog(TransactionEdit.createAborted(tx.getWritePointer()));
      txMetricsCollector.gauge("abort.latency", (int) timer.elapsedMillis());
    } finally {
      this.logReadLock.unlock();
    }
  }
View Full Code Here

      synchronized (this) {
        ensureAvailable();
        success = doInvalidate(tx);
      }
      appendToLog(TransactionEdit.createInvalid(tx));
      txMetricsCollector.gauge("invalidate.latency", (int) timer.elapsedMillis());
      return success;
    } finally {
      this.logReadLock.unlock();
    }
  }
View Full Code Here

  private void appendToLog(TransactionEdit edit) {
    try {
      Stopwatch timer = new Stopwatch().start();
      currentLog.append(edit);
      txMetricsCollector.gauge("append.edit", (int) timer.elapsedMillis());
    } catch (IOException ioe) {
      abortService("Error appending to transaction log", ioe);
    }
  }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.