com.obsidiandynamics.worker.WorkerThreadBuilder类的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(6.6k)|赞(0)|评价(0)|浏览(150)

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

WorkerThreadBuilder介绍

暂无

代码示例

代码示例来源:origin: com.obsidiandynamics.blackstrom/blackstrom-core

  1. public SingleNodeQueueLedger(Config config) {
  2. maxYields = config.maxYields;
  3. thread = WorkerThread.builder()
  4. .withOptions(new WorkerOptions()
  5. .daemon()
  6. .withName(SingleNodeQueueLedger.class, Integer.toHexString(System.identityHashCode(this))))
  7. .onCycle(this::cycle)
  8. .buildAndStart();
  9. }

代码示例来源:origin: com.obsidiandynamics.fulcrum/fulcrum-scheduler

  1. public TaskScheduler(String threadName) {
  2. executor = WorkerThread.builder()
  3. .withOptions(new WorkerOptions().daemon().withName(threadName))
  4. .onCycle(this::cycle)
  5. .build();
  6. }

代码示例来源:origin: com.obsidiandynamics.fulcrum/fulcrum-worker

  1. public static WorkerThreadBuilder builder() {
  2. return new WorkerThreadBuilder();
  3. }
  4. }

代码示例来源:origin: com.obsidiandynamics.jackdaw/jackdaw-core

  1. public AsyncReceiver(Consumer<K, V> consumer, int pollTimeoutMillis, String threadName,
  2. RecordHandler<K, V> recordHandler, ExceptionHandler exceptionHandler) {
  3. this.consumer = consumer;
  4. this.pollTimeoutMillis = pollTimeoutMillis;
  5. this.recordHandler = recordHandler;
  6. this.exceptionHandlerHandler = exceptionHandler;
  7. thread = WorkerThread.builder()
  8. .withOptions(new WorkerOptions().daemon().withName(threadName))
  9. .onCycle(this::cycle)
  10. .onShutdown(this::shutdown)
  11. .buildAndStart();
  12. }

代码示例来源:origin: com.obsidiandynamics.fulcrum/fulcrum-worker

  1. public WorkerThread buildAndStart() {
  2. final WorkerThread thread = build();
  3. thread.start();
  4. return thread;
  5. }
  6. }

代码示例来源:origin: com.obsidiandynamics.fulcrum/fulcrum-flow

  1. public Flow(FiringStrategy.Factory firingStrategyFactory, String threadName) {
  2. executor = WorkerThread.builder()
  3. .withOptions(new WorkerOptions().daemon().withName(threadName))
  4. .onCycle(firingStrategyFactory.create(this, tail))
  5. .buildAndStart();
  6. }

代码示例来源:origin: com.obsidiandynamics.hazelq/hazelq-elect

  1. public Election(ElectionConfig config, IMap<String, byte[]> leases) {
  2. this.config = config;
  3. final Retry retry = new Retry()
  4. .withExceptionClass(HazelcastException.class)
  5. .withAttempts(Integer.MAX_VALUE)
  6. .withBackoff(100)
  7. .withFaultHandler(config.getZlg()::w)
  8. .withErrorHandler(config.getZlg()::e);
  9. this.leases = new RetryableMap<>(retry, leases);
  10. registry = new Registry();
  11. scavengerThread = WorkerThread.builder()
  12. .withOptions(new WorkerOptions().daemon().withName(Election.class, "scavenger"))
  13. .onCycle(this::scavegerCycle)
  14. .build();
  15. }

代码示例来源:origin: com.obsidiandynamics.jackdaw/jackdaw-core

  1. public ConsumerPipe(ConsumerPipeConfig config, RecordHandler<K, V> handler, String threadName) {
  2. this.handler = handler;
  3. if (config.isAsync()) {
  4. mustExist(threadName, "Thread name cannot be null");
  5. queue = new LinkedBlockingQueue<>(config.getBacklogBatches());
  6. thread = WorkerThread.builder()
  7. .withOptions(new WorkerOptions().daemon().withName(threadName))
  8. .onCycle(this::cycle)
  9. .buildAndStart();
  10. } else {
  11. queue = null;
  12. thread = null;
  13. }
  14. }

代码示例来源:origin: com.obsidiandynamics.meteor/meteor-elect

  1. public Election(ElectionConfig config, IMap<String, byte[]> leases) {
  2. this.config = config;
  3. final Retry retry = new Retry()
  4. .withExceptionMatcher(isA(HazelcastException.class))
  5. .withAttempts(Integer.MAX_VALUE)
  6. .withBackoff(100)
  7. .withFaultHandler(config.getZlg()::w)
  8. .withErrorHandler(config.getZlg()::e);
  9. this.leases = new RetryableMap<>(retry, leases);
  10. registry = new Registry();
  11. scavengerThread = WorkerThread.builder()
  12. .withOptions(new WorkerOptions().daemon().withName(Election.class, "scavenger"))
  13. .onCycle(this::scavegerCycle)
  14. .build();
  15. }

