コード例 #1
0
  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);
    }
  }
コード例 #2
0
  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;
  }
コード例 #3
0
  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);
  }
コード例 #4
0
 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);
     }
   }
 }
コード例 #5
0
  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);
    }
  }
コード例 #6
0
 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;
 }
コード例 #7
0
  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);
    }
  }
コード例 #8
0
  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;
  }
コード例 #9
0
 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);
 }
コード例 #10
0
 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;
   }
 }
コード例 #11
0
 public boolean queryIdExists(String streamName, String queryId) {
   StreamStatusDTO streamStatus = streamStatusDao.get(streamName);
   if (streamStatus != null) {
     return streamStatus.getAddedQueries().containsKey(queryId);
   } else {
     return false;
   }
 }
コード例 #12
0
  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);
  }
コード例 #13
0
 public boolean isActionEnabled(String streamName, StreamAction action) {
   return streamStatusDao.getEnabledActions(streamName).contains(action);
 }
コード例 #14
0
  public Boolean columnExists(String streamName, String columnName) {

    return streamStatusDao.existsColumnDefinition(streamName, columnName);
  }
コード例 #15
0
 public boolean isUserDefined(String streamName) {
   StreamStatusDTO streamStatus = streamStatusDao.get(streamName);
   return streamStatus != null ? streamStatus.getUserDefined() : false;
 }
コード例 #16
0
 public boolean streamExist(String streamName) {
   return streamStatusDao.get(streamName) != null ? true : false;
 }