本文整理了Java中org.jgroups.util.Util.parseRejectionPolicy()
方法的一些代码示例,展示了Util.parseRejectionPolicy()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Util.parseRejectionPolicy()
方法的具体详情如下:
包路径:org.jgroups.util.Util
类名称:Util
方法名:parseRejectionPolicy
暂无
代码示例来源:origin: wildfly/wildfly
public TimeScheduler3(ThreadFactory factory, int min_threads, int max_threads, long keep_alive_time,
BlockingQueue<Runnable> queue, String rejection_policy, boolean thread_pool_enabled) {
timer_thread_factory=factory;
pool=thread_pool_enabled?
new ThreadPoolExecutor(min_threads, max_threads,keep_alive_time, TimeUnit.MILLISECONDS,
queue, factory, Util.parseRejectionPolicy(rejection_policy))
: new DirectExecutor();
start();
}
代码示例来源:origin: wildfly/wildfly
public ProgressCheckRejectionPolicy(String rejection_policy) {
String policy = rejection_policy.toLowerCase();
if (!policy.startsWith(NAME)) {
throw new IllegalStateException(rejection_policy);
}
policy = policy.substring(NAME.length());
if (policy.startsWith("=")) {
String[] attributes = policy.substring(1).split(",", 0);
for (String attribute : attributes) {
String[] parts = attribute.split(":");
if (parts.length != 2) {
throw new IllegalArgumentException("Attribute '" + attribute + "' in " + rejection_policy);
}
String key = parts[0].trim();
String value = parts[1].trim();
if (key.equals("period")) {
try {
period = Long.parseLong(value);
} catch (NumberFormatException e) {
throw new IllegalArgumentException("Cannot parse period value in " + rejection_policy, e);
}
} else if (key.equals("fallback")) {
// in order to be able to define also different policy with attributes (use as the last attribute)
fallback = Util.parseRejectionPolicy(rejection_policy.substring(rejection_policy.indexOf("fallback:") + 9));
}
}
}
}
代码示例来源:origin: wildfly/wildfly
protected static ExecutorService createThreadPool(int min_threads, int max_threads, long keep_alive_time, String rejection_policy,
BlockingQueue<Runnable> queue, final ThreadFactory factory, Log log,
boolean use_fork_join_pool, boolean use_common_fork_join_pool) {
if(use_fork_join_pool) {
if(use_common_fork_join_pool)
return ForkJoinPool.commonPool();
int num_cores=Runtime.getRuntime().availableProcessors();
if(max_threads > num_cores)
log.warn("max_threads (%d) is higher than available cores (%d)", max_threads, num_cores);
return new ForkJoinPool(max_threads, ForkJoinPool.defaultForkJoinWorkerThreadFactory, null, true);
}
ThreadPoolExecutor pool=new ThreadPoolExecutor(min_threads, max_threads, keep_alive_time, TimeUnit.MILLISECONDS, queue, factory);
RejectedExecutionHandler handler=Util.parseRejectionPolicy(rejection_policy);
pool.setRejectedExecutionHandler(new ShutdownRejectedExecutionHandler(handler));
return pool;
}
代码示例来源:origin: org.jboss.eap/wildfly-client-all
public ProgressCheckRejectionPolicy(String rejection_policy) {
String policy = rejection_policy.toLowerCase();
if (!policy.startsWith(NAME)) {
throw new IllegalStateException(rejection_policy);
}
policy = policy.substring(NAME.length());
if (policy.startsWith("=")) {
String[] attributes = policy.substring(1).split(",", 0);
for (String attribute : attributes) {
String[] parts = attribute.split(":");
if (parts.length != 2) {
throw new IllegalArgumentException("Attribute '" + attribute + "' in " + rejection_policy);
}
String key = parts[0].trim();
String value = parts[1].trim();
if (key.equals("period")) {
try {
period = Long.parseLong(value);
} catch (NumberFormatException e) {
throw new IllegalArgumentException("Cannot parse period value in " + rejection_policy, e);
}
} else if (key.equals("fallback")) {
// in order to be able to define also different policy with attributes (use as the last attribute)
fallback = Util.parseRejectionPolicy(rejection_policy.substring(rejection_policy.indexOf("fallback:") + 9));
}
}
}
}
代码示例来源:origin: org.jboss.eap/wildfly-client-all
public TimeScheduler3(ThreadFactory factory, int min_threads, int max_threads, long keep_alive_time,
BlockingQueue<Runnable> queue, String rejection_policy, boolean thread_pool_enabled) {
timer_thread_factory=factory;
pool=thread_pool_enabled?
new ThreadPoolExecutor(min_threads, max_threads,keep_alive_time, TimeUnit.MILLISECONDS,
queue, factory, Util.parseRejectionPolicy(rejection_policy))
: new DirectExecutor();
start();
}
代码示例来源:origin: org.jboss.eap/wildfly-client-all
protected static ExecutorService createThreadPool(int min_threads, int max_threads, long keep_alive_time, String rejection_policy,
BlockingQueue<Runnable> queue, final ThreadFactory factory, Log log,
boolean use_fork_join_pool, boolean use_common_fork_join_pool) {
if(use_fork_join_pool) {
if(use_common_fork_join_pool)
return ForkJoinPool.commonPool();
int num_cores=Runtime.getRuntime().availableProcessors();
if(max_threads > num_cores)
log.warn("max_threads (%d) is higher than available cores (%d)", max_threads, num_cores);
return new ForkJoinPool(max_threads, ForkJoinPool.defaultForkJoinWorkerThreadFactory, null, true);
}
ThreadPoolExecutor pool=new ThreadPoolExecutor(min_threads, max_threads, keep_alive_time, TimeUnit.MILLISECONDS, queue, factory);
RejectedExecutionHandler handler=Util.parseRejectionPolicy(rejection_policy);
pool.setRejectedExecutionHandler(new ShutdownRejectedExecutionHandler(handler));
return pool;
}
内容来源于网络,如有侵权,请联系作者删除!