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 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 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 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);
  }