org.jgroups.util.Util.parseRejectionPolicy()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(5.1k)|赞(0)|评价(0)|浏览(180)

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

Util.parseRejectionPolicy介绍

暂无

代码示例

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

  1. public TimeScheduler3(ThreadFactory factory, int min_threads, int max_threads, long keep_alive_time,
  2. BlockingQueue<Runnable> queue, String rejection_policy, boolean thread_pool_enabled) {
  3. timer_thread_factory=factory;
  4. pool=thread_pool_enabled?
  5. new ThreadPoolExecutor(min_threads, max_threads,keep_alive_time, TimeUnit.MILLISECONDS,
  6. queue, factory, Util.parseRejectionPolicy(rejection_policy))
  7. : new DirectExecutor();
  8. start();
  9. }

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

  1. public ProgressCheckRejectionPolicy(String rejection_policy) {
  2. String policy = rejection_policy.toLowerCase();
  3. if (!policy.startsWith(NAME)) {
  4. throw new IllegalStateException(rejection_policy);
  5. }
  6. policy = policy.substring(NAME.length());
  7. if (policy.startsWith("=")) {
  8. String[] attributes = policy.substring(1).split(",", 0);
  9. for (String attribute : attributes) {
  10. String[] parts = attribute.split(":");
  11. if (parts.length != 2) {
  12. throw new IllegalArgumentException("Attribute '" + attribute + "' in " + rejection_policy);
  13. }
  14. String key = parts[0].trim();
  15. String value = parts[1].trim();
  16. if (key.equals("period")) {
  17. try {
  18. period = Long.parseLong(value);
  19. } catch (NumberFormatException e) {
  20. throw new IllegalArgumentException("Cannot parse period value in " + rejection_policy, e);
  21. }
  22. } else if (key.equals("fallback")) {
  23. // in order to be able to define also different policy with attributes (use as the last attribute)
  24. fallback = Util.parseRejectionPolicy(rejection_policy.substring(rejection_policy.indexOf("fallback:") + 9));
  25. }
  26. }
  27. }
  28. }

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

  1. protected static ExecutorService createThreadPool(int min_threads, int max_threads, long keep_alive_time, String rejection_policy,
  2. BlockingQueue<Runnable> queue, final ThreadFactory factory, Log log,
  3. boolean use_fork_join_pool, boolean use_common_fork_join_pool) {
  4. if(use_fork_join_pool) {
  5. if(use_common_fork_join_pool)
  6. return ForkJoinPool.commonPool();
  7. int num_cores=Runtime.getRuntime().availableProcessors();
  8. if(max_threads > num_cores)
  9. log.warn("max_threads (%d) is higher than available cores (%d)", max_threads, num_cores);
  10. return new ForkJoinPool(max_threads, ForkJoinPool.defaultForkJoinWorkerThreadFactory, null, true);
  11. }
  12. ThreadPoolExecutor pool=new ThreadPoolExecutor(min_threads, max_threads, keep_alive_time, TimeUnit.MILLISECONDS, queue, factory);
  13. RejectedExecutionHandler handler=Util.parseRejectionPolicy(rejection_policy);
  14. pool.setRejectedExecutionHandler(new ShutdownRejectedExecutionHandler(handler));
  15. return pool;
  16. }

代码示例来源:origin: org.jboss.eap/wildfly-client-all

  1. public ProgressCheckRejectionPolicy(String rejection_policy) {
  2. String policy = rejection_policy.toLowerCase();
  3. if (!policy.startsWith(NAME)) {
  4. throw new IllegalStateException(rejection_policy);
  5. }
  6. policy = policy.substring(NAME.length());
  7. if (policy.startsWith("=")) {
  8. String[] attributes = policy.substring(1).split(",", 0);
  9. for (String attribute : attributes) {
  10. String[] parts = attribute.split(":");
  11. if (parts.length != 2) {
  12. throw new IllegalArgumentException("Attribute '" + attribute + "' in " + rejection_policy);
  13. }
  14. String key = parts[0].trim();
  15. String value = parts[1].trim();
  16. if (key.equals("period")) {
  17. try {
  18. period = Long.parseLong(value);
  19. } catch (NumberFormatException e) {
  20. throw new IllegalArgumentException("Cannot parse period value in " + rejection_policy, e);
  21. }
  22. } else if (key.equals("fallback")) {
  23. // in order to be able to define also different policy with attributes (use as the last attribute)
  24. fallback = Util.parseRejectionPolicy(rejection_policy.substring(rejection_policy.indexOf("fallback:") + 9));
  25. }
  26. }
  27. }
  28. }

代码示例来源:origin: org.jboss.eap/wildfly-client-all

  1. public TimeScheduler3(ThreadFactory factory, int min_threads, int max_threads, long keep_alive_time,
  2. BlockingQueue<Runnable> queue, String rejection_policy, boolean thread_pool_enabled) {
  3. timer_thread_factory=factory;
  4. pool=thread_pool_enabled?
  5. new ThreadPoolExecutor(min_threads, max_threads,keep_alive_time, TimeUnit.MILLISECONDS,
  6. queue, factory, Util.parseRejectionPolicy(rejection_policy))
  7. : new DirectExecutor();
  8. start();
  9. }

代码示例来源:origin: org.jboss.eap/wildfly-client-all

  1. protected static ExecutorService createThreadPool(int min_threads, int max_threads, long keep_alive_time, String rejection_policy,
  2. BlockingQueue<Runnable> queue, final ThreadFactory factory, Log log,
  3. boolean use_fork_join_pool, boolean use_common_fork_join_pool) {
  4. if(use_fork_join_pool) {
  5. if(use_common_fork_join_pool)
  6. return ForkJoinPool.commonPool();
  7. int num_cores=Runtime.getRuntime().availableProcessors();
  8. if(max_threads > num_cores)
  9. log.warn("max_threads (%d) is higher than available cores (%d)", max_threads, num_cores);
  10. return new ForkJoinPool(max_threads, ForkJoinPool.defaultForkJoinWorkerThreadFactory, null, true);
  11. }
  12. ThreadPoolExecutor pool=new ThreadPoolExecutor(min_threads, max_threads, keep_alive_time, TimeUnit.MILLISECONDS, queue, factory);
  13. RejectedExecutionHandler handler=Util.parseRejectionPolicy(rejection_policy);
  14. pool.setRejectedExecutionHandler(new ShutdownRejectedExecutionHandler(handler));
  15. return pool;
  16. }

相关文章

Util类方法