com.obsidiandynamics.worker.WorkerOptions.daemon()方法的使用及代码示例

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

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

WorkerOptions.daemon介绍

[英]A shortcut way of calling withDaemon(true).
[中]

代码示例

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

public SingleNodeQueueLedger(Config config) {
 maxYields = config.maxYields;
 thread = WorkerThread.builder()
   .withOptions(new WorkerOptions()
          .daemon()
          .withName(SingleNodeQueueLedger.class, Integer.toHexString(System.identityHashCode(this))))
   .onCycle(this::cycle)
   .buildAndStart();
}

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

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

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

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

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

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

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

public MonitorEngine(MonitorAction action, String groupId, MonitorEngineConfig config) {
 this.groupId = groupId;
 trackingEnabled = config.isTrackingEnabled();
 gcIntervalMillis = config.getGCInterval();
 outcomeLifetimeMillis = config.getOutcomeLifetime();
 timeoutIntervalMillis = config.getTimeoutInterval();
 metadataEnabled = config.isMetadataEnabled();
 this.action = action;
 
 if (trackingEnabled) {
  gcThread = WorkerThread.builder()
    .withOptions(new WorkerOptions()
           .daemon()
           .withName(MonitorEngine.class, groupId, "gc", Integer.toHexString(System.identityHashCode(this))))
    .onCycle(this::gcCycle)
    .buildAndStart();
 } else {
  gcThread = null;
 }
 
 timeoutThread = WorkerThread.builder()
   .withOptions(new WorkerOptions()
          .daemon()
          .withName(MonitorEngine.class, groupId, "timeout", Integer.toHexString(System.identityHashCode(this))))
   .onCycle(this::timeoutCycle)
   .buildAndStart();
}

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

public ConsumerPipe(ConsumerPipeConfig config, RecordHandler<K, V> handler, String threadName) {
 this.handler = handler;
 if (config.isAsync()) {
  mustExist(threadName, "Thread name cannot be null");
  queue = new LinkedBlockingQueue<>(config.getBacklogBatches());
  thread = WorkerThread.builder()
    .withOptions(new WorkerOptions().daemon().withName(threadName))
    .onCycle(this::cycle)
    .buildAndStart();
 } else {
  queue = null;
  thread = null;
 }
}

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

public AsyncReceiver(Consumer<K, V> consumer, int pollTimeoutMillis, String threadName, 
           RecordHandler<K, V> recordHandler, ExceptionHandler exceptionHandler) {
 this.consumer = consumer;
 this.pollTimeoutMillis = pollTimeoutMillis;
 this.recordHandler = recordHandler;
 this.exceptionHandlerHandler = exceptionHandler;
 thread = WorkerThread.builder()
   .withOptions(new WorkerOptions().daemon().withName(threadName))
   .onCycle(this::cycle)
   .onShutdown(this::shutdown)
   .buildAndStart();
}

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

DefaultReceiver(Subscriber subscriber, RecordHandler recordHandler, int pollTimeoutMillis) {
 this.subscriber = subscriber;
 this.recordHandler = recordHandler;
 this.pollTimeoutMillis = pollTimeoutMillis;
 pollerThread = WorkerThread.builder()
   .withOptions(new WorkerOptions()
          .daemon()
          .withName(Receiver.class, subscriber.getConfig().getStreamConfig().getName(), "poller"))
   .onCycle(this::pollerCycle)
   .buildAndStart();
}

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

public ProducerPipe(ProducerPipeConfig config, Producer<K, V> producer, String threadName, ExceptionHandler exceptionHandler) {
 this.producer = producer;
 this.exceptionHandler = exceptionHandler;
 if (config.isAsync()) {
  queue = new NodeQueue<>();
  queueConsumer = queue.consumer();
  thread = WorkerThread.builder()
    .withOptions(new WorkerOptions().daemon().withName(threadName))
    .onCycle(this::cycle)
    .buildAndStart();
 } else {
  queue = null;
  queueConsumer = null;
  thread = null;
 }
}

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

public Election(ElectionConfig config, IMap<String, byte[]> leases) {
 this.config = config;
 final Retry retry = new Retry()
   .withExceptionClass(HazelcastException.class)
   .withAttempts(Integer.MAX_VALUE)
   .withBackoff(100)
   .withFaultHandler(config.getZlg()::w)
   .withErrorHandler(config.getZlg()::e);
 this.leases = new RetryableMap<>(retry, leases);
 registry = new Registry();
 
 scavengerThread = WorkerThread.builder()
   .withOptions(new WorkerOptions().daemon().withName(Election.class, "scavenger"))
   .onCycle(this::scavegerCycle)
   .build();
}

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

public Election(ElectionConfig config, IMap<String, byte[]> leases) {
 this.config = config;
 final Retry retry = new Retry()
   .withExceptionMatcher(isA(HazelcastException.class))
   .withAttempts(Integer.MAX_VALUE)
   .withBackoff(100)
   .withFaultHandler(config.getZlg()::w)
   .withErrorHandler(config.getZlg()::e);
 this.leases = new RetryableMap<>(retry, leases);
 registry = new Registry();
 
 scavengerThread = WorkerThread.builder()
   .withOptions(new WorkerOptions().daemon().withName(Election.class, "scavenger"))
   .onCycle(this::scavegerCycle)
   .build();
}

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

DefaultPublisher(HazelcastInstance instance, PublisherConfig config) {
 this.instance = instance;
 this.config = config;
 final StreamConfig streamConfig = config.getStreamConfig();
 final Retry retry = new Retry()
   .withExceptionMatcher(isA(HazelcastException.class))
   .withAttempts(Integer.MAX_VALUE)
   .withBackoff(100)
   .withFaultHandler(config.getZlg()::w)
   .withErrorHandler(config.getZlg()::e);
 buffer = new RetryableRingbuffer<>(retry, StreamHelper.getRingbuffer(instance, streamConfig));
 
 publishThread = WorkerThread.builder()
   .withOptions(new WorkerOptions().daemon().withName(Publisher.class, streamConfig.getName(), "publisher"))
   .onCycle(this::publisherCycle)
   .buildAndStart();
}

相关文章