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(); }
@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); }
public Flow(FiringStrategy.Factory firingStrategyFactory, String threadName) { executor = WorkerThread.builder() .withOptions(new WorkerOptions().daemon().withName(threadName)) .onCycle(firingStrategyFactory.create(this, tail)) .buildAndStart(); }
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(); }
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; } }
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(); }
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(); }
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; } }
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(); }