代码示例来源:origin: com.obsidiandynamics.meteor/meteor-core

  1. DefaultReceiver(Subscriber subscriber, RecordHandler recordHandler, int pollTimeoutMillis) {
  2. this.subscriber = subscriber;
  3. this.recordHandler = recordHandler;
  4. this.pollTimeoutMillis = pollTimeoutMillis;
  5. pollerThread = WorkerThread.builder()
  6. .withOptions(new WorkerOptions()
  7. .daemon()
  8. .withName(Receiver.class, subscriber.getConfig().getStreamConfig().getName(), "poller"))
  9. .onCycle(this::pollerCycle)
  10. .buildAndStart();
  11. }

代码示例来源:origin: com.obsidiandynamics.blackstrom/blackstrom-core

  1. @Override
  2. public void attach(MessageHandler handler) {
  3. if (handler.getGroupId() != null && ! groups.add(handler.getGroupId())) return;
  4. final WorkerThread thread = WorkerThread.builder()
  5. .withOptions(new WorkerOptions().daemon().withName(MultiNodeQueueLedger.class, handler.getGroupId()))
  6. .onCycle(new NodeWorker(handler, handler.getGroupId(), queue.consumer()))
  7. .buildAndStart();
  8. threads.add(thread);
  9. }

代码示例来源:origin: com.obsidiandynamics.blackstrom/blackstrom-core

  1. public MonitorEngine(MonitorAction action, String groupId, MonitorEngineConfig config) {
  2. this.groupId = groupId;
  3. trackingEnabled = config.isTrackingEnabled();
  4. gcIntervalMillis = config.getGCInterval();
  5. outcomeLifetimeMillis = config.getOutcomeLifetime();
  6. timeoutIntervalMillis = config.getTimeoutInterval();
  7. metadataEnabled = config.isMetadataEnabled();
  8. this.action = action;
  9. if (trackingEnabled) {
  10. gcThread = WorkerThread.builder()
  11. .withOptions(new WorkerOptions()
  12. .daemon()
  13. .withName(MonitorEngine.class, groupId, "gc", Integer.toHexString(System.identityHashCode(this))))
  14. .onCycle(this::gcCycle)
  15. .buildAndStart();
  16. } else {
  17. gcThread = null;
  18. }
  19. timeoutThread = WorkerThread.builder()
  20. .withOptions(new WorkerOptions()
  21. .daemon()
  22. .withName(MonitorEngine.class, groupId, "timeout", Integer.toHexString(System.identityHashCode(this))))
  23. .onCycle(this::timeoutCycle)
  24. .buildAndStart();
  25. }

代码示例来源:origin: com.obsidiandynamics.jackdaw/jackdaw-core

  1. public ProducerPipe(ProducerPipeConfig config, Producer<K, V> producer, String threadName, ExceptionHandler exceptionHandler) {
  2. this.producer = producer;
  3. this.exceptionHandler = exceptionHandler;
  4. if (config.isAsync()) {
  5. queue = new NodeQueue<>();
  6. queueConsumer = queue.consumer();
  7. thread = WorkerThread.builder()
  8. .withOptions(new WorkerOptions().daemon().withName(threadName))
  9. .onCycle(this::cycle)
  10. .buildAndStart();
  11. } else {
  12. queue = null;
  13. queueConsumer = null;
  14. thread = null;
  15. }
  16. }

代码示例来源:origin: com.obsidiandynamics.meteor/meteor-core

  1. DefaultPublisher(HazelcastInstance instance, PublisherConfig config) {
  2. this.instance = instance;
  3. this.config = config;
  4. final StreamConfig streamConfig = config.getStreamConfig();
  5. final Retry retry = new Retry()
  6. .withExceptionMatcher(isA(HazelcastException.class))
  7. .withAttempts(Integer.MAX_VALUE)
  8. .withBackoff(100)
  9. .withFaultHandler(config.getZlg()::w)
  10. .withErrorHandler(config.getZlg()::e);
  11. buffer = new RetryableRingbuffer<>(retry, StreamHelper.getRingbuffer(instance, streamConfig));
  12. publishThread = WorkerThread.builder()
  13. .withOptions(new WorkerOptions().daemon().withName(Publisher.class, streamConfig.getName(), "publisher"))
  14. .onCycle(this::publisherCycle)
  15. .buildAndStart();
  16. }

相关文章