protected void enableEngineAction( String streamName, EngineActionType engineActionType, Map<String, Object> engineActionParams, StreamOperationServiceWithoutMetrics streamOperationService) { if (!streamStatusDao.isEngineActionEnabled(streamName, engineActionType)) { String engineActionQueryId = siddhiManager.addQuery( QueryFactory.createQuery() .from(QueryFactory.inputStream(streamName)) .insertInto(STREAMING.STATS_NAMES.SINK_STREAM_PREFIX.concat(streamName))); BaseEngineAction engineAction = null; if (engineActionType == EngineActionType.FIRE_RULES) { engineAction = new DroolsEngineAction( droolsConnectionContainer, engineActionParams, siddhiManager, streamOperationService); } siddhiManager.addCallback( engineActionQueryId, callbackService.addEngineCallback(streamName, engineActionType, engineAction)); streamStatusDao.enableEngineAction( streamName, engineActionType, engineActionParams, engineActionQueryId); } }
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 dropStream(String streamName) { Map<String, QueryDTO> attachedQueries = streamStatusDao.get(streamName).getAddedQueries(); for (String queryId : attachedQueries.keySet()) { siddhiManager.removeQuery(queryId); } siddhiManager.removeStream(streamName); streamStatusDao.remove(streamName); }
public void removeQuery(String queryId, String streamName) { siddhiManager.removeQuery(queryId); streamStatusDao.removeQuery(streamName, queryId); for (Map.Entry<String, StreamStatusDTO> streamStatus : streamStatusDao.getAll().entrySet()) { String temporalStreamName = streamStatus.getKey(); if (siddhiManager.getStreamDefinition(temporalStreamName) == null) { this.dropStream(temporalStreamName); } } }
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 String addQuery(String streamName, String queryString) { String queryId = siddhiManager.addQuery(queryString); streamStatusDao.addQuery(streamName, queryId, queryString); for (StreamDefinition streamDefinition : siddhiManager.getStreamDefinitions()) { // XXX refactor to obtain exactly siddhi inferred streams. streamStatusDao.createInferredStream( streamDefinition.getStreamId(), castToColumnNameTypeValue(streamDefinition.getAttributeList())); } return queryId; }
public void disableEngineAction(String streamName, EngineActionType engineActionType) { if (streamStatusDao.isEngineActionEnabled(streamName, engineActionType)) { String engineActionQueryId = streamStatusDao.getEngineActionQueryId(streamName, engineActionType); if (engineActionQueryId != null) { siddhiManager.removeQuery(engineActionQueryId); } streamStatusDao.disableEngineAction(streamName, engineActionType); callbackService.removeEngineAction(streamName, engineActionType); } }
public int enlargeStream( String streamName, List<ColumnNameTypeValue> columns, Boolean raiseException) throws ServiceException { int addedColumns = 0; StreamDefinition streamMetaData = siddhiManager.getStreamDefinition(streamName); for (ColumnNameTypeValue columnNameTypeValue : columns) { if (!SiddhiUtils.columnAlreadyExistsInStream( columnNameTypeValue.getColumn(), streamMetaData)) { addedColumns++; // JPFM -- Updating the columns in streamStatusDao streamStatusDao.addColumn(streamName, columnNameTypeValue); streamMetaData.attribute( columnNameTypeValue.getColumn(), getSiddhiType(columnNameTypeValue.getType())); } else { if (raiseException) { throw new ServiceException( String.format( "Alter stream error, Column %s already " + "exists.", columnNameTypeValue.getColumn())); } } } return addedColumns; }
public void createInternalStream(String streamName, List<ColumnNameTypeValue> columns) { StreamDefinition newStream = QueryFactory.createStreamDefinition().name(streamName); for (ColumnNameTypeValue column : columns) { newStream.attribute(column.getColumn(), getSiddhiType(column.getType())); } siddhiManager.defineStream(newStream); streamStatusDao.createInferredStream(streamName, columns); }
public boolean queryRawExists(String streamName, String queryRaw) { StreamStatusDTO streamStatus = streamStatusDao.get(streamName); if (streamStatus != null) { return streamStatus.getAddedQueries().containsValue(new QueryDTO(queryRaw)); } else { return false; } }
public boolean queryIdExists(String streamName, String queryId) { StreamStatusDTO streamStatus = streamStatusDao.get(streamName); if (streamStatus != null) { return streamStatus.getAddedQueries().containsKey(queryId); } else { return false; } }
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); }
public Boolean columnExists(String streamName, String columnName) { return streamStatusDao.existsColumnDefinition(streamName, columnName); }
public boolean isUserDefined(String streamName) { StreamStatusDTO streamStatus = streamStatusDao.get(streamName); return streamStatus != null ? streamStatus.getUserDefined() : false; }
public boolean streamExist(String streamName) { return streamStatusDao.get(streamName) != null ? true : false; }