public Queue<FileSystemEvent> execute(Queue<FileSystemEvent> events) throws ActionException { try { listenerForwarder.started(); Queue<FileSystemEvent> forwardingEvents = new LinkedList<FileSystemEvent>(); int numEvents = events.size(); for (int i = 0; i < numEvents; i++) { FileSystemEvent event = events.remove(); // // // data flow configuration and dataStore name must not be null. // // if (getConfiguration() == null) { LOGGER.error("Conf is null."); throw new IllegalStateException("Conf is null."); } // final String configId = getConfiguration().getName(); listenerForwarder.setTask("Processing event " + event); // FORWARDING EVENTS for (String flowId : ((SplittingConfiguration) getConfiguration()).getServiceIDs()) { FileBasedFlowManager flow = CatalogHolder.getCatalog().getResource(flowId, FileBasedFlowManager.class); if (flow != null) { flow.postEvent(event); } else { LOGGER.warn("Trying to forward event to flow " + flowId + " but it was unavailable!"); } } forwardingEvents.add(event); } listenerForwarder.completed(); return forwardingEvents; } catch (Exception t) { LOGGER.error(t.getLocalizedMessage(), t); // no need to log, we're // rethrowing it listenerForwarder.failed(t); throw new ActionException(this, t.getMessage(), t); } }
/* * (non-Javadoc) * * @see org.springframework.web.servlet.mvc.AbstractController#handleRequestInternal * (javax.servlet .http.HttpServletRequest, javax.servlet.http.HttpServletResponse) */ @Override protected ModelAndView handleRequestInternal( HttpServletRequest request, HttpServletResponse response) throws Exception { Catalog catalog = (Catalog) getApplicationContext().getBean("catalog"); String fmId = request.getParameter("fmId"); ModelAndView mav = new ModelAndView("flowinfo"); FileBasedFlowManager fm = catalog.getResource(fmId, FileBasedFlowManager.class); mav.addObject("flowManager", fm); Set<BaseEventConsumer> tree = fm.getEventConsumers(); mav.addObject("ecList", tree.toArray()); return mav; }
@Override protected ModelAndView handleRequestInternal( HttpServletRequest request, HttpServletResponse response) throws Exception { catalog = (Catalog) getApplicationContext().getBean("catalog"); final String fmId = request.getParameter(FLOW_MANAGER_ID_KEY); final String ecId = request.getParameter(CONSUMER_ID_KEY); if (fmId == null || fmId.isEmpty()) { throw new IllegalArgumentException("fmId parameter is null or empty"); } if (ecId == null || ecId.isEmpty()) { throw new IllegalArgumentException("ecId parameter is null or empty"); } final ModelAndView mav = new ModelAndView(MAV_NAME_KEY); mav.addObject("flowManagers", catalog.getFlowManagers(FileBasedFlowManager.class)); final FileBasedFlowManager fm = catalog.getResource(fmId, FileBasedFlowManager.class); handleFlowManager(mav, fm); final EventConsumer consumer = fm.getConsumer(ecId); handleConsumer(mav, consumer); // final Collection<FileBasedEventConsumer> // consumers=fm.getEventConsumers(); // final Iterator<FileBasedEventConsumer> it=consumers.iterator(); // while (it.hasNext()){ // final FileBasedEventConsumer consumer=it.next(); // if (consumer == null) // { // mav.addObject("error", "Flow instance '" + consumer.getId() + // "' not found"); // } else { // runStuff(mav, consumer); // } // // } return mav; }