java.util.concurrent.ThreadPoolExecutor.getLargestPoolSize()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(8.0k)|赞(0)|评价(0)|浏览(127)

本文整理了Java中java.util.concurrent.ThreadPoolExecutor.getLargestPoolSize()方法的一些代码示例,展示了ThreadPoolExecutor.getLargestPoolSize()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ThreadPoolExecutor.getLargestPoolSize()方法的具体详情如下:
包路径:java.util.concurrent.ThreadPoolExecutor
类名称:ThreadPoolExecutor
方法名:getLargestPoolSize

ThreadPoolExecutor.getLargestPoolSize介绍

[英]Returns the largest number of threads that have ever simultaneously been in the pool.
[中]返回池中同时存在的最大线程数。

代码示例

代码示例来源:origin: SonarSource/sonarqube

@Override
 public int getLargestWorkerCount() {
  return delegate.getLargestPoolSize();
 }
}

代码示例来源:origin: PipelineAI/pipeline

/**
 * Value from {@link ThreadPoolExecutor#getLargestPoolSize()}
 * 
 * @return Number
 */
public Number getCurrentLargestPoolSize() {
  return threadPool.getLargestPoolSize();
}

代码示例来源:origin: apache/hbase

@Override
public int getPoolLargestPoolSize() {
 return pool.getLargestPoolSize();
}

代码示例来源:origin: apache/ignite

/** {@inheritDoc} */
@Override public int getLargestPoolSize() {
  return exec instanceof ThreadPoolExecutor ? ((ThreadPoolExecutor)exec).getLargestPoolSize() : -1;
}

代码示例来源:origin: wildfly/wildfly

public int getLargestThreadCount() {
  return super.getLargestPoolSize();
}

代码示例来源:origin: jmxtrans/jmxtrans

@Override
public int getLargestPoolSize() {
  return executor.getLargestPoolSize();
}

代码示例来源:origin: apache/geode

@Override
public int getLargestPoolSize() {
 return super.getLargestPoolSize() + 1;
}

代码示例来源:origin: rapidoid/rapidoid

public int getLargestPoolSize() {
  return executor.getLargestPoolSize();
}

代码示例来源:origin: wildfly/wildfly

@ManagedAttribute(description="Largest number of threads in the internal thread pool")
public int getInternalThreadPoolSizeLargest() {
  if(internal_pool instanceof ThreadPoolExecutor)
    return ((ThreadPoolExecutor)internal_pool).getLargestPoolSize();
  return 0;
}

代码示例来源:origin: wildfly/wildfly

@ManagedAttribute(description="Largest number of threads in the thread pool")
public int getThreadPoolSizeLargest() {
  if(thread_pool instanceof ThreadPoolExecutor)
    return ((ThreadPoolExecutor)thread_pool).getLargestPoolSize();
  return 0;
}

代码示例来源:origin: alipay/sofa-rpc

@Override
  public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {
    if (LOGGER.isWarnEnabled()) {
      LOGGER.warn(LogCodes.getLog(LogCodes.ERROR_PROVIDER_TR_POOL_REJECTION, executor.getActiveCount(),
        executor.getPoolSize(), executor.getLargestPoolSize(), executor
          .getCorePoolSize(), executor.getMaximumPoolSize(), executor.getQueue()
          .size(), executor.getQueue().remainingCapacity()));
    }
    throw new RejectedExecutionException();
  }
}

代码示例来源:origin: apache/incubator-dubbo

@Override
public void rejectedExecution(Runnable r, ThreadPoolExecutor e) {
  String msg = String.format("Thread pool is EXHAUSTED!" +
          " Thread Name: %s, Pool Size: %d (active: %d, core: %d, max: %d, largest: %d), Task: %d (completed: %d)," +
          " Executor status:(isShutdown:%s, isTerminated:%s, isTerminating:%s), in %s://%s:%d!",
      threadName, e.getPoolSize(), e.getActiveCount(), e.getCorePoolSize(), e.getMaximumPoolSize(), e.getLargestPoolSize(),
      e.getTaskCount(), e.getCompletedTaskCount(), e.isShutdown(), e.isTerminated(), e.isTerminating(),
      url.getProtocol(), url.getIp(), url.getPort());
  logger.warn(msg);
  dumpJStack();
  throw new RejectedExecutionException(msg);
}

代码示例来源:origin: apache/incubator-dubbo

+ ", max:" + tp.getMaximumPoolSize()
+ ", core:" + tp.getCorePoolSize()
+ ", largest:" + tp.getLargestPoolSize()
+ ", active:" + tp.getActiveCount()
+ ", task:" + tp.getTaskCount()

代码示例来源:origin: alipay/sofa-rpc

@Override
  public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {
    if (LOGGER.isWarnEnabled()) {
      LOGGER.warn(LogCodes.getLog(LogCodes.ERROR_PROVIDER_TR_POOL_REJECTION, executor.getActiveCount(),
        executor.getPoolSize(), executor.getLargestPoolSize(), executor
          .getCorePoolSize(), executor.getMaximumPoolSize(), executor.getQueue()
          .size(), executor.getQueue().remainingCapacity()));
    }
    throw new RejectedExecutionException();
  }
}

