public List<StratioStreamingMessage> list() { List<StratioStreamingMessage> result = new ArrayList<>(); for (StreamDefinition streamDefinition : siddhiManager.getStreamDefinitions()) { if (suitableToList(streamDefinition.getStreamId())) { StratioStreamingMessage message = new StratioStreamingMessage(); for (Attribute attribute : streamDefinition.getAttributeList()) { message.addColumn( new ColumnNameTypeValue( attribute.getName(), this.getStreamingType(attribute.getType()), null)); } StreamStatusDTO streamStatus = streamStatusDao.get(streamDefinition.getStreamId()); if (streamStatus != null) { Map<String, QueryDTO> attachedQueries = streamStatus.getAddedQueries(); for (Map.Entry<String, QueryDTO> entry : attachedQueries.entrySet()) { message.addQuery(new StreamQuery(entry.getKey(), entry.getValue().getQueryRaw())); } message.setUserDefined(streamStatus.getUserDefined()); message.setActiveActions( streamStatusDao.getEnabledActions(streamDefinition.getStreamId())); } message.setStreamName(streamDefinition.getStreamId()); result.add(message); } } return result; }
public void disableAction(String streamName, StreamAction action) { streamStatusDao.disableAction(streamName, action); if (streamStatusDao.getEnabledActions(streamName).size() == 0) { String actionQueryId = streamStatusDao.getActionQuery(streamName); if (actionQueryId != null) { siddhiManager.removeQuery(actionQueryId); } callbackService.remove(streamName); } }
public void enableAction(String streamName, StreamAction action) { if (streamStatusDao.getEnabledActions(streamName).size() == 0) { String actionQueryId = siddhiManager.addQuery( QueryFactory.createQuery() .from(QueryFactory.inputStream(streamName)) .insertInto(STREAMING.STATS_NAMES.SINK_STREAM_PREFIX.concat(streamName))); streamStatusDao.setActionQuery(streamName, actionQueryId); String groupId = null; if (configurationContext != null && configurationContext.isClusteringEnabled()) { groupId = configurationContext.getGroupId(); } siddhiManager.addCallback( actionQueryId, callbackService.add(streamName, streamStatusDao.getEnabledActions(streamName), groupId)); } streamStatusDao.enableAction(streamName, action); }
public boolean isActionEnabled(String streamName, StreamAction action) { return streamStatusDao.getEnabledActions(streamName).contains(action); }