private StreamWorkSlotQueue findWorkSlotQueue(MonitoredStream targetdStream, PolicyDefinition def) { StreamWorkSlotQueue targetQueue = null; for (StreamWorkSlotQueue queue : targetdStream.getQueues()) { if (isQueueAvailable(queue, def)) { targetQueue = queue; break; } } if (targetQueue == null) { WorkQueueBuilder builder = new WorkQueueBuilder(context, mgmtService); // TODO : get the properties from policy definiton targetQueue = builder.createQueue(targetdStream, def.isDedicated(), getQueueSize(def.getParallelismHint()), new HashMap<String, Object>()); } return targetQueue; }
public StreamWorkSlotQueue createQueue(MonitoredStream stream, boolean isDedicated, int size, Map<String, Object> properties) { // FIXME: make extensible and configurable IWorkSlotStrategy strategy = new SameTopologySlotStrategy(context, stream.getStreamGroup(), mgmtService); List<WorkSlot> slots = strategy.reserveWorkSlots(size, isDedicated, properties); if (slots.size() < size) { LOG.error("allocate stream work queue failed, required size"); return null; } StreamWorkSlotQueue queue = new StreamWorkSlotQueue(stream.getStreamGroup(), isDedicated, properties, slots); calculateGroupIndexAndCount(queue); assignQueueSlots(stream, queue);// build reverse reference stream.addQueues(queue); return queue; }
WorkQueueBuilder wrb = new WorkQueueBuilder(context, mgmtService); StreamWorkSlotQueue queue = wrb.createQueue(new MonitoredStream(group1), group1.isDedicated(), 2, new HashMap<String, Object>()); print(context.getTopologyUsages().values()); }); StreamWorkSlotQueue queue2 = wrb.createQueue(new MonitoredStream(group2), group2.isDedicated(), 2, new HashMap<String, Object>()); print(context.getTopologyUsages().values()); StreamWorkSlotQueue queue3 = wrb.createQueue(new MonitoredStream(group3), group3.isDedicated(), 2, new HashMap<String, Object>()); print(context.getTopologyUsages().values()); StreamWorkSlotQueue queue4 = wrb.createQueue(new MonitoredStream(group4), group4.isDedicated(), 2, new HashMap<String, Object>()); print(context.getTopologyUsages().values());
WorkQueueBuilder wrb = new WorkQueueBuilder(context, mgmtService); StreamWorkSlotQueue queue = wrb.createQueue(new MonitoredStream(group1), group1.isDedicated(), 2, new HashMap<String, Object>()); print(context.getTopologyUsages().values()); }); StreamWorkSlotQueue queue2 = wrb.createQueue(new MonitoredStream(group2), group2.isDedicated(), 2, new HashMap<String, Object>()); print(context.getTopologyUsages().values()); StreamWorkSlotQueue queue3 = wrb.createQueue(new MonitoredStream(group3), group3.isDedicated(), 2, new HashMap<String, Object>()); print(context.getTopologyUsages().values()); }); StreamWorkSlotQueue queue4 = wrb.createQueue(new MonitoredStream(group4), group4.isDedicated(), 2, new HashMap<String, Object>()); print(context.getTopologyUsages().values());
WorkQueueBuilder wrb = new WorkQueueBuilder(context, mgmtService); StreamWorkSlotQueue queue = wrb.createQueue(ms1, false, 5, new HashMap<String, Object>()); sg2.addStreamPartition(partition2); MonitoredStream ms2 = new MonitoredStream(sg2); queue = wrb.createQueue(ms2, false, 5, new HashMap<String, Object>());