Beispiel #1
0
 // when any constructor of java.lang.Throwable returns
 // print the currentException's stack trace.
 @OnMethod(clazz = "java.lang.Throwable", method = "<init>", location = @Location(Kind.RETURN))
 public static void onthrowreturn() {
   if (currentException != null) {
     Threads.jstack(currentException);
     println("=====================");
     currentException = null;
   }
 }
Beispiel #2
0
 // Copied from ConnectionImplementation.getBatchPool()
 // We should get rid of this when Connection.processBatchCallback is un-deprecated and provides
 // an API to manage a batch pool
 private void createBatchPool(Configuration conf) {
   // Use the same config for keep alive as in ConnectionImplementation.getBatchPool();
   int maxThreads = conf.getInt("hbase.multihconnection.threads.max", 256);
   if (maxThreads == 0) {
     maxThreads = Runtime.getRuntime().availableProcessors() * 8;
   }
   long keepAliveTime = conf.getLong("hbase.multihconnection.threads.keepalivetime", 60);
   LinkedBlockingQueue<Runnable> workQueue =
       new LinkedBlockingQueue<>(
           maxThreads
               * conf.getInt(
                   HConstants.HBASE_CLIENT_MAX_TOTAL_TASKS,
                   HConstants.DEFAULT_HBASE_CLIENT_MAX_TOTAL_TASKS));
   ThreadPoolExecutor tpe =
       new ThreadPoolExecutor(
           maxThreads,
           maxThreads,
           keepAliveTime,
           TimeUnit.SECONDS,
           workQueue,
           Threads.newDaemonThreadFactory("MultiHConnection" + "-shared-"));
   tpe.allowCoreThreadTimeOut(true);
   this.batchPool = tpe;
 }
Beispiel #3
0
 public void waitForFinish() {
   while (numThreadsWorking.get() != 0) {
     Threads.sleepWithoutInterrupt(1000);
   }
   close();
 }
Beispiel #4
0
    @Override
    public void run() {
      long startTime = System.currentTimeMillis();
      long priorNumKeys = 0;
      long priorCumulativeOpTime = 0;
      int priorAverageKeysPerSecond = 0;

      // Give other threads time to start.
      Threads.sleep(REPORTING_INTERVAL_MS);

      while (numThreadsWorking.get() != 0) {
        String threadsLeft = "[" + reporterId + ":" + numThreadsWorking.get() + "] ";
        if (numKeys.get() == 0) {
          LOG.info(threadsLeft + "Number of keys = 0");
        } else {
          long numKeys = MultiThreadedAction.this.numKeys.get();
          long time = System.currentTimeMillis() - startTime;
          long totalOpTime = totalOpTimeMs.get();

          long numKeysDelta = numKeys - priorNumKeys;
          long totalOpTimeDelta = totalOpTime - priorCumulativeOpTime;

          double averageKeysPerSecond = (time > 0) ? (numKeys * 1000 / time) : 0;

          LOG.info(
              threadsLeft
                  + "Keys="
                  + numKeys
                  + ", cols="
                  + StringUtils.humanReadableInt(numCols.get())
                  + ", time="
                  + formatTime(time)
                  + ((numKeys > 0 && time > 0)
                      ? (" Overall: ["
                          + "keys/s= "
                          + numKeys * 1000 / time
                          + ", latency="
                          + totalOpTime / numKeys
                          + " ms]")
                      : "")
                  + ((numKeysDelta > 0)
                      ? (" Current: ["
                          + "keys/s="
                          + numKeysDelta * 1000 / REPORTING_INTERVAL_MS
                          + ", latency="
                          + totalOpTimeDelta / numKeysDelta
                          + " ms]")
                      : "")
                  + progressInfo());

          if (streamingCounters) {
            printStreamingCounters(numKeysDelta, averageKeysPerSecond - priorAverageKeysPerSecond);
          }

          priorNumKeys = numKeys;
          priorCumulativeOpTime = totalOpTime;
          priorAverageKeysPerSecond = (int) averageKeysPerSecond;
        }

        Threads.sleep(REPORTING_INTERVAL_MS);
      }
    }