代码示例来源:origin: apache/incubator-dubbo

@Override
public void rejectedExecution(Runnable r, ThreadPoolExecutor e) {
  String msg = String.format("Thread pool is EXHAUSTED!" +
          " Thread Name: %s, Pool Size: %d (active: %d, core: %d, max: %d, largest: %d), Task: %d (completed: %d)," +
          " Executor status:(isShutdown:%s, isTerminated:%s, isTerminating:%s), in %s://%s:%d!",
      threadName, e.getPoolSize(), e.getActiveCount(), e.getCorePoolSize(), e.getMaximumPoolSize(), e.getLargestPoolSize(),
      e.getTaskCount(), e.getCompletedTaskCount(), e.isShutdown(), e.isTerminated(), e.isTerminating(),
      url.getProtocol(), url.getIp(), url.getPort());
  logger.warn(msg);
  dumpJStack();
  throw new RejectedExecutionException(msg);
}

代码示例来源:origin: apache/incubator-dubbo

+ ", max:" + tp.getMaximumPoolSize()
+ ", core:" + tp.getCorePoolSize()
+ ", largest:" + tp.getLargestPoolSize()
+ ", active:" + tp.getActiveCount()
+ ", task:" + tp.getTaskCount()

代码示例来源:origin: vipshop/vjtools

@Override
public void rejectedExecution(Runnable r, ThreadPoolExecutor e) {
  String msg = String.format(
      "Thread pool is EXHAUSTED!"
          + " Thread Name: %s, Pool Size: %d (active: %d, core: %d, max: %d, largest: %d), Task: %d (completed: %d),"
          + " Executor status:(isShutdown:%s, isTerminated:%s, isTerminating:%s)!",
      threadName, e.getPoolSize(), e.getActiveCount(), e.getCorePoolSize(), e.getMaximumPoolSize(),
      e.getLargestPoolSize(), e.getTaskCount(), e.getCompletedTaskCount(), e.isShutdown(), e.isTerminated(),
      e.isTerminating());
  logger.warn(msg);
  dummper.tryThreadDump(null);
  throw new RejectedExecutionException(msg);
}

代码示例来源:origin: voldemort/voldemort

public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {
    SocketServerSession session = (SocketServerSession) r;
    if(interrupted()) {
      logger.info("Denying connection from "
            + session.getSocket().getRemoteSocketAddress()
            + ", server is shutting down.");
    } else {
      logger.error("Too many open connections, " + executor.getActiveCount() + " of "
             + executor.getLargestPoolSize()
             + " threads in use, denying connection from "
             + session.getSocket().getRemoteSocketAddress());
    }
    try {
      session.getSocket().close();
    } catch(IOException e) {
      logger.error("Could not close socket.", e);
    }
  }
};

代码示例来源:origin: wildfly/wildfly

@Override
  public synchronized void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {
    long completed = executor.getCompletedTaskCount();
    if (completed < last_completed) {
      throw new IllegalStateException("Number of completed tasks shouldn't decrease");
    } else if (completed == last_completed) {
      long now = System.currentTimeMillis();
      if (now - last_change > period) {
        String message = String.format(
            "No progress for %d ms, possible distributed deadlock. Try raising threadpool size\n" +
            "\tMin size: %d\n\tMax size: %d\n\tCurrent size: %d\n\tActive: %d\n\tLargest size: %d\n" +
            "\tCompleted tasks: %d\n\tTotal scheduled: %d",
            now - last_change, executor.getCorePoolSize(), executor.getMaximumPoolSize(),
            executor.getPoolSize(), executor.getActiveCount(), executor.getLargestPoolSize(),
            executor.getCompletedTaskCount(), executor.getTaskCount());
        throw new NoProgressException(message);
      }
    } else {
      last_change = System.currentTimeMillis();
      last_completed = completed;
    }
    if (fallback != null) {
      fallback.rejectedExecution(r, executor);
    }
  }
}

代码示例来源:origin: apache/hbase

/**
 * This is for testing the active number of threads that were used while
 * doing a batch operation. It inserts one row per region via the batch
 * operation, and then checks the number of active threads.
 * <p/>
 * For HBASE-3553
 */
@Test
public void testActiveThreadsCount() throws Exception {
 UTIL.getConfiguration().setLong("hbase.htable.threads.coresize", slaves + 1);
 try (Connection connection = ConnectionFactory.createConnection(UTIL.getConfiguration())) {
  ThreadPoolExecutor executor = HTable.getDefaultExecutor(UTIL.getConfiguration());
  try {
   try (Table t = connection.getTable(TEST_TABLE, executor)) {
    List<Put> puts = constructPutRequests(); // creates a Put for every region
    t.batch(puts, null);
    HashSet<ServerName> regionservers = new HashSet<>();
    try (RegionLocator locator = connection.getRegionLocator(TEST_TABLE)) {
     for (Row r : puts) {
      HRegionLocation location = locator.getRegionLocation(r.getRow());
      regionservers.add(location.getServerName());
     }
    }
    assertEquals(regionservers.size(), executor.getLargestPoolSize());
   }
  } finally {
   executor.shutdownNow();
  }
 }
}

相关文章

ThreadPoolExecutor类方法