/**
   * Activate Inactive Execution Plan Configurations
   *
   * @param tenantId the tenant id of the tenant which triggered this call
   * @param resolvedDependencyId the id of the dependency that was resolved which resulted in
   *     triggering this method call
   */
  public void activateInactiveExecutionPlanConfigurations(
      ExecutionPlanConfigurationFile.Status status, String resolvedDependencyId, int tenantId)
      throws ExecutionPlanConfigurationException {

    List<ExecutionPlanConfigurationFile> reloadFileList =
        new ArrayList<ExecutionPlanConfigurationFile>();

    if (tenantSpecificExecutionPlanFiles != null && tenantSpecificExecutionPlanFiles.size() > 0) {
      List<ExecutionPlanConfigurationFile> executionPlanConfigurationFiles =
          tenantSpecificExecutionPlanFiles.get(tenantId);

      if (executionPlanConfigurationFiles != null) {
        for (ExecutionPlanConfigurationFile executionPlanConfigurationFile :
            executionPlanConfigurationFiles) {
          if ((executionPlanConfigurationFile.getStatus().equals(status))
              && resolvedDependencyId.equalsIgnoreCase(
                  executionPlanConfigurationFile.getDependency())) {
            reloadFileList.add(executionPlanConfigurationFile);
          }
        }
      }
    }
    for (ExecutionPlanConfigurationFile executionPlanConfigurationFile : reloadFileList) {
      try {
        EventProcessorConfigurationFilesystemInvoker.reload(
            executionPlanConfigurationFile.getFileName(),
            executionPlanConfigurationFile.getAxisConfiguration());
      } catch (Exception e) {
        log.error(
            "Exception occurred while trying to deploy the Execution Plan configuration file : "
                + new File(executionPlanConfigurationFile.getFileName()).getName());
      }
    }
  }
  public void deactivateActiveExecutionPlanConfigurations(String streamId, int tenantId) {

    List<String> toDeactivateExecutionPlan = new ArrayList<String>();
    Map<String, ExecutionPlan> executionPlanMap = tenantSpecificExecutionPlans.get(tenantId);
    if (executionPlanMap != null) {
      for (ExecutionPlan executionPlan : executionPlanMap.values()) {
        boolean done = false;
        for (EventProducer eventProducer : executionPlan.getEventProducers()) {
          if (eventProducer.getStreamId().equals(streamId)) {
            toDeactivateExecutionPlan.add(executionPlan.getName());
            done = true;
            break;
          }
        }

        if (!done) {
          for (SiddhiEventConsumer eventConsumer : executionPlan.getSiddhiEventConsumers()) {
            if (eventConsumer.getStreamId().equals(streamId)) {
              toDeactivateExecutionPlan.add(executionPlan.getName());
              break;
            }
          }
        }
      }
    }
    if (toDeactivateExecutionPlan.size() > 0) {
      for (String name : toDeactivateExecutionPlan) {
        ExecutionPlanConfigurationFile executionPlanConfigurationFile =
            getExecutionPlanConfigurationFileByPlanName(name, tenantId);
        try {
          EventProcessorConfigurationFilesystemInvoker.reload(
              executionPlanConfigurationFile.getFileName(),
              executionPlanConfigurationFile.getAxisConfiguration());
        } catch (Exception e) {
          log.error(
              "Exception occurred while trying to deploy the Execution Plan configuration file : "
                  + new File(executionPlanConfigurationFile.getFileName()).getName());
        }
      }
    }
  }