/** * 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 addExecutionPlanConfigurationFile( ExecutionPlanConfigurationFile configurationFile, int tenantId) { List<ExecutionPlanConfigurationFile> executionPlanConfigurationFiles = tenantSpecificExecutionPlanFiles.get(tenantId); if (executionPlanConfigurationFiles == null) { executionPlanConfigurationFiles = new ArrayList<ExecutionPlanConfigurationFile>(); tenantSpecificExecutionPlanFiles.put(tenantId, executionPlanConfigurationFiles); } executionPlanConfigurationFiles.add(configurationFile); }
/** * Just removes the configuration file * * @param fileName the filename of the {@link ExecutionPlanConfigurationFile} to be removed * @param tenantId the tenantId of the tenant to which this configuration file belongs */ public void removeExecutionPlanConfigurationFile(String fileName, int tenantId) { List<ExecutionPlanConfigurationFile> executionPlanConfigurationFiles = tenantSpecificExecutionPlanFiles.get(tenantId); for (Iterator<ExecutionPlanConfigurationFile> iterator = executionPlanConfigurationFiles.iterator(); iterator.hasNext(); ) { ExecutionPlanConfigurationFile configurationFile = iterator.next(); if (configurationFile.getFileName().equals(fileName)) { if (configurationFile.getStatus().equals(ExecutionPlanConfigurationFile.Status.DEPLOYED)) { removeExecutionPlanConfiguration(configurationFile.getExecutionPlanName(), tenantId); } iterator.remove(); break; } } }
public List<StreamDefinition> getSiddhiStreams( String[] inputStreamDefinitions, String queryExpressions) throws SiddhiParserException { SiddhiManager siddhiManager = createMockSiddhiManager(inputStreamDefinitions, queryExpressions); List<org.wso2.siddhi.query.api.definition.StreamDefinition> streamDefinitions = siddhiManager.getStreamDefinitions(); List<StreamDefinition> databridgeStreamDefinitions = new ArrayList<StreamDefinition>(streamDefinitions.size()); for (org.wso2.siddhi.query.api.definition.StreamDefinition siddhiStreamDef : streamDefinitions) { StreamConfiguration streamConfig = new StreamConfiguration(siddhiStreamDef.getStreamId()); StreamDefinition databridgeStreamDef = EventProcessorUtil.convertToDatabridgeStreamDefinition(siddhiStreamDef, streamConfig); databridgeStreamDefinitions.add(databridgeStreamDef); } siddhiManager.shutdown(); return databridgeStreamDefinitions; }
@Override public List<ExecutionPlanConfigurationFile> getAllInactiveExecutionPlanConfiguration( int tenantId) { List<ExecutionPlanConfigurationFile> executionPlanConfigurationFiles = this.tenantSpecificExecutionPlanFiles.get(tenantId); List<ExecutionPlanConfigurationFile> files = new ArrayList<ExecutionPlanConfigurationFile>(); if (executionPlanConfigurationFiles != null) { for (ExecutionPlanConfigurationFile configFile : executionPlanConfigurationFiles) { if (configFile.getStatus() == ExecutionPlanConfigurationFile.Status.ERROR || configFile.getStatus() == ExecutionPlanConfigurationFile.Status.WAITING_FOR_DEPENDENCY || configFile.getStatus() == ExecutionPlanConfigurationFile.Status.WAITING_FOR_OSGI_SERVICE) { files.add(configFile); } } } return files; }
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()); } } } }