protected void index() { List<WorkQueueDescriptor> descriptors = getDescriptors(QUEUES_EP); descriptors.forEach(d -> d.categories.forEach(c -> { categoryToQueueId.computeIfPresent(c, (k, v) -> { if (!v.equals(d.getId())) { log.error("Work category '{}' cannot be assigned to work queue '{}'" + " because it is already assigned to work queue '{}'", c, d.getId(), v); } return v; }); categoryToQueueId.putIfAbsent(c, d.getId()); })); }
protected void initTopology() { // create a single topology with one root per work pool Topology.Builder builder = Topology.builder(); List<WorkQueueDescriptor> descriptors = getDescriptors(QUEUES_EP); descriptors.stream().filter(WorkQueueDescriptor::isProcessingEnabled).forEach(d -> builder.addComputation( () -> new WorkComputation(d.getId()), Collections.singletonList("i1:" + d.getId()))); topology = builder.build(); settings = new Settings(DEFAULT_CONCURRENCY, getPartitions(DEFAULT_CONCURRENCY), getCodec()); descriptors.forEach(item -> settings.setConcurrency(item.getId(), item.getMaxThreads())); descriptors.forEach(item -> settings.setPartitions(item.getId(), getPartitions(item.getMaxThreads()))); }
@Override public void registerContribution(Object contribution, String xp, ComponentInstance component) { if (QUEUES_EP.equals(xp)) { WorkQueueDescriptor descriptor = (WorkQueueDescriptor) contribution; if (ALL_QUEUES.equals(descriptor.getId())) { Boolean processing = descriptor.processing; if (processing == null) { log.error("Ignoring work queue descriptor {} with no processing/queuing", ALL_QUEUES); return; } log.info("Setting on all work queues:{}", () -> " processing=" + processing + (queuing == null ? "" : " queuing=" + queuing)); // activate/deactivate processing on all queues getDescriptors(QUEUES_EP).forEach(d -> { WorkQueueDescriptor wqd = new WorkQueueDescriptor(); wqd.id = d.getId(); wqd.processing = processing; register(QUEUES_EP, wqd); }); } else { register(QUEUES_EP, descriptor); } } else { super.registerContribution(contribution, xp, component); } }