/** * Converts a string value to Data Flow ID. If the supplied string * is null or empty, the returned value is null. * * @param inFlowID the flow ID represented as a string. * * @return the data flow ID. */ private DataFlowID toFlowID(String inFlowID) { return inFlowID == null || inFlowID.trim().isEmpty() ? null : new DataFlowID(inFlowID); }
@Override public AttributeList getAttributes(String[] attributes) { Map<DataFlowID, Integer> sizes = getQueueSizes(); AttributeList list = new AttributeList(); for(String attribute: attributes) { if (attribute.startsWith(ATTRIB_PREFIX)) { Integer value = null; String flowID = attribute.substring(ATTRIB_PREFIX.length()); if(!flowID.isEmpty()) { DataFlowID id = new DataFlowID(flowID); value = sizes.get(id); } if (value != null) { list.add(new Attribute(attribute, value)); } } } return list; }
@Override public Object getAttribute(String attribute) throws AttributeNotFoundException { Integer value = null; if (attribute.startsWith(ATTRIB_PREFIX)) { String flowID = attribute.substring(ATTRIB_PREFIX.length()); if(!flowID.isEmpty()) { DataFlowID id = new DataFlowID(flowID); DataFlowHandler handler = mFlows.get(id); if(handler != null) { value = handler.getQueueSize(); } } } if(value == null) { throw new AttributeNotFoundException(attribute); } else { return value; } }
/** * Generates a unique ID for a data flow. * * @return a unique ID for identifying a data flow * * @throws ModuleException if there were errors generating the * data flow ID. */ private static DataFlowID generateFlowID() throws ModuleException { try { return new DataFlowID(sIDFactory.getNext()); } catch (NoMoreIDsException e) { throw new ModuleException(e, Messages.UNABLE_GENERATE_FLOW_ID); } }