コード例 #1
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;
  }
コード例 #2
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);
    }
  }
コード例 #3
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);
  }
コード例 #4
0
 public boolean isActionEnabled(String streamName, StreamAction action) {
   return streamStatusDao.getEnabledActions(streamName).contains(action);
 }