diff --git a/components/event-flow/org.wso2.carbon.event.flow.ui/pom.xml b/components/event-flow/org.wso2.carbon.event.flow.ui/pom.xml index 2b8ddf2fc..a6e8a2546 100644 --- a/components/event-flow/org.wso2.carbon.event.flow.ui/pom.xml +++ b/components/event-flow/org.wso2.carbon.event.flow.ui/pom.xml @@ -1,5 +1,4 @@ - - - + --> org.wso2.carbon.event-processing event-flow - 2.2.14 + 2.2.17-SNAPSHOT ../pom.xml @@ -74,4 +72,4 @@ - + \ No newline at end of file diff --git a/components/event-flow/org.wso2.carbon.event.flow/pom.xml b/components/event-flow/org.wso2.carbon.event.flow/pom.xml index 9b9ca3ae7..416689a9d 100644 --- a/components/event-flow/org.wso2.carbon.event.flow/pom.xml +++ b/components/event-flow/org.wso2.carbon.event.flow/pom.xml @@ -1,5 +1,4 @@ - - - + --> org.wso2.carbon.event-processing event-flow - 2.2.14 + 2.2.17-SNAPSHOT ../pom.xml @@ -98,4 +96,4 @@ - + \ No newline at end of file diff --git a/components/event-flow/pom.xml b/components/event-flow/pom.xml index a8599df9d..b6b438882 100644 --- a/components/event-flow/pom.xml +++ b/components/event-flow/pom.xml @@ -1,5 +1,4 @@ - - - + --> org.wso2.carbon.event-processing carbon-event-processing - 2.2.14 + 2.2.17-SNAPSHOT ../../pom.xml @@ -34,4 +32,4 @@ org.wso2.carbon.event.flow.ui - + \ No newline at end of file diff --git a/components/event-processor/org.wso2.carbon.event.processor.admin/pom.xml b/components/event-processor/org.wso2.carbon.event.processor.admin/pom.xml index 77d4413e0..d26ef4197 100644 --- a/components/event-processor/org.wso2.carbon.event.processor.admin/pom.xml +++ b/components/event-processor/org.wso2.carbon.event.processor.admin/pom.xml @@ -1,5 +1,4 @@ - - - + --> org.wso2.carbon.event-processing event-processor - 2.2.14 + 2.2.17-SNAPSHOT ../pom.xml @@ -102,4 +100,4 @@ - + \ No newline at end of file diff --git a/components/event-processor/org.wso2.carbon.event.processor.admin/src/main/java/org/wso2/carbon/event/processor/admin/EventProcessorAdminService.java b/components/event-processor/org.wso2.carbon.event.processor.admin/src/main/java/org/wso2/carbon/event/processor/admin/EventProcessorAdminService.java index eb96e09ac..ba4ef7b05 100644 --- a/components/event-processor/org.wso2.carbon.event.processor.admin/src/main/java/org/wso2/carbon/event/processor/admin/EventProcessorAdminService.java +++ b/components/event-processor/org.wso2.carbon.event.processor.admin/src/main/java/org/wso2/carbon/event/processor/admin/EventProcessorAdminService.java @@ -159,25 +159,11 @@ public ExecutionPlanConfigurationDto[] getAllActiveExecutionPlanConfigurations() ExecutionPlanConfigurationDto[] configurationDtos = new ExecutionPlanConfigurationDto[executionPlanConfigurations.size()]; int i = 0; - if (isDistributedProcessingEnabled()) { - Map executionPlanStatuses = eventProcessorService.getAllExecutionPlanStatusesInStorm(); - for (Map.Entry entry : executionPlanConfigurations.entrySet()) { - ExecutionPlanConfigurationDto dto = new ExecutionPlanConfigurationDto(); - String status = executionPlanStatuses.get(entry.getKey()); - if (status == null) { - log.error("No distributed deployment status information available for execution plan " + entry.getKey()); - } - copyConfigurationsToDto(entry.getValue(), dto, status); - configurationDtos[i] = dto; - i++; - } - } else { - for (ExecutionPlanConfiguration planConfiguration : executionPlanConfigurations.values()) { - ExecutionPlanConfigurationDto dto = new ExecutionPlanConfigurationDto(); - copyConfigurationsToDto(planConfiguration, dto, null); - configurationDtos[i] = dto; - i++; - } + for (ExecutionPlanConfiguration planConfiguration : executionPlanConfigurations.values()) { + ExecutionPlanConfigurationDto dto = new ExecutionPlanConfigurationDto(); + copyConfigurationsToDto(planConfiguration, dto, null); + configurationDtos[i] = dto; + i++; } Arrays.sort(configurationDtos, new Comparator() { diff --git a/components/event-processor/org.wso2.carbon.event.processor.admin/src/main/java/org/wso2/carbon/event/processor/admin/internal/ds/EventProcessorAdminServiceDS.java b/components/event-processor/org.wso2.carbon.event.processor.admin/src/main/java/org/wso2/carbon/event/processor/admin/internal/ds/EventProcessorAdminServiceDS.java index 7a65398dc..cdf956b65 100644 --- a/components/event-processor/org.wso2.carbon.event.processor.admin/src/main/java/org/wso2/carbon/event/processor/admin/internal/ds/EventProcessorAdminServiceDS.java +++ b/components/event-processor/org.wso2.carbon.event.processor.admin/src/main/java/org/wso2/carbon/event/processor/admin/internal/ds/EventProcessorAdminServiceDS.java @@ -24,6 +24,7 @@ import org.osgi.service.component.annotations.ReferenceCardinality; import org.osgi.service.component.annotations.ReferencePolicy; + /** * This class is used to get the EventProcessor service. */ diff --git a/components/event-processor/org.wso2.carbon.event.processor.common/pom.xml b/components/event-processor/org.wso2.carbon.event.processor.common/pom.xml index 83143e749..0bb59bc9b 100644 --- a/components/event-processor/org.wso2.carbon.event.processor.common/pom.xml +++ b/components/event-processor/org.wso2.carbon.event.processor.common/pom.xml @@ -1,5 +1,4 @@ - - - + --> org.wso2.carbon.event-processing event-processor - 2.2.14 + 2.2.17-SNAPSHOT ../pom.xml @@ -29,11 +27,6 @@ bundle - - org.wso2.orbit.org.apache.storm - storm-core - ${storm.orbit.version} - org.wso2.siddhi siddhi-core @@ -125,4 +118,4 @@ - + \ No newline at end of file diff --git a/components/event-processor/org.wso2.carbon.event.processor.common/src/main/java/org/wso2/carbon/event/processor/common/storm/component/EventPublisherBolt.java b/components/event-processor/org.wso2.carbon.event.processor.common/src/main/java/org/wso2/carbon/event/processor/common/storm/component/EventPublisherBolt.java deleted file mode 100644 index 4b1744020..000000000 --- a/components/event-processor/org.wso2.carbon.event.processor.common/src/main/java/org/wso2/carbon/event/processor/common/storm/component/EventPublisherBolt.java +++ /dev/null @@ -1,185 +0,0 @@ -/* - * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.wso2.carbon.event.processor.common.storm.component; - -import backtype.storm.task.TopologyContext; -import backtype.storm.topology.BasicOutputCollector; -import backtype.storm.topology.OutputFieldsDeclarer; -import backtype.storm.topology.base.BaseBasicBolt; -import backtype.storm.tuple.Tuple; -import org.apache.commons.lang.ArrayUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.event.processor.common.util.AsyncEventPublisher; -import org.wso2.carbon.event.processor.manager.commons.utils.Utils; -import org.wso2.carbon.event.processor.manager.core.config.DistributedConfiguration; -import org.wso2.siddhi.core.ExecutionPlanRuntime; -import org.wso2.siddhi.core.SiddhiManager; -import org.wso2.siddhi.core.event.Event; -import org.wso2.siddhi.core.stream.output.StreamCallback; -import org.wso2.siddhi.query.api.definition.StreamDefinition; -import org.wso2.siddhi.query.compiler.SiddhiCompiler; - -import java.util.*; - -/** - * Publish events processed by Siddhi engine to CEP publisher - */ -public class EventPublisherBolt extends BaseBasicBolt { - private transient Log log = LogFactory.getLog(EventPublisherBolt.class); - /** - * All stream definitions processed - */ - private List inputStreamDefinitions; - private List outputStreamDefinitions; - private String query; - /** - * Keep track of relevant data bridge stream id for a given Siddhi stream id - */ - private transient Map streamIdToDefinitionMap; - - private transient AsyncEventPublisher asyncEventPublisher; - private BasicOutputCollector collector; - - private String executionPlanName; - - private String logPrefix; - - private int tenantId = -1234; - private DistributedConfiguration stormDeploymentConfig; - private Boolean initialized = false; - - private transient SiddhiManager siddhiManager; - private transient ExecutionPlanRuntime executionPlanRuntime; - - private int eventCount; - private long batchStartTime; - - public EventPublisherBolt(DistributedConfiguration stormDeploymentConfig, List inputStreamDefinitions, - List outputStreamDefinitions, String query, String executionPlanName, int tenantId) { - this.stormDeploymentConfig = stormDeploymentConfig; - this.inputStreamDefinitions = inputStreamDefinitions; - this.outputStreamDefinitions = outputStreamDefinitions; - this.query = query; - this.executionPlanName = executionPlanName; - this.tenantId = tenantId; - this.logPrefix = "[" + tenantId + ":" + executionPlanName + ":" + "EventPublisherBolt]"; - - } - - @Override - public void execute(Tuple tuple, BasicOutputCollector basicOutputCollector) { - if (log.isDebugEnabled()) { - log.debug(logPrefix + "Received Event: " + tuple.getSourceStreamId() + ":" + Arrays.deepToString(tuple - .getValues().toArray())); - } - - this.collector = basicOutputCollector; - if (!initialized) { - init(); - } - - Object[] dataArray = tuple.getValues().toArray(); - long timestamp = (Long) dataArray[dataArray.length - 1]; - dataArray = ArrayUtils.remove(dataArray, dataArray.length - 1); - - StreamDefinition streamDefinition = streamIdToDefinitionMap.get(tuple.getSourceStreamId()); - if (streamDefinition != null) { - asyncEventPublisher.sendEvent(dataArray, timestamp, tuple.getSourceStreamId()); - } else { - log.warn(logPrefix + "Tuple received for unknown stream " + tuple.getSourceStreamId() + ". Discarding " + - "Event: " + tuple.getSourceStreamId() + ":" + Arrays.deepToString(dataArray) + "@" + timestamp); - } - if (log.isDebugEnabled()) { - log.debug(logPrefix + "Emitted Event: " + tuple.getSourceStreamId() + ":" + Arrays.deepToString(dataArray) + "@" + timestamp); - } - } - - @Override - public void declareOutputFields(OutputFieldsDeclarer outputFieldsDeclarer) { - - } - - @Override - public void prepare(Map stormConf, TopologyContext context) { - super.prepare(stormConf, context); - init(); - } - - private void init() { - try { - log = LogFactory.getLog(EventPublisherBolt.class); - initialized = true; - //Adding functionality to support query execution at publisher level for future use cases. - if (query != null && (!query.isEmpty())) { - siddhiManager = new SiddhiManager(); - eventCount = 0; - batchStartTime = System.currentTimeMillis(); - log = LogFactory.getLog(SiddhiBolt.class); - - String fullQueryExpression = Utils.constructQueryExpression(inputStreamDefinitions, outputStreamDefinitions, - query); - executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(fullQueryExpression); - - for (String outputStreamDefinition : outputStreamDefinitions) { - final StreamDefinition outputSiddhiDefinition = SiddhiCompiler.parseStreamDefinition - (outputStreamDefinition); - log.info(logPrefix + "Adding callback for stream:" + outputSiddhiDefinition.getId()); - executionPlanRuntime.addCallback(outputSiddhiDefinition.getId(), new StreamCallback() { - - @Override - public void receive(Event[] events) { - for (Event event : events) { - Object[] eventData = Arrays.copyOf(event.getData(), event.getData().length + 1); - eventData[event.getData().length] = event.getTimestamp(); - collector.emit(outputSiddhiDefinition.getId(), Arrays.asList(eventData)); - if (log.isDebugEnabled()) { - if (++eventCount % 10000 == 0) { - double timeSpentInSecs = (System.currentTimeMillis() - batchStartTime) / 1000.0D; - double throughput = 10000 / timeSpentInSecs; - log.debug(logPrefix + "Processed 10000 events in " + timeSpentInSecs + " " + - "seconds, throughput : " + throughput + " events/sec. Stream : " + - outputSiddhiDefinition.getId()); - eventCount = 0; - batchStartTime = System.currentTimeMillis(); - } - log.debug(logPrefix + "Emitted Event:" + outputSiddhiDefinition.getId() + - ":" + Arrays.deepToString(eventData) + "@" + event.getTimestamp()); - } - } - } - }); - - } - executionPlanRuntime.start(); - } - streamIdToDefinitionMap = new HashMap(); - StreamDefinition siddhiDefinition; - for (String outputStreamDefinition : outputStreamDefinitions) { - siddhiDefinition = SiddhiCompiler.parseStreamDefinition(outputStreamDefinition); - streamIdToDefinitionMap.put(siddhiDefinition.getId(), siddhiDefinition); - } - - asyncEventPublisher = new AsyncEventPublisher(AsyncEventPublisher.DestinationType.CEP_PUBLISHER, - new HashSet(streamIdToDefinitionMap.values()), - stormDeploymentConfig.getManagers(), executionPlanName, tenantId, stormDeploymentConfig, null); - - asyncEventPublisher.initializeConnection(false); - } catch (Throwable e) { - log.error(logPrefix + "Error starting event publisher bolt: " + e.getMessage(), e); - } - } -} diff --git a/components/event-processor/org.wso2.carbon.event.processor.common/src/main/java/org/wso2/carbon/event/processor/common/storm/component/EventReceiverSpout.java b/components/event-processor/org.wso2.carbon.event.processor.common/src/main/java/org/wso2/carbon/event/processor/common/storm/component/EventReceiverSpout.java deleted file mode 100644 index be17f4cdb..000000000 --- a/components/event-processor/org.wso2.carbon.event.processor.common/src/main/java/org/wso2/carbon/event/processor/common/storm/component/EventReceiverSpout.java +++ /dev/null @@ -1,281 +0,0 @@ -/* - * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.wso2.carbon.event.processor.common.storm.component; - -import backtype.storm.spout.SpoutOutputCollector; -import backtype.storm.task.TopologyContext; -import backtype.storm.topology.OutputFieldsDeclarer; -import backtype.storm.topology.base.BaseRichSpout; -import backtype.storm.tuple.Fields; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.thrift.protocol.TBinaryProtocol; -import org.apache.thrift.protocol.TProtocol; -import org.apache.thrift.transport.TSocket; -import org.apache.thrift.transport.TTransport; -import org.wso2.carbon.event.processor.common.storm.event.Event; -import org.wso2.carbon.event.processor.common.storm.manager.service.StormManagerService; -import org.wso2.carbon.event.processor.common.util.ThroughputProbe; -import org.wso2.carbon.event.processor.manager.commons.transport.server.StreamCallback; -import org.wso2.carbon.event.processor.manager.commons.transport.server.TCPEventServer; -import org.wso2.carbon.event.processor.manager.commons.transport.server.TCPEventServerConfig; -import org.wso2.carbon.event.processor.manager.commons.utils.HostAndPort; -import org.wso2.carbon.event.processor.manager.commons.utils.Utils; -import org.wso2.carbon.event.processor.manager.core.config.DistributedConfiguration; -import org.wso2.siddhi.query.api.definition.StreamDefinition; -import org.wso2.siddhi.query.compiler.SiddhiCompiler; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Map; -import java.util.concurrent.LinkedBlockingQueue; - -/** - * Receive events from CEP receivers through thrift receiver and pass through - * the events as tuples to the connected component(i.e. Siddhi Bolt). - */ -public class EventReceiverSpout extends BaseRichSpout implements StreamCallback { - private static transient Log log = LogFactory.getLog(EventReceiverSpout.class); - /** - * Listening port of the thrift receiver - */ - private int listeningPort; - private String thisHostIp; - - private DistributedConfiguration stormDeploymentConfig; - /** - * Siddhi stream definitions of all incoming streams. Required to declare output fields - */ - private List incomingStreamDefinitions; - private TCPEventServer tcpEventServer; - - /** - * Stream IDs of incoming streams - */ - private List incomingStreamIDs = new ArrayList(); - - /** - * Store received events until nextTuple is called. This list has to be synchronized since - * this is filled by the receiver thread of data bridge and consumed by the nextTuple which - * runs on the worker thread of spout. - */ - private transient LinkedBlockingQueue storedEvents = null; - - private SpoutOutputCollector spoutOutputCollector = null; - - private String executionPlanName; - private int tenantId = -1234; - private String logPrefix; - private int heartbeatInterval; - - private transient ThroughputProbe inputThroughputProbe; - private transient ThroughputProbe outputThroughputProbe; - - /** - * Receives events from the CEP Receiver through Thrift using data bridge and pass through the events - * to a downstream component as tupels. - * - * @param stormDeploymentConfig - * @param incomingStreamDefinitions - Incoming Siddhi stream definitions - * @param executionPlanName - * @param tenantId - */ - public EventReceiverSpout(DistributedConfiguration stormDeploymentConfig, List incomingStreamDefinitions, - String executionPlanName, int tenantId, int heartbeatInterval) { - this.incomingStreamDefinitions = new ArrayList(incomingStreamDefinitions.size()); - this.stormDeploymentConfig = stormDeploymentConfig; - this.executionPlanName = executionPlanName; - this.tenantId = tenantId; - this.heartbeatInterval = heartbeatInterval; - for (String definition : incomingStreamDefinitions) { - this.incomingStreamDefinitions.add(SiddhiCompiler.parseStreamDefinition(definition)); - } - this.logPrefix = "[" + tenantId + ":" + executionPlanName + ":" + "EventReceiverSpout] "; - - - } - - @Override - public void declareOutputFields(OutputFieldsDeclarer outputFieldsDeclarer) { - // Declaring all incoming streams as output streams because this spouts role is to pass through all the incoming events as tuples. - for (StreamDefinition siddhiStreamDefinition : incomingStreamDefinitions) { - List attributeList = new ArrayList<>(Arrays.asList(siddhiStreamDefinition.getAttributeNameArray())); - attributeList.add(0, "_timestamp"); - Fields fields = new Fields(attributeList); - outputFieldsDeclarer.declareStream(siddhiStreamDefinition.getId(), fields); - incomingStreamIDs.add(siddhiStreamDefinition.getId()); - log.info(logPrefix + "Declaring output fields for stream : " + siddhiStreamDefinition.getId()); - } - } - - @Override - public void open(Map map, TopologyContext topologyContext, SpoutOutputCollector spoutOutputCollector) { - this.spoutOutputCollector = spoutOutputCollector; - this.storedEvents = new LinkedBlockingQueue(stormDeploymentConfig.getStormSpoutBufferSize()); - - inputThroughputProbe = new ThroughputProbe(logPrefix + "-IN", 10); - outputThroughputProbe = new ThroughputProbe(logPrefix + " -OUT", 10); - - inputThroughputProbe.startSampling(); - outputThroughputProbe.startSampling(); - - try { - thisHostIp = Utils.findAddress("localhost"); - listeningPort = findPort(thisHostIp); - TCPEventServerConfig configs = new TCPEventServerConfig(thisHostIp, listeningPort); - tcpEventServer = new TCPEventServer(configs, this, null); - for (StreamDefinition siddhiStreamDefinition : incomingStreamDefinitions) { - tcpEventServer.addStreamDefinition(siddhiStreamDefinition); - } - tcpEventServer.start(); - log.info(logPrefix + "EventReceiverSpout starting to listen for events on port " + listeningPort); - Thread thread = new Thread(new Registrar()); - thread.start(); - } catch (Throwable e) { - log.error(logPrefix + "Error starting event listener for spout: " + e.getMessage(), e); - } - } - - @Override - public void nextTuple() { - Event event = storedEvents.poll(); - if (event != null) { - final String siddhiStreamName = event.getStreamId(); - if (incomingStreamIDs.contains(siddhiStreamName)) { - Object[] eventData = Arrays.copyOf(event.getData(), event.getData().length + 1); - eventData[event.getData().length] = event.getTimestamp(); - spoutOutputCollector.emit(siddhiStreamName, Arrays.asList(eventData)); - - if (log.isDebugEnabled()) { - log.debug(logPrefix + "Emitted Event: " + siddhiStreamName + ":" + Arrays.deepToString(eventData) + "@" + event.getTimestamp()); - } - outputThroughputProbe.update(); - } else { - log.warn(logPrefix + "Event received for unknown stream : " + siddhiStreamName); - } - } - - } - - private int findPort(String host) throws Exception { - for (int i = stormDeploymentConfig.getTransportMinPort(); i <= stormDeploymentConfig.getTransportMaxPort(); i++) { - if (!Utils.isPortUsed(i, host)) { - return i; - } - } - throw new Exception("Cannot find free port in range " + stormDeploymentConfig.getTransportMinPort() + "~" + stormDeploymentConfig.getTransportMaxPort()); - } - - - @Override - public void receive(String streamId, long timestamp, Object[] eventData, Map arbitraryMapData) { - if (log.isDebugEnabled()) { - log.debug(logPrefix + "Received Event: " + streamId + ":" + Arrays.deepToString(eventData) + "@" + timestamp); - } - try { - storedEvents.put(new Event(timestamp, eventData, streamId)); - inputThroughputProbe.update(); - } catch (InterruptedException e) { - //ignore - } - } - - - class Registrar implements Runnable { - private String managerHost; - private int managerPort; - - @Override - public void run() { - log.info(logPrefix + "Registering Event Receiver Spout for " + thisHostIp + ":" + listeningPort); - - // Infinitely call register. Each register call will act as a heartbeat - while (true) { - if (registerStormReceiverWithStormMangerService()) { - while (true) { - TTransport transport = null; - try { - transport = new TSocket(managerHost, managerPort); - TProtocol protocol = new TBinaryProtocol(transport); - transport.open(); - - StormManagerService.Client client = new StormManagerService.Client(protocol); - client.registerStormReceiver(tenantId, executionPlanName, thisHostIp, listeningPort); - if (log.isDebugEnabled()) { - log.debug(logPrefix + "Successfully registered Event Receiver Spout for " + - thisHostIp + ":" + listeningPort); - } - try { - Thread.sleep(heartbeatInterval); - } catch (InterruptedException e1) { - continue; - } - } catch (Exception e) { - log.error(logPrefix + "Error in registering Event Receiver Spout for " + thisHostIp + ":" + - listeningPort + " with manager " + managerHost + ":" + managerPort + ". Trying next " + - "manager after " + heartbeatInterval + "ms", e); - break; - } finally { - if (transport != null) { - transport.close(); - } - } - } - } else { - log.error(logPrefix + "Error registering Event Receiver Spout with given set of manager nodes. " + - "Retrying after " + heartbeatInterval + "ms"); - } - try { - Thread.sleep(heartbeatInterval); - } catch (InterruptedException e1) { - continue; - } - } - } - - private boolean registerStormReceiverWithStormMangerService() { - TTransport transport = null; - for (HostAndPort endpoint : stormDeploymentConfig.getManagers()) { - try { - transport = new TSocket(endpoint.getHostName(), endpoint.getPort()); - TProtocol protocol = new TBinaryProtocol(transport); - transport.open(); - - StormManagerService.Client client = new StormManagerService.Client(protocol); - client.registerStormReceiver(tenantId, executionPlanName, thisHostIp, listeningPort); - - log.info(logPrefix + "Successfully registered Event Receiver Spout for " + thisHostIp + ":" + listeningPort - + " with manager service at " + endpoint.getHostName() + ":" + endpoint.getPort()); - - managerHost = endpoint.getHostName(); - managerPort = endpoint.getPort(); - return true; - } catch (Exception e) { - log.error(logPrefix + "Error in registering Event Receiver Spout for " + thisHostIp + ":" + - listeningPort + " with manager " + endpoint.getHostName() + ":" + endpoint.getPort() + - ", Trying next manager.", e); - continue; - } finally { - if (transport != null) { - transport.close(); - } - } - } - return false; - } - } -} diff --git a/components/event-processor/org.wso2.carbon.event.processor.common/src/main/java/org/wso2/carbon/event/processor/common/storm/component/SiddhiBolt.java b/components/event-processor/org.wso2.carbon.event.processor.common/src/main/java/org/wso2/carbon/event/processor/common/storm/component/SiddhiBolt.java deleted file mode 100644 index c090501aa..000000000 --- a/components/event-processor/org.wso2.carbon.event.processor.common/src/main/java/org/wso2/carbon/event/processor/common/storm/component/SiddhiBolt.java +++ /dev/null @@ -1,190 +0,0 @@ -/* - * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.wso2.carbon.event.processor.common.storm.component; - -import backtype.storm.task.TopologyContext; -import backtype.storm.topology.BasicOutputCollector; -import backtype.storm.topology.OutputFieldsDeclarer; -import backtype.storm.topology.base.BaseBasicBolt; -import backtype.storm.tuple.Fields; -import backtype.storm.tuple.Tuple; -import org.apache.commons.lang.ArrayUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.event.processor.common.util.ThroughputProbe; -import org.wso2.carbon.event.processor.manager.commons.utils.Utils; -import org.wso2.siddhi.core.ExecutionPlanRuntime; -import org.wso2.siddhi.core.SiddhiManager; -import org.wso2.siddhi.core.event.Event; -import org.wso2.siddhi.core.stream.input.InputHandler; -import org.wso2.siddhi.core.stream.output.StreamCallback; -import org.wso2.siddhi.query.api.definition.Attribute; -import org.wso2.siddhi.query.api.definition.StreamDefinition; -import org.wso2.siddhi.query.compiler.SiddhiCompiler; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Map; - -/** - * Bold which runs Siddhi engine - */ - -public class SiddhiBolt extends BaseBasicBolt { - private final String name; - private transient Log log = LogFactory.getLog(SiddhiBolt.class); - private transient SiddhiManager siddhiManager; - - /** - * Exported stream IDs. Must declare output filed for each exported stream - */ - private List outputStreamDefinitions; - /** - * All stream inputStreamDefinitions and partition inputStreamDefinitions(if any) - */ - private List inputStreamDefinitions; - /** - * Queries to be executed in Siddhi. - */ - private String query; - - private BasicOutputCollector collector; - private String logPrefix; - - private transient ExecutionPlanRuntime executionPlanRuntime; - - private transient ThroughputProbe inputThroughputProbe; - private transient ThroughputProbe emitThroughputProbe; - - /** - * Bolt which runs the Siddhi engine. - * - * @param inputStreamDefinitions - All stream and partition inputStreamDefinitions - * @param query - Siddhi query - * @param outputSiddhiDefinitions - The names of streams that will be output from this particular bolt - */ - public SiddhiBolt(String name, List inputStreamDefinitions, String query, - List outputSiddhiDefinitions, String executionPlanName, int tenantId) { - this.inputStreamDefinitions = inputStreamDefinitions; - this.query = query; - this.outputStreamDefinitions = outputSiddhiDefinitions; - this.name = name; - this.logPrefix = "[" + tenantId + ":" + executionPlanName + ":" + name + "] "; - init(); - } - - /** - * Bolt get saved and reloaded, this to redo the configurations. - */ - private void init() { - log = LogFactory.getLog(SiddhiBolt.class); - - inputThroughputProbe = new ThroughputProbe(logPrefix + "-IN", 10); - emitThroughputProbe = new ThroughputProbe(logPrefix + " -EMIT", 10); - - inputThroughputProbe.startSampling(); - emitThroughputProbe.startSampling(); - - siddhiManager = new SiddhiManager(); - String fullQueryExpression = Utils.constructQueryExpression(inputStreamDefinitions, outputStreamDefinitions, - query); - executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(fullQueryExpression); - - for (String outputStreamDefinition : outputStreamDefinitions) { - final StreamDefinition outputSiddhiDefinition = SiddhiCompiler.parseStreamDefinition(outputStreamDefinition); - if (log.isDebugEnabled()) { - log.debug(logPrefix + " Adding callback for stream: " + outputSiddhiDefinition.getId()); - } - executionPlanRuntime.addCallback(outputSiddhiDefinition.getId(), new StreamCallback() { - - @Override - public void receive(Event[] events) { - for (Event event : events) { - Object[] eventData = Arrays.copyOf(event.getData(), event.getData().length + 1); - eventData[event.getData().length] = event.getTimestamp(); - collector.emit(outputSiddhiDefinition.getId(), Arrays.asList(eventData)); - - if (log.isDebugEnabled()) { - log.debug(logPrefix + "Emitted Event:" + outputSiddhiDefinition.getId() + - ":" + Arrays.deepToString(eventData) + "@" + event.getTimestamp()); - } - - emitThroughputProbe.update(); - } - } - }); - } - executionPlanRuntime.start(); - } - - @Override - public void prepare(Map stormConf, TopologyContext context) { - super.prepare(stormConf, context); - } - - @Override - public void execute(Tuple tuple, BasicOutputCollector collector) { - if (siddhiManager == null) { - init(); - } - inputThroughputProbe.update(); - - try { - this.collector = collector; - InputHandler inputHandler = executionPlanRuntime.getInputHandler(tuple.getSourceStreamId()); - Object[] dataArray = tuple.getValues().toArray(); - long timestamp = (Long) dataArray[dataArray.length - 1]; - dataArray = ArrayUtils.remove(dataArray, dataArray.length - 1); - - if (log.isDebugEnabled()) { - log.debug(logPrefix + "Received Event: " + tuple.getSourceStreamId() + ":" + Arrays.deepToString(dataArray) + "@" + timestamp); - } - - if (inputHandler != null) { - inputHandler.send(timestamp, dataArray); - } else { - log.warn(logPrefix + "Event received for unknown stream " + tuple.getSourceStreamId() + ". Discarding" + - " the Event: " + tuple.getSourceStreamId() + ":" + Arrays.deepToString(dataArray) + "@" + timestamp); - } - } catch (InterruptedException e) { - log.error(e); - } - } - - @Override - public void declareOutputFields(OutputFieldsDeclarer declarer) { - if (siddhiManager == null) { - init(); - } - - // Declaring output fields for each exported stream ID - for (String outputStreamDefinition : outputStreamDefinitions) { - StreamDefinition siddhiOutputDefinition = SiddhiCompiler.parseStreamDefinition(outputStreamDefinition); - if (outputStreamDefinition == null) { - throw new RuntimeException(logPrefix + "Cannot find exported stream : " + siddhiOutputDefinition.getId()); - } - List list = new ArrayList(); - list.add(0,"_timestamp"); - for (Attribute attribute : siddhiOutputDefinition.getAttributeList()) { - list.add(attribute.getName()); - } - Fields fields = new Fields(list); - declarer.declareStream(siddhiOutputDefinition.getId(), fields); - log.info(logPrefix + "Declaring output field for stream :" + siddhiOutputDefinition.getId()); - } - } -} diff --git a/components/event-processor/org.wso2.carbon.event.processor.common/src/main/java/org/wso2/carbon/event/processor/common/storm/component/TriggerSpout.java b/components/event-processor/org.wso2.carbon.event.processor.common/src/main/java/org/wso2/carbon/event/processor/common/storm/component/TriggerSpout.java deleted file mode 100644 index 66b8c51cf..000000000 --- a/components/event-processor/org.wso2.carbon.event.processor.common/src/main/java/org/wso2/carbon/event/processor/common/storm/component/TriggerSpout.java +++ /dev/null @@ -1,80 +0,0 @@ -package org.wso2.carbon.event.processor.common.storm.component; - -import backtype.storm.spout.SpoutOutputCollector; -import backtype.storm.task.TopologyContext; -import backtype.storm.topology.OutputFieldsDeclarer; -import backtype.storm.topology.base.BaseRichSpout; -import backtype.storm.tuple.Fields; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.siddhi.core.ExecutionPlanRuntime; -import org.wso2.siddhi.core.SiddhiManager; -import org.wso2.siddhi.core.event.Event; -import org.wso2.siddhi.core.stream.output.StreamCallback; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Map; - -/** - * Spout to hold a siddhi trigger. There will be one instance of this class per trigger. - * - */ -public class TriggerSpout extends BaseRichSpout { - public static final String TRIGGER_TIME_FIELD_NAME = "triggered_time"; - String triggerId; - String triggerDefinition; - SpoutOutputCollector outputCollector; - private transient SiddhiManager siddhiManager; - private transient ExecutionPlanRuntime executionPlanRuntime; - private static transient Log log = LogFactory.getLog(TriggerSpout.class); - String logPrefix; - - public TriggerSpout(String triggerId, String triggerDefinition, String executionPlanName, int tenantId){ - this.triggerId = triggerId; - this.triggerDefinition = triggerDefinition; - this.logPrefix = "[" + tenantId + ":" + executionPlanName + ":" + triggerId + "] "; - } - - @Override - public void declareOutputFields(OutputFieldsDeclarer outputFieldsDeclarer) { - List list = new ArrayList(); - list.add(0,"_timestamp"); - list.add(0, TRIGGER_TIME_FIELD_NAME); - Fields fields = new Fields(list); - - outputFieldsDeclarer.declareStream(triggerId, fields); - } - - @Override - public void open(Map map, TopologyContext topologyContext, final SpoutOutputCollector spoutOutputCollector) { - this.outputCollector = spoutOutputCollector; - - siddhiManager = new SiddhiManager(); - String fullQueryExpression = triggerDefinition; - executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(fullQueryExpression); - - executionPlanRuntime.addCallback(triggerId, new StreamCallback() { - - @Override - public void receive(Event[] events) { - for (Event event : events) { - Object[] eventData = Arrays.copyOf(event.getData(), event.getData().length + 1); - eventData[event.getData().length] = event.getTimestamp(); - outputCollector.emit(triggerId, Arrays.asList(eventData)); - - if (log.isDebugEnabled()) { - log.debug(logPrefix + "Trigger Event Emitted :" + Arrays.deepToString(eventData)); - } - } - } - }); - executionPlanRuntime.start(); - } - - @Override - public void nextTuple() { - - } -} diff --git a/components/event-processor/org.wso2.carbon.event.processor.common/src/main/java/org/wso2/carbon/event/processor/common/storm/event/Event.java b/components/event-processor/org.wso2.carbon.event.processor.common/src/main/java/org/wso2/carbon/event/processor/common/storm/event/Event.java deleted file mode 100644 index ece0f5a6b..000000000 --- a/components/event-processor/org.wso2.carbon.event.processor.common/src/main/java/org/wso2/carbon/event/processor/common/storm/event/Event.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.wso2.carbon.event.processor.common.storm.event; - -/** - * Extended Event class to hold additional Stream ID info needed in - * Storm EventReceiverSpout - */ -public class Event extends org.wso2.siddhi.core.event.Event { - - private String streamId; - - public Event (long timestamp, Object[] data, String streamId){ - super.setTimestamp(timestamp); - super.setData(data); - this.streamId = streamId; - } - - public String getStreamId() { - return streamId; - } - - public void setStreamId(String streamId) { - this.streamId = streamId; - } - - -} diff --git a/components/event-processor/org.wso2.carbon.event.processor.common/src/main/java/org/wso2/carbon/event/processor/common/storm/manager/service/StormManagerService.java b/components/event-processor/org.wso2.carbon.event.processor.common/src/main/java/org/wso2/carbon/event/processor/common/storm/manager/service/StormManagerService.java deleted file mode 100644 index 3a25018b7..000000000 --- a/components/event-processor/org.wso2.carbon.event.processor.common/src/main/java/org/wso2/carbon/event/processor/common/storm/manager/service/StormManagerService.java +++ /dev/null @@ -1,4976 +0,0 @@ -/** - * Autogenerated by Thrift Compiler (0.9.1) - * - * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING - * @generated - */ -package org.wso2.carbon.event.processor.common.storm.manager.service; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.thrift.scheme.IScheme; -import org.apache.thrift.scheme.SchemeFactory; -import org.apache.thrift.scheme.StandardScheme; - -import org.apache.thrift.scheme.TupleScheme; -import org.apache.thrift.protocol.TTupleProtocol; -import org.apache.thrift.protocol.TProtocolException; -import org.apache.thrift.EncodingUtils; -import org.apache.thrift.TException; -import org.apache.thrift.async.AsyncMethodCallback; -import org.apache.thrift.server.AbstractNonblockingServer.*; -import java.util.List; -import java.util.ArrayList; -import java.util.Map; -import java.util.HashMap; -import java.util.EnumMap; -import java.util.Set; -import java.util.HashSet; -import java.util.EnumSet; -import java.util.Collections; -import java.util.BitSet; -import java.nio.ByteBuffer; -import java.util.Arrays; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class StormManagerService { - - public interface Iface { - - public void registerStormReceiver(int tenantId, String executionPlanName, String hostName, int port) throws org.wso2.carbon.event.processor.common.storm.manager.service.exception.NotStormCoordinatorException, org.apache.thrift.TException; - - public void registerCEPPublisher(int tenantId, String executionPlanName, String hostName, int port) throws org.wso2.carbon.event.processor.common.storm.manager.service.exception.NotStormCoordinatorException, org.apache.thrift.TException; - - public String getStormReceiver(int tenantId, String executionPlanName, String cepReceiverHostName) throws org.wso2.carbon.event.processor.common.storm.manager.service.exception.NotStormCoordinatorException, org.wso2.carbon.event.processor.common.storm.manager.service.exception.EndpointNotFoundException, org.apache.thrift.TException; - - public String getCEPPublisher(int tenantId, String executionPlanName, String stormPublisherHostName) throws org.wso2.carbon.event.processor.common.storm.manager.service.exception.NotStormCoordinatorException, org.wso2.carbon.event.processor.common.storm.manager.service.exception.EndpointNotFoundException, org.apache.thrift.TException; - - } - - public interface AsyncIface { - - public void registerStormReceiver(int tenantId, String executionPlanName, String hostName, int port, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException; - - public void registerCEPPublisher(int tenantId, String executionPlanName, String hostName, int port, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException; - - public void getStormReceiver(int tenantId, String executionPlanName, String cepReceiverHostName, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException; - - public void getCEPPublisher(int tenantId, String executionPlanName, String stormPublisherHostName, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException; - - } - - public static class Client extends org.apache.thrift.TServiceClient implements Iface { - public static class Factory implements org.apache.thrift.TServiceClientFactory { - public Factory() {} - public Client getClient(org.apache.thrift.protocol.TProtocol prot) { - return new Client(prot); - } - public Client getClient(org.apache.thrift.protocol.TProtocol iprot, org.apache.thrift.protocol.TProtocol oprot) { - return new Client(iprot, oprot); - } - } - - public Client(org.apache.thrift.protocol.TProtocol prot) - { - super(prot, prot); - } - - public Client(org.apache.thrift.protocol.TProtocol iprot, org.apache.thrift.protocol.TProtocol oprot) { - super(iprot, oprot); - } - - public void registerStormReceiver(int tenantId, String executionPlanName, String hostName, int port) throws org.wso2.carbon.event.processor.common.storm.manager.service.exception.NotStormCoordinatorException, org.apache.thrift.TException - { - send_registerStormReceiver(tenantId, executionPlanName, hostName, port); - recv_registerStormReceiver(); - } - - public void send_registerStormReceiver(int tenantId, String executionPlanName, String hostName, int port) throws org.apache.thrift.TException - { - registerStormReceiver_args args = new registerStormReceiver_args(); - args.setTenantId(tenantId); - args.setExecutionPlanName(executionPlanName); - args.setHostName(hostName); - args.setPort(port); - sendBase("registerStormReceiver", args); - } - - public void recv_registerStormReceiver() throws org.wso2.carbon.event.processor.common.storm.manager.service.exception.NotStormCoordinatorException, org.apache.thrift.TException - { - registerStormReceiver_result result = new registerStormReceiver_result(); - receiveBase(result, "registerStormReceiver"); - if (result.nsme != null) { - throw result.nsme; - } - return; - } - - public void registerCEPPublisher(int tenantId, String executionPlanName, String hostName, int port) throws org.wso2.carbon.event.processor.common.storm.manager.service.exception.NotStormCoordinatorException, org.apache.thrift.TException - { - send_registerCEPPublisher(tenantId, executionPlanName, hostName, port); - recv_registerCEPPublisher(); - } - - public void send_registerCEPPublisher(int tenantId, String executionPlanName, String hostName, int port) throws org.apache.thrift.TException - { - registerCEPPublisher_args args = new registerCEPPublisher_args(); - args.setTenantId(tenantId); - args.setExecutionPlanName(executionPlanName); - args.setHostName(hostName); - args.setPort(port); - sendBase("registerCEPPublisher", args); - } - - public void recv_registerCEPPublisher() throws org.wso2.carbon.event.processor.common.storm.manager.service.exception.NotStormCoordinatorException, org.apache.thrift.TException - { - registerCEPPublisher_result result = new registerCEPPublisher_result(); - receiveBase(result, "registerCEPPublisher"); - if (result.nsme != null) { - throw result.nsme; - } - return; - } - - public String getStormReceiver(int tenantId, String executionPlanName, String cepReceiverHostName) throws org.wso2.carbon.event.processor.common.storm.manager.service.exception.NotStormCoordinatorException, org.wso2.carbon.event.processor.common.storm.manager.service.exception.EndpointNotFoundException, org.apache.thrift.TException - { - send_getStormReceiver(tenantId, executionPlanName, cepReceiverHostName); - return recv_getStormReceiver(); - } - - public void send_getStormReceiver(int tenantId, String executionPlanName, String cepReceiverHostName) throws org.apache.thrift.TException - { - getStormReceiver_args args = new getStormReceiver_args(); - args.setTenantId(tenantId); - args.setExecutionPlanName(executionPlanName); - args.setCepReceiverHostName(cepReceiverHostName); - sendBase("getStormReceiver", args); - } - - public String recv_getStormReceiver() throws org.wso2.carbon.event.processor.common.storm.manager.service.exception.NotStormCoordinatorException, org.wso2.carbon.event.processor.common.storm.manager.service.exception.EndpointNotFoundException, org.apache.thrift.TException - { - getStormReceiver_result result = new getStormReceiver_result(); - receiveBase(result, "getStormReceiver"); - if (result.isSetSuccess()) { - return result.success; - } - if (result.nsme != null) { - throw result.nsme; - } - if (result.enfe != null) { - throw result.enfe; - } - throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "getStormReceiver failed: unknown result"); - } - - public String getCEPPublisher(int tenantId, String executionPlanName, String stormPublisherHostName) throws org.wso2.carbon.event.processor.common.storm.manager.service.exception.NotStormCoordinatorException, org.wso2.carbon.event.processor.common.storm.manager.service.exception.EndpointNotFoundException, org.apache.thrift.TException - { - send_getCEPPublisher(tenantId, executionPlanName, stormPublisherHostName); - return recv_getCEPPublisher(); - } - - public void send_getCEPPublisher(int tenantId, String executionPlanName, String stormPublisherHostName) throws org.apache.thrift.TException - { - getCEPPublisher_args args = new getCEPPublisher_args(); - args.setTenantId(tenantId); - args.setExecutionPlanName(executionPlanName); - args.setStormPublisherHostName(stormPublisherHostName); - sendBase("getCEPPublisher", args); - } - - public String recv_getCEPPublisher() throws org.wso2.carbon.event.processor.common.storm.manager.service.exception.NotStormCoordinatorException, org.wso2.carbon.event.processor.common.storm.manager.service.exception.EndpointNotFoundException, org.apache.thrift.TException - { - getCEPPublisher_result result = new getCEPPublisher_result(); - receiveBase(result, "getCEPPublisher"); - if (result.isSetSuccess()) { - return result.success; - } - if (result.nsme != null) { - throw result.nsme; - } - if (result.enfe != null) { - throw result.enfe; - } - throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "getCEPPublisher failed: unknown result"); - } - - } - public static class AsyncClient extends org.apache.thrift.async.TAsyncClient implements AsyncIface { - public static class Factory implements org.apache.thrift.async.TAsyncClientFactory { - private org.apache.thrift.async.TAsyncClientManager clientManager; - private org.apache.thrift.protocol.TProtocolFactory protocolFactory; - public Factory(org.apache.thrift.async.TAsyncClientManager clientManager, org.apache.thrift.protocol.TProtocolFactory protocolFactory) { - this.clientManager = clientManager; - this.protocolFactory = protocolFactory; - } - public AsyncClient getAsyncClient(org.apache.thrift.transport.TNonblockingTransport transport) { - return new AsyncClient(protocolFactory, clientManager, transport); - } - } - - public AsyncClient(org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.async.TAsyncClientManager clientManager, org.apache.thrift.transport.TNonblockingTransport transport) { - super(protocolFactory, clientManager, transport); - } - - public void registerStormReceiver(int tenantId, String executionPlanName, String hostName, int port, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException { - checkReady(); - registerStormReceiver_call method_call = new registerStormReceiver_call(tenantId, executionPlanName, hostName, port, resultHandler, this, ___protocolFactory, ___transport); - this.___currentMethod = method_call; - ___manager.call(method_call); - } - - public static class registerStormReceiver_call extends org.apache.thrift.async.TAsyncMethodCall { - private int tenantId; - private String executionPlanName; - private String hostName; - private int port; - public registerStormReceiver_call(int tenantId, String executionPlanName, String hostName, int port, org.apache.thrift.async.AsyncMethodCallback resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException { - super(client, protocolFactory, transport, resultHandler, false); - this.tenantId = tenantId; - this.executionPlanName = executionPlanName; - this.hostName = hostName; - this.port = port; - } - - public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException { - prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("registerStormReceiver", org.apache.thrift.protocol.TMessageType.CALL, 0)); - registerStormReceiver_args args = new registerStormReceiver_args(); - args.setTenantId(tenantId); - args.setExecutionPlanName(executionPlanName); - args.setHostName(hostName); - args.setPort(port); - args.write(prot); - prot.writeMessageEnd(); - } - - public void getResult() throws org.wso2.carbon.event.processor.common.storm.manager.service.exception.NotStormCoordinatorException, org.apache.thrift.TException { - if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) { - throw new IllegalStateException("Method call not finished!"); - } - org.apache.thrift.transport.TMemoryInputTransport memoryTransport = new org.apache.thrift.transport.TMemoryInputTransport(getFrameBuffer().array()); - org.apache.thrift.protocol.TProtocol prot = client.getProtocolFactory().getProtocol(memoryTransport); - (new Client(prot)).recv_registerStormReceiver(); - } - } - - public void registerCEPPublisher(int tenantId, String executionPlanName, String hostName, int port, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException { - checkReady(); - registerCEPPublisher_call method_call = new registerCEPPublisher_call(tenantId, executionPlanName, hostName, port, resultHandler, this, ___protocolFactory, ___transport); - this.___currentMethod = method_call; - ___manager.call(method_call); - } - - public static class registerCEPPublisher_call extends org.apache.thrift.async.TAsyncMethodCall { - private int tenantId; - private String executionPlanName; - private String hostName; - private int port; - public registerCEPPublisher_call(int tenantId, String executionPlanName, String hostName, int port, org.apache.thrift.async.AsyncMethodCallback resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException { - super(client, protocolFactory, transport, resultHandler, false); - this.tenantId = tenantId; - this.executionPlanName = executionPlanName; - this.hostName = hostName; - this.port = port; - } - - public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException { - prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("registerCEPPublisher", org.apache.thrift.protocol.TMessageType.CALL, 0)); - registerCEPPublisher_args args = new registerCEPPublisher_args(); - args.setTenantId(tenantId); - args.setExecutionPlanName(executionPlanName); - args.setHostName(hostName); - args.setPort(port); - args.write(prot); - prot.writeMessageEnd(); - } - - public void getResult() throws org.wso2.carbon.event.processor.common.storm.manager.service.exception.NotStormCoordinatorException, org.apache.thrift.TException { - if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) { - throw new IllegalStateException("Method call not finished!"); - } - org.apache.thrift.transport.TMemoryInputTransport memoryTransport = new org.apache.thrift.transport.TMemoryInputTransport(getFrameBuffer().array()); - org.apache.thrift.protocol.TProtocol prot = client.getProtocolFactory().getProtocol(memoryTransport); - (new Client(prot)).recv_registerCEPPublisher(); - } - } - - public void getStormReceiver(int tenantId, String executionPlanName, String cepReceiverHostName, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException { - checkReady(); - getStormReceiver_call method_call = new getStormReceiver_call(tenantId, executionPlanName, cepReceiverHostName, resultHandler, this, ___protocolFactory, ___transport); - this.___currentMethod = method_call; - ___manager.call(method_call); - } - - public static class getStormReceiver_call extends org.apache.thrift.async.TAsyncMethodCall { - private int tenantId; - private String executionPlanName; - private String cepReceiverHostName; - public getStormReceiver_call(int tenantId, String executionPlanName, String cepReceiverHostName, org.apache.thrift.async.AsyncMethodCallback resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException { - super(client, protocolFactory, transport, resultHandler, false); - this.tenantId = tenantId; - this.executionPlanName = executionPlanName; - this.cepReceiverHostName = cepReceiverHostName; - } - - public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException { - prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("getStormReceiver", org.apache.thrift.protocol.TMessageType.CALL, 0)); - getStormReceiver_args args = new getStormReceiver_args(); - args.setTenantId(tenantId); - args.setExecutionPlanName(executionPlanName); - args.setCepReceiverHostName(cepReceiverHostName); - args.write(prot); - prot.writeMessageEnd(); - } - - public String getResult() throws org.wso2.carbon.event.processor.common.storm.manager.service.exception.NotStormCoordinatorException, org.wso2.carbon.event.processor.common.storm.manager.service.exception.EndpointNotFoundException, org.apache.thrift.TException { - if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) { - throw new IllegalStateException("Method call not finished!"); - } - org.apache.thrift.transport.TMemoryInputTransport memoryTransport = new org.apache.thrift.transport.TMemoryInputTransport(getFrameBuffer().array()); - org.apache.thrift.protocol.TProtocol prot = client.getProtocolFactory().getProtocol(memoryTransport); - return (new Client(prot)).recv_getStormReceiver(); - } - } - - public void getCEPPublisher(int tenantId, String executionPlanName, String stormPublisherHostName, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException { - checkReady(); - getCEPPublisher_call method_call = new getCEPPublisher_call(tenantId, executionPlanName, stormPublisherHostName, resultHandler, this, ___protocolFactory, ___transport); - this.___currentMethod = method_call; - ___manager.call(method_call); - } - - public static class getCEPPublisher_call extends org.apache.thrift.async.TAsyncMethodCall { - private int tenantId; - private String executionPlanName; - private String stormPublisherHostName; - public getCEPPublisher_call(int tenantId, String executionPlanName, String stormPublisherHostName, org.apache.thrift.async.AsyncMethodCallback resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException { - super(client, protocolFactory, transport, resultHandler, false); - this.tenantId = tenantId; - this.executionPlanName = executionPlanName; - this.stormPublisherHostName = stormPublisherHostName; - } - - public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException { - prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("getCEPPublisher", org.apache.thrift.protocol.TMessageType.CALL, 0)); - getCEPPublisher_args args = new getCEPPublisher_args(); - args.setTenantId(tenantId); - args.setExecutionPlanName(executionPlanName); - args.setStormPublisherHostName(stormPublisherHostName); - args.write(prot); - prot.writeMessageEnd(); - } - - public String getResult() throws org.wso2.carbon.event.processor.common.storm.manager.service.exception.NotStormCoordinatorException, org.wso2.carbon.event.processor.common.storm.manager.service.exception.EndpointNotFoundException, org.apache.thrift.TException { - if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) { - throw new IllegalStateException("Method call not finished!"); - } - org.apache.thrift.transport.TMemoryInputTransport memoryTransport = new org.apache.thrift.transport.TMemoryInputTransport(getFrameBuffer().array()); - org.apache.thrift.protocol.TProtocol prot = client.getProtocolFactory().getProtocol(memoryTransport); - return (new Client(prot)).recv_getCEPPublisher(); - } - } - - } - - public static class Processor extends org.apache.thrift.TBaseProcessor implements org.apache.thrift.TProcessor { - private static final Log LOGGER = LogFactory.getLog(Processor.class.getName()); - public Processor(I iface) { - super(iface, getProcessMap(new HashMap>())); - } - - protected Processor(I iface, Map> processMap) { - super(iface, getProcessMap(processMap)); - } - - private static Map> getProcessMap(Map> processMap) { - processMap.put("registerStormReceiver", new registerStormReceiver()); - processMap.put("registerCEPPublisher", new registerCEPPublisher()); - processMap.put("getStormReceiver", new getStormReceiver()); - processMap.put("getCEPPublisher", new getCEPPublisher()); - return processMap; - } - - public static class registerStormReceiver extends org.apache.thrift.ProcessFunction { - public registerStormReceiver() { - super("registerStormReceiver"); - } - - public registerStormReceiver_args getEmptyArgsInstance() { - return new registerStormReceiver_args(); - } - - protected boolean isOneway() { - return false; - } - - public registerStormReceiver_result getResult(I iface, registerStormReceiver_args args) throws org.apache.thrift.TException { - registerStormReceiver_result result = new registerStormReceiver_result(); - try { - iface.registerStormReceiver(args.tenantId, args.executionPlanName, args.hostName, args.port); - } catch (org.wso2.carbon.event.processor.common.storm.manager.service.exception.NotStormCoordinatorException nsme) { - result.nsme = nsme; - } - return result; - } - } - - public static class registerCEPPublisher extends org.apache.thrift.ProcessFunction { - public registerCEPPublisher() { - super("registerCEPPublisher"); - } - - public registerCEPPublisher_args getEmptyArgsInstance() { - return new registerCEPPublisher_args(); - } - - protected boolean isOneway() { - return false; - } - - public registerCEPPublisher_result getResult(I iface, registerCEPPublisher_args args) throws org.apache.thrift.TException { - registerCEPPublisher_result result = new registerCEPPublisher_result(); - try { - iface.registerCEPPublisher(args.tenantId, args.executionPlanName, args.hostName, args.port); - } catch (org.wso2.carbon.event.processor.common.storm.manager.service.exception.NotStormCoordinatorException nsme) { - result.nsme = nsme; - } - return result; - } - } - - public static class getStormReceiver extends org.apache.thrift.ProcessFunction { - public getStormReceiver() { - super("getStormReceiver"); - } - - public getStormReceiver_args getEmptyArgsInstance() { - return new getStormReceiver_args(); - } - - protected boolean isOneway() { - return false; - } - - public getStormReceiver_result getResult(I iface, getStormReceiver_args args) throws org.apache.thrift.TException { - getStormReceiver_result result = new getStormReceiver_result(); - try { - result.success = iface.getStormReceiver(args.tenantId, args.executionPlanName, args.cepReceiverHostName); - } catch (org.wso2.carbon.event.processor.common.storm.manager.service.exception.NotStormCoordinatorException nsme) { - result.nsme = nsme; - } catch (org.wso2.carbon.event.processor.common.storm.manager.service.exception.EndpointNotFoundException enfe) { - result.enfe = enfe; - } - return result; - } - } - - public static class getCEPPublisher extends org.apache.thrift.ProcessFunction { - public getCEPPublisher() { - super("getCEPPublisher"); - } - - public getCEPPublisher_args getEmptyArgsInstance() { - return new getCEPPublisher_args(); - } - - protected boolean isOneway() { - return false; - } - - public getCEPPublisher_result getResult(I iface, getCEPPublisher_args args) throws org.apache.thrift.TException { - getCEPPublisher_result result = new getCEPPublisher_result(); - try { - result.success = iface.getCEPPublisher(args.tenantId, args.executionPlanName, args.stormPublisherHostName); - } catch (org.wso2.carbon.event.processor.common.storm.manager.service.exception.NotStormCoordinatorException nsme) { - result.nsme = nsme; - } catch (org.wso2.carbon.event.processor.common.storm.manager.service.exception.EndpointNotFoundException enfe) { - result.enfe = enfe; - } - return result; - } - } - - } - - public static class AsyncProcessor extends org.apache.thrift.TBaseAsyncProcessor { - - private static final Log LOGGER = LogFactory.getLog(AsyncProcessor.class.getName()); - public AsyncProcessor(I iface) { - super(iface, getProcessMap(new HashMap>())); - } - - protected AsyncProcessor(I iface, Map> processMap) { - super(iface, getProcessMap(processMap)); - } - - private static Map> getProcessMap(Map> processMap) { - processMap.put("registerStormReceiver", new registerStormReceiver()); - processMap.put("registerCEPPublisher", new registerCEPPublisher()); - processMap.put("getStormReceiver", new getStormReceiver()); - processMap.put("getCEPPublisher", new getCEPPublisher()); - return processMap; - } - - public static class registerStormReceiver extends org.apache.thrift.AsyncProcessFunction { - public registerStormReceiver() { - super("registerStormReceiver"); - } - - public registerStormReceiver_args getEmptyArgsInstance() { - return new registerStormReceiver_args(); - } - - public AsyncMethodCallback getResultHandler(final AsyncFrameBuffer fb, final int seqid) { - final org.apache.thrift.AsyncProcessFunction fcall = this; - return new AsyncMethodCallback() { - public void onComplete(Void o) { - registerStormReceiver_result result = new registerStormReceiver_result(); - try { - fcall.sendResponse(fb,result, org.apache.thrift.protocol.TMessageType.REPLY,seqid); - return; - } catch (Exception e) { - LOGGER.error("Exception writing to internal frame buffer", e); - } - fb.close(); - } - public void onError(Exception e) { - byte msgType = org.apache.thrift.protocol.TMessageType.REPLY; - org.apache.thrift.TBase msg; - registerStormReceiver_result result = new registerStormReceiver_result(); - if (e instanceof org.wso2.carbon.event.processor.common.storm.manager.service.exception.NotStormCoordinatorException) { - result.nsme = (org.wso2.carbon.event.processor.common.storm.manager.service.exception.NotStormCoordinatorException) e; - result.setNsmeIsSet(true); - msg = result; - } - else - { - msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION; - msg = (org.apache.thrift.TBase)new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.INTERNAL_ERROR, e.getMessage()); - } - try { - fcall.sendResponse(fb,msg,msgType,seqid); - return; - } catch (Exception ex) { - LOGGER.error("Exception writing to internal frame buffer", ex); - } - fb.close(); - } - }; - } - - protected boolean isOneway() { - return false; - } - - public void start(I iface, registerStormReceiver_args args, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws TException { - iface.registerStormReceiver(args.tenantId, args.executionPlanName, args.hostName, args.port,resultHandler); - } - } - - public static class registerCEPPublisher extends org.apache.thrift.AsyncProcessFunction { - public registerCEPPublisher() { - super("registerCEPPublisher"); - } - - public registerCEPPublisher_args getEmptyArgsInstance() { - return new registerCEPPublisher_args(); - } - - public AsyncMethodCallback getResultHandler(final AsyncFrameBuffer fb, final int seqid) { - final org.apache.thrift.AsyncProcessFunction fcall = this; - return new AsyncMethodCallback() { - public void onComplete(Void o) { - registerCEPPublisher_result result = new registerCEPPublisher_result(); - try { - fcall.sendResponse(fb,result, org.apache.thrift.protocol.TMessageType.REPLY,seqid); - return; - } catch (Exception e) { - LOGGER.error("Exception writing to internal frame buffer", e); - } - fb.close(); - } - public void onError(Exception e) { - byte msgType = org.apache.thrift.protocol.TMessageType.REPLY; - org.apache.thrift.TBase msg; - registerCEPPublisher_result result = new registerCEPPublisher_result(); - if (e instanceof org.wso2.carbon.event.processor.common.storm.manager.service.exception.NotStormCoordinatorException) { - result.nsme = (org.wso2.carbon.event.processor.common.storm.manager.service.exception.NotStormCoordinatorException) e; - result.setNsmeIsSet(true); - msg = result; - } - else - { - msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION; - msg = (org.apache.thrift.TBase)new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.INTERNAL_ERROR, e.getMessage()); - } - try { - fcall.sendResponse(fb,msg,msgType,seqid); - return; - } catch (Exception ex) { - LOGGER.error("Exception writing to internal frame buffer", ex); - } - fb.close(); - } - }; - } - - protected boolean isOneway() { - return false; - } - - public void start(I iface, registerCEPPublisher_args args, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws TException { - iface.registerCEPPublisher(args.tenantId, args.executionPlanName, args.hostName, args.port,resultHandler); - } - } - - public static class getStormReceiver extends org.apache.thrift.AsyncProcessFunction { - public getStormReceiver() { - super("getStormReceiver"); - } - - public getStormReceiver_args getEmptyArgsInstance() { - return new getStormReceiver_args(); - } - - public AsyncMethodCallback getResultHandler(final AsyncFrameBuffer fb, final int seqid) { - final org.apache.thrift.AsyncProcessFunction fcall = this; - return new AsyncMethodCallback() { - public void onComplete(String o) { - getStormReceiver_result result = new getStormReceiver_result(); - result.success = o; - try { - fcall.sendResponse(fb,result, org.apache.thrift.protocol.TMessageType.REPLY,seqid); - return; - } catch (Exception e) { - LOGGER.error("Exception writing to internal frame buffer", e); - } - fb.close(); - } - public void onError(Exception e) { - byte msgType = org.apache.thrift.protocol.TMessageType.REPLY; - org.apache.thrift.TBase msg; - getStormReceiver_result result = new getStormReceiver_result(); - if (e instanceof org.wso2.carbon.event.processor.common.storm.manager.service.exception.NotStormCoordinatorException) { - result.nsme = (org.wso2.carbon.event.processor.common.storm.manager.service.exception.NotStormCoordinatorException) e; - result.setNsmeIsSet(true); - msg = result; - } - else if (e instanceof org.wso2.carbon.event.processor.common.storm.manager.service.exception.EndpointNotFoundException) { - result.enfe = (org.wso2.carbon.event.processor.common.storm.manager.service.exception.EndpointNotFoundException) e; - result.setEnfeIsSet(true); - msg = result; - } - else - { - msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION; - msg = (org.apache.thrift.TBase)new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.INTERNAL_ERROR, e.getMessage()); - } - try { - fcall.sendResponse(fb,msg,msgType,seqid); - return; - } catch (Exception ex) { - LOGGER.error("Exception writing to internal frame buffer", ex); - } - fb.close(); - } - }; - } - - protected boolean isOneway() { - return false; - } - - public void start(I iface, getStormReceiver_args args, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws TException { - iface.getStormReceiver(args.tenantId, args.executionPlanName, args.cepReceiverHostName,resultHandler); - } - } - - public static class getCEPPublisher extends org.apache.thrift.AsyncProcessFunction { - public getCEPPublisher() { - super("getCEPPublisher"); - } - - public getCEPPublisher_args getEmptyArgsInstance() { - return new getCEPPublisher_args(); - } - - public AsyncMethodCallback getResultHandler(final AsyncFrameBuffer fb, final int seqid) { - final org.apache.thrift.AsyncProcessFunction fcall = this; - return new AsyncMethodCallback() { - public void onComplete(String o) { - getCEPPublisher_result result = new getCEPPublisher_result(); - result.success = o; - try { - fcall.sendResponse(fb,result, org.apache.thrift.protocol.TMessageType.REPLY,seqid); - return; - } catch (Exception e) { - LOGGER.error("Exception writing to internal frame buffer", e); - } - fb.close(); - } - public void onError(Exception e) { - byte msgType = org.apache.thrift.protocol.TMessageType.REPLY; - org.apache.thrift.TBase msg; - getCEPPublisher_result result = new getCEPPublisher_result(); - if (e instanceof org.wso2.carbon.event.processor.common.storm.manager.service.exception.NotStormCoordinatorException) { - result.nsme = (org.wso2.carbon.event.processor.common.storm.manager.service.exception.NotStormCoordinatorException) e; - result.setNsmeIsSet(true); - msg = result; - } - else if (e instanceof org.wso2.carbon.event.processor.common.storm.manager.service.exception.EndpointNotFoundException) { - result.enfe = (org.wso2.carbon.event.processor.common.storm.manager.service.exception.EndpointNotFoundException) e; - result.setEnfeIsSet(true); - msg = result; - } - else - { - msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION; - msg = (org.apache.thrift.TBase)new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.INTERNAL_ERROR, e.getMessage()); - } - try { - fcall.sendResponse(fb,msg,msgType,seqid); - return; - } catch (Exception ex) { - LOGGER.error("Exception writing to internal frame buffer", ex); - } - fb.close(); - } - }; - } - - protected boolean isOneway() { - return false; - } - - public void start(I iface, getCEPPublisher_args args, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws TException { - iface.getCEPPublisher(args.tenantId, args.executionPlanName, args.stormPublisherHostName,resultHandler); - } - } - - } - - public static class registerStormReceiver_args implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { - private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("registerStormReceiver_args"); - - private static final org.apache.thrift.protocol.TField TENANT_ID_FIELD_DESC = new org.apache.thrift.protocol.TField("tenantId", org.apache.thrift.protocol.TType.I32, (short)1); - private static final org.apache.thrift.protocol.TField EXECUTION_PLAN_NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("executionPlanName", org.apache.thrift.protocol.TType.STRING, (short)2); - private static final org.apache.thrift.protocol.TField HOST_NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("hostName", org.apache.thrift.protocol.TType.STRING, (short)3); - private static final org.apache.thrift.protocol.TField PORT_FIELD_DESC = new org.apache.thrift.protocol.TField("port", org.apache.thrift.protocol.TType.I32, (short)4); - - private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); - static { - schemes.put(StandardScheme.class, new registerStormReceiver_argsStandardSchemeFactory()); - schemes.put(TupleScheme.class, new registerStormReceiver_argsTupleSchemeFactory()); - } - - public int tenantId; // required - public String executionPlanName; // required - public String hostName; // required - public int port; // required - - /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ - public enum _Fields implements org.apache.thrift.TFieldIdEnum { - TENANT_ID((short)1, "tenantId"), - EXECUTION_PLAN_NAME((short)2, "executionPlanName"), - HOST_NAME((short)3, "hostName"), - PORT((short)4, "port"); - - private static final Map byName = new HashMap(); - - static { - for (_Fields field : EnumSet.allOf(_Fields.class)) { - byName.put(field.getFieldName(), field); - } - } - - /** - * Find the _Fields constant that matches fieldId, or null if its not found. - */ - public static _Fields findByThriftId(int fieldId) { - switch(fieldId) { - case 1: // TENANT_ID - return TENANT_ID; - case 2: // EXECUTION_PLAN_NAME - return EXECUTION_PLAN_NAME; - case 3: // HOST_NAME - return HOST_NAME; - case 4: // PORT - return PORT; - default: - return null; - } - } - - /** - * Find the _Fields constant that matches fieldId, throwing an exception - * if it is not found. - */ - public static _Fields findByThriftIdOrThrow(int fieldId) { - _Fields fields = findByThriftId(fieldId); - if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); - return fields; - } - - /** - * Find the _Fields constant that matches name, or null if its not found. - */ - public static _Fields findByName(String name) { - return byName.get(name); - } - - private final short _thriftId; - private final String _fieldName; - - _Fields(short thriftId, String fieldName) { - _thriftId = thriftId; - _fieldName = fieldName; - } - - public short getThriftFieldId() { - return _thriftId; - } - - public String getFieldName() { - return _fieldName; - } - } - - // isset id assignments - private static final int __TENANTID_ISSET_ID = 0; - private static final int __PORT_ISSET_ID = 1; - private byte __isset_bitfield = 0; - public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; - static { - Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); - tmpMap.put(_Fields.TENANT_ID, new org.apache.thrift.meta_data.FieldMetaData("tenantId", org.apache.thrift.TFieldRequirementType.DEFAULT, - new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32))); - tmpMap.put(_Fields.EXECUTION_PLAN_NAME, new org.apache.thrift.meta_data.FieldMetaData("executionPlanName", org.apache.thrift.TFieldRequirementType.DEFAULT, - new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); - tmpMap.put(_Fields.HOST_NAME, new org.apache.thrift.meta_data.FieldMetaData("hostName", org.apache.thrift.TFieldRequirementType.DEFAULT, - new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); - tmpMap.put(_Fields.PORT, new org.apache.thrift.meta_data.FieldMetaData("port", org.apache.thrift.TFieldRequirementType.DEFAULT, - new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32))); - metaDataMap = Collections.unmodifiableMap(tmpMap); - org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(registerStormReceiver_args.class, metaDataMap); - } - - public registerStormReceiver_args() { - } - - public registerStormReceiver_args( - int tenantId, - String executionPlanName, - String hostName, - int port) - { - this(); - this.tenantId = tenantId; - setTenantIdIsSet(true); - this.executionPlanName = executionPlanName; - this.hostName = hostName; - this.port = port; - setPortIsSet(true); - } - - /** - * Performs a deep copy on other. - */ - public registerStormReceiver_args(registerStormReceiver_args other) { - __isset_bitfield = other.__isset_bitfield; - this.tenantId = other.tenantId; - if (other.isSetExecutionPlanName()) { - this.executionPlanName = other.executionPlanName; - } - if (other.isSetHostName()) { - this.hostName = other.hostName; - } - this.port = other.port; - } - - public registerStormReceiver_args deepCopy() { - return new registerStormReceiver_args(this); - } - - @Override - public void clear() { - setTenantIdIsSet(false); - this.tenantId = 0; - this.executionPlanName = null; - this.hostName = null; - setPortIsSet(false); - this.port = 0; - } - - public int getTenantId() { - return this.tenantId; - } - - public registerStormReceiver_args setTenantId(int tenantId) { - this.tenantId = tenantId; - setTenantIdIsSet(true); - return this; - } - - public void unsetTenantId() { - __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __TENANTID_ISSET_ID); - } - - /** Returns true if field tenantId is set (has been assigned a value) and false otherwise */ - public boolean isSetTenantId() { - return EncodingUtils.testBit(__isset_bitfield, __TENANTID_ISSET_ID); - } - - public void setTenantIdIsSet(boolean value) { - __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __TENANTID_ISSET_ID, value); - } - - public String getExecutionPlanName() { - return this.executionPlanName; - } - - public registerStormReceiver_args setExecutionPlanName(String executionPlanName) { - this.executionPlanName = executionPlanName; - return this; - } - - public void unsetExecutionPlanName() { - this.executionPlanName = null; - } - - /** Returns true if field executionPlanName is set (has been assigned a value) and false otherwise */ - public boolean isSetExecutionPlanName() { - return this.executionPlanName != null; - } - - public void setExecutionPlanNameIsSet(boolean value) { - if (!value) { - this.executionPlanName = null; - } - } - - public String getHostName() { - return this.hostName; - } - - public registerStormReceiver_args setHostName(String hostName) { - this.hostName = hostName; - return this; - } - - public void unsetHostName() { - this.hostName = null; - } - - /** Returns true if field hostName is set (has been assigned a value) and false otherwise */ - public boolean isSetHostName() { - return this.hostName != null; - } - - public void setHostNameIsSet(boolean value) { - if (!value) { - this.hostName = null; - } - } - - public int getPort() { - return this.port; - } - - public registerStormReceiver_args setPort(int port) { - this.port = port; - setPortIsSet(true); - return this; - } - - public void unsetPort() { - __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __PORT_ISSET_ID); - } - - /** Returns true if field port is set (has been assigned a value) and false otherwise */ - public boolean isSetPort() { - return EncodingUtils.testBit(__isset_bitfield, __PORT_ISSET_ID); - } - - public void setPortIsSet(boolean value) { - __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __PORT_ISSET_ID, value); - } - - public void setFieldValue(_Fields field, Object value) { - switch (field) { - case TENANT_ID: - if (value == null) { - unsetTenantId(); - } else { - setTenantId((Integer)value); - } - break; - - case EXECUTION_PLAN_NAME: - if (value == null) { - unsetExecutionPlanName(); - } else { - setExecutionPlanName((String)value); - } - break; - - case HOST_NAME: - if (value == null) { - unsetHostName(); - } else { - setHostName((String)value); - } - break; - - case PORT: - if (value == null) { - unsetPort(); - } else { - setPort((Integer)value); - } - break; - - } - } - - public Object getFieldValue(_Fields field) { - switch (field) { - case TENANT_ID: - return Integer.valueOf(getTenantId()); - - case EXECUTION_PLAN_NAME: - return getExecutionPlanName(); - - case HOST_NAME: - return getHostName(); - - case PORT: - return Integer.valueOf(getPort()); - - } - throw new IllegalStateException(); - } - - /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ - public boolean isSet(_Fields field) { - if (field == null) { - throw new IllegalArgumentException(); - } - - switch (field) { - case TENANT_ID: - return isSetTenantId(); - case EXECUTION_PLAN_NAME: - return isSetExecutionPlanName(); - case HOST_NAME: - return isSetHostName(); - case PORT: - return isSetPort(); - } - throw new IllegalStateException(); - } - - @Override - public boolean equals(Object that) { - if (that == null) - return false; - if (that instanceof registerStormReceiver_args) - return this.equals((registerStormReceiver_args)that); - return false; - } - - public boolean equals(registerStormReceiver_args that) { - if (that == null) - return false; - - boolean this_present_tenantId = true; - boolean that_present_tenantId = true; - if (this_present_tenantId || that_present_tenantId) { - if (!(this_present_tenantId && that_present_tenantId)) - return false; - if (this.tenantId != that.tenantId) - return false; - } - - boolean this_present_executionPlanName = true && this.isSetExecutionPlanName(); - boolean that_present_executionPlanName = true && that.isSetExecutionPlanName(); - if (this_present_executionPlanName || that_present_executionPlanName) { - if (!(this_present_executionPlanName && that_present_executionPlanName)) - return false; - if (!this.executionPlanName.equals(that.executionPlanName)) - return false; - } - - boolean this_present_hostName = true && this.isSetHostName(); - boolean that_present_hostName = true && that.isSetHostName(); - if (this_present_hostName || that_present_hostName) { - if (!(this_present_hostName && that_present_hostName)) - return false; - if (!this.hostName.equals(that.hostName)) - return false; - } - - boolean this_present_port = true; - boolean that_present_port = true; - if (this_present_port || that_present_port) { - if (!(this_present_port && that_present_port)) - return false; - if (this.port != that.port) - return false; - } - - return true; - } - - @Override - public int hashCode() { - return 0; - } - - @Override - public int compareTo(registerStormReceiver_args other) { - if (!getClass().equals(other.getClass())) { - return getClass().getName().compareTo(other.getClass().getName()); - } - - int lastComparison = 0; - - lastComparison = Boolean.valueOf(isSetTenantId()).compareTo(other.isSetTenantId()); - if (lastComparison != 0) { - return lastComparison; - } - if (isSetTenantId()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.tenantId, other.tenantId); - if (lastComparison != 0) { - return lastComparison; - } - } - lastComparison = Boolean.valueOf(isSetExecutionPlanName()).compareTo(other.isSetExecutionPlanName()); - if (lastComparison != 0) { - return lastComparison; - } - if (isSetExecutionPlanName()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.executionPlanName, other.executionPlanName); - if (lastComparison != 0) { - return lastComparison; - } - } - lastComparison = Boolean.valueOf(isSetHostName()).compareTo(other.isSetHostName()); - if (lastComparison != 0) { - return lastComparison; - } - if (isSetHostName()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.hostName, other.hostName); - if (lastComparison != 0) { - return lastComparison; - } - } - lastComparison = Boolean.valueOf(isSetPort()).compareTo(other.isSetPort()); - if (lastComparison != 0) { - return lastComparison; - } - if (isSetPort()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.port, other.port); - if (lastComparison != 0) { - return lastComparison; - } - } - return 0; - } - - public _Fields fieldForId(int fieldId) { - return _Fields.findByThriftId(fieldId); - } - - public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { - schemes.get(iprot.getScheme()).getScheme().read(iprot, this); - } - - public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { - schemes.get(oprot.getScheme()).getScheme().write(oprot, this); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder("registerStormReceiver_args("); - boolean first = true; - - sb.append("tenantId:"); - sb.append(this.tenantId); - first = false; - if (!first) sb.append(", "); - sb.append("executionPlanName:"); - if (this.executionPlanName == null) { - sb.append("null"); - } else { - sb.append(this.executionPlanName); - } - first = false; - if (!first) sb.append(", "); - sb.append("hostName:"); - if (this.hostName == null) { - sb.append("null"); - } else { - sb.append(this.hostName); - } - first = false; - if (!first) sb.append(", "); - sb.append("port:"); - sb.append(this.port); - first = false; - sb.append(")"); - return sb.toString(); - } - - public void validate() throws org.apache.thrift.TException { - // check for required fields - // check for sub-struct validity - } - - private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { - try { - write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); - } catch (org.apache.thrift.TException te) { - throw new java.io.IOException(te); - } - } - - private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { - try { - // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor. - __isset_bitfield = 0; - read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); - } catch (org.apache.thrift.TException te) { - throw new java.io.IOException(te); - } - } - - private static class registerStormReceiver_argsStandardSchemeFactory implements SchemeFactory { - public registerStormReceiver_argsStandardScheme getScheme() { - return new registerStormReceiver_argsStandardScheme(); - } - } - - private static class registerStormReceiver_argsStandardScheme extends StandardScheme { - - public void read(org.apache.thrift.protocol.TProtocol iprot, registerStormReceiver_args struct) throws org.apache.thrift.TException { - org.apache.thrift.protocol.TField schemeField; - iprot.readStructBegin(); - while (true) - { - schemeField = iprot.readFieldBegin(); - if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { - break; - } - switch (schemeField.id) { - case 1: // TENANT_ID - if (schemeField.type == org.apache.thrift.protocol.TType.I32) { - struct.tenantId = iprot.readI32(); - struct.setTenantIdIsSet(true); - } else { - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - break; - case 2: // EXECUTION_PLAN_NAME - if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { - struct.executionPlanName = iprot.readString(); - struct.setExecutionPlanNameIsSet(true); - } else { - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - break; - case 3: // HOST_NAME - if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { - struct.hostName = iprot.readString(); - struct.setHostNameIsSet(true); - } else { - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - break; - case 4: // PORT - if (schemeField.type == org.apache.thrift.protocol.TType.I32) { - struct.port = iprot.readI32(); - struct.setPortIsSet(true); - } else { - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - break; - default: - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - iprot.readFieldEnd(); - } - iprot.readStructEnd(); - - // check for required fields of primitive type, which can't be checked in the validate method - struct.validate(); - } - - public void write(org.apache.thrift.protocol.TProtocol oprot, registerStormReceiver_args struct) throws org.apache.thrift.TException { - struct.validate(); - - oprot.writeStructBegin(STRUCT_DESC); - oprot.writeFieldBegin(TENANT_ID_FIELD_DESC); - oprot.writeI32(struct.tenantId); - oprot.writeFieldEnd(); - if (struct.executionPlanName != null) { - oprot.writeFieldBegin(EXECUTION_PLAN_NAME_FIELD_DESC); - oprot.writeString(struct.executionPlanName); - oprot.writeFieldEnd(); - } - if (struct.hostName != null) { - oprot.writeFieldBegin(HOST_NAME_FIELD_DESC); - oprot.writeString(struct.hostName); - oprot.writeFieldEnd(); - } - oprot.writeFieldBegin(PORT_FIELD_DESC); - oprot.writeI32(struct.port); - oprot.writeFieldEnd(); - oprot.writeFieldStop(); - oprot.writeStructEnd(); - } - - } - - private static class registerStormReceiver_argsTupleSchemeFactory implements SchemeFactory { - public registerStormReceiver_argsTupleScheme getScheme() { - return new registerStormReceiver_argsTupleScheme(); - } - } - - private static class registerStormReceiver_argsTupleScheme extends TupleScheme { - - @Override - public void write(org.apache.thrift.protocol.TProtocol prot, registerStormReceiver_args struct) throws org.apache.thrift.TException { - TTupleProtocol oprot = (TTupleProtocol) prot; - BitSet optionals = new BitSet(); - if (struct.isSetTenantId()) { - optionals.set(0); - } - if (struct.isSetExecutionPlanName()) { - optionals.set(1); - } - if (struct.isSetHostName()) { - optionals.set(2); - } - if (struct.isSetPort()) { - optionals.set(3); - } - oprot.writeBitSet(optionals, 4); - if (struct.isSetTenantId()) { - oprot.writeI32(struct.tenantId); - } - if (struct.isSetExecutionPlanName()) { - oprot.writeString(struct.executionPlanName); - } - if (struct.isSetHostName()) { - oprot.writeString(struct.hostName); - } - if (struct.isSetPort()) { - oprot.writeI32(struct.port); - } - } - - @Override - public void read(org.apache.thrift.protocol.TProtocol prot, registerStormReceiver_args struct) throws org.apache.thrift.TException { - TTupleProtocol iprot = (TTupleProtocol) prot; - BitSet incoming = iprot.readBitSet(4); - if (incoming.get(0)) { - struct.tenantId = iprot.readI32(); - struct.setTenantIdIsSet(true); - } - if (incoming.get(1)) { - struct.executionPlanName = iprot.readString(); - struct.setExecutionPlanNameIsSet(true); - } - if (incoming.get(2)) { - struct.hostName = iprot.readString(); - struct.setHostNameIsSet(true); - } - if (incoming.get(3)) { - struct.port = iprot.readI32(); - struct.setPortIsSet(true); - } - } - } - - } - - public static class registerStormReceiver_result implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { - private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("registerStormReceiver_result"); - - private static final org.apache.thrift.protocol.TField NSME_FIELD_DESC = new org.apache.thrift.protocol.TField("nsme", org.apache.thrift.protocol.TType.STRUCT, (short)1); - - private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); - static { - schemes.put(StandardScheme.class, new registerStormReceiver_resultStandardSchemeFactory()); - schemes.put(TupleScheme.class, new registerStormReceiver_resultTupleSchemeFactory()); - } - - public org.wso2.carbon.event.processor.common.storm.manager.service.exception.NotStormCoordinatorException nsme; // required - - /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ - public enum _Fields implements org.apache.thrift.TFieldIdEnum { - NSME((short)1, "nsme"); - - private static final Map byName = new HashMap(); - - static { - for (_Fields field : EnumSet.allOf(_Fields.class)) { - byName.put(field.getFieldName(), field); - } - } - - /** - * Find the _Fields constant that matches fieldId, or null if its not found. - */ - public static _Fields findByThriftId(int fieldId) { - switch(fieldId) { - case 1: // NSME - return NSME; - default: - return null; - } - } - - /** - * Find the _Fields constant that matches fieldId, throwing an exception - * if it is not found. - */ - public static _Fields findByThriftIdOrThrow(int fieldId) { - _Fields fields = findByThriftId(fieldId); - if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); - return fields; - } - - /** - * Find the _Fields constant that matches name, or null if its not found. - */ - public static _Fields findByName(String name) { - return byName.get(name); - } - - private final short _thriftId; - private final String _fieldName; - - _Fields(short thriftId, String fieldName) { - _thriftId = thriftId; - _fieldName = fieldName; - } - - public short getThriftFieldId() { - return _thriftId; - } - - public String getFieldName() { - return _fieldName; - } - } - - // isset id assignments - public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; - static { - Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); - tmpMap.put(_Fields.NSME, new org.apache.thrift.meta_data.FieldMetaData("nsme", org.apache.thrift.TFieldRequirementType.DEFAULT, - new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT))); - metaDataMap = Collections.unmodifiableMap(tmpMap); - org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(registerStormReceiver_result.class, metaDataMap); - } - - public registerStormReceiver_result() { - } - - public registerStormReceiver_result( - org.wso2.carbon.event.processor.common.storm.manager.service.exception.NotStormCoordinatorException nsme) - { - this(); - this.nsme = nsme; - } - - /** - * Performs a deep copy on other. - */ - public registerStormReceiver_result(registerStormReceiver_result other) { - if (other.isSetNsme()) { - this.nsme = new org.wso2.carbon.event.processor.common.storm.manager.service.exception.NotStormCoordinatorException(other.nsme); - } - } - - public registerStormReceiver_result deepCopy() { - return new registerStormReceiver_result(this); - } - - @Override - public void clear() { - this.nsme = null; - } - - public org.wso2.carbon.event.processor.common.storm.manager.service.exception.NotStormCoordinatorException getNsme() { - return this.nsme; - } - - public registerStormReceiver_result setNsme(org.wso2.carbon.event.processor.common.storm.manager.service.exception.NotStormCoordinatorException nsme) { - this.nsme = nsme; - return this; - } - - public void unsetNsme() { - this.nsme = null; - } - - /** Returns true if field nsme is set (has been assigned a value) and false otherwise */ - public boolean isSetNsme() { - return this.nsme != null; - } - - public void setNsmeIsSet(boolean value) { - if (!value) { - this.nsme = null; - } - } - - public void setFieldValue(_Fields field, Object value) { - switch (field) { - case NSME: - if (value == null) { - unsetNsme(); - } else { - setNsme((org.wso2.carbon.event.processor.common.storm.manager.service.exception.NotStormCoordinatorException)value); - } - break; - - } - } - - public Object getFieldValue(_Fields field) { - switch (field) { - case NSME: - return getNsme(); - - } - throw new IllegalStateException(); - } - - /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ - public boolean isSet(_Fields field) { - if (field == null) { - throw new IllegalArgumentException(); - } - - switch (field) { - case NSME: - return isSetNsme(); - } - throw new IllegalStateException(); - } - - @Override - public boolean equals(Object that) { - if (that == null) - return false; - if (that instanceof registerStormReceiver_result) - return this.equals((registerStormReceiver_result)that); - return false; - } - - public boolean equals(registerStormReceiver_result that) { - if (that == null) - return false; - - boolean this_present_nsme = true && this.isSetNsme(); - boolean that_present_nsme = true && that.isSetNsme(); - if (this_present_nsme || that_present_nsme) { - if (!(this_present_nsme && that_present_nsme)) - return false; - if (!this.nsme.equals(that.nsme)) - return false; - } - - return true; - } - - @Override - public int hashCode() { - return 0; - } - - @Override - public int compareTo(registerStormReceiver_result other) { - if (!getClass().equals(other.getClass())) { - return getClass().getName().compareTo(other.getClass().getName()); - } - - int lastComparison = 0; - - lastComparison = Boolean.valueOf(isSetNsme()).compareTo(other.isSetNsme()); - if (lastComparison != 0) { - return lastComparison; - } - if (isSetNsme()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.nsme, other.nsme); - if (lastComparison != 0) { - return lastComparison; - } - } - return 0; - } - - public _Fields fieldForId(int fieldId) { - return _Fields.findByThriftId(fieldId); - } - - public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { - schemes.get(iprot.getScheme()).getScheme().read(iprot, this); - } - - public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { - schemes.get(oprot.getScheme()).getScheme().write(oprot, this); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder("registerStormReceiver_result("); - boolean first = true; - - sb.append("nsme:"); - if (this.nsme == null) { - sb.append("null"); - } else { - sb.append(this.nsme); - } - first = false; - sb.append(")"); - return sb.toString(); - } - - public void validate() throws org.apache.thrift.TException { - // check for required fields - // check for sub-struct validity - } - - private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { - try { - write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); - } catch (org.apache.thrift.TException te) { - throw new java.io.IOException(te); - } - } - - private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { - try { - read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); - } catch (org.apache.thrift.TException te) { - throw new java.io.IOException(te); - } - } - - private static class registerStormReceiver_resultStandardSchemeFactory implements SchemeFactory { - public registerStormReceiver_resultStandardScheme getScheme() { - return new registerStormReceiver_resultStandardScheme(); - } - } - - private static class registerStormReceiver_resultStandardScheme extends StandardScheme { - - public void read(org.apache.thrift.protocol.TProtocol iprot, registerStormReceiver_result struct) throws org.apache.thrift.TException { - org.apache.thrift.protocol.TField schemeField; - iprot.readStructBegin(); - while (true) - { - schemeField = iprot.readFieldBegin(); - if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { - break; - } - switch (schemeField.id) { - case 1: // NSME - if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { - struct.nsme = new org.wso2.carbon.event.processor.common.storm.manager.service.exception.NotStormCoordinatorException(); - struct.nsme.read(iprot); - struct.setNsmeIsSet(true); - } else { - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - break; - default: - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - iprot.readFieldEnd(); - } - iprot.readStructEnd(); - - // check for required fields of primitive type, which can't be checked in the validate method - struct.validate(); - } - - public void write(org.apache.thrift.protocol.TProtocol oprot, registerStormReceiver_result struct) throws org.apache.thrift.TException { - struct.validate(); - - oprot.writeStructBegin(STRUCT_DESC); - if (struct.nsme != null) { - oprot.writeFieldBegin(NSME_FIELD_DESC); - struct.nsme.write(oprot); - oprot.writeFieldEnd(); - } - oprot.writeFieldStop(); - oprot.writeStructEnd(); - } - - } - - private static class registerStormReceiver_resultTupleSchemeFactory implements SchemeFactory { - public registerStormReceiver_resultTupleScheme getScheme() { - return new registerStormReceiver_resultTupleScheme(); - } - } - - private static class registerStormReceiver_resultTupleScheme extends TupleScheme { - - @Override - public void write(org.apache.thrift.protocol.TProtocol prot, registerStormReceiver_result struct) throws org.apache.thrift.TException { - TTupleProtocol oprot = (TTupleProtocol) prot; - BitSet optionals = new BitSet(); - if (struct.isSetNsme()) { - optionals.set(0); - } - oprot.writeBitSet(optionals, 1); - if (struct.isSetNsme()) { - struct.nsme.write(oprot); - } - } - - @Override - public void read(org.apache.thrift.protocol.TProtocol prot, registerStormReceiver_result struct) throws org.apache.thrift.TException { - TTupleProtocol iprot = (TTupleProtocol) prot; - BitSet incoming = iprot.readBitSet(1); - if (incoming.get(0)) { - struct.nsme = new org.wso2.carbon.event.processor.common.storm.manager.service.exception.NotStormCoordinatorException(); - struct.nsme.read(iprot); - struct.setNsmeIsSet(true); - } - } - } - - } - - public static class registerCEPPublisher_args implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { - private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("registerCEPPublisher_args"); - - private static final org.apache.thrift.protocol.TField TENANT_ID_FIELD_DESC = new org.apache.thrift.protocol.TField("tenantId", org.apache.thrift.protocol.TType.I32, (short)1); - private static final org.apache.thrift.protocol.TField EXECUTION_PLAN_NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("executionPlanName", org.apache.thrift.protocol.TType.STRING, (short)2); - private static final org.apache.thrift.protocol.TField HOST_NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("hostName", org.apache.thrift.protocol.TType.STRING, (short)3); - private static final org.apache.thrift.protocol.TField PORT_FIELD_DESC = new org.apache.thrift.protocol.TField("port", org.apache.thrift.protocol.TType.I32, (short)4); - - private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); - static { - schemes.put(StandardScheme.class, new registerCEPPublisher_argsStandardSchemeFactory()); - schemes.put(TupleScheme.class, new registerCEPPublisher_argsTupleSchemeFactory()); - } - - public int tenantId; // required - public String executionPlanName; // required - public String hostName; // required - public int port; // required - - /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ - public enum _Fields implements org.apache.thrift.TFieldIdEnum { - TENANT_ID((short)1, "tenantId"), - EXECUTION_PLAN_NAME((short)2, "executionPlanName"), - HOST_NAME((short)3, "hostName"), - PORT((short)4, "port"); - - private static final Map byName = new HashMap(); - - static { - for (_Fields field : EnumSet.allOf(_Fields.class)) { - byName.put(field.getFieldName(), field); - } - } - - /** - * Find the _Fields constant that matches fieldId, or null if its not found. - */ - public static _Fields findByThriftId(int fieldId) { - switch(fieldId) { - case 1: // TENANT_ID - return TENANT_ID; - case 2: // EXECUTION_PLAN_NAME - return EXECUTION_PLAN_NAME; - case 3: // HOST_NAME - return HOST_NAME; - case 4: // PORT - return PORT; - default: - return null; - } - } - - /** - * Find the _Fields constant that matches fieldId, throwing an exception - * if it is not found. - */ - public static _Fields findByThriftIdOrThrow(int fieldId) { - _Fields fields = findByThriftId(fieldId); - if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); - return fields; - } - - /** - * Find the _Fields constant that matches name, or null if its not found. - */ - public static _Fields findByName(String name) { - return byName.get(name); - } - - private final short _thriftId; - private final String _fieldName; - - _Fields(short thriftId, String fieldName) { - _thriftId = thriftId; - _fieldName = fieldName; - } - - public short getThriftFieldId() { - return _thriftId; - } - - public String getFieldName() { - return _fieldName; - } - } - - // isset id assignments - private static final int __TENANTID_ISSET_ID = 0; - private static final int __PORT_ISSET_ID = 1; - private byte __isset_bitfield = 0; - public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; - static { - Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); - tmpMap.put(_Fields.TENANT_ID, new org.apache.thrift.meta_data.FieldMetaData("tenantId", org.apache.thrift.TFieldRequirementType.DEFAULT, - new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32))); - tmpMap.put(_Fields.EXECUTION_PLAN_NAME, new org.apache.thrift.meta_data.FieldMetaData("executionPlanName", org.apache.thrift.TFieldRequirementType.DEFAULT, - new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); - tmpMap.put(_Fields.HOST_NAME, new org.apache.thrift.meta_data.FieldMetaData("hostName", org.apache.thrift.TFieldRequirementType.DEFAULT, - new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); - tmpMap.put(_Fields.PORT, new org.apache.thrift.meta_data.FieldMetaData("port", org.apache.thrift.TFieldRequirementType.DEFAULT, - new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32))); - metaDataMap = Collections.unmodifiableMap(tmpMap); - org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(registerCEPPublisher_args.class, metaDataMap); - } - - public registerCEPPublisher_args() { - } - - public registerCEPPublisher_args( - int tenantId, - String executionPlanName, - String hostName, - int port) - { - this(); - this.tenantId = tenantId; - setTenantIdIsSet(true); - this.executionPlanName = executionPlanName; - this.hostName = hostName; - this.port = port; - setPortIsSet(true); - } - - /** - * Performs a deep copy on other. - */ - public registerCEPPublisher_args(registerCEPPublisher_args other) { - __isset_bitfield = other.__isset_bitfield; - this.tenantId = other.tenantId; - if (other.isSetExecutionPlanName()) { - this.executionPlanName = other.executionPlanName; - } - if (other.isSetHostName()) { - this.hostName = other.hostName; - } - this.port = other.port; - } - - public registerCEPPublisher_args deepCopy() { - return new registerCEPPublisher_args(this); - } - - @Override - public void clear() { - setTenantIdIsSet(false); - this.tenantId = 0; - this.executionPlanName = null; - this.hostName = null; - setPortIsSet(false); - this.port = 0; - } - - public int getTenantId() { - return this.tenantId; - } - - public registerCEPPublisher_args setTenantId(int tenantId) { - this.tenantId = tenantId; - setTenantIdIsSet(true); - return this; - } - - public void unsetTenantId() { - __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __TENANTID_ISSET_ID); - } - - /** Returns true if field tenantId is set (has been assigned a value) and false otherwise */ - public boolean isSetTenantId() { - return EncodingUtils.testBit(__isset_bitfield, __TENANTID_ISSET_ID); - } - - public void setTenantIdIsSet(boolean value) { - __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __TENANTID_ISSET_ID, value); - } - - public String getExecutionPlanName() { - return this.executionPlanName; - } - - public registerCEPPublisher_args setExecutionPlanName(String executionPlanName) { - this.executionPlanName = executionPlanName; - return this; - } - - public void unsetExecutionPlanName() { - this.executionPlanName = null; - } - - /** Returns true if field executionPlanName is set (has been assigned a value) and false otherwise */ - public boolean isSetExecutionPlanName() { - return this.executionPlanName != null; - } - - public void setExecutionPlanNameIsSet(boolean value) { - if (!value) { - this.executionPlanName = null; - } - } - - public String getHostName() { - return this.hostName; - } - - public registerCEPPublisher_args setHostName(String hostName) { - this.hostName = hostName; - return this; - } - - public void unsetHostName() { - this.hostName = null; - } - - /** Returns true if field hostName is set (has been assigned a value) and false otherwise */ - public boolean isSetHostName() { - return this.hostName != null; - } - - public void setHostNameIsSet(boolean value) { - if (!value) { - this.hostName = null; - } - } - - public int getPort() { - return this.port; - } - - public registerCEPPublisher_args setPort(int port) { - this.port = port; - setPortIsSet(true); - return this; - } - - public void unsetPort() { - __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __PORT_ISSET_ID); - } - - /** Returns true if field port is set (has been assigned a value) and false otherwise */ - public boolean isSetPort() { - return EncodingUtils.testBit(__isset_bitfield, __PORT_ISSET_ID); - } - - public void setPortIsSet(boolean value) { - __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __PORT_ISSET_ID, value); - } - - public void setFieldValue(_Fields field, Object value) { - switch (field) { - case TENANT_ID: - if (value == null) { - unsetTenantId(); - } else { - setTenantId((Integer)value); - } - break; - - case EXECUTION_PLAN_NAME: - if (value == null) { - unsetExecutionPlanName(); - } else { - setExecutionPlanName((String)value); - } - break; - - case HOST_NAME: - if (value == null) { - unsetHostName(); - } else { - setHostName((String)value); - } - break; - - case PORT: - if (value == null) { - unsetPort(); - } else { - setPort((Integer)value); - } - break; - - } - } - - public Object getFieldValue(_Fields field) { - switch (field) { - case TENANT_ID: - return Integer.valueOf(getTenantId()); - - case EXECUTION_PLAN_NAME: - return getExecutionPlanName(); - - case HOST_NAME: - return getHostName(); - - case PORT: - return Integer.valueOf(getPort()); - - } - throw new IllegalStateException(); - } - - /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ - public boolean isSet(_Fields field) { - if (field == null) { - throw new IllegalArgumentException(); - } - - switch (field) { - case TENANT_ID: - return isSetTenantId(); - case EXECUTION_PLAN_NAME: - return isSetExecutionPlanName(); - case HOST_NAME: - return isSetHostName(); - case PORT: - return isSetPort(); - } - throw new IllegalStateException(); - } - - @Override - public boolean equals(Object that) { - if (that == null) - return false; - if (that instanceof registerCEPPublisher_args) - return this.equals((registerCEPPublisher_args)that); - return false; - } - - public boolean equals(registerCEPPublisher_args that) { - if (that == null) - return false; - - boolean this_present_tenantId = true; - boolean that_present_tenantId = true; - if (this_present_tenantId || that_present_tenantId) { - if (!(this_present_tenantId && that_present_tenantId)) - return false; - if (this.tenantId != that.tenantId) - return false; - } - - boolean this_present_executionPlanName = true && this.isSetExecutionPlanName(); - boolean that_present_executionPlanName = true && that.isSetExecutionPlanName(); - if (this_present_executionPlanName || that_present_executionPlanName) { - if (!(this_present_executionPlanName && that_present_executionPlanName)) - return false; - if (!this.executionPlanName.equals(that.executionPlanName)) - return false; - } - - boolean this_present_hostName = true && this.isSetHostName(); - boolean that_present_hostName = true && that.isSetHostName(); - if (this_present_hostName || that_present_hostName) { - if (!(this_present_hostName && that_present_hostName)) - return false; - if (!this.hostName.equals(that.hostName)) - return false; - } - - boolean this_present_port = true; - boolean that_present_port = true; - if (this_present_port || that_present_port) { - if (!(this_present_port && that_present_port)) - return false; - if (this.port != that.port) - return false; - } - - return true; - } - - @Override - public int hashCode() { - return 0; - } - - @Override - public int compareTo(registerCEPPublisher_args other) { - if (!getClass().equals(other.getClass())) { - return getClass().getName().compareTo(other.getClass().getName()); - } - - int lastComparison = 0; - - lastComparison = Boolean.valueOf(isSetTenantId()).compareTo(other.isSetTenantId()); - if (lastComparison != 0) { - return lastComparison; - } - if (isSetTenantId()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.tenantId, other.tenantId); - if (lastComparison != 0) { - return lastComparison; - } - } - lastComparison = Boolean.valueOf(isSetExecutionPlanName()).compareTo(other.isSetExecutionPlanName()); - if (lastComparison != 0) { - return lastComparison; - } - if (isSetExecutionPlanName()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.executionPlanName, other.executionPlanName); - if (lastComparison != 0) { - return lastComparison; - } - } - lastComparison = Boolean.valueOf(isSetHostName()).compareTo(other.isSetHostName()); - if (lastComparison != 0) { - return lastComparison; - } - if (isSetHostName()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.hostName, other.hostName); - if (lastComparison != 0) { - return lastComparison; - } - } - lastComparison = Boolean.valueOf(isSetPort()).compareTo(other.isSetPort()); - if (lastComparison != 0) { - return lastComparison; - } - if (isSetPort()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.port, other.port); - if (lastComparison != 0) { - return lastComparison; - } - } - return 0; - } - - public _Fields fieldForId(int fieldId) { - return _Fields.findByThriftId(fieldId); - } - - public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { - schemes.get(iprot.getScheme()).getScheme().read(iprot, this); - } - - public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { - schemes.get(oprot.getScheme()).getScheme().write(oprot, this); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder("registerCEPPublisher_args("); - boolean first = true; - - sb.append("tenantId:"); - sb.append(this.tenantId); - first = false; - if (!first) sb.append(", "); - sb.append("executionPlanName:"); - if (this.executionPlanName == null) { - sb.append("null"); - } else { - sb.append(this.executionPlanName); - } - first = false; - if (!first) sb.append(", "); - sb.append("hostName:"); - if (this.hostName == null) { - sb.append("null"); - } else { - sb.append(this.hostName); - } - first = false; - if (!first) sb.append(", "); - sb.append("port:"); - sb.append(this.port); - first = false; - sb.append(")"); - return sb.toString(); - } - - public void validate() throws org.apache.thrift.TException { - // check for required fields - // check for sub-struct validity - } - - private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { - try { - write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); - } catch (org.apache.thrift.TException te) { - throw new java.io.IOException(te); - } - } - - private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { - try { - // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor. - __isset_bitfield = 0; - read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); - } catch (org.apache.thrift.TException te) { - throw new java.io.IOException(te); - } - } - - private static class registerCEPPublisher_argsStandardSchemeFactory implements SchemeFactory { - public registerCEPPublisher_argsStandardScheme getScheme() { - return new registerCEPPublisher_argsStandardScheme(); - } - } - - private static class registerCEPPublisher_argsStandardScheme extends StandardScheme { - - public void read(org.apache.thrift.protocol.TProtocol iprot, registerCEPPublisher_args struct) throws org.apache.thrift.TException { - org.apache.thrift.protocol.TField schemeField; - iprot.readStructBegin(); - while (true) - { - schemeField = iprot.readFieldBegin(); - if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { - break; - } - switch (schemeField.id) { - case 1: // TENANT_ID - if (schemeField.type == org.apache.thrift.protocol.TType.I32) { - struct.tenantId = iprot.readI32(); - struct.setTenantIdIsSet(true); - } else { - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - break; - case 2: // EXECUTION_PLAN_NAME - if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { - struct.executionPlanName = iprot.readString(); - struct.setExecutionPlanNameIsSet(true); - } else { - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - break; - case 3: // HOST_NAME - if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { - struct.hostName = iprot.readString(); - struct.setHostNameIsSet(true); - } else { - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - break; - case 4: // PORT - if (schemeField.type == org.apache.thrift.protocol.TType.I32) { - struct.port = iprot.readI32(); - struct.setPortIsSet(true); - } else { - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - break; - default: - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - iprot.readFieldEnd(); - } - iprot.readStructEnd(); - - // check for required fields of primitive type, which can't be checked in the validate method - struct.validate(); - } - - public void write(org.apache.thrift.protocol.TProtocol oprot, registerCEPPublisher_args struct) throws org.apache.thrift.TException { - struct.validate(); - - oprot.writeStructBegin(STRUCT_DESC); - oprot.writeFieldBegin(TENANT_ID_FIELD_DESC); - oprot.writeI32(struct.tenantId); - oprot.writeFieldEnd(); - if (struct.executionPlanName != null) { - oprot.writeFieldBegin(EXECUTION_PLAN_NAME_FIELD_DESC); - oprot.writeString(struct.executionPlanName); - oprot.writeFieldEnd(); - } - if (struct.hostName != null) { - oprot.writeFieldBegin(HOST_NAME_FIELD_DESC); - oprot.writeString(struct.hostName); - oprot.writeFieldEnd(); - } - oprot.writeFieldBegin(PORT_FIELD_DESC); - oprot.writeI32(struct.port); - oprot.writeFieldEnd(); - oprot.writeFieldStop(); - oprot.writeStructEnd(); - } - - } - - private static class registerCEPPublisher_argsTupleSchemeFactory implements SchemeFactory { - public registerCEPPublisher_argsTupleScheme getScheme() { - return new registerCEPPublisher_argsTupleScheme(); - } - } - - private static class registerCEPPublisher_argsTupleScheme extends TupleScheme { - - @Override - public void write(org.apache.thrift.protocol.TProtocol prot, registerCEPPublisher_args struct) throws org.apache.thrift.TException { - TTupleProtocol oprot = (TTupleProtocol) prot; - BitSet optionals = new BitSet(); - if (struct.isSetTenantId()) { - optionals.set(0); - } - if (struct.isSetExecutionPlanName()) { - optionals.set(1); - } - if (struct.isSetHostName()) { - optionals.set(2); - } - if (struct.isSetPort()) { - optionals.set(3); - } - oprot.writeBitSet(optionals, 4); - if (struct.isSetTenantId()) { - oprot.writeI32(struct.tenantId); - } - if (struct.isSetExecutionPlanName()) { - oprot.writeString(struct.executionPlanName); - } - if (struct.isSetHostName()) { - oprot.writeString(struct.hostName); - } - if (struct.isSetPort()) { - oprot.writeI32(struct.port); - } - } - - @Override - public void read(org.apache.thrift.protocol.TProtocol prot, registerCEPPublisher_args struct) throws org.apache.thrift.TException { - TTupleProtocol iprot = (TTupleProtocol) prot; - BitSet incoming = iprot.readBitSet(4); - if (incoming.get(0)) { - struct.tenantId = iprot.readI32(); - struct.setTenantIdIsSet(true); - } - if (incoming.get(1)) { - struct.executionPlanName = iprot.readString(); - struct.setExecutionPlanNameIsSet(true); - } - if (incoming.get(2)) { - struct.hostName = iprot.readString(); - struct.setHostNameIsSet(true); - } - if (incoming.get(3)) { - struct.port = iprot.readI32(); - struct.setPortIsSet(true); - } - } - } - - } - - public static class registerCEPPublisher_result implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { - private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("registerCEPPublisher_result"); - - private static final org.apache.thrift.protocol.TField NSME_FIELD_DESC = new org.apache.thrift.protocol.TField("nsme", org.apache.thrift.protocol.TType.STRUCT, (short)1); - - private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); - static { - schemes.put(StandardScheme.class, new registerCEPPublisher_resultStandardSchemeFactory()); - schemes.put(TupleScheme.class, new registerCEPPublisher_resultTupleSchemeFactory()); - } - - public org.wso2.carbon.event.processor.common.storm.manager.service.exception.NotStormCoordinatorException nsme; // required - - /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ - public enum _Fields implements org.apache.thrift.TFieldIdEnum { - NSME((short)1, "nsme"); - - private static final Map byName = new HashMap(); - - static { - for (_Fields field : EnumSet.allOf(_Fields.class)) { - byName.put(field.getFieldName(), field); - } - } - - /** - * Find the _Fields constant that matches fieldId, or null if its not found. - */ - public static _Fields findByThriftId(int fieldId) { - switch(fieldId) { - case 1: // NSME - return NSME; - default: - return null; - } - } - - /** - * Find the _Fields constant that matches fieldId, throwing an exception - * if it is not found. - */ - public static _Fields findByThriftIdOrThrow(int fieldId) { - _Fields fields = findByThriftId(fieldId); - if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); - return fields; - } - - /** - * Find the _Fields constant that matches name, or null if its not found. - */ - public static _Fields findByName(String name) { - return byName.get(name); - } - - private final short _thriftId; - private final String _fieldName; - - _Fields(short thriftId, String fieldName) { - _thriftId = thriftId; - _fieldName = fieldName; - } - - public short getThriftFieldId() { - return _thriftId; - } - - public String getFieldName() { - return _fieldName; - } - } - - // isset id assignments - public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; - static { - Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); - tmpMap.put(_Fields.NSME, new org.apache.thrift.meta_data.FieldMetaData("nsme", org.apache.thrift.TFieldRequirementType.DEFAULT, - new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT))); - metaDataMap = Collections.unmodifiableMap(tmpMap); - org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(registerCEPPublisher_result.class, metaDataMap); - } - - public registerCEPPublisher_result() { - } - - public registerCEPPublisher_result( - org.wso2.carbon.event.processor.common.storm.manager.service.exception.NotStormCoordinatorException nsme) - { - this(); - this.nsme = nsme; - } - - /** - * Performs a deep copy on other. - */ - public registerCEPPublisher_result(registerCEPPublisher_result other) { - if (other.isSetNsme()) { - this.nsme = new org.wso2.carbon.event.processor.common.storm.manager.service.exception.NotStormCoordinatorException(other.nsme); - } - } - - public registerCEPPublisher_result deepCopy() { - return new registerCEPPublisher_result(this); - } - - @Override - public void clear() { - this.nsme = null; - } - - public org.wso2.carbon.event.processor.common.storm.manager.service.exception.NotStormCoordinatorException getNsme() { - return this.nsme; - } - - public registerCEPPublisher_result setNsme(org.wso2.carbon.event.processor.common.storm.manager.service.exception.NotStormCoordinatorException nsme) { - this.nsme = nsme; - return this; - } - - public void unsetNsme() { - this.nsme = null; - } - - /** Returns true if field nsme is set (has been assigned a value) and false otherwise */ - public boolean isSetNsme() { - return this.nsme != null; - } - - public void setNsmeIsSet(boolean value) { - if (!value) { - this.nsme = null; - } - } - - public void setFieldValue(_Fields field, Object value) { - switch (field) { - case NSME: - if (value == null) { - unsetNsme(); - } else { - setNsme((org.wso2.carbon.event.processor.common.storm.manager.service.exception.NotStormCoordinatorException)value); - } - break; - - } - } - - public Object getFieldValue(_Fields field) { - switch (field) { - case NSME: - return getNsme(); - - } - throw new IllegalStateException(); - } - - /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ - public boolean isSet(_Fields field) { - if (field == null) { - throw new IllegalArgumentException(); - } - - switch (field) { - case NSME: - return isSetNsme(); - } - throw new IllegalStateException(); - } - - @Override - public boolean equals(Object that) { - if (that == null) - return false; - if (that instanceof registerCEPPublisher_result) - return this.equals((registerCEPPublisher_result)that); - return false; - } - - public boolean equals(registerCEPPublisher_result that) { - if (that == null) - return false; - - boolean this_present_nsme = true && this.isSetNsme(); - boolean that_present_nsme = true && that.isSetNsme(); - if (this_present_nsme || that_present_nsme) { - if (!(this_present_nsme && that_present_nsme)) - return false; - if (!this.nsme.equals(that.nsme)) - return false; - } - - return true; - } - - @Override - public int hashCode() { - return 0; - } - - @Override - public int compareTo(registerCEPPublisher_result other) { - if (!getClass().equals(other.getClass())) { - return getClass().getName().compareTo(other.getClass().getName()); - } - - int lastComparison = 0; - - lastComparison = Boolean.valueOf(isSetNsme()).compareTo(other.isSetNsme()); - if (lastComparison != 0) { - return lastComparison; - } - if (isSetNsme()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.nsme, other.nsme); - if (lastComparison != 0) { - return lastComparison; - } - } - return 0; - } - - public _Fields fieldForId(int fieldId) { - return _Fields.findByThriftId(fieldId); - } - - public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { - schemes.get(iprot.getScheme()).getScheme().read(iprot, this); - } - - public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { - schemes.get(oprot.getScheme()).getScheme().write(oprot, this); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder("registerCEPPublisher_result("); - boolean first = true; - - sb.append("nsme:"); - if (this.nsme == null) { - sb.append("null"); - } else { - sb.append(this.nsme); - } - first = false; - sb.append(")"); - return sb.toString(); - } - - public void validate() throws org.apache.thrift.TException { - // check for required fields - // check for sub-struct validity - } - - private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { - try { - write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); - } catch (org.apache.thrift.TException te) { - throw new java.io.IOException(te); - } - } - - private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { - try { - read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); - } catch (org.apache.thrift.TException te) { - throw new java.io.IOException(te); - } - } - - private static class registerCEPPublisher_resultStandardSchemeFactory implements SchemeFactory { - public registerCEPPublisher_resultStandardScheme getScheme() { - return new registerCEPPublisher_resultStandardScheme(); - } - } - - private static class registerCEPPublisher_resultStandardScheme extends StandardScheme { - - public void read(org.apache.thrift.protocol.TProtocol iprot, registerCEPPublisher_result struct) throws org.apache.thrift.TException { - org.apache.thrift.protocol.TField schemeField; - iprot.readStructBegin(); - while (true) - { - schemeField = iprot.readFieldBegin(); - if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { - break; - } - switch (schemeField.id) { - case 1: // NSME - if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { - struct.nsme = new org.wso2.carbon.event.processor.common.storm.manager.service.exception.NotStormCoordinatorException(); - struct.nsme.read(iprot); - struct.setNsmeIsSet(true); - } else { - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - break; - default: - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - iprot.readFieldEnd(); - } - iprot.readStructEnd(); - - // check for required fields of primitive type, which can't be checked in the validate method - struct.validate(); - } - - public void write(org.apache.thrift.protocol.TProtocol oprot, registerCEPPublisher_result struct) throws org.apache.thrift.TException { - struct.validate(); - - oprot.writeStructBegin(STRUCT_DESC); - if (struct.nsme != null) { - oprot.writeFieldBegin(NSME_FIELD_DESC); - struct.nsme.write(oprot); - oprot.writeFieldEnd(); - } - oprot.writeFieldStop(); - oprot.writeStructEnd(); - } - - } - - private static class registerCEPPublisher_resultTupleSchemeFactory implements SchemeFactory { - public registerCEPPublisher_resultTupleScheme getScheme() { - return new registerCEPPublisher_resultTupleScheme(); - } - } - - private static class registerCEPPublisher_resultTupleScheme extends TupleScheme { - - @Override - public void write(org.apache.thrift.protocol.TProtocol prot, registerCEPPublisher_result struct) throws org.apache.thrift.TException { - TTupleProtocol oprot = (TTupleProtocol) prot; - BitSet optionals = new BitSet(); - if (struct.isSetNsme()) { - optionals.set(0); - } - oprot.writeBitSet(optionals, 1); - if (struct.isSetNsme()) { - struct.nsme.write(oprot); - } - } - - @Override - public void read(org.apache.thrift.protocol.TProtocol prot, registerCEPPublisher_result struct) throws org.apache.thrift.TException { - TTupleProtocol iprot = (TTupleProtocol) prot; - BitSet incoming = iprot.readBitSet(1); - if (incoming.get(0)) { - struct.nsme = new org.wso2.carbon.event.processor.common.storm.manager.service.exception.NotStormCoordinatorException(); - struct.nsme.read(iprot); - struct.setNsmeIsSet(true); - } - } - } - - } - - public static class getStormReceiver_args implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { - private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("getStormReceiver_args"); - - private static final org.apache.thrift.protocol.TField TENANT_ID_FIELD_DESC = new org.apache.thrift.protocol.TField("tenantId", org.apache.thrift.protocol.TType.I32, (short)1); - private static final org.apache.thrift.protocol.TField EXECUTION_PLAN_NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("executionPlanName", org.apache.thrift.protocol.TType.STRING, (short)2); - private static final org.apache.thrift.protocol.TField CEP_RECEIVER_HOST_NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("cepReceiverHostName", org.apache.thrift.protocol.TType.STRING, (short)3); - - private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); - static { - schemes.put(StandardScheme.class, new getStormReceiver_argsStandardSchemeFactory()); - schemes.put(TupleScheme.class, new getStormReceiver_argsTupleSchemeFactory()); - } - - public int tenantId; // required - public String executionPlanName; // required - public String cepReceiverHostName; // required - - /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ - public enum _Fields implements org.apache.thrift.TFieldIdEnum { - TENANT_ID((short)1, "tenantId"), - EXECUTION_PLAN_NAME((short)2, "executionPlanName"), - CEP_RECEIVER_HOST_NAME((short)3, "cepReceiverHostName"); - - private static final Map byName = new HashMap(); - - static { - for (_Fields field : EnumSet.allOf(_Fields.class)) { - byName.put(field.getFieldName(), field); - } - } - - /** - * Find the _Fields constant that matches fieldId, or null if its not found. - */ - public static _Fields findByThriftId(int fieldId) { - switch(fieldId) { - case 1: // TENANT_ID - return TENANT_ID; - case 2: // EXECUTION_PLAN_NAME - return EXECUTION_PLAN_NAME; - case 3: // CEP_RECEIVER_HOST_NAME - return CEP_RECEIVER_HOST_NAME; - default: - return null; - } - } - - /** - * Find the _Fields constant that matches fieldId, throwing an exception - * if it is not found. - */ - public static _Fields findByThriftIdOrThrow(int fieldId) { - _Fields fields = findByThriftId(fieldId); - if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); - return fields; - } - - /** - * Find the _Fields constant that matches name, or null if its not found. - */ - public static _Fields findByName(String name) { - return byName.get(name); - } - - private final short _thriftId; - private final String _fieldName; - - _Fields(short thriftId, String fieldName) { - _thriftId = thriftId; - _fieldName = fieldName; - } - - public short getThriftFieldId() { - return _thriftId; - } - - public String getFieldName() { - return _fieldName; - } - } - - // isset id assignments - private static final int __TENANTID_ISSET_ID = 0; - private byte __isset_bitfield = 0; - public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; - static { - Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); - tmpMap.put(_Fields.TENANT_ID, new org.apache.thrift.meta_data.FieldMetaData("tenantId", org.apache.thrift.TFieldRequirementType.DEFAULT, - new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32))); - tmpMap.put(_Fields.EXECUTION_PLAN_NAME, new org.apache.thrift.meta_data.FieldMetaData("executionPlanName", org.apache.thrift.TFieldRequirementType.DEFAULT, - new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); - tmpMap.put(_Fields.CEP_RECEIVER_HOST_NAME, new org.apache.thrift.meta_data.FieldMetaData("cepReceiverHostName", org.apache.thrift.TFieldRequirementType.DEFAULT, - new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); - metaDataMap = Collections.unmodifiableMap(tmpMap); - org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(getStormReceiver_args.class, metaDataMap); - } - - public getStormReceiver_args() { - } - - public getStormReceiver_args( - int tenantId, - String executionPlanName, - String cepReceiverHostName) - { - this(); - this.tenantId = tenantId; - setTenantIdIsSet(true); - this.executionPlanName = executionPlanName; - this.cepReceiverHostName = cepReceiverHostName; - } - - /** - * Performs a deep copy on other. - */ - public getStormReceiver_args(getStormReceiver_args other) { - __isset_bitfield = other.__isset_bitfield; - this.tenantId = other.tenantId; - if (other.isSetExecutionPlanName()) { - this.executionPlanName = other.executionPlanName; - } - if (other.isSetCepReceiverHostName()) { - this.cepReceiverHostName = other.cepReceiverHostName; - } - } - - public getStormReceiver_args deepCopy() { - return new getStormReceiver_args(this); - } - - @Override - public void clear() { - setTenantIdIsSet(false); - this.tenantId = 0; - this.executionPlanName = null; - this.cepReceiverHostName = null; - } - - public int getTenantId() { - return this.tenantId; - } - - public getStormReceiver_args setTenantId(int tenantId) { - this.tenantId = tenantId; - setTenantIdIsSet(true); - return this; - } - - public void unsetTenantId() { - __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __TENANTID_ISSET_ID); - } - - /** Returns true if field tenantId is set (has been assigned a value) and false otherwise */ - public boolean isSetTenantId() { - return EncodingUtils.testBit(__isset_bitfield, __TENANTID_ISSET_ID); - } - - public void setTenantIdIsSet(boolean value) { - __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __TENANTID_ISSET_ID, value); - } - - public String getExecutionPlanName() { - return this.executionPlanName; - } - - public getStormReceiver_args setExecutionPlanName(String executionPlanName) { - this.executionPlanName = executionPlanName; - return this; - } - - public void unsetExecutionPlanName() { - this.executionPlanName = null; - } - - /** Returns true if field executionPlanName is set (has been assigned a value) and false otherwise */ - public boolean isSetExecutionPlanName() { - return this.executionPlanName != null; - } - - public void setExecutionPlanNameIsSet(boolean value) { - if (!value) { - this.executionPlanName = null; - } - } - - public String getCepReceiverHostName() { - return this.cepReceiverHostName; - } - - public getStormReceiver_args setCepReceiverHostName(String cepReceiverHostName) { - this.cepReceiverHostName = cepReceiverHostName; - return this; - } - - public void unsetCepReceiverHostName() { - this.cepReceiverHostName = null; - } - - /** Returns true if field cepReceiverHostName is set (has been assigned a value) and false otherwise */ - public boolean isSetCepReceiverHostName() { - return this.cepReceiverHostName != null; - } - - public void setCepReceiverHostNameIsSet(boolean value) { - if (!value) { - this.cepReceiverHostName = null; - } - } - - public void setFieldValue(_Fields field, Object value) { - switch (field) { - case TENANT_ID: - if (value == null) { - unsetTenantId(); - } else { - setTenantId((Integer)value); - } - break; - - case EXECUTION_PLAN_NAME: - if (value == null) { - unsetExecutionPlanName(); - } else { - setExecutionPlanName((String)value); - } - break; - - case CEP_RECEIVER_HOST_NAME: - if (value == null) { - unsetCepReceiverHostName(); - } else { - setCepReceiverHostName((String)value); - } - break; - - } - } - - public Object getFieldValue(_Fields field) { - switch (field) { - case TENANT_ID: - return Integer.valueOf(getTenantId()); - - case EXECUTION_PLAN_NAME: - return getExecutionPlanName(); - - case CEP_RECEIVER_HOST_NAME: - return getCepReceiverHostName(); - - } - throw new IllegalStateException(); - } - - /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ - public boolean isSet(_Fields field) { - if (field == null) { - throw new IllegalArgumentException(); - } - - switch (field) { - case TENANT_ID: - return isSetTenantId(); - case EXECUTION_PLAN_NAME: - return isSetExecutionPlanName(); - case CEP_RECEIVER_HOST_NAME: - return isSetCepReceiverHostName(); - } - throw new IllegalStateException(); - } - - @Override - public boolean equals(Object that) { - if (that == null) - return false; - if (that instanceof getStormReceiver_args) - return this.equals((getStormReceiver_args)that); - return false; - } - - public boolean equals(getStormReceiver_args that) { - if (that == null) - return false; - - boolean this_present_tenantId = true; - boolean that_present_tenantId = true; - if (this_present_tenantId || that_present_tenantId) { - if (!(this_present_tenantId && that_present_tenantId)) - return false; - if (this.tenantId != that.tenantId) - return false; - } - - boolean this_present_executionPlanName = true && this.isSetExecutionPlanName(); - boolean that_present_executionPlanName = true && that.isSetExecutionPlanName(); - if (this_present_executionPlanName || that_present_executionPlanName) { - if (!(this_present_executionPlanName && that_present_executionPlanName)) - return false; - if (!this.executionPlanName.equals(that.executionPlanName)) - return false; - } - - boolean this_present_cepReceiverHostName = true && this.isSetCepReceiverHostName(); - boolean that_present_cepReceiverHostName = true && that.isSetCepReceiverHostName(); - if (this_present_cepReceiverHostName || that_present_cepReceiverHostName) { - if (!(this_present_cepReceiverHostName && that_present_cepReceiverHostName)) - return false; - if (!this.cepReceiverHostName.equals(that.cepReceiverHostName)) - return false; - } - - return true; - } - - @Override - public int hashCode() { - return 0; - } - - @Override - public int compareTo(getStormReceiver_args other) { - if (!getClass().equals(other.getClass())) { - return getClass().getName().compareTo(other.getClass().getName()); - } - - int lastComparison = 0; - - lastComparison = Boolean.valueOf(isSetTenantId()).compareTo(other.isSetTenantId()); - if (lastComparison != 0) { - return lastComparison; - } - if (isSetTenantId()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.tenantId, other.tenantId); - if (lastComparison != 0) { - return lastComparison; - } - } - lastComparison = Boolean.valueOf(isSetExecutionPlanName()).compareTo(other.isSetExecutionPlanName()); - if (lastComparison != 0) { - return lastComparison; - } - if (isSetExecutionPlanName()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.executionPlanName, other.executionPlanName); - if (lastComparison != 0) { - return lastComparison; - } - } - lastComparison = Boolean.valueOf(isSetCepReceiverHostName()).compareTo(other.isSetCepReceiverHostName()); - if (lastComparison != 0) { - return lastComparison; - } - if (isSetCepReceiverHostName()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.cepReceiverHostName, other.cepReceiverHostName); - if (lastComparison != 0) { - return lastComparison; - } - } - return 0; - } - - public _Fields fieldForId(int fieldId) { - return _Fields.findByThriftId(fieldId); - } - - public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { - schemes.get(iprot.getScheme()).getScheme().read(iprot, this); - } - - public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { - schemes.get(oprot.getScheme()).getScheme().write(oprot, this); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder("getStormReceiver_args("); - boolean first = true; - - sb.append("tenantId:"); - sb.append(this.tenantId); - first = false; - if (!first) sb.append(", "); - sb.append("executionPlanName:"); - if (this.executionPlanName == null) { - sb.append("null"); - } else { - sb.append(this.executionPlanName); - } - first = false; - if (!first) sb.append(", "); - sb.append("cepReceiverHostName:"); - if (this.cepReceiverHostName == null) { - sb.append("null"); - } else { - sb.append(this.cepReceiverHostName); - } - first = false; - sb.append(")"); - return sb.toString(); - } - - public void validate() throws org.apache.thrift.TException { - // check for required fields - // check for sub-struct validity - } - - private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { - try { - write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); - } catch (org.apache.thrift.TException te) { - throw new java.io.IOException(te); - } - } - - private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { - try { - // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor. - __isset_bitfield = 0; - read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); - } catch (org.apache.thrift.TException te) { - throw new java.io.IOException(te); - } - } - - private static class getStormReceiver_argsStandardSchemeFactory implements SchemeFactory { - public getStormReceiver_argsStandardScheme getScheme() { - return new getStormReceiver_argsStandardScheme(); - } - } - - private static class getStormReceiver_argsStandardScheme extends StandardScheme { - - public void read(org.apache.thrift.protocol.TProtocol iprot, getStormReceiver_args struct) throws org.apache.thrift.TException { - org.apache.thrift.protocol.TField schemeField; - iprot.readStructBegin(); - while (true) - { - schemeField = iprot.readFieldBegin(); - if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { - break; - } - switch (schemeField.id) { - case 1: // TENANT_ID - if (schemeField.type == org.apache.thrift.protocol.TType.I32) { - struct.tenantId = iprot.readI32(); - struct.setTenantIdIsSet(true); - } else { - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - break; - case 2: // EXECUTION_PLAN_NAME - if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { - struct.executionPlanName = iprot.readString(); - struct.setExecutionPlanNameIsSet(true); - } else { - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - break; - case 3: // CEP_RECEIVER_HOST_NAME - if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { - struct.cepReceiverHostName = iprot.readString(); - struct.setCepReceiverHostNameIsSet(true); - } else { - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - break; - default: - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - iprot.readFieldEnd(); - } - iprot.readStructEnd(); - - // check for required fields of primitive type, which can't be checked in the validate method - struct.validate(); - } - - public void write(org.apache.thrift.protocol.TProtocol oprot, getStormReceiver_args struct) throws org.apache.thrift.TException { - struct.validate(); - - oprot.writeStructBegin(STRUCT_DESC); - oprot.writeFieldBegin(TENANT_ID_FIELD_DESC); - oprot.writeI32(struct.tenantId); - oprot.writeFieldEnd(); - if (struct.executionPlanName != null) { - oprot.writeFieldBegin(EXECUTION_PLAN_NAME_FIELD_DESC); - oprot.writeString(struct.executionPlanName); - oprot.writeFieldEnd(); - } - if (struct.cepReceiverHostName != null) { - oprot.writeFieldBegin(CEP_RECEIVER_HOST_NAME_FIELD_DESC); - oprot.writeString(struct.cepReceiverHostName); - oprot.writeFieldEnd(); - } - oprot.writeFieldStop(); - oprot.writeStructEnd(); - } - - } - - private static class getStormReceiver_argsTupleSchemeFactory implements SchemeFactory { - public getStormReceiver_argsTupleScheme getScheme() { - return new getStormReceiver_argsTupleScheme(); - } - } - - private static class getStormReceiver_argsTupleScheme extends TupleScheme { - - @Override - public void write(org.apache.thrift.protocol.TProtocol prot, getStormReceiver_args struct) throws org.apache.thrift.TException { - TTupleProtocol oprot = (TTupleProtocol) prot; - BitSet optionals = new BitSet(); - if (struct.isSetTenantId()) { - optionals.set(0); - } - if (struct.isSetExecutionPlanName()) { - optionals.set(1); - } - if (struct.isSetCepReceiverHostName()) { - optionals.set(2); - } - oprot.writeBitSet(optionals, 3); - if (struct.isSetTenantId()) { - oprot.writeI32(struct.tenantId); - } - if (struct.isSetExecutionPlanName()) { - oprot.writeString(struct.executionPlanName); - } - if (struct.isSetCepReceiverHostName()) { - oprot.writeString(struct.cepReceiverHostName); - } - } - - @Override - public void read(org.apache.thrift.protocol.TProtocol prot, getStormReceiver_args struct) throws org.apache.thrift.TException { - TTupleProtocol iprot = (TTupleProtocol) prot; - BitSet incoming = iprot.readBitSet(3); - if (incoming.get(0)) { - struct.tenantId = iprot.readI32(); - struct.setTenantIdIsSet(true); - } - if (incoming.get(1)) { - struct.executionPlanName = iprot.readString(); - struct.setExecutionPlanNameIsSet(true); - } - if (incoming.get(2)) { - struct.cepReceiverHostName = iprot.readString(); - struct.setCepReceiverHostNameIsSet(true); - } - } - } - - } - - public static class getStormReceiver_result implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { - private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("getStormReceiver_result"); - - private static final org.apache.thrift.protocol.TField SUCCESS_FIELD_DESC = new org.apache.thrift.protocol.TField("success", org.apache.thrift.protocol.TType.STRING, (short)0); - private static final org.apache.thrift.protocol.TField NSME_FIELD_DESC = new org.apache.thrift.protocol.TField("nsme", org.apache.thrift.protocol.TType.STRUCT, (short)1); - private static final org.apache.thrift.protocol.TField ENFE_FIELD_DESC = new org.apache.thrift.protocol.TField("enfe", org.apache.thrift.protocol.TType.STRUCT, (short)2); - - private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); - static { - schemes.put(StandardScheme.class, new getStormReceiver_resultStandardSchemeFactory()); - schemes.put(TupleScheme.class, new getStormReceiver_resultTupleSchemeFactory()); - } - - public String success; // required - public org.wso2.carbon.event.processor.common.storm.manager.service.exception.NotStormCoordinatorException nsme; // required - public org.wso2.carbon.event.processor.common.storm.manager.service.exception.EndpointNotFoundException enfe; // required - - /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ - public enum _Fields implements org.apache.thrift.TFieldIdEnum { - SUCCESS((short)0, "success"), - NSME((short)1, "nsme"), - ENFE((short)2, "enfe"); - - private static final Map byName = new HashMap(); - - static { - for (_Fields field : EnumSet.allOf(_Fields.class)) { - byName.put(field.getFieldName(), field); - } - } - - /** - * Find the _Fields constant that matches fieldId, or null if its not found. - */ - public static _Fields findByThriftId(int fieldId) { - switch(fieldId) { - case 0: // SUCCESS - return SUCCESS; - case 1: // NSME - return NSME; - case 2: // ENFE - return ENFE; - default: - return null; - } - } - - /** - * Find the _Fields constant that matches fieldId, throwing an exception - * if it is not found. - */ - public static _Fields findByThriftIdOrThrow(int fieldId) { - _Fields fields = findByThriftId(fieldId); - if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); - return fields; - } - - /** - * Find the _Fields constant that matches name, or null if its not found. - */ - public static _Fields findByName(String name) { - return byName.get(name); - } - - private final short _thriftId; - private final String _fieldName; - - _Fields(short thriftId, String fieldName) { - _thriftId = thriftId; - _fieldName = fieldName; - } - - public short getThriftFieldId() { - return _thriftId; - } - - public String getFieldName() { - return _fieldName; - } - } - - // isset id assignments - public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; - static { - Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); - tmpMap.put(_Fields.SUCCESS, new org.apache.thrift.meta_data.FieldMetaData("success", org.apache.thrift.TFieldRequirementType.DEFAULT, - new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); - tmpMap.put(_Fields.NSME, new org.apache.thrift.meta_data.FieldMetaData("nsme", org.apache.thrift.TFieldRequirementType.DEFAULT, - new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT))); - tmpMap.put(_Fields.ENFE, new org.apache.thrift.meta_data.FieldMetaData("enfe", org.apache.thrift.TFieldRequirementType.DEFAULT, - new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT))); - metaDataMap = Collections.unmodifiableMap(tmpMap); - org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(getStormReceiver_result.class, metaDataMap); - } - - public getStormReceiver_result() { - } - - public getStormReceiver_result( - String success, - org.wso2.carbon.event.processor.common.storm.manager.service.exception.NotStormCoordinatorException nsme, - org.wso2.carbon.event.processor.common.storm.manager.service.exception.EndpointNotFoundException enfe) - { - this(); - this.success = success; - this.nsme = nsme; - this.enfe = enfe; - } - - /** - * Performs a deep copy on other. - */ - public getStormReceiver_result(getStormReceiver_result other) { - if (other.isSetSuccess()) { - this.success = other.success; - } - if (other.isSetNsme()) { - this.nsme = new org.wso2.carbon.event.processor.common.storm.manager.service.exception.NotStormCoordinatorException(other.nsme); - } - if (other.isSetEnfe()) { - this.enfe = new org.wso2.carbon.event.processor.common.storm.manager.service.exception.EndpointNotFoundException(other.enfe); - } - } - - public getStormReceiver_result deepCopy() { - return new getStormReceiver_result(this); - } - - @Override - public void clear() { - this.success = null; - this.nsme = null; - this.enfe = null; - } - - public String getSuccess() { - return this.success; - } - - public getStormReceiver_result setSuccess(String success) { - this.success = success; - return this; - } - - public void unsetSuccess() { - this.success = null; - } - - /** Returns true if field success is set (has been assigned a value) and false otherwise */ - public boolean isSetSuccess() { - return this.success != null; - } - - public void setSuccessIsSet(boolean value) { - if (!value) { - this.success = null; - } - } - - public org.wso2.carbon.event.processor.common.storm.manager.service.exception.NotStormCoordinatorException getNsme() { - return this.nsme; - } - - public getStormReceiver_result setNsme(org.wso2.carbon.event.processor.common.storm.manager.service.exception.NotStormCoordinatorException nsme) { - this.nsme = nsme; - return this; - } - - public void unsetNsme() { - this.nsme = null; - } - - /** Returns true if field nsme is set (has been assigned a value) and false otherwise */ - public boolean isSetNsme() { - return this.nsme != null; - } - - public void setNsmeIsSet(boolean value) { - if (!value) { - this.nsme = null; - } - } - - public org.wso2.carbon.event.processor.common.storm.manager.service.exception.EndpointNotFoundException getEnfe() { - return this.enfe; - } - - public getStormReceiver_result setEnfe(org.wso2.carbon.event.processor.common.storm.manager.service.exception.EndpointNotFoundException enfe) { - this.enfe = enfe; - return this; - } - - public void unsetEnfe() { - this.enfe = null; - } - - /** Returns true if field enfe is set (has been assigned a value) and false otherwise */ - public boolean isSetEnfe() { - return this.enfe != null; - } - - public void setEnfeIsSet(boolean value) { - if (!value) { - this.enfe = null; - } - } - - public void setFieldValue(_Fields field, Object value) { - switch (field) { - case SUCCESS: - if (value == null) { - unsetSuccess(); - } else { - setSuccess((String)value); - } - break; - - case NSME: - if (value == null) { - unsetNsme(); - } else { - setNsme((org.wso2.carbon.event.processor.common.storm.manager.service.exception.NotStormCoordinatorException)value); - } - break; - - case ENFE: - if (value == null) { - unsetEnfe(); - } else { - setEnfe((org.wso2.carbon.event.processor.common.storm.manager.service.exception.EndpointNotFoundException)value); - } - break; - - } - } - - public Object getFieldValue(_Fields field) { - switch (field) { - case SUCCESS: - return getSuccess(); - - case NSME: - return getNsme(); - - case ENFE: - return getEnfe(); - - } - throw new IllegalStateException(); - } - - /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ - public boolean isSet(_Fields field) { - if (field == null) { - throw new IllegalArgumentException(); - } - - switch (field) { - case SUCCESS: - return isSetSuccess(); - case NSME: - return isSetNsme(); - case ENFE: - return isSetEnfe(); - } - throw new IllegalStateException(); - } - - @Override - public boolean equals(Object that) { - if (that == null) - return false; - if (that instanceof getStormReceiver_result) - return this.equals((getStormReceiver_result)that); - return false; - } - - public boolean equals(getStormReceiver_result that) { - if (that == null) - return false; - - boolean this_present_success = true && this.isSetSuccess(); - boolean that_present_success = true && that.isSetSuccess(); - if (this_present_success || that_present_success) { - if (!(this_present_success && that_present_success)) - return false; - if (!this.success.equals(that.success)) - return false; - } - - boolean this_present_nsme = true && this.isSetNsme(); - boolean that_present_nsme = true && that.isSetNsme(); - if (this_present_nsme || that_present_nsme) { - if (!(this_present_nsme && that_present_nsme)) - return false; - if (!this.nsme.equals(that.nsme)) - return false; - } - - boolean this_present_enfe = true && this.isSetEnfe(); - boolean that_present_enfe = true && that.isSetEnfe(); - if (this_present_enfe || that_present_enfe) { - if (!(this_present_enfe && that_present_enfe)) - return false; - if (!this.enfe.equals(that.enfe)) - return false; - } - - return true; - } - - @Override - public int hashCode() { - return 0; - } - - @Override - public int compareTo(getStormReceiver_result other) { - if (!getClass().equals(other.getClass())) { - return getClass().getName().compareTo(other.getClass().getName()); - } - - int lastComparison = 0; - - lastComparison = Boolean.valueOf(isSetSuccess()).compareTo(other.isSetSuccess()); - if (lastComparison != 0) { - return lastComparison; - } - if (isSetSuccess()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.success, other.success); - if (lastComparison != 0) { - return lastComparison; - } - } - lastComparison = Boolean.valueOf(isSetNsme()).compareTo(other.isSetNsme()); - if (lastComparison != 0) { - return lastComparison; - } - if (isSetNsme()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.nsme, other.nsme); - if (lastComparison != 0) { - return lastComparison; - } - } - lastComparison = Boolean.valueOf(isSetEnfe()).compareTo(other.isSetEnfe()); - if (lastComparison != 0) { - return lastComparison; - } - if (isSetEnfe()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.enfe, other.enfe); - if (lastComparison != 0) { - return lastComparison; - } - } - return 0; - } - - public _Fields fieldForId(int fieldId) { - return _Fields.findByThriftId(fieldId); - } - - public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { - schemes.get(iprot.getScheme()).getScheme().read(iprot, this); - } - - public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { - schemes.get(oprot.getScheme()).getScheme().write(oprot, this); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder("getStormReceiver_result("); - boolean first = true; - - sb.append("success:"); - if (this.success == null) { - sb.append("null"); - } else { - sb.append(this.success); - } - first = false; - if (!first) sb.append(", "); - sb.append("nsme:"); - if (this.nsme == null) { - sb.append("null"); - } else { - sb.append(this.nsme); - } - first = false; - if (!first) sb.append(", "); - sb.append("enfe:"); - if (this.enfe == null) { - sb.append("null"); - } else { - sb.append(this.enfe); - } - first = false; - sb.append(")"); - return sb.toString(); - } - - public void validate() throws org.apache.thrift.TException { - // check for required fields - // check for sub-struct validity - } - - private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { - try { - write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); - } catch (org.apache.thrift.TException te) { - throw new java.io.IOException(te); - } - } - - private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { - try { - read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); - } catch (org.apache.thrift.TException te) { - throw new java.io.IOException(te); - } - } - - private static class getStormReceiver_resultStandardSchemeFactory implements SchemeFactory { - public getStormReceiver_resultStandardScheme getScheme() { - return new getStormReceiver_resultStandardScheme(); - } - } - - private static class getStormReceiver_resultStandardScheme extends StandardScheme { - - public void read(org.apache.thrift.protocol.TProtocol iprot, getStormReceiver_result struct) throws org.apache.thrift.TException { - org.apache.thrift.protocol.TField schemeField; - iprot.readStructBegin(); - while (true) - { - schemeField = iprot.readFieldBegin(); - if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { - break; - } - switch (schemeField.id) { - case 0: // SUCCESS - if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { - struct.success = iprot.readString(); - struct.setSuccessIsSet(true); - } else { - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - break; - case 1: // NSME - if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { - struct.nsme = new org.wso2.carbon.event.processor.common.storm.manager.service.exception.NotStormCoordinatorException(); - struct.nsme.read(iprot); - struct.setNsmeIsSet(true); - } else { - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - break; - case 2: // ENFE - if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { - struct.enfe = new org.wso2.carbon.event.processor.common.storm.manager.service.exception.EndpointNotFoundException(); - struct.enfe.read(iprot); - struct.setEnfeIsSet(true); - } else { - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - break; - default: - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - iprot.readFieldEnd(); - } - iprot.readStructEnd(); - - // check for required fields of primitive type, which can't be checked in the validate method - struct.validate(); - } - - public void write(org.apache.thrift.protocol.TProtocol oprot, getStormReceiver_result struct) throws org.apache.thrift.TException { - struct.validate(); - - oprot.writeStructBegin(STRUCT_DESC); - if (struct.success != null) { - oprot.writeFieldBegin(SUCCESS_FIELD_DESC); - oprot.writeString(struct.success); - oprot.writeFieldEnd(); - } - if (struct.nsme != null) { - oprot.writeFieldBegin(NSME_FIELD_DESC); - struct.nsme.write(oprot); - oprot.writeFieldEnd(); - } - if (struct.enfe != null) { - oprot.writeFieldBegin(ENFE_FIELD_DESC); - struct.enfe.write(oprot); - oprot.writeFieldEnd(); - } - oprot.writeFieldStop(); - oprot.writeStructEnd(); - } - - } - - private static class getStormReceiver_resultTupleSchemeFactory implements SchemeFactory { - public getStormReceiver_resultTupleScheme getScheme() { - return new getStormReceiver_resultTupleScheme(); - } - } - - private static class getStormReceiver_resultTupleScheme extends TupleScheme { - - @Override - public void write(org.apache.thrift.protocol.TProtocol prot, getStormReceiver_result struct) throws org.apache.thrift.TException { - TTupleProtocol oprot = (TTupleProtocol) prot; - BitSet optionals = new BitSet(); - if (struct.isSetSuccess()) { - optionals.set(0); - } - if (struct.isSetNsme()) { - optionals.set(1); - } - if (struct.isSetEnfe()) { - optionals.set(2); - } - oprot.writeBitSet(optionals, 3); - if (struct.isSetSuccess()) { - oprot.writeString(struct.success); - } - if (struct.isSetNsme()) { - struct.nsme.write(oprot); - } - if (struct.isSetEnfe()) { - struct.enfe.write(oprot); - } - } - - @Override - public void read(org.apache.thrift.protocol.TProtocol prot, getStormReceiver_result struct) throws org.apache.thrift.TException { - TTupleProtocol iprot = (TTupleProtocol) prot; - BitSet incoming = iprot.readBitSet(3); - if (incoming.get(0)) { - struct.success = iprot.readString(); - struct.setSuccessIsSet(true); - } - if (incoming.get(1)) { - struct.nsme = new org.wso2.carbon.event.processor.common.storm.manager.service.exception.NotStormCoordinatorException(); - struct.nsme.read(iprot); - struct.setNsmeIsSet(true); - } - if (incoming.get(2)) { - struct.enfe = new org.wso2.carbon.event.processor.common.storm.manager.service.exception.EndpointNotFoundException(); - struct.enfe.read(iprot); - struct.setEnfeIsSet(true); - } - } - } - - } - - public static class getCEPPublisher_args implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { - private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("getCEPPublisher_args"); - - private static final org.apache.thrift.protocol.TField TENANT_ID_FIELD_DESC = new org.apache.thrift.protocol.TField("tenantId", org.apache.thrift.protocol.TType.I32, (short)1); - private static final org.apache.thrift.protocol.TField EXECUTION_PLAN_NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("executionPlanName", org.apache.thrift.protocol.TType.STRING, (short)2); - private static final org.apache.thrift.protocol.TField STORM_PUBLISHER_HOST_NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("stormPublisherHostName", org.apache.thrift.protocol.TType.STRING, (short)3); - - private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); - static { - schemes.put(StandardScheme.class, new getCEPPublisher_argsStandardSchemeFactory()); - schemes.put(TupleScheme.class, new getCEPPublisher_argsTupleSchemeFactory()); - } - - public int tenantId; // required - public String executionPlanName; // required - public String stormPublisherHostName; // required - - /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ - public enum _Fields implements org.apache.thrift.TFieldIdEnum { - TENANT_ID((short)1, "tenantId"), - EXECUTION_PLAN_NAME((short)2, "executionPlanName"), - STORM_PUBLISHER_HOST_NAME((short)3, "stormPublisherHostName"); - - private static final Map byName = new HashMap(); - - static { - for (_Fields field : EnumSet.allOf(_Fields.class)) { - byName.put(field.getFieldName(), field); - } - } - - /** - * Find the _Fields constant that matches fieldId, or null if its not found. - */ - public static _Fields findByThriftId(int fieldId) { - switch(fieldId) { - case 1: // TENANT_ID - return TENANT_ID; - case 2: // EXECUTION_PLAN_NAME - return EXECUTION_PLAN_NAME; - case 3: // STORM_PUBLISHER_HOST_NAME - return STORM_PUBLISHER_HOST_NAME; - default: - return null; - } - } - - /** - * Find the _Fields constant that matches fieldId, throwing an exception - * if it is not found. - */ - public static _Fields findByThriftIdOrThrow(int fieldId) { - _Fields fields = findByThriftId(fieldId); - if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); - return fields; - } - - /** - * Find the _Fields constant that matches name, or null if its not found. - */ - public static _Fields findByName(String name) { - return byName.get(name); - } - - private final short _thriftId; - private final String _fieldName; - - _Fields(short thriftId, String fieldName) { - _thriftId = thriftId; - _fieldName = fieldName; - } - - public short getThriftFieldId() { - return _thriftId; - } - - public String getFieldName() { - return _fieldName; - } - } - - // isset id assignments - private static final int __TENANTID_ISSET_ID = 0; - private byte __isset_bitfield = 0; - public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; - static { - Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); - tmpMap.put(_Fields.TENANT_ID, new org.apache.thrift.meta_data.FieldMetaData("tenantId", org.apache.thrift.TFieldRequirementType.DEFAULT, - new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32))); - tmpMap.put(_Fields.EXECUTION_PLAN_NAME, new org.apache.thrift.meta_data.FieldMetaData("executionPlanName", org.apache.thrift.TFieldRequirementType.DEFAULT, - new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); - tmpMap.put(_Fields.STORM_PUBLISHER_HOST_NAME, new org.apache.thrift.meta_data.FieldMetaData("stormPublisherHostName", org.apache.thrift.TFieldRequirementType.DEFAULT, - new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); - metaDataMap = Collections.unmodifiableMap(tmpMap); - org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(getCEPPublisher_args.class, metaDataMap); - } - - public getCEPPublisher_args() { - } - - public getCEPPublisher_args( - int tenantId, - String executionPlanName, - String stormPublisherHostName) - { - this(); - this.tenantId = tenantId; - setTenantIdIsSet(true); - this.executionPlanName = executionPlanName; - this.stormPublisherHostName = stormPublisherHostName; - } - - /** - * Performs a deep copy on other. - */ - public getCEPPublisher_args(getCEPPublisher_args other) { - __isset_bitfield = other.__isset_bitfield; - this.tenantId = other.tenantId; - if (other.isSetExecutionPlanName()) { - this.executionPlanName = other.executionPlanName; - } - if (other.isSetStormPublisherHostName()) { - this.stormPublisherHostName = other.stormPublisherHostName; - } - } - - public getCEPPublisher_args deepCopy() { - return new getCEPPublisher_args(this); - } - - @Override - public void clear() { - setTenantIdIsSet(false); - this.tenantId = 0; - this.executionPlanName = null; - this.stormPublisherHostName = null; - } - - public int getTenantId() { - return this.tenantId; - } - - public getCEPPublisher_args setTenantId(int tenantId) { - this.tenantId = tenantId; - setTenantIdIsSet(true); - return this; - } - - public void unsetTenantId() { - __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __TENANTID_ISSET_ID); - } - - /** Returns true if field tenantId is set (has been assigned a value) and false otherwise */ - public boolean isSetTenantId() { - return EncodingUtils.testBit(__isset_bitfield, __TENANTID_ISSET_ID); - } - - public void setTenantIdIsSet(boolean value) { - __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __TENANTID_ISSET_ID, value); - } - - public String getExecutionPlanName() { - return this.executionPlanName; - } - - public getCEPPublisher_args setExecutionPlanName(String executionPlanName) { - this.executionPlanName = executionPlanName; - return this; - } - - public void unsetExecutionPlanName() { - this.executionPlanName = null; - } - - /** Returns true if field executionPlanName is set (has been assigned a value) and false otherwise */ - public boolean isSetExecutionPlanName() { - return this.executionPlanName != null; - } - - public void setExecutionPlanNameIsSet(boolean value) { - if (!value) { - this.executionPlanName = null; - } - } - - public String getStormPublisherHostName() { - return this.stormPublisherHostName; - } - - public getCEPPublisher_args setStormPublisherHostName(String stormPublisherHostName) { - this.stormPublisherHostName = stormPublisherHostName; - return this; - } - - public void unsetStormPublisherHostName() { - this.stormPublisherHostName = null; - } - - /** Returns true if field stormPublisherHostName is set (has been assigned a value) and false otherwise */ - public boolean isSetStormPublisherHostName() { - return this.stormPublisherHostName != null; - } - - public void setStormPublisherHostNameIsSet(boolean value) { - if (!value) { - this.stormPublisherHostName = null; - } - } - - public void setFieldValue(_Fields field, Object value) { - switch (field) { - case TENANT_ID: - if (value == null) { - unsetTenantId(); - } else { - setTenantId((Integer)value); - } - break; - - case EXECUTION_PLAN_NAME: - if (value == null) { - unsetExecutionPlanName(); - } else { - setExecutionPlanName((String)value); - } - break; - - case STORM_PUBLISHER_HOST_NAME: - if (value == null) { - unsetStormPublisherHostName(); - } else { - setStormPublisherHostName((String)value); - } - break; - - } - } - - public Object getFieldValue(_Fields field) { - switch (field) { - case TENANT_ID: - return Integer.valueOf(getTenantId()); - - case EXECUTION_PLAN_NAME: - return getExecutionPlanName(); - - case STORM_PUBLISHER_HOST_NAME: - return getStormPublisherHostName(); - - } - throw new IllegalStateException(); - } - - /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ - public boolean isSet(_Fields field) { - if (field == null) { - throw new IllegalArgumentException(); - } - - switch (field) { - case TENANT_ID: - return isSetTenantId(); - case EXECUTION_PLAN_NAME: - return isSetExecutionPlanName(); - case STORM_PUBLISHER_HOST_NAME: - return isSetStormPublisherHostName(); - } - throw new IllegalStateException(); - } - - @Override - public boolean equals(Object that) { - if (that == null) - return false; - if (that instanceof getCEPPublisher_args) - return this.equals((getCEPPublisher_args)that); - return false; - } - - public boolean equals(getCEPPublisher_args that) { - if (that == null) - return false; - - boolean this_present_tenantId = true; - boolean that_present_tenantId = true; - if (this_present_tenantId || that_present_tenantId) { - if (!(this_present_tenantId && that_present_tenantId)) - return false; - if (this.tenantId != that.tenantId) - return false; - } - - boolean this_present_executionPlanName = true && this.isSetExecutionPlanName(); - boolean that_present_executionPlanName = true && that.isSetExecutionPlanName(); - if (this_present_executionPlanName || that_present_executionPlanName) { - if (!(this_present_executionPlanName && that_present_executionPlanName)) - return false; - if (!this.executionPlanName.equals(that.executionPlanName)) - return false; - } - - boolean this_present_stormPublisherHostName = true && this.isSetStormPublisherHostName(); - boolean that_present_stormPublisherHostName = true && that.isSetStormPublisherHostName(); - if (this_present_stormPublisherHostName || that_present_stormPublisherHostName) { - if (!(this_present_stormPublisherHostName && that_present_stormPublisherHostName)) - return false; - if (!this.stormPublisherHostName.equals(that.stormPublisherHostName)) - return false; - } - - return true; - } - - @Override - public int hashCode() { - return 0; - } - - @Override - public int compareTo(getCEPPublisher_args other) { - if (!getClass().equals(other.getClass())) { - return getClass().getName().compareTo(other.getClass().getName()); - } - - int lastComparison = 0; - - lastComparison = Boolean.valueOf(isSetTenantId()).compareTo(other.isSetTenantId()); - if (lastComparison != 0) { - return lastComparison; - } - if (isSetTenantId()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.tenantId, other.tenantId); - if (lastComparison != 0) { - return lastComparison; - } - } - lastComparison = Boolean.valueOf(isSetExecutionPlanName()).compareTo(other.isSetExecutionPlanName()); - if (lastComparison != 0) { - return lastComparison; - } - if (isSetExecutionPlanName()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.executionPlanName, other.executionPlanName); - if (lastComparison != 0) { - return lastComparison; - } - } - lastComparison = Boolean.valueOf(isSetStormPublisherHostName()).compareTo(other.isSetStormPublisherHostName()); - if (lastComparison != 0) { - return lastComparison; - } - if (isSetStormPublisherHostName()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.stormPublisherHostName, other.stormPublisherHostName); - if (lastComparison != 0) { - return lastComparison; - } - } - return 0; - } - - public _Fields fieldForId(int fieldId) { - return _Fields.findByThriftId(fieldId); - } - - public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { - schemes.get(iprot.getScheme()).getScheme().read(iprot, this); - } - - public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { - schemes.get(oprot.getScheme()).getScheme().write(oprot, this); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder("getCEPPublisher_args("); - boolean first = true; - - sb.append("tenantId:"); - sb.append(this.tenantId); - first = false; - if (!first) sb.append(", "); - sb.append("executionPlanName:"); - if (this.executionPlanName == null) { - sb.append("null"); - } else { - sb.append(this.executionPlanName); - } - first = false; - if (!first) sb.append(", "); - sb.append("stormPublisherHostName:"); - if (this.stormPublisherHostName == null) { - sb.append("null"); - } else { - sb.append(this.stormPublisherHostName); - } - first = false; - sb.append(")"); - return sb.toString(); - } - - public void validate() throws org.apache.thrift.TException { - // check for required fields - // check for sub-struct validity - } - - private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { - try { - write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); - } catch (org.apache.thrift.TException te) { - throw new java.io.IOException(te); - } - } - - private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { - try { - // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor. - __isset_bitfield = 0; - read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); - } catch (org.apache.thrift.TException te) { - throw new java.io.IOException(te); - } - } - - private static class getCEPPublisher_argsStandardSchemeFactory implements SchemeFactory { - public getCEPPublisher_argsStandardScheme getScheme() { - return new getCEPPublisher_argsStandardScheme(); - } - } - - private static class getCEPPublisher_argsStandardScheme extends StandardScheme { - - public void read(org.apache.thrift.protocol.TProtocol iprot, getCEPPublisher_args struct) throws org.apache.thrift.TException { - org.apache.thrift.protocol.TField schemeField; - iprot.readStructBegin(); - while (true) - { - schemeField = iprot.readFieldBegin(); - if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { - break; - } - switch (schemeField.id) { - case 1: // TENANT_ID - if (schemeField.type == org.apache.thrift.protocol.TType.I32) { - struct.tenantId = iprot.readI32(); - struct.setTenantIdIsSet(true); - } else { - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - break; - case 2: // EXECUTION_PLAN_NAME - if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { - struct.executionPlanName = iprot.readString(); - struct.setExecutionPlanNameIsSet(true); - } else { - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - break; - case 3: // STORM_PUBLISHER_HOST_NAME - if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { - struct.stormPublisherHostName = iprot.readString(); - struct.setStormPublisherHostNameIsSet(true); - } else { - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - break; - default: - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - iprot.readFieldEnd(); - } - iprot.readStructEnd(); - - // check for required fields of primitive type, which can't be checked in the validate method - struct.validate(); - } - - public void write(org.apache.thrift.protocol.TProtocol oprot, getCEPPublisher_args struct) throws org.apache.thrift.TException { - struct.validate(); - - oprot.writeStructBegin(STRUCT_DESC); - oprot.writeFieldBegin(TENANT_ID_FIELD_DESC); - oprot.writeI32(struct.tenantId); - oprot.writeFieldEnd(); - if (struct.executionPlanName != null) { - oprot.writeFieldBegin(EXECUTION_PLAN_NAME_FIELD_DESC); - oprot.writeString(struct.executionPlanName); - oprot.writeFieldEnd(); - } - if (struct.stormPublisherHostName != null) { - oprot.writeFieldBegin(STORM_PUBLISHER_HOST_NAME_FIELD_DESC); - oprot.writeString(struct.stormPublisherHostName); - oprot.writeFieldEnd(); - } - oprot.writeFieldStop(); - oprot.writeStructEnd(); - } - - } - - private static class getCEPPublisher_argsTupleSchemeFactory implements SchemeFactory { - public getCEPPublisher_argsTupleScheme getScheme() { - return new getCEPPublisher_argsTupleScheme(); - } - } - - private static class getCEPPublisher_argsTupleScheme extends TupleScheme { - - @Override - public void write(org.apache.thrift.protocol.TProtocol prot, getCEPPublisher_args struct) throws org.apache.thrift.TException { - TTupleProtocol oprot = (TTupleProtocol) prot; - BitSet optionals = new BitSet(); - if (struct.isSetTenantId()) { - optionals.set(0); - } - if (struct.isSetExecutionPlanName()) { - optionals.set(1); - } - if (struct.isSetStormPublisherHostName()) { - optionals.set(2); - } - oprot.writeBitSet(optionals, 3); - if (struct.isSetTenantId()) { - oprot.writeI32(struct.tenantId); - } - if (struct.isSetExecutionPlanName()) { - oprot.writeString(struct.executionPlanName); - } - if (struct.isSetStormPublisherHostName()) { - oprot.writeString(struct.stormPublisherHostName); - } - } - - @Override - public void read(org.apache.thrift.protocol.TProtocol prot, getCEPPublisher_args struct) throws org.apache.thrift.TException { - TTupleProtocol iprot = (TTupleProtocol) prot; - BitSet incoming = iprot.readBitSet(3); - if (incoming.get(0)) { - struct.tenantId = iprot.readI32(); - struct.setTenantIdIsSet(true); - } - if (incoming.get(1)) { - struct.executionPlanName = iprot.readString(); - struct.setExecutionPlanNameIsSet(true); - } - if (incoming.get(2)) { - struct.stormPublisherHostName = iprot.readString(); - struct.setStormPublisherHostNameIsSet(true); - } - } - } - - } - - public static class getCEPPublisher_result implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { - private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("getCEPPublisher_result"); - - private static final org.apache.thrift.protocol.TField SUCCESS_FIELD_DESC = new org.apache.thrift.protocol.TField("success", org.apache.thrift.protocol.TType.STRING, (short)0); - private static final org.apache.thrift.protocol.TField NSME_FIELD_DESC = new org.apache.thrift.protocol.TField("nsme", org.apache.thrift.protocol.TType.STRUCT, (short)1); - private static final org.apache.thrift.protocol.TField ENFE_FIELD_DESC = new org.apache.thrift.protocol.TField("enfe", org.apache.thrift.protocol.TType.STRUCT, (short)2); - - private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); - static { - schemes.put(StandardScheme.class, new getCEPPublisher_resultStandardSchemeFactory()); - schemes.put(TupleScheme.class, new getCEPPublisher_resultTupleSchemeFactory()); - } - - public String success; // required - public org.wso2.carbon.event.processor.common.storm.manager.service.exception.NotStormCoordinatorException nsme; // required - public org.wso2.carbon.event.processor.common.storm.manager.service.exception.EndpointNotFoundException enfe; // required - - /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ - public enum _Fields implements org.apache.thrift.TFieldIdEnum { - SUCCESS((short)0, "success"), - NSME((short)1, "nsme"), - ENFE((short)2, "enfe"); - - private static final Map byName = new HashMap(); - - static { - for (_Fields field : EnumSet.allOf(_Fields.class)) { - byName.put(field.getFieldName(), field); - } - } - - /** - * Find the _Fields constant that matches fieldId, or null if its not found. - */ - public static _Fields findByThriftId(int fieldId) { - switch(fieldId) { - case 0: // SUCCESS - return SUCCESS; - case 1: // NSME - return NSME; - case 2: // ENFE - return ENFE; - default: - return null; - } - } - - /** - * Find the _Fields constant that matches fieldId, throwing an exception - * if it is not found. - */ - public static _Fields findByThriftIdOrThrow(int fieldId) { - _Fields fields = findByThriftId(fieldId); - if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); - return fields; - } - - /** - * Find the _Fields constant that matches name, or null if its not found. - */ - public static _Fields findByName(String name) { - return byName.get(name); - } - - private final short _thriftId; - private final String _fieldName; - - _Fields(short thriftId, String fieldName) { - _thriftId = thriftId; - _fieldName = fieldName; - } - - public short getThriftFieldId() { - return _thriftId; - } - - public String getFieldName() { - return _fieldName; - } - } - - // isset id assignments - public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; - static { - Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); - tmpMap.put(_Fields.SUCCESS, new org.apache.thrift.meta_data.FieldMetaData("success", org.apache.thrift.TFieldRequirementType.DEFAULT, - new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); - tmpMap.put(_Fields.NSME, new org.apache.thrift.meta_data.FieldMetaData("nsme", org.apache.thrift.TFieldRequirementType.DEFAULT, - new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT))); - tmpMap.put(_Fields.ENFE, new org.apache.thrift.meta_data.FieldMetaData("enfe", org.apache.thrift.TFieldRequirementType.DEFAULT, - new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT))); - metaDataMap = Collections.unmodifiableMap(tmpMap); - org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(getCEPPublisher_result.class, metaDataMap); - } - - public getCEPPublisher_result() { - } - - public getCEPPublisher_result( - String success, - org.wso2.carbon.event.processor.common.storm.manager.service.exception.NotStormCoordinatorException nsme, - org.wso2.carbon.event.processor.common.storm.manager.service.exception.EndpointNotFoundException enfe) - { - this(); - this.success = success; - this.nsme = nsme; - this.enfe = enfe; - } - - /** - * Performs a deep copy on other. - */ - public getCEPPublisher_result(getCEPPublisher_result other) { - if (other.isSetSuccess()) { - this.success = other.success; - } - if (other.isSetNsme()) { - this.nsme = new org.wso2.carbon.event.processor.common.storm.manager.service.exception.NotStormCoordinatorException(other.nsme); - } - if (other.isSetEnfe()) { - this.enfe = new org.wso2.carbon.event.processor.common.storm.manager.service.exception.EndpointNotFoundException(other.enfe); - } - } - - public getCEPPublisher_result deepCopy() { - return new getCEPPublisher_result(this); - } - - @Override - public void clear() { - this.success = null; - this.nsme = null; - this.enfe = null; - } - - public String getSuccess() { - return this.success; - } - - public getCEPPublisher_result setSuccess(String success) { - this.success = success; - return this; - } - - public void unsetSuccess() { - this.success = null; - } - - /** Returns true if field success is set (has been assigned a value) and false otherwise */ - public boolean isSetSuccess() { - return this.success != null; - } - - public void setSuccessIsSet(boolean value) { - if (!value) { - this.success = null; - } - } - - public org.wso2.carbon.event.processor.common.storm.manager.service.exception.NotStormCoordinatorException getNsme() { - return this.nsme; - } - - public getCEPPublisher_result setNsme(org.wso2.carbon.event.processor.common.storm.manager.service.exception.NotStormCoordinatorException nsme) { - this.nsme = nsme; - return this; - } - - public void unsetNsme() { - this.nsme = null; - } - - /** Returns true if field nsme is set (has been assigned a value) and false otherwise */ - public boolean isSetNsme() { - return this.nsme != null; - } - - public void setNsmeIsSet(boolean value) { - if (!value) { - this.nsme = null; - } - } - - public org.wso2.carbon.event.processor.common.storm.manager.service.exception.EndpointNotFoundException getEnfe() { - return this.enfe; - } - - public getCEPPublisher_result setEnfe(org.wso2.carbon.event.processor.common.storm.manager.service.exception.EndpointNotFoundException enfe) { - this.enfe = enfe; - return this; - } - - public void unsetEnfe() { - this.enfe = null; - } - - /** Returns true if field enfe is set (has been assigned a value) and false otherwise */ - public boolean isSetEnfe() { - return this.enfe != null; - } - - public void setEnfeIsSet(boolean value) { - if (!value) { - this.enfe = null; - } - } - - public void setFieldValue(_Fields field, Object value) { - switch (field) { - case SUCCESS: - if (value == null) { - unsetSuccess(); - } else { - setSuccess((String)value); - } - break; - - case NSME: - if (value == null) { - unsetNsme(); - } else { - setNsme((org.wso2.carbon.event.processor.common.storm.manager.service.exception.NotStormCoordinatorException)value); - } - break; - - case ENFE: - if (value == null) { - unsetEnfe(); - } else { - setEnfe((org.wso2.carbon.event.processor.common.storm.manager.service.exception.EndpointNotFoundException)value); - } - break; - - } - } - - public Object getFieldValue(_Fields field) { - switch (field) { - case SUCCESS: - return getSuccess(); - - case NSME: - return getNsme(); - - case ENFE: - return getEnfe(); - - } - throw new IllegalStateException(); - } - - /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ - public boolean isSet(_Fields field) { - if (field == null) { - throw new IllegalArgumentException(); - } - - switch (field) { - case SUCCESS: - return isSetSuccess(); - case NSME: - return isSetNsme(); - case ENFE: - return isSetEnfe(); - } - throw new IllegalStateException(); - } - - @Override - public boolean equals(Object that) { - if (that == null) - return false; - if (that instanceof getCEPPublisher_result) - return this.equals((getCEPPublisher_result)that); - return false; - } - - public boolean equals(getCEPPublisher_result that) { - if (that == null) - return false; - - boolean this_present_success = true && this.isSetSuccess(); - boolean that_present_success = true && that.isSetSuccess(); - if (this_present_success || that_present_success) { - if (!(this_present_success && that_present_success)) - return false; - if (!this.success.equals(that.success)) - return false; - } - - boolean this_present_nsme = true && this.isSetNsme(); - boolean that_present_nsme = true && that.isSetNsme(); - if (this_present_nsme || that_present_nsme) { - if (!(this_present_nsme && that_present_nsme)) - return false; - if (!this.nsme.equals(that.nsme)) - return false; - } - - boolean this_present_enfe = true && this.isSetEnfe(); - boolean that_present_enfe = true && that.isSetEnfe(); - if (this_present_enfe || that_present_enfe) { - if (!(this_present_enfe && that_present_enfe)) - return false; - if (!this.enfe.equals(that.enfe)) - return false; - } - - return true; - } - - @Override - public int hashCode() { - return 0; - } - - @Override - public int compareTo(getCEPPublisher_result other) { - if (!getClass().equals(other.getClass())) { - return getClass().getName().compareTo(other.getClass().getName()); - } - - int lastComparison = 0; - - lastComparison = Boolean.valueOf(isSetSuccess()).compareTo(other.isSetSuccess()); - if (lastComparison != 0) { - return lastComparison; - } - if (isSetSuccess()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.success, other.success); - if (lastComparison != 0) { - return lastComparison; - } - } - lastComparison = Boolean.valueOf(isSetNsme()).compareTo(other.isSetNsme()); - if (lastComparison != 0) { - return lastComparison; - } - if (isSetNsme()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.nsme, other.nsme); - if (lastComparison != 0) { - return lastComparison; - } - } - lastComparison = Boolean.valueOf(isSetEnfe()).compareTo(other.isSetEnfe()); - if (lastComparison != 0) { - return lastComparison; - } - if (isSetEnfe()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.enfe, other.enfe); - if (lastComparison != 0) { - return lastComparison; - } - } - return 0; - } - - public _Fields fieldForId(int fieldId) { - return _Fields.findByThriftId(fieldId); - } - - public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { - schemes.get(iprot.getScheme()).getScheme().read(iprot, this); - } - - public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { - schemes.get(oprot.getScheme()).getScheme().write(oprot, this); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder("getCEPPublisher_result("); - boolean first = true; - - sb.append("success:"); - if (this.success == null) { - sb.append("null"); - } else { - sb.append(this.success); - } - first = false; - if (!first) sb.append(", "); - sb.append("nsme:"); - if (this.nsme == null) { - sb.append("null"); - } else { - sb.append(this.nsme); - } - first = false; - if (!first) sb.append(", "); - sb.append("enfe:"); - if (this.enfe == null) { - sb.append("null"); - } else { - sb.append(this.enfe); - } - first = false; - sb.append(")"); - return sb.toString(); - } - - public void validate() throws org.apache.thrift.TException { - // check for required fields - // check for sub-struct validity - } - - private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { - try { - write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); - } catch (org.apache.thrift.TException te) { - throw new java.io.IOException(te); - } - } - - private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { - try { - read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); - } catch (org.apache.thrift.TException te) { - throw new java.io.IOException(te); - } - } - - private static class getCEPPublisher_resultStandardSchemeFactory implements SchemeFactory { - public getCEPPublisher_resultStandardScheme getScheme() { - return new getCEPPublisher_resultStandardScheme(); - } - } - - private static class getCEPPublisher_resultStandardScheme extends StandardScheme { - - public void read(org.apache.thrift.protocol.TProtocol iprot, getCEPPublisher_result struct) throws org.apache.thrift.TException { - org.apache.thrift.protocol.TField schemeField; - iprot.readStructBegin(); - while (true) - { - schemeField = iprot.readFieldBegin(); - if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { - break; - } - switch (schemeField.id) { - case 0: // SUCCESS - if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { - struct.success = iprot.readString(); - struct.setSuccessIsSet(true); - } else { - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - break; - case 1: // NSME - if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { - struct.nsme = new org.wso2.carbon.event.processor.common.storm.manager.service.exception.NotStormCoordinatorException(); - struct.nsme.read(iprot); - struct.setNsmeIsSet(true); - } else { - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - break; - case 2: // ENFE - if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { - struct.enfe = new org.wso2.carbon.event.processor.common.storm.manager.service.exception.EndpointNotFoundException(); - struct.enfe.read(iprot); - struct.setEnfeIsSet(true); - } else { - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - break; - default: - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - iprot.readFieldEnd(); - } - iprot.readStructEnd(); - - // check for required fields of primitive type, which can't be checked in the validate method - struct.validate(); - } - - public void write(org.apache.thrift.protocol.TProtocol oprot, getCEPPublisher_result struct) throws org.apache.thrift.TException { - struct.validate(); - - oprot.writeStructBegin(STRUCT_DESC); - if (struct.success != null) { - oprot.writeFieldBegin(SUCCESS_FIELD_DESC); - oprot.writeString(struct.success); - oprot.writeFieldEnd(); - } - if (struct.nsme != null) { - oprot.writeFieldBegin(NSME_FIELD_DESC); - struct.nsme.write(oprot); - oprot.writeFieldEnd(); - } - if (struct.enfe != null) { - oprot.writeFieldBegin(ENFE_FIELD_DESC); - struct.enfe.write(oprot); - oprot.writeFieldEnd(); - } - oprot.writeFieldStop(); - oprot.writeStructEnd(); - } - - } - - private static class getCEPPublisher_resultTupleSchemeFactory implements SchemeFactory { - public getCEPPublisher_resultTupleScheme getScheme() { - return new getCEPPublisher_resultTupleScheme(); - } - } - - private static class getCEPPublisher_resultTupleScheme extends TupleScheme { - - @Override - public void write(org.apache.thrift.protocol.TProtocol prot, getCEPPublisher_result struct) throws org.apache.thrift.TException { - TTupleProtocol oprot = (TTupleProtocol) prot; - BitSet optionals = new BitSet(); - if (struct.isSetSuccess()) { - optionals.set(0); - } - if (struct.isSetNsme()) { - optionals.set(1); - } - if (struct.isSetEnfe()) { - optionals.set(2); - } - oprot.writeBitSet(optionals, 3); - if (struct.isSetSuccess()) { - oprot.writeString(struct.success); - } - if (struct.isSetNsme()) { - struct.nsme.write(oprot); - } - if (struct.isSetEnfe()) { - struct.enfe.write(oprot); - } - } - - @Override - public void read(org.apache.thrift.protocol.TProtocol prot, getCEPPublisher_result struct) throws org.apache.thrift.TException { - TTupleProtocol iprot = (TTupleProtocol) prot; - BitSet incoming = iprot.readBitSet(3); - if (incoming.get(0)) { - struct.success = iprot.readString(); - struct.setSuccessIsSet(true); - } - if (incoming.get(1)) { - struct.nsme = new org.wso2.carbon.event.processor.common.storm.manager.service.exception.NotStormCoordinatorException(); - struct.nsme.read(iprot); - struct.setNsmeIsSet(true); - } - if (incoming.get(2)) { - struct.enfe = new org.wso2.carbon.event.processor.common.storm.manager.service.exception.EndpointNotFoundException(); - struct.enfe.read(iprot); - struct.setEnfeIsSet(true); - } - } - } - - } - -} diff --git a/components/event-processor/org.wso2.carbon.event.processor.common/src/main/java/org/wso2/carbon/event/processor/common/storm/manager/service/exception/EndpointNotFoundException.java b/components/event-processor/org.wso2.carbon.event.processor.common/src/main/java/org/wso2/carbon/event/processor/common/storm/manager/service/exception/EndpointNotFoundException.java deleted file mode 100644 index 2cebadd5a..000000000 --- a/components/event-processor/org.wso2.carbon.event.processor.common/src/main/java/org/wso2/carbon/event/processor/common/storm/manager/service/exception/EndpointNotFoundException.java +++ /dev/null @@ -1,381 +0,0 @@ -/** - * Autogenerated by Thrift Compiler (0.9.1) - * - * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING - * @generated - */ -package org.wso2.carbon.event.processor.common.storm.manager.service.exception; - -import org.apache.thrift.scheme.IScheme; -import org.apache.thrift.scheme.SchemeFactory; -import org.apache.thrift.scheme.StandardScheme; - -import org.apache.thrift.scheme.TupleScheme; -import org.apache.thrift.protocol.TTupleProtocol; -import org.apache.thrift.protocol.TProtocolException; -import org.apache.thrift.EncodingUtils; -import org.apache.thrift.TException; -import org.apache.thrift.async.AsyncMethodCallback; -import org.apache.thrift.server.AbstractNonblockingServer.*; -import java.util.List; -import java.util.ArrayList; -import java.util.Map; -import java.util.HashMap; -import java.util.EnumMap; -import java.util.Set; -import java.util.HashSet; -import java.util.EnumSet; -import java.util.Collections; -import java.util.BitSet; -import java.nio.ByteBuffer; -import java.util.Arrays; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class EndpointNotFoundException extends TException implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { - private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("EndpointNotFoundException"); - - private static final org.apache.thrift.protocol.TField MESSAGE_FIELD_DESC = new org.apache.thrift.protocol.TField("message", org.apache.thrift.protocol.TType.STRING, (short)1); - - private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); - static { - schemes.put(StandardScheme.class, new EndpointNotFoundExceptionStandardSchemeFactory()); - schemes.put(TupleScheme.class, new EndpointNotFoundExceptionTupleSchemeFactory()); - } - - public String message; // required - - /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ - public enum _Fields implements org.apache.thrift.TFieldIdEnum { - MESSAGE((short)1, "message"); - - private static final Map byName = new HashMap(); - - static { - for (_Fields field : EnumSet.allOf(_Fields.class)) { - byName.put(field.getFieldName(), field); - } - } - - /** - * Find the _Fields constant that matches fieldId, or null if its not found. - */ - public static _Fields findByThriftId(int fieldId) { - switch(fieldId) { - case 1: // MESSAGE - return MESSAGE; - default: - return null; - } - } - - /** - * Find the _Fields constant that matches fieldId, throwing an exception - * if it is not found. - */ - public static _Fields findByThriftIdOrThrow(int fieldId) { - _Fields fields = findByThriftId(fieldId); - if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); - return fields; - } - - /** - * Find the _Fields constant that matches name, or null if its not found. - */ - public static _Fields findByName(String name) { - return byName.get(name); - } - - private final short _thriftId; - private final String _fieldName; - - _Fields(short thriftId, String fieldName) { - _thriftId = thriftId; - _fieldName = fieldName; - } - - public short getThriftFieldId() { - return _thriftId; - } - - public String getFieldName() { - return _fieldName; - } - } - - // isset id assignments - public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; - static { - Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); - tmpMap.put(_Fields.MESSAGE, new org.apache.thrift.meta_data.FieldMetaData("message", org.apache.thrift.TFieldRequirementType.REQUIRED, - new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); - metaDataMap = Collections.unmodifiableMap(tmpMap); - org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(EndpointNotFoundException.class, metaDataMap); - } - - public EndpointNotFoundException() { - } - - public EndpointNotFoundException( - String message) - { - this(); - this.message = message; - } - - /** - * Performs a deep copy on other. - */ - public EndpointNotFoundException(EndpointNotFoundException other) { - if (other.isSetMessage()) { - this.message = other.message; - } - } - - public EndpointNotFoundException deepCopy() { - return new EndpointNotFoundException(this); - } - - @Override - public void clear() { - this.message = null; - } - - public String getMessage() { - return this.message; - } - - public EndpointNotFoundException setMessage(String message) { - this.message = message; - return this; - } - - public void unsetMessage() { - this.message = null; - } - - /** Returns true if field message is set (has been assigned a value) and false otherwise */ - public boolean isSetMessage() { - return this.message != null; - } - - public void setMessageIsSet(boolean value) { - if (!value) { - this.message = null; - } - } - - public void setFieldValue(_Fields field, Object value) { - switch (field) { - case MESSAGE: - if (value == null) { - unsetMessage(); - } else { - setMessage((String)value); - } - break; - - } - } - - public Object getFieldValue(_Fields field) { - switch (field) { - case MESSAGE: - return getMessage(); - - } - throw new IllegalStateException(); - } - - /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ - public boolean isSet(_Fields field) { - if (field == null) { - throw new IllegalArgumentException(); - } - - switch (field) { - case MESSAGE: - return isSetMessage(); - } - throw new IllegalStateException(); - } - - @Override - public boolean equals(Object that) { - if (that == null) - return false; - if (that instanceof EndpointNotFoundException) - return this.equals((EndpointNotFoundException)that); - return false; - } - - public boolean equals(EndpointNotFoundException that) { - if (that == null) - return false; - - boolean this_present_message = true && this.isSetMessage(); - boolean that_present_message = true && that.isSetMessage(); - if (this_present_message || that_present_message) { - if (!(this_present_message && that_present_message)) - return false; - if (!this.message.equals(that.message)) - return false; - } - - return true; - } - - @Override - public int hashCode() { - return 0; - } - - @Override - public int compareTo(EndpointNotFoundException other) { - if (!getClass().equals(other.getClass())) { - return getClass().getName().compareTo(other.getClass().getName()); - } - - int lastComparison = 0; - - lastComparison = Boolean.valueOf(isSetMessage()).compareTo(other.isSetMessage()); - if (lastComparison != 0) { - return lastComparison; - } - if (isSetMessage()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.message, other.message); - if (lastComparison != 0) { - return lastComparison; - } - } - return 0; - } - - public _Fields fieldForId(int fieldId) { - return _Fields.findByThriftId(fieldId); - } - - public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { - schemes.get(iprot.getScheme()).getScheme().read(iprot, this); - } - - public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { - schemes.get(oprot.getScheme()).getScheme().write(oprot, this); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder("EndpointNotFoundException("); - boolean first = true; - - sb.append("message:"); - if (this.message == null) { - sb.append("null"); - } else { - sb.append(this.message); - } - first = false; - sb.append(")"); - return sb.toString(); - } - - public void validate() throws org.apache.thrift.TException { - // check for required fields - if (message == null) { - throw new org.apache.thrift.protocol.TProtocolException("Required field 'message' was not present! Struct: " + toString()); - } - // check for sub-struct validity - } - - private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { - try { - write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); - } catch (org.apache.thrift.TException te) { - throw new java.io.IOException(te); - } - } - - private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { - try { - read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); - } catch (org.apache.thrift.TException te) { - throw new java.io.IOException(te); - } - } - - private static class EndpointNotFoundExceptionStandardSchemeFactory implements SchemeFactory { - public EndpointNotFoundExceptionStandardScheme getScheme() { - return new EndpointNotFoundExceptionStandardScheme(); - } - } - - private static class EndpointNotFoundExceptionStandardScheme extends StandardScheme { - - public void read(org.apache.thrift.protocol.TProtocol iprot, EndpointNotFoundException struct) throws org.apache.thrift.TException { - org.apache.thrift.protocol.TField schemeField; - iprot.readStructBegin(); - while (true) - { - schemeField = iprot.readFieldBegin(); - if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { - break; - } - switch (schemeField.id) { - case 1: // MESSAGE - if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { - struct.message = iprot.readString(); - struct.setMessageIsSet(true); - } else { - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - break; - default: - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - iprot.readFieldEnd(); - } - iprot.readStructEnd(); - - // check for required fields of primitive type, which can't be checked in the validate method - struct.validate(); - } - - public void write(org.apache.thrift.protocol.TProtocol oprot, EndpointNotFoundException struct) throws org.apache.thrift.TException { - struct.validate(); - - oprot.writeStructBegin(STRUCT_DESC); - if (struct.message != null) { - oprot.writeFieldBegin(MESSAGE_FIELD_DESC); - oprot.writeString(struct.message); - oprot.writeFieldEnd(); - } - oprot.writeFieldStop(); - oprot.writeStructEnd(); - } - - } - - private static class EndpointNotFoundExceptionTupleSchemeFactory implements SchemeFactory { - public EndpointNotFoundExceptionTupleScheme getScheme() { - return new EndpointNotFoundExceptionTupleScheme(); - } - } - - private static class EndpointNotFoundExceptionTupleScheme extends TupleScheme { - - @Override - public void write(org.apache.thrift.protocol.TProtocol prot, EndpointNotFoundException struct) throws org.apache.thrift.TException { - TTupleProtocol oprot = (TTupleProtocol) prot; - oprot.writeString(struct.message); - } - - @Override - public void read(org.apache.thrift.protocol.TProtocol prot, EndpointNotFoundException struct) throws org.apache.thrift.TException { - TTupleProtocol iprot = (TTupleProtocol) prot; - struct.message = iprot.readString(); - struct.setMessageIsSet(true); - } - } - -} - diff --git a/components/event-processor/org.wso2.carbon.event.processor.common/src/main/java/org/wso2/carbon/event/processor/common/storm/manager/service/exception/NotStormCoordinatorException.java b/components/event-processor/org.wso2.carbon.event.processor.common/src/main/java/org/wso2/carbon/event/processor/common/storm/manager/service/exception/NotStormCoordinatorException.java deleted file mode 100644 index 17335c961..000000000 --- a/components/event-processor/org.wso2.carbon.event.processor.common/src/main/java/org/wso2/carbon/event/processor/common/storm/manager/service/exception/NotStormCoordinatorException.java +++ /dev/null @@ -1,381 +0,0 @@ -/** - * Autogenerated by Thrift Compiler (0.9.1) - * - * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING - * @generated - */ -package org.wso2.carbon.event.processor.common.storm.manager.service.exception; - -import org.apache.thrift.scheme.IScheme; -import org.apache.thrift.scheme.SchemeFactory; -import org.apache.thrift.scheme.StandardScheme; - -import org.apache.thrift.scheme.TupleScheme; -import org.apache.thrift.protocol.TTupleProtocol; -import org.apache.thrift.protocol.TProtocolException; -import org.apache.thrift.EncodingUtils; -import org.apache.thrift.TException; -import org.apache.thrift.async.AsyncMethodCallback; -import org.apache.thrift.server.AbstractNonblockingServer.*; -import java.util.List; -import java.util.ArrayList; -import java.util.Map; -import java.util.HashMap; -import java.util.EnumMap; -import java.util.Set; -import java.util.HashSet; -import java.util.EnumSet; -import java.util.Collections; -import java.util.BitSet; -import java.nio.ByteBuffer; -import java.util.Arrays; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class NotStormCoordinatorException extends TException implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { - private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("NotStormCoordinatorException"); - - private static final org.apache.thrift.protocol.TField MESSAGE_FIELD_DESC = new org.apache.thrift.protocol.TField("message", org.apache.thrift.protocol.TType.STRING, (short)1); - - private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); - static { - schemes.put(StandardScheme.class, new NotStormCoordinatorExceptionStandardSchemeFactory()); - schemes.put(TupleScheme.class, new NotStormCoordinatorExceptionTupleSchemeFactory()); - } - - public String message; // required - - /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ - public enum _Fields implements org.apache.thrift.TFieldIdEnum { - MESSAGE((short)1, "message"); - - private static final Map byName = new HashMap(); - - static { - for (_Fields field : EnumSet.allOf(_Fields.class)) { - byName.put(field.getFieldName(), field); - } - } - - /** - * Find the _Fields constant that matches fieldId, or null if its not found. - */ - public static _Fields findByThriftId(int fieldId) { - switch(fieldId) { - case 1: // MESSAGE - return MESSAGE; - default: - return null; - } - } - - /** - * Find the _Fields constant that matches fieldId, throwing an exception - * if it is not found. - */ - public static _Fields findByThriftIdOrThrow(int fieldId) { - _Fields fields = findByThriftId(fieldId); - if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); - return fields; - } - - /** - * Find the _Fields constant that matches name, or null if its not found. - */ - public static _Fields findByName(String name) { - return byName.get(name); - } - - private final short _thriftId; - private final String _fieldName; - - _Fields(short thriftId, String fieldName) { - _thriftId = thriftId; - _fieldName = fieldName; - } - - public short getThriftFieldId() { - return _thriftId; - } - - public String getFieldName() { - return _fieldName; - } - } - - // isset id assignments - public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; - static { - Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); - tmpMap.put(_Fields.MESSAGE, new org.apache.thrift.meta_data.FieldMetaData("message", org.apache.thrift.TFieldRequirementType.REQUIRED, - new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); - metaDataMap = Collections.unmodifiableMap(tmpMap); - org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(NotStormCoordinatorException.class, metaDataMap); - } - - public NotStormCoordinatorException() { - } - - public NotStormCoordinatorException( - String message) - { - this(); - this.message = message; - } - - /** - * Performs a deep copy on other. - */ - public NotStormCoordinatorException(NotStormCoordinatorException other) { - if (other.isSetMessage()) { - this.message = other.message; - } - } - - public NotStormCoordinatorException deepCopy() { - return new NotStormCoordinatorException(this); - } - - @Override - public void clear() { - this.message = null; - } - - public String getMessage() { - return this.message; - } - - public NotStormCoordinatorException setMessage(String message) { - this.message = message; - return this; - } - - public void unsetMessage() { - this.message = null; - } - - /** Returns true if field message is set (has been assigned a value) and false otherwise */ - public boolean isSetMessage() { - return this.message != null; - } - - public void setMessageIsSet(boolean value) { - if (!value) { - this.message = null; - } - } - - public void setFieldValue(_Fields field, Object value) { - switch (field) { - case MESSAGE: - if (value == null) { - unsetMessage(); - } else { - setMessage((String)value); - } - break; - - } - } - - public Object getFieldValue(_Fields field) { - switch (field) { - case MESSAGE: - return getMessage(); - - } - throw new IllegalStateException(); - } - - /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ - public boolean isSet(_Fields field) { - if (field == null) { - throw new IllegalArgumentException(); - } - - switch (field) { - case MESSAGE: - return isSetMessage(); - } - throw new IllegalStateException(); - } - - @Override - public boolean equals(Object that) { - if (that == null) - return false; - if (that instanceof NotStormCoordinatorException) - return this.equals((NotStormCoordinatorException)that); - return false; - } - - public boolean equals(NotStormCoordinatorException that) { - if (that == null) - return false; - - boolean this_present_message = true && this.isSetMessage(); - boolean that_present_message = true && that.isSetMessage(); - if (this_present_message || that_present_message) { - if (!(this_present_message && that_present_message)) - return false; - if (!this.message.equals(that.message)) - return false; - } - - return true; - } - - @Override - public int hashCode() { - return 0; - } - - @Override - public int compareTo(NotStormCoordinatorException other) { - if (!getClass().equals(other.getClass())) { - return getClass().getName().compareTo(other.getClass().getName()); - } - - int lastComparison = 0; - - lastComparison = Boolean.valueOf(isSetMessage()).compareTo(other.isSetMessage()); - if (lastComparison != 0) { - return lastComparison; - } - if (isSetMessage()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.message, other.message); - if (lastComparison != 0) { - return lastComparison; - } - } - return 0; - } - - public _Fields fieldForId(int fieldId) { - return _Fields.findByThriftId(fieldId); - } - - public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { - schemes.get(iprot.getScheme()).getScheme().read(iprot, this); - } - - public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { - schemes.get(oprot.getScheme()).getScheme().write(oprot, this); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder("NotStormCoordinatorException("); - boolean first = true; - - sb.append("message:"); - if (this.message == null) { - sb.append("null"); - } else { - sb.append(this.message); - } - first = false; - sb.append(")"); - return sb.toString(); - } - - public void validate() throws org.apache.thrift.TException { - // check for required fields - if (message == null) { - throw new org.apache.thrift.protocol.TProtocolException("Required field 'message' was not present! Struct: " + toString()); - } - // check for sub-struct validity - } - - private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { - try { - write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); - } catch (org.apache.thrift.TException te) { - throw new java.io.IOException(te); - } - } - - private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { - try { - read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); - } catch (org.apache.thrift.TException te) { - throw new java.io.IOException(te); - } - } - - private static class NotStormCoordinatorExceptionStandardSchemeFactory implements SchemeFactory { - public NotStormCoordinatorExceptionStandardScheme getScheme() { - return new NotStormCoordinatorExceptionStandardScheme(); - } - } - - private static class NotStormCoordinatorExceptionStandardScheme extends StandardScheme { - - public void read(org.apache.thrift.protocol.TProtocol iprot, NotStormCoordinatorException struct) throws org.apache.thrift.TException { - org.apache.thrift.protocol.TField schemeField; - iprot.readStructBegin(); - while (true) - { - schemeField = iprot.readFieldBegin(); - if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { - break; - } - switch (schemeField.id) { - case 1: // MESSAGE - if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { - struct.message = iprot.readString(); - struct.setMessageIsSet(true); - } else { - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - break; - default: - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - iprot.readFieldEnd(); - } - iprot.readStructEnd(); - - // check for required fields of primitive type, which can't be checked in the validate method - struct.validate(); - } - - public void write(org.apache.thrift.protocol.TProtocol oprot, NotStormCoordinatorException struct) throws org.apache.thrift.TException { - struct.validate(); - - oprot.writeStructBegin(STRUCT_DESC); - if (struct.message != null) { - oprot.writeFieldBegin(MESSAGE_FIELD_DESC); - oprot.writeString(struct.message); - oprot.writeFieldEnd(); - } - oprot.writeFieldStop(); - oprot.writeStructEnd(); - } - - } - - private static class NotStormCoordinatorExceptionTupleSchemeFactory implements SchemeFactory { - public NotStormCoordinatorExceptionTupleScheme getScheme() { - return new NotStormCoordinatorExceptionTupleScheme(); - } - } - - private static class NotStormCoordinatorExceptionTupleScheme extends TupleScheme { - - @Override - public void write(org.apache.thrift.protocol.TProtocol prot, NotStormCoordinatorException struct) throws org.apache.thrift.TException { - TTupleProtocol oprot = (TTupleProtocol) prot; - oprot.writeString(struct.message); - } - - @Override - public void read(org.apache.thrift.protocol.TProtocol prot, NotStormCoordinatorException struct) throws org.apache.thrift.TException { - TTupleProtocol iprot = (TTupleProtocol) prot; - struct.message = iprot.readString(); - struct.setMessageIsSet(true); - } - } - -} - diff --git a/components/event-processor/org.wso2.carbon.event.processor.common/src/main/java/org/wso2/carbon/event/processor/common/util/AsyncEventPublisher.java b/components/event-processor/org.wso2.carbon.event.processor.common/src/main/java/org/wso2/carbon/event/processor/common/util/AsyncEventPublisher.java deleted file mode 100644 index 7c4fd837a..000000000 --- a/components/event-processor/org.wso2.carbon.event.processor.common/src/main/java/org/wso2/carbon/event/processor/common/util/AsyncEventPublisher.java +++ /dev/null @@ -1,472 +0,0 @@ -/* - * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.wso2.carbon.event.processor.common.util; - -import com.google.common.util.concurrent.ThreadFactoryBuilder; -import com.lmax.disruptor.EventFactory; -import com.lmax.disruptor.EventHandler; -import com.lmax.disruptor.RingBuffer; -import com.lmax.disruptor.dsl.Disruptor; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.thrift.TException; -import org.apache.thrift.protocol.TBinaryProtocol; -import org.apache.thrift.protocol.TProtocol; -import org.apache.thrift.transport.TSocket; -import org.apache.thrift.transport.TTransport; -import org.apache.thrift.transport.TTransportException; -import org.wso2.carbon.event.processor.common.storm.manager.service.StormManagerService; -import org.wso2.carbon.event.processor.common.storm.manager.service.exception.EndpointNotFoundException; -import org.wso2.carbon.event.processor.common.storm.manager.service.exception.NotStormCoordinatorException; -import org.wso2.carbon.event.processor.manager.commons.transport.client.ConnectionFailureHandler; -import org.wso2.carbon.event.processor.manager.commons.transport.client.TCPEventPublisher; -import org.wso2.carbon.event.processor.manager.commons.transport.server.ConnectionCallback; -import org.wso2.carbon.event.processor.manager.commons.utils.HostAndPort; -import org.wso2.carbon.event.processor.manager.commons.utils.Utils; -import org.wso2.carbon.event.processor.manager.core.config.DistributedConfiguration; -import org.wso2.siddhi.query.api.definition.StreamDefinition; - -import java.io.IOException; -import java.net.SocketException; -import java.util.List; -import java.util.Set; -import java.util.concurrent.Executors; - -/** - * Sending events asynchronously from "CEP Receiver" -> "Storm Receiver" and - * "Storm Publisher" -> "CEP Publisher" using TCPEventPublisher. This will - * discover and connect to the endpoint(i.e. Storm Receiver/CEP Publisher) to - * send events by talking to "Storm Management" service using EndpointConnectionCreator. - */ -public class AsyncEventPublisher implements EventHandler, ConnectionFailureHandler { - public enum DestinationType {STORM_RECEIVER, CEP_PUBLISHER} - - private transient Log log = LogFactory.getLog(AsyncEventPublisher.class); - private String logPrefix; - - private String destinationTypeString; - private String publisherTypeString; - private DestinationType destinationType; - - private Set streams; - private String executionPlanName; - private int tenantId; - private String thisHostIp; - private List managerServiceEndpoints; - private DistributedConfiguration stormDeploymentConfig; - AsynchronousEventBuffer eventSendBuffer = null; - - private ConnectionCallback connectionCallback; - - private TCPEventPublisher tcpEventPublisher = null; - private EndpointConnectionCreator endpointConnectionCreator; - - private boolean shutdown = false; - - private ThroughputProbe inputThroughputProbe; - private ThroughputProbe publishThroughputProbe; - - /** - * @param connectionCallback is a callback, invoked on connect() and disconnect() methods of TCPEventPublisher. Set to null if the callback is not needed. - */ - public AsyncEventPublisher(DestinationType destinationType, Set streams, - List managerServiceEndpoints, - String executionPlanName, int tenantId, DistributedConfiguration stormDeploymentConfig, - ConnectionCallback connectionCallback) { - this.destinationType = destinationType; - this.streams = streams; - this.executionPlanName = executionPlanName; - this.tenantId = tenantId; - this.managerServiceEndpoints = managerServiceEndpoints; - this.stormDeploymentConfig = stormDeploymentConfig; - this.connectionCallback = connectionCallback; - this.endpointConnectionCreator = new EndpointConnectionCreator(); - - this.destinationTypeString = (destinationType == DestinationType.STORM_RECEIVER) ? "StormReceiver" : "CEPPublisher"; - this.publisherTypeString = (destinationType == DestinationType.STORM_RECEIVER) ? "CEPReceiver" : "PublisherBolt"; - - int bufferSize = (publisherTypeString.equals("CEPReceiver")) ? - stormDeploymentConfig.getCepReceiverOutputQueueSize() : stormDeploymentConfig.getStormPublisherOutputQueueSize(); - eventSendBuffer = new AsynchronousEventBuffer(bufferSize, this); - - this.logPrefix = "[" + tenantId + ":" + executionPlanName + ":" + publisherTypeString + "] "; - } - - /** - * Initialize and try to make a connection with remote endpoint - * - * @param sync if set to true returns only after obtaining a connection to the remote endpoint. Otherwise initialization happens on a newly spawned - * thread and this method returns immediately. - */ - public void initializeConnection(boolean sync) { - try { - this.thisHostIp = Utils.findAddress("localhost"); - - if (sync) { - endpointConnectionCreator.establishConnection(); - } else { - Thread thread = new Thread(endpointConnectionCreator); - thread.start(); - } - inputThroughputProbe = new ThroughputProbe(logPrefix + "-In", 10); - publishThroughputProbe = new ThroughputProbe(logPrefix + " -Publish", 10); - - inputThroughputProbe.startSampling(); - publishThroughputProbe.startSampling(); - - } catch (SocketException e) { - log.error(logPrefix + "Error while trying to obtain this host IP address", e); - } - } - - /** - * Add event to the outbound event buffer and this call will return. Event will be sent asynchronously by disruptor consumer thread - * via AsyncEventPublisher#onEvent. - * - * @param eventData - * @param streamId - */ - public void sendEvent(Object[] eventData, long timestamp, String streamId) { - eventSendBuffer.addEvent(eventData, timestamp, streamId); - inputThroughputProbe.update(); - } - - /** - * Callback from disruptor for the consumer to consume data. This is where events are actually dispatched to the remote end. - * If an exception occurs when trying send data it will keep trying to send for ever until succeeds. Returns only - * after sending the event. - * - * @param dataHolder - * @param sequence - * @param endOfBatch - */ - @Override - public void onEvent(AsynchronousEventBuffer.DataHolder dataHolder, long sequence, boolean endOfBatch) { - while (tcpEventPublisher == null) { - log.info(logPrefix + "Can't send event. TCP event publisher not initialized. Waiting " + stormDeploymentConfig.getTransportReconnectInterval() + "s"); - try { - synchronized (this) { - if (shutdown) { - log.info(logPrefix + "Aborting retry to send events. AsyncEventPublisher has shutdown."); - return; - } - } - Thread.sleep(stormDeploymentConfig.getTransportReconnectInterval()); - } catch (InterruptedException e) { - } - } - - // TODO : comment on message lost of the last batch - try { - tcpEventPublisher.sendEvent(dataHolder.getStreamId(), dataHolder.getTimestamp(), (Object[]) dataHolder.getData(), endOfBatch); - publishThroughputProbe.update(); - } catch (IOException e) { - log.error(logPrefix + "Error while trying to send event to " + destinationTypeString + " at " + tcpEventPublisher.getHostUrl(), e); - reconnect(); - onEvent(dataHolder, sequence, endOfBatch); - } - } - - /** - * First tires to reconnect to the already obtained end point. If failed re-initialize the connection. - */ - private void reconnect() { - String destinationHostPort = tcpEventPublisher.getHostUrl(); - resetTCPEventPublisher(); - // Retrying to connect to the existing endpoint. - tcpEventPublisher = endpointConnectionCreator.connectToEndpoint(destinationHostPort, 3); - // Initialize connection from the beginning if can't connect to the existing endpoint - if (tcpEventPublisher == null) { - log.error(logPrefix + "Failed to connect to existing " + destinationTypeString + " at " + destinationHostPort + ". Reinitializing connection process"); - initializeConnection(true); - } - } - - private void resetTCPEventPublisher() { - if (tcpEventPublisher != null) { - tcpEventPublisher.terminate(); - tcpEventPublisher = null; - } - } - - @Override - protected void finalize() { - if (tcpEventPublisher != null) { - tcpEventPublisher.shutdown(); - tcpEventPublisher = null; - } - } - - public void shutdown() { - synchronized (this) { - shutdown = true; - } - eventSendBuffer.terminate(); - finalize(); - } - - @Override - public void onConnectionFail(Exception e) { - if (log.isDebugEnabled()) { - log.debug("Pinging failed to " + tcpEventPublisher.getHostUrl() + ". Trying to re-connect."); - } - - if (!shutdown) { - reconnect(); - } else { - log.info("Not trying to reconnect to " + tcpEventPublisher.getHostUrl() + " because event publisher is shutdown"); - } - } - - /** - * Creates connection to remote endpoint. First, talk to manager service to retrieve endpoint for given execution plan and tenant. - * And then creates a connection to connect to remote endpoint. - */ - class EndpointConnectionCreator implements Runnable { - /** - * Get the IP and the port of CEP Publisher/ Storm Receive by talking to Storm manager service. - * Returns only after retrieving information from manager service. In case of a failure keep trying - * to connect to manager service. - * - * @return endpoint Host and port in : format - */ - public String getEndpointFromManagerService() { - String endpointHostPort = null; - do { - for (HostAndPort endpoint : managerServiceEndpoints) { - TTransport transport = null; - try { - transport = new TSocket(endpoint.getHostName(), endpoint.getPort()); - TProtocol protocol = new TBinaryProtocol(transport); - transport.open(); - StormManagerService.Client client = new StormManagerService.Client(protocol); - - if (destinationType == DestinationType.CEP_PUBLISHER) { - endpointHostPort = client.getCEPPublisher(tenantId, executionPlanName, thisHostIp); - } else { - endpointHostPort = client.getStormReceiver(tenantId, executionPlanName, thisHostIp); - } - log.info(logPrefix + "Retrieved " + destinationTypeString + " at " + endpointHostPort + " " + - "from storm manager service at " + endpoint.getHostName() + ":" + endpoint.getPort()); - break; - } catch (NotStormCoordinatorException e) { - log.info(logPrefix + "Cannot retrieve " + destinationType.name() + - " endpoint information from storm manager service at " + - endpoint.getHostName() + ":" + endpoint.getPort() + " as it's not a Storm coordinator, Trying next Storm manager."); - - } catch (EndpointNotFoundException e) { - log.info(logPrefix + destinationType.name() + - " endpoint information not available on storm manager service at " + - endpoint.getHostName() + ":" + endpoint.getPort() + ". Trying next Storm manager."); - } catch (TTransportException e) { - log.info(logPrefix + "Cannot retrieve " + destinationType.name() + - " endpoint information from storm manager service at " + - endpoint.getHostName() + ":" + endpoint.getPort() + " as it's not reachable, " + e.getMessage() + ". Trying next Storm manager."); - - } catch (TException e) { - log.info(logPrefix + "Cannot retrieve " + destinationType.name() + - " endpoint information from storm manager service at " + - endpoint.getHostName() + ":" + endpoint.getPort() + " as it's not reachable, " + e.getMessage() + ". Trying next Storm manager."); - - } finally { - if (transport != null) { - transport.close(); - } - } - } - - synchronized (AsyncEventPublisher.this) { - if (shutdown) { - log.info(logPrefix + "Stopping attempting to connect to Storm manager service. Async event publisher is shutdown"); - return null; - } - } - - if (endpointHostPort == null) { - try { - log.info(logPrefix + "Failed to retrieve " + destinationType.name() + " from given " + - "set of Storm Managers. Retrying to retrieve endpoint from manager " + - "service in " + stormDeploymentConfig.getManagementReconnectInterval() - + " ms to get a " + destinationTypeString); - Thread.sleep(stormDeploymentConfig.getManagementReconnectInterval()); - } catch (InterruptedException e1) { - Thread.currentThread().interrupt(); - } - } - - } while (endpointHostPort == null); - - return endpointHostPort; - } - - /** - * Connect to a given endpoint (i.e. CEP publisher or storm receiver). In case of failure retry to connect. Returns only - * after connecting to the endpoint or after reaching maximum attempts. - * - * @param endpoint Destination Ip and port in : format - * @param retryAttempts maximum number of retry attempts. 0 means retry for ever. - * @return Returns TCPEvent publisher to talk to endpoint or null if reaches maximum number of attempts without succeeding - */ - public TCPEventPublisher connectToEndpoint(String endpoint, int retryAttempts) { - TCPEventPublisher tcpEventPublisher = null; - int attemptCount = 0; - do { - synchronized (AsyncEventPublisher.this) { - if (shutdown) { - log.info(logPrefix + "Stopping attempting to connect to endpoint " + endpoint + ". Async event publisher is shutdown"); - return null; - } - } - - try { - tcpEventPublisher = new TCPEventPublisher(endpoint, stormDeploymentConfig.constructTransportPublisherConfig(), true, connectionCallback); - StringBuilder streamsIDs = new StringBuilder(); - for (StreamDefinition siddhiStreamDefinition : streams) { - tcpEventPublisher.addStreamDefinition(siddhiStreamDefinition); - streamsIDs.append(siddhiStreamDefinition.getId() + ","); - } - tcpEventPublisher.registerConnectionFailureHandler(AsyncEventPublisher.this); - log.info(logPrefix + "Connected to " + destinationTypeString + " at " + endpoint + " for the Stream(s) " + streamsIDs.toString()); - } catch (IOException e) { - log.info(logPrefix + "Cannot connect to " + destinationTypeString + " at " + endpoint + ", " + e.getMessage()); - if (log.isDebugEnabled()) { - log.debug(logPrefix + "Cannot connect to " + destinationTypeString + " at " + endpoint, e); - } - } - - if (tcpEventPublisher == null) { - ++attemptCount; - if (retryAttempts > 0 && (attemptCount > retryAttempts)) { - return null; - } - - try { - log.info(logPrefix + "Retrying(" + attemptCount + ") to connect to " + destinationTypeString + " at " + endpoint + " in " - + stormDeploymentConfig.getTransportReconnectInterval() + "ms"); - Thread.sleep(stormDeploymentConfig.getTransportReconnectInterval()); - } catch (InterruptedException e1) { - Thread.currentThread().interrupt(); - } - } - } while (tcpEventPublisher == null); - - return tcpEventPublisher; - } - - /** - * First connect to the manager service and retrieve endpoint ip and port. Then connect to the endpoint. - * Returns only after completing these tasks. Keeps trying forever until succeeds. - */ - public void establishConnection() { - log.info(logPrefix + "Requesting a " + destinationTypeString + " for " + thisHostIp); - - do { - String endpointHostPort = getEndpointFromManagerService(); - if (endpointHostPort != null) { - tcpEventPublisher = connectToEndpoint(endpointHostPort, 3); - } - } while (tcpEventPublisher == null); - } - - @Override - public void run() { - establishConnection(); - } - } -} - -/** - * Store events in a disruptor - * - * @param Type of data to be stored in buffer. - */ -class AsynchronousEventBuffer { - private Disruptor disruptor; - private RingBuffer ringBuffer; - - /** - * Creates a AsynchronousEventBuffer instance - * - * @param bufferSize size of the buffer - * @param publishHandler Instance of publish handler which is responsible for consuming events in the buffer - */ - public AsynchronousEventBuffer(int bufferSize, EventHandler publishHandler) { - this.disruptor = new Disruptor(new EventFactory() { - @Override - public DataHolder newInstance() { - return new DataHolder(); - } - - }, bufferSize, Executors.newSingleThreadExecutor(new ThreadFactoryBuilder(). - setNameFormat("Thread pool- component - AsynchronousEventBuffer").build())); - - this.ringBuffer = disruptor.getRingBuffer(); - - this.disruptor.handleEventsWith(publishHandler); - - disruptor.start(); - } - - public void addEvent(Type data, long timestamp, String streamId) { - long sequenceNo = ringBuffer.next(); - try { - DataHolder existingHolder = ringBuffer.get(sequenceNo); - existingHolder.setData(data); - existingHolder.setTimestamp(timestamp); - existingHolder.setStreamId(streamId); - } finally { - ringBuffer.publish(sequenceNo); - } - } - - public void terminate() { - disruptor.halt(); - } - - class DataHolder { - Type data; - String streamId; - private long timestamp; - - public void setData(Type data) { - this.data = data; - } - - public Type getData() { - return data; - } - - public void setStreamId(String streamId) { - this.streamId = streamId; - } - - public String getStreamId() { - return streamId; - } - - public long getTimestamp() { - return timestamp; - } - - public void setTimestamp(long timestamp) { - this.timestamp = timestamp; - } - - } -} - - diff --git a/components/event-processor/org.wso2.carbon.event.processor.common/src/main/java/org/wso2/carbon/event/processor/common/util/ThroughputProbe.java b/components/event-processor/org.wso2.carbon.event.processor.common/src/main/java/org/wso2/carbon/event/processor/common/util/ThroughputProbe.java deleted file mode 100644 index a2ac5a257..000000000 --- a/components/event-processor/org.wso2.carbon.event.processor.common/src/main/java/org/wso2/carbon/event/processor/common/util/ThroughputProbe.java +++ /dev/null @@ -1,79 +0,0 @@ -package org.wso2.carbon.event.processor.common.util; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import java.text.DecimalFormat; -import java.util.Timer; -import java.util.TimerTask; - -/** - * Probe to calculate the throughput by sampling in a given rate. first the the startSampling() must be used to start the probe - * and the call update() for each message. - */ -public class ThroughputProbe extends TimerTask { - private static Log log = LogFactory.getLog(ThroughputProbe.class); - private long count = 0; - private int sampleCount = 0; - private long samplingRateInSeconds; - private String name; - private double maxThroughput = 0.0; - private double minThroughput = Double.MAX_VALUE; - private double accumulatedThroughput = 0.0; - DecimalFormat formatter = new DecimalFormat("#.000"); - Timer timer; - private long totalEventCount = 0; - - public ThroughputProbe(String name, int samplingRateInSeconds){ - this.name = name; - this.samplingRateInSeconds = samplingRateInSeconds; - } - - /** - Starting the probe, this will start calculating the throughout - */ - public void startSampling(){ - count = 0l; - timer = new Timer(); - timer.schedule(this, samplingRateInSeconds * 1000, samplingRateInSeconds * 1000); - } - - /** - * This must be called when a message received. - */ - public void update(){ - count++; - totalEventCount++; - } - - /** - * The action to be performed by this timer task. - */ - @Override - public void run() { - if (log.isDebugEnabled()){ - if (totalEventCount > 0){ - double throughput = count / samplingRateInSeconds; - - if (maxThroughput < throughput){ - maxThroughput = throughput; - } - if (minThroughput > throughput && throughput != 0.0){ - minThroughput = throughput; - } - - accumulatedThroughput += throughput; - sampleCount++; - - log.debug("[ThroughputProbe:" + name + "] " + count + " events in " + samplingRateInSeconds - + " seconds. Throughput=" + formatter.format(throughput) - + " events/s.(Avg=" + formatter.format(accumulatedThroughput / sampleCount) - + " ,Max=" + formatter.format(maxThroughput) - + " ,Min=" + ((minThroughput == Double.MAX_VALUE) ? "0.0" : formatter.format(minThroughput)) - + " ) TotalEvents=" + totalEventCount); - - count = 0l; - } - } - } -} diff --git a/components/event-processor/org.wso2.carbon.event.processor.core/pom.xml b/components/event-processor/org.wso2.carbon.event.processor.core/pom.xml index ad0d0c20f..f5bf08bba 100644 --- a/components/event-processor/org.wso2.carbon.event.processor.core/pom.xml +++ b/components/event-processor/org.wso2.carbon.event.processor.core/pom.xml @@ -1,5 +1,4 @@ - - - + --> org.wso2.carbon.event-processing event-processor - 2.2.14 + 2.2.17-SNAPSHOT ../pom.xml 4.0.0 - 2.2.14 + 2.2.17-SNAPSHOT org.wso2.carbon.event.processor.core bundle WSO2 Carbon - Event Processor Core @@ -78,10 +76,6 @@ org.wso2.carbon.event-processing org.wso2.carbon.siddhi.metrics.core - - org.wso2.orbit.org.apache.storm - storm-core - org.yaml snakeyaml @@ -172,4 +166,4 @@ - + \ No newline at end of file diff --git a/components/event-processor/org.wso2.carbon.event.processor.core/src/main/java/org/wso2/carbon/event/processor/core/EventProcessorService.java b/components/event-processor/org.wso2.carbon.event.processor.core/src/main/java/org/wso2/carbon/event/processor/core/EventProcessorService.java index c724e9a24..c5731d686 100644 --- a/components/event-processor/org.wso2.carbon.event.processor.core/src/main/java/org/wso2/carbon/event/processor/core/EventProcessorService.java +++ b/components/event-processor/org.wso2.carbon.event.processor.core/src/main/java/org/wso2/carbon/event/processor/core/EventProcessorService.java @@ -167,12 +167,6 @@ public void validateExecutionPlan(String executionPlan) public boolean isDistributedProcessingEnabled(); - /** - * The returned status string explains whether the topology is active or not, how many CEP Receivers are connected to a Spout and - * how many Storm Publishing Bolts are connected to CEP Publishers. - * @return a Map which maps the execution plan name to its status. This status is a string, explaining the status of the execution plan in Storm. - */ - public Map getAllExecutionPlanStatusesInStorm(); } diff --git a/components/event-processor/org.wso2.carbon.event.processor.core/src/main/java/org/wso2/carbon/event/processor/core/ExecutionPlan.java b/components/event-processor/org.wso2.carbon.event.processor.core/src/main/java/org/wso2/carbon/event/processor/core/ExecutionPlan.java index 2f4dd267d..f0fb388fa 100644 --- a/components/event-processor/org.wso2.carbon.event.processor.core/src/main/java/org/wso2/carbon/event/processor/core/ExecutionPlan.java +++ b/components/event-processor/org.wso2.carbon.event.processor.core/src/main/java/org/wso2/carbon/event/processor/core/ExecutionPlan.java @@ -15,9 +15,6 @@ */ package org.wso2.carbon.event.processor.core; -import org.wso2.carbon.event.processor.core.internal.storm.SiddhiStormOutputEventListener; -import org.wso2.carbon.event.processor.core.internal.storm.status.monitor.StormStatusMapListener; -import org.wso2.carbon.event.processor.core.internal.storm.status.monitor.StormStatusMonitor; import org.wso2.carbon.event.stream.core.EventProducer; import org.wso2.carbon.event.stream.core.SiddhiEventConsumer; import org.wso2.siddhi.core.ExecutionPlanRuntime; @@ -32,9 +29,6 @@ public class ExecutionPlan { private String name; private List eventProducers = new ArrayList(); private List siddhiEventConsumers = new ArrayList(); - private SiddhiStormOutputEventListener stormOutputListener; - private StormStatusMonitor stormStatusMonitor; - private StormStatusMapListener stormStatusMapListener; public ExecutionPlan(String name, ExecutionPlanRuntime executionPlanRuntime, @@ -69,27 +63,13 @@ public void setExecutionPlanConfiguration( this.executionPlanConfiguration = executionPlanConfiguration; } - public void setStormStatusMonitor(StormStatusMonitor stormStatusMonitor) { - this.stormStatusMonitor = stormStatusMonitor; - } - public void setStormStatusMapListener(StormStatusMapListener stormStatusMapListener) { - this.stormStatusMapListener = stormStatusMapListener; - } public void shutdown() { - if (stormOutputListener != null) { - stormOutputListener.shutdown(); - } for (SiddhiEventConsumer siddhiEventConsumer : siddhiEventConsumers) { siddhiEventConsumer.shutdown(); } - if(stormStatusMonitor != null){ - stormStatusMonitor.shutdown(); - } - if(stormStatusMapListener != null){ - stormStatusMapListener.removeEntryListener(); - } + executionPlanRuntime.shutdown(); } @@ -110,7 +90,4 @@ public List getSiddhiEventConsumers() { return siddhiEventConsumers; } - public void addStormOutputListener(SiddhiStormOutputEventListener stormOutputListener) { - this.stormOutputListener = stormOutputListener; - } } diff --git a/components/event-processor/org.wso2.carbon.event.processor.core/src/main/java/org/wso2/carbon/event/processor/core/exception/ExcecutionPlanRuntimeException.java b/components/event-processor/org.wso2.carbon.event.processor.core/src/main/java/org/wso2/carbon/event/processor/core/exception/ExcecutionPlanRuntimeException.java index aa89daff5..e70b0fcf0 100644 --- a/components/event-processor/org.wso2.carbon.event.processor.core/src/main/java/org/wso2/carbon/event/processor/core/exception/ExcecutionPlanRuntimeException.java +++ b/components/event-processor/org.wso2.carbon.event.processor.core/src/main/java/org/wso2/carbon/event/processor/core/exception/ExcecutionPlanRuntimeException.java @@ -16,6 +16,7 @@ package org.wso2.carbon.event.processor.core.exception; + public class ExcecutionPlanRuntimeException extends RuntimeException{ public ExcecutionPlanRuntimeException() { } diff --git a/components/event-processor/org.wso2.carbon.event.processor.core/src/main/java/org/wso2/carbon/event/processor/core/internal/CarbonEventProcessorService.java b/components/event-processor/org.wso2.carbon.event.processor.core/src/main/java/org/wso2/carbon/event/processor/core/internal/CarbonEventProcessorService.java index b8396744e..8871e0533 100644 --- a/components/event-processor/org.wso2.carbon.event.processor.core/src/main/java/org/wso2/carbon/event/processor/core/internal/CarbonEventProcessorService.java +++ b/components/event-processor/org.wso2.carbon.event.processor.core/src/main/java/org/wso2/carbon/event/processor/core/internal/CarbonEventProcessorService.java @@ -15,8 +15,6 @@ */ package org.wso2.carbon.event.processor.core.internal; -import com.hazelcast.core.HazelcastInstance; -import com.hazelcast.core.IMap; import com.lmax.disruptor.ExceptionHandler; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -29,24 +27,14 @@ import org.wso2.carbon.event.processor.core.StreamConfiguration; import org.wso2.carbon.event.processor.core.exception.ExecutionPlanConfigurationException; import org.wso2.carbon.event.processor.core.exception.ExecutionPlanDependencyValidationException; -import org.wso2.carbon.event.processor.core.exception.StormDeploymentException; import org.wso2.carbon.event.processor.core.internal.ds.EventProcessorValueHolder; import org.wso2.carbon.event.processor.core.internal.listener.AbstractSiddhiInputEventDispatcher; import org.wso2.carbon.event.processor.core.internal.listener.SiddhiInputEventDispatcher; import org.wso2.carbon.event.processor.core.internal.listener.SiddhiOutputStreamListener; -import org.wso2.carbon.event.processor.core.internal.storm.SiddhiStormInputEventDispatcher; -import org.wso2.carbon.event.processor.core.internal.storm.SiddhiStormOutputEventListener; -import org.wso2.carbon.event.processor.core.internal.storm.StormTopologyManager; -import org.wso2.carbon.event.processor.core.internal.storm.status.monitor.StormStatusMapListener; -import org.wso2.carbon.event.processor.core.internal.storm.status.monitor.StormStatusMonitor; -import org.wso2.carbon.event.processor.core.internal.storm.status.monitor.exception.DeploymentStatusMonitorException; import org.wso2.carbon.event.processor.core.internal.util.EventProcessorConfigurationFilesystemInvoker; import org.wso2.carbon.event.processor.core.internal.util.EventProcessorConstants; import org.wso2.carbon.event.processor.core.internal.util.EventProcessorUtil; import org.wso2.carbon.event.processor.core.internal.util.helper.EventProcessorHelper; -import org.wso2.carbon.event.processor.core.util.DistributedModeConstants; -import org.wso2.carbon.event.processor.core.util.ExecutionPlanStatusHolder; -import org.wso2.carbon.event.processor.manager.core.config.DistributedConfiguration; import org.wso2.carbon.event.processor.manager.core.config.ManagementModeInfo; import org.wso2.carbon.event.processor.manager.core.config.Mode; import org.wso2.carbon.event.stream.core.EventProducer; @@ -67,7 +55,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.CopyOnWriteArrayList; @@ -300,7 +287,6 @@ public void addExecutionPlan(String executionPlan, boolean isEditable) throws Ex /** * Section to handle query deployment */ - DistributedConfiguration stormDeploymentConfiguration = EventProcessorValueHolder.getStormDeploymentConfiguration(); try { executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(executionPlan); @@ -327,17 +313,6 @@ public void handleOnShutdownException(Throwable throwable) { throw new ExecutionPlanConfigurationException("Invalid query specified, " + e.getMessage(), e); } - if (managementInfo.getMode() == Mode.Distributed) { - if (stormDeploymentConfiguration != null && stormDeploymentConfiguration.isManagerNode() && EventProcessorValueHolder - .getStormManagerServer().isStormCoordinator()) { - try { - EventProcessorValueHolder.getStormTopologyManager().submitTopology(executionPlanConfiguration, importDefinitions, exportDefinitions, - tenantId, stormDeploymentConfiguration.getTopologySubmitRetryInterval()); - } catch (StormDeploymentException e) { - throw new ExecutionPlanConfigurationException("Invalid distributed query specified, " + e.getMessage(), e); - } - } - } for (Map.Entry entry : importsMap.entrySet()) { inputHandlerMap.put(entry.getValue(), executionPlanRuntime.getInputHandler(entry.getKey())); @@ -348,32 +323,10 @@ public void handleOnShutdownException(Throwable throwable) { executionPlanConfiguration); tenantExecutionPlans.put(executionPlanName, processorExecutionPlan); - boolean isDistributedEnabledAndIsWorker = (managementInfo.getMode() == Mode.Distributed && stormDeploymentConfiguration != null - && stormDeploymentConfiguration.isWorkerNode()); - - StormStatusMonitor stormStatusMonitor = null; - if (isDistributedEnabledAndIsWorker) { - StormStatusMapListener mapListener = null; - try { - stormStatusMonitor = new StormStatusMonitor(tenantId, executionPlanName, importsMap.size()); - mapListener = new StormStatusMapListener(executionPlanName, tenantId, stormStatusMonitor); - } catch (DeploymentStatusMonitorException e) { - log.error("Failed to initialize map listener. Reason: " + e.getMessage(), e); - } - processorExecutionPlan.setStormStatusMonitor(stormStatusMonitor); - processorExecutionPlan.setStormStatusMapListener(mapListener); - } - /** * Section to configure outputs */ - SiddhiStormOutputEventListener stormOutputListener = null; - if (managementInfo.getMode() == Mode.Distributed && managementInfo.getDistributedConfiguration().isWorkerNode()) { - stormOutputListener = new SiddhiStormOutputEventListener(executionPlanConfiguration, tenantId, - stormDeploymentConfiguration, stormStatusMonitor); - processorExecutionPlan.addStormOutputListener(stormOutputListener); - } for (Map.Entry entry : exportsMap.entrySet()) { @@ -390,21 +343,7 @@ public void handleOnShutdownException(Throwable throwable) { } catch (EventStreamConfigurationException e) { //ignored as this will never happen } - - if (managementInfo.getMode() == Mode.Distributed && stormDeploymentConfiguration != null && stormDeploymentConfiguration.isWorkerNode()) { - try { - StreamDefinition databridgeDefinition = EventProcessorValueHolder.getEventStreamService() - .getStreamDefinition(entry.getValue()); - org.wso2.siddhi.query.api.definition.StreamDefinition siddhiStreamDefinition = EventProcessorUtil - .convertToSiddhiStreamDefinition(databridgeDefinition, entry.getKey()); - stormOutputListener.registerOutputStreamListener(siddhiStreamDefinition, streamCallback); - } catch (EventStreamConfigurationException e) { - throw new ExecutionPlanConfigurationException(e.getMessage(), e); - } - } else { - executionPlanRuntime.addCallback(entry.getKey(), streamCallback); - } - + executionPlanRuntime.addCallback(entry.getKey(), streamCallback); processorExecutionPlan.addProducer(streamCallback); } @@ -417,28 +356,13 @@ public void handleOnShutdownException(Throwable throwable) { InputHandler inputHandler = inputHandlerMap.get(entry.getValue()); AbstractSiddhiInputEventDispatcher eventDispatcher; - if (isDistributedEnabledAndIsWorker) { - StreamDefinition streamDefinition = null; - try { - streamDefinition = EventProcessorValueHolder.getEventStreamService().getStreamDefinition - (entry.getValue()); - } catch (EventStreamConfigurationException e) { - // Ignore as this would never happen - } - eventDispatcher = new SiddhiStormInputEventDispatcher(streamDefinition, - entry.getKey(), executionPlanConfiguration, tenantId, - stormDeploymentConfiguration, stormStatusMonitor); - } else { - eventDispatcher = new SiddhiInputEventDispatcher(entry.getValue(), - inputHandler, executionPlanConfiguration, tenantId); - } + eventDispatcher = new SiddhiInputEventDispatcher(entry.getValue(), + inputHandler, executionPlanConfiguration, tenantId); inputEventDispatchers.add(eventDispatcher); } - if (executionPlanRuntime != null) { - executionPlanRuntime.start(); - } + executionPlanRuntime.start(); for (AbstractSiddhiInputEventDispatcher eventDispatcher : inputEventDispatchers) { try { @@ -480,35 +404,6 @@ public boolean isDistributedProcessingEnabled() { } - @Override - public Map getAllExecutionPlanStatusesInStorm() { - HazelcastInstance hazelcastInstance = EventProcessorValueHolder.getHazelcastInstance(); - - int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); - Map executionPlanMap = tenantSpecificExecutionPlans.get(tenantId); - - Set executionPlanNames = executionPlanMap.keySet(); - - Map executionPlanStatuses = new HashMap(); //key:ExecutionPlanName, Value:Status Explanation. - String status; - - for (String executionPlanName : executionPlanNames) { - if (hazelcastInstance == null) { - status = "No status info available. \nTo get status info, enable clustering."; - } else { - IMap executionPlanStatusHolderIMap = hazelcastInstance.getMap(DistributedModeConstants.STORM_STATUS_MAP); - ExecutionPlanStatusHolder statusHolder = executionPlanStatusHolderIMap.get(StormTopologyManager.getTopologyName(executionPlanName, tenantId)); - if (statusHolder == null) { - status = "Execution plan not deployed to a manager. Hence no status info available."; - } else { - status = statusHolder.getExecutionPlanStatus(); - } - } - executionPlanStatuses.put(executionPlanName, status); - } - return executionPlanStatuses; - } - public void validateExecutionPlan(String executionPlan) throws ExecutionPlanConfigurationException, ExecutionPlanDependencyValidationException { EventProcessorHelper.validateExecutionPlan(executionPlan); @@ -544,21 +439,6 @@ private void removeExecutionPlanConfiguration(String name) { ExecutionPlan executionPlan = executionPlanMap.remove(name); executionPlan.shutdown(); - ExecutionPlanConfiguration executionPlanConfiguration = executionPlan.getExecutionPlanConfiguration(); - - DistributedConfiguration stormDeploymentConfig = EventProcessorValueHolder.getStormDeploymentConfiguration(); - if (managementInfo.getMode() == Mode.Distributed && stormDeploymentConfig != null && stormDeploymentConfig.isManagerNode() && - EventProcessorValueHolder.getStormManagerServer().isStormCoordinator()) { - try { - // Kill the topology and notify the manager that execution plan is removed. - removeExecutionPlanStatusHolder(executionPlanConfiguration.getName(), tenantId); //todo: test in #worker>1 and watch for NPE - EventProcessorValueHolder.getStormTopologyManager().killTopology(executionPlanConfiguration.getName(), tenantId); - EventProcessorValueHolder.getStormManagerServer().onExecutionPlanRemove(name, tenantId); - } catch (Exception e) { - log.error(e.getMessage(), e); - } - } - // releasing junction listeners. for (SiddhiEventConsumer eventConsumer : executionPlan.getSiddhiEventConsumers()) { EventProcessorValueHolder.getEventStreamService().unsubscribe(eventConsumer); @@ -572,24 +452,6 @@ private void removeExecutionPlanConfiguration(String name) { } - void removeExecutionPlanStatusHolder(String executionPlanName, int tenantId) { - HazelcastInstance hazelcastInstance = EventProcessorValueHolder.getHazelcastInstance(); - if (hazelcastInstance != null && hazelcastInstance.getLifecycleService().isRunning()) { - IMap executionPlanStatusHolderIMap = - hazelcastInstance.getMap(DistributedModeConstants.STORM_STATUS_MAP); - - String stormTopologyName = StormTopologyManager.getTopologyName(executionPlanName, tenantId); - ExecutionPlanStatusHolder executionPlanStatusHolder = - executionPlanStatusHolderIMap.get(stormTopologyName); - - executionPlanStatusHolderIMap.remove(stormTopologyName, executionPlanStatusHolder); - } else { - log.error("Couldn't clean status info for execution plan: " + executionPlanName + - ", for tenant ID : " + tenantId - + " as the hazelcast instance is not active or not available."); - } - } - public void addExecutionPlanConfigurationFile(ExecutionPlanConfigurationFile configurationFile) { int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); List executionPlanConfigurationFiles = tenantSpecificExecutionPlanFiles.get(tenantId); diff --git a/components/event-processor/org.wso2.carbon.event.processor.core/src/main/java/org/wso2/carbon/event/processor/core/internal/ds/EventProcessorServiceDS.java b/components/event-processor/org.wso2.carbon.event.processor.core/src/main/java/org/wso2/carbon/event/processor/core/internal/ds/EventProcessorServiceDS.java index 73ac2a38d..706b78182 100644 --- a/components/event-processor/org.wso2.carbon.event.processor.core/src/main/java/org/wso2/carbon/event/processor/core/internal/ds/EventProcessorServiceDS.java +++ b/components/event-processor/org.wso2.carbon.event.processor.core/src/main/java/org/wso2/carbon/event/processor/core/internal/ds/EventProcessorServiceDS.java @@ -28,11 +28,8 @@ import org.wso2.carbon.event.processor.core.internal.CarbonEventProcessorManagementService; import org.wso2.carbon.event.processor.core.internal.CarbonEventProcessorService; import org.wso2.carbon.event.processor.core.internal.listener.EventStreamListenerImpl; -import org.wso2.carbon.event.processor.core.internal.storm.StormTopologyManager; -import org.wso2.carbon.event.processor.core.internal.storm.manager.StormManagerServer; import org.wso2.carbon.event.processor.core.internal.util.EventProcessorConstants; import org.wso2.carbon.event.processor.manager.core.EventManagementService; -import org.wso2.carbon.event.processor.manager.core.config.DistributedConfiguration; import org.wso2.carbon.event.processor.manager.core.config.PersistenceConfiguration; import org.wso2.carbon.event.stream.core.EventStreamListener; import org.wso2.carbon.event.stream.core.EventStreamService; @@ -67,18 +64,6 @@ protected void activate(ComponentContext context) { CarbonEventProcessorManagementService carbonEventReceiverManagementService = new CarbonEventProcessorManagementService(); EventProcessorValueHolder.registerProcessorManagementService(carbonEventReceiverManagementService); - DistributedConfiguration stormDeploymentConfig = carbonEventProcessorService.getManagementInfo() - .getDistributedConfiguration(); - if (stormDeploymentConfig != null) { - EventProcessorValueHolder.registerStormDeploymentConfiguration(stormDeploymentConfig); - EventProcessorValueHolder.registerStormTopologyManager(new StormTopologyManager()); - if (stormDeploymentConfig.isManagerNode()) { - StormManagerServer stormManagerServer = new StormManagerServer(stormDeploymentConfig - .getLocalManagerConfig().getHostName(), stormDeploymentConfig.getLocalManagerConfig() - .getPort()); - EventProcessorValueHolder.registerStormManagerServer(stormManagerServer); - } - } context.getBundleContext().registerService(EventProcessorService.class.getName(), carbonEventProcessorService, null); context.getBundleContext().registerService(EventStreamListener.class.getName(), new @@ -122,14 +107,6 @@ protected void checkIsStatsEnabled() { @Deactivate protected void deactivate(ComponentContext context) { - try { - StormManagerServer stormManagerServer = EventProcessorValueHolder.getStormManagerServer(); - if (stormManagerServer != null) { - stormManagerServer.stop(); - } - } catch (RuntimeException e) { - log.error("Error in stopping Storm Manager Service : " + e.getMessage(), e); - } EventProcessorValueHolder.getEventProcessorService().shutdown(); } @@ -158,29 +135,16 @@ protected void unsetEventStreamService(EventStreamService eventStreamService) { protected void setHazelcastInstance(HazelcastInstance hazelcastInstance) { EventProcessorValueHolder.registerHazelcastInstance(hazelcastInstance); - StormManagerServer stormManagerServer = EventProcessorValueHolder.getStormManagerServer(); - if (stormManagerServer != null) { - stormManagerServer.setHzaelCastInstance(hazelcastInstance); - stormManagerServer.tryBecomeCoordinator(); - } hazelcastInstance.getCluster().addMembershipListener(new MembershipListener() { @Override public void memberAdded(MembershipEvent membershipEvent) { - StormManagerServer stormManagerServer = EventProcessorValueHolder.getStormManagerServer(); - if (stormManagerServer != null) { - stormManagerServer.verifyState(); - } } @Override public void memberRemoved(MembershipEvent membershipEvent) { - StormManagerServer stormManagerServer = EventProcessorValueHolder.getStormManagerServer(); - if (stormManagerServer != null) { - stormManagerServer.tryBecomeCoordinator(); - } } @Override diff --git a/components/event-processor/org.wso2.carbon.event.processor.core/src/main/java/org/wso2/carbon/event/processor/core/internal/ds/EventProcessorValueHolder.java b/components/event-processor/org.wso2.carbon.event.processor.core/src/main/java/org/wso2/carbon/event/processor/core/internal/ds/EventProcessorValueHolder.java index bde9f5abc..55192bbe4 100644 --- a/components/event-processor/org.wso2.carbon.event.processor.core/src/main/java/org/wso2/carbon/event/processor/core/internal/ds/EventProcessorValueHolder.java +++ b/components/event-processor/org.wso2.carbon.event.processor.core/src/main/java/org/wso2/carbon/event/processor/core/internal/ds/EventProcessorValueHolder.java @@ -20,10 +20,7 @@ import org.wso2.carbon.base.api.ServerConfigurationService; import org.wso2.carbon.event.processor.core.internal.CarbonEventProcessorManagementService; import org.wso2.carbon.event.processor.core.internal.CarbonEventProcessorService; -import org.wso2.carbon.event.processor.core.internal.storm.StormTopologyManager; -import org.wso2.carbon.event.processor.core.internal.storm.manager.StormManagerServer; import org.wso2.carbon.event.processor.manager.core.EventManagementService; -import org.wso2.carbon.event.processor.manager.core.config.DistributedConfiguration; import org.wso2.carbon.event.processor.manager.core.config.PersistenceConfiguration; import org.wso2.carbon.event.stream.core.EventStreamService; import org.wso2.carbon.ndatasource.core.DataSourceService; @@ -42,12 +39,9 @@ public class EventProcessorValueHolder { private static DataSourceService dataSourceService; private static ServerConfigurationService serverConfiguration; private static ConfigurationContextService configurationContext; - private static StormManagerServer stormManagerServer; - private static DistributedConfiguration stormDeploymentConfiguration; private static PersistenceConfiguration persistenceConfiguration; private static CarbonEventProcessorManagementService carbonEventProcessorManagementService; private static SiddhiManager siddhiManager; - private static StormTopologyManager stormTopologyManager; private static ConcurrentHashMap tenantConfigs = new ConcurrentHashMap<>(); private static boolean globalStatisticsEnabled; @@ -132,30 +126,6 @@ public static void setConfigurationContext(ConfigurationContextService configura EventProcessorValueHolder.configurationContext = configurationContext; } - public static void registerStormManagerServer(StormManagerServer stormManagerServer) { - EventProcessorValueHolder.stormManagerServer = stormManagerServer; - } - - public static StormManagerServer getStormManagerServer() { - return stormManagerServer; - } - - public static void registerStormDeploymentConfiguration(DistributedConfiguration stormDeploymentConfig) { - EventProcessorValueHolder.stormDeploymentConfiguration = stormDeploymentConfig; - } - - public static DistributedConfiguration getStormDeploymentConfiguration() { - return stormDeploymentConfiguration; - } - - public static void registerStormTopologyManager(StormTopologyManager stormTopologyManager) { - EventProcessorValueHolder.stormTopologyManager = stormTopologyManager; - } - - public static StormTopologyManager getStormTopologyManager() { - return stormTopologyManager; - } - public static void registerPersistenceConfiguration(PersistenceConfiguration persistenceConfiguration) { EventProcessorValueHolder.persistenceConfiguration = persistenceConfiguration; diff --git a/components/event-processor/org.wso2.carbon.event.processor.core/src/main/java/org/wso2/carbon/event/processor/core/internal/storm/SiddhiStormInputEventDispatcher.java b/components/event-processor/org.wso2.carbon.event.processor.core/src/main/java/org/wso2/carbon/event/processor/core/internal/storm/SiddhiStormInputEventDispatcher.java deleted file mode 100644 index 49757ff7f..000000000 --- a/components/event-processor/org.wso2.carbon.event.processor.core/src/main/java/org/wso2/carbon/event/processor/core/internal/storm/SiddhiStormInputEventDispatcher.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.wso2.carbon.event.processor.core.internal.storm; - -import com.google.common.util.concurrent.ThreadFactoryBuilder; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.databridge.commons.StreamDefinition; -import org.wso2.carbon.event.processor.common.util.AsyncEventPublisher; -import org.wso2.carbon.event.processor.core.ExecutionPlanConfiguration; -import org.wso2.carbon.event.processor.core.internal.listener.AbstractSiddhiInputEventDispatcher; -import org.wso2.carbon.event.processor.core.internal.util.EventProcessorUtil; -import org.wso2.carbon.event.processor.manager.commons.transport.server.ConnectionCallback; -import org.wso2.carbon.event.processor.manager.core.config.DistributedConfiguration; -import org.wso2.siddhi.core.event.Event; - -import java.util.HashSet; -import java.util.Set; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; - -/** - * Publishes events of a stream to the event receiver spout running on Storm. There will be SiddhiStormInputEventDispatcher - * instance for each imported stream of execution plan - */ -public class SiddhiStormInputEventDispatcher extends AbstractSiddhiInputEventDispatcher{ - private static final Log log = LogFactory.getLog(SiddhiStormInputEventDispatcher.class); - - private final DistributedConfiguration stormDeploymentConfig; - - private org.wso2.siddhi.query.api.definition.StreamDefinition siddhiStreamDefinition; - private String logPrefix; - private ExecutorService executorService; - private AsyncEventPublisher asyncEventPublisher; - private final ConnectionCallback connectionCallback; - - public SiddhiStormInputEventDispatcher(StreamDefinition streamDefinition, String siddhiStreamId, - ExecutionPlanConfiguration executionPlanConfiguration, int tenantId, - DistributedConfiguration stormDeploymentConfig, - ConnectionCallback connectionCallback) { - super(streamDefinition.getStreamId(), siddhiStreamId, executionPlanConfiguration, tenantId); - this.stormDeploymentConfig = stormDeploymentConfig; - this.connectionCallback = connectionCallback; - this.executorService = Executors.newSingleThreadExecutor(new ThreadFactoryBuilder(). - setNameFormat("Thread pool- component - SiddhiStormInputEventDispatcher.executorService;" + - "tenantId - " + tenantId + ";executionPlanName - " + executionPlanConfiguration.getName() + - ";streamDefinition - " + streamDefinition.getStreamId()).build()); - init(streamDefinition, siddhiStreamId, executionPlanConfiguration); - } - - private void init(StreamDefinition streamDefinition, String siddhiStreamName, ExecutionPlanConfiguration executionPlanConfiguration) { - logPrefix = "[CEP Receiver|ExecPlan:" + executionPlanConfiguration.getName() + ", Tenant:" + tenantId + ", Stream:" + siddhiStreamName + "] "; - - try { - this.siddhiStreamDefinition = EventProcessorUtil.convertToSiddhiStreamDefinition(streamDefinition, siddhiStreamName); - Set streamDefinitions = new HashSet<>(); - streamDefinitions.add(siddhiStreamDefinition); - - asyncEventPublisher = new AsyncEventPublisher(AsyncEventPublisher.DestinationType.STORM_RECEIVER, - streamDefinitions, - stormDeploymentConfig.getManagers(), - executionPlanConfiguration.getName(), - tenantId, - stormDeploymentConfig, - this.connectionCallback); - - asyncEventPublisher.initializeConnection(false); - } catch (Exception e) { - log.error(logPrefix + "Failed to start event listener", e); - } - } - - @Override - public void sendEvent(Event event) throws InterruptedException { - asyncEventPublisher.sendEvent(event.getData(),event.getTimestamp(), this.siddhiStreamDefinition.getId()); - } - - @Override - public void shutdown() { - asyncEventPublisher.shutdown(); - executorService.shutdown(); - } -} diff --git a/components/event-processor/org.wso2.carbon.event.processor.core/src/main/java/org/wso2/carbon/event/processor/core/internal/storm/SiddhiStormOutputEventListener.java b/components/event-processor/org.wso2.carbon.event.processor.core/src/main/java/org/wso2/carbon/event/processor/core/internal/storm/SiddhiStormOutputEventListener.java deleted file mode 100644 index 56d975dc7..000000000 --- a/components/event-processor/org.wso2.carbon.event.processor.core/src/main/java/org/wso2/carbon/event/processor/core/internal/storm/SiddhiStormOutputEventListener.java +++ /dev/null @@ -1,217 +0,0 @@ -/* - * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.wso2.carbon.event.processor.core.internal.storm; - -import com.google.common.util.concurrent.ThreadFactoryBuilder; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.thrift.protocol.TBinaryProtocol; -import org.apache.thrift.protocol.TProtocol; -import org.apache.thrift.transport.TSocket; -import org.apache.thrift.transport.TTransport; -import org.wso2.carbon.databridge.commons.thrift.utils.HostAddressFinder; -import org.wso2.carbon.event.processor.common.storm.manager.service.StormManagerService; -import org.wso2.carbon.event.processor.common.util.ThroughputProbe; -import org.wso2.carbon.event.processor.core.ExecutionPlanConfiguration; -import org.wso2.carbon.event.processor.core.internal.listener.SiddhiOutputStreamListener; -import org.wso2.carbon.event.processor.manager.commons.transport.server.ConnectionCallback; -import org.wso2.carbon.event.processor.manager.commons.transport.server.StreamCallback; -import org.wso2.carbon.event.processor.manager.commons.transport.server.TCPEventServer; -import org.wso2.carbon.event.processor.manager.commons.transport.server.TCPEventServerConfig; -import org.wso2.carbon.event.processor.manager.commons.utils.HostAndPort; -import org.wso2.carbon.event.processor.manager.commons.utils.Utils; -import org.wso2.carbon.event.processor.manager.core.config.DistributedConfiguration; -import org.wso2.siddhi.core.event.Event; -import org.wso2.siddhi.query.api.definition.StreamDefinition; - -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; - -/** - * Receives events from the Event publisher bolt running on storm. There will be one SiddhiStormOutputEventListener instance - * per execution plan per tenant (all exported streams of execution plan are handled form a single SiddhiStormOutputEventListener). When events are - * received from storm, the event will be directed to the relevant output stream listener depending on the stream to forward - * the event to the relevant output adaptor for the stream. - */ -public class SiddhiStormOutputEventListener implements StreamCallback { - private static final Log log = LogFactory.getLog(SiddhiStormOutputEventListener.class); - private ExecutionPlanConfiguration executionPlanConfiguration; - private int listeningPort; - private int tenantId; - private final DistributedConfiguration stormDeploymentConfig; - private String thisHostIp; - private HashMap streamNameToOutputStreamListenerMap = new HashMap<>(); - private TCPEventServer tcpEventServer; - private String logPrefix = ""; - private ExecutorService executorService; - private int heartbeatInterval; - private ThroughputProbe inputThroughputProbe; - - private final ConnectionCallback connectionCallback; - - public SiddhiStormOutputEventListener(ExecutionPlanConfiguration executionPlanConfiguration, int tenantId, - DistributedConfiguration stormDeploymentConfig, ConnectionCallback connectionCallback) { - this.executionPlanConfiguration = executionPlanConfiguration; - this.tenantId = tenantId; - this.stormDeploymentConfig = stormDeploymentConfig; - this.heartbeatInterval = stormDeploymentConfig.getManagementHeartbeatInterval(); - this.connectionCallback = connectionCallback; - this.executorService = Executors.newSingleThreadExecutor(new ThreadFactoryBuilder(). - setNameFormat("Thread pool- component - SiddhiStormOutputEventListener.executorService;tenantId - " + - tenantId + ";executionPlanName - " + executionPlanConfiguration.getName()).build()); - init(); - } - - private void init() { - logPrefix = "[" + tenantId + ":" + executionPlanConfiguration.getName() + ":" + "CEPPublisher" + "] "; - log.info(logPrefix + "Initializing storm output event listener"); - inputThroughputProbe = new ThroughputProbe(logPrefix + "-Receive", 10); - inputThroughputProbe.startSampling(); - try { - thisHostIp = HostAddressFinder.findAddress("localhost"); - listeningPort = findPort(thisHostIp); - TCPEventServerConfig configs = new TCPEventServerConfig(thisHostIp, listeningPort); - tcpEventServer = new TCPEventServer(configs, this, connectionCallback); - tcpEventServer.start(); - executorService.execute(new Registrar()); - } catch (Exception e) { - log.error(logPrefix + "Failed to start event listener", e); - } - } - - - public void registerOutputStreamListener(StreamDefinition siddhiStreamDefinition, SiddhiOutputStreamListener outputStreamListener) { - log.info(logPrefix + "Registering output stream listener for Siddhi stream : " + siddhiStreamDefinition.getId()); - streamNameToOutputStreamListenerMap.put(siddhiStreamDefinition.getId(), outputStreamListener); - tcpEventServer.addStreamDefinition(siddhiStreamDefinition); - } - - @Override - public void receive(String streamId, long timestamp, Object[] eventData, Map arbitraryMapData) { - SiddhiOutputStreamListener outputStreamListener = streamNameToOutputStreamListenerMap.get(streamId); - if (outputStreamListener != null) { - outputStreamListener.sendEvent(new Event(timestamp, eventData)); - inputThroughputProbe.update(); - } else { - log.warn("Cannot find output event listener for stream " + streamId + " in execution plan " + executionPlanConfiguration.getName() - + " of tenant " + tenantId + ". Discarding Event:" + streamId + - ":" + Arrays.deepToString(eventData) + "@" + timestamp); - } - } - - private int findPort(String host) throws Exception { - for (int i = stormDeploymentConfig.getTransportMinPort(); i <= stormDeploymentConfig.getTransportMaxPort(); i++) { - if (!Utils.isPortUsed(i, host)) { - return i; - } - } - throw new Exception("Cannot find free port in range " + stormDeploymentConfig.getTransportMinPort() + "~" + stormDeploymentConfig.getTransportMaxPort()); - } - - public void shutdown() { - executorService.shutdown(); - tcpEventServer.shutdown(); - } - - - class Registrar implements Runnable { - private String managerHost; - private int managerPort; - - @Override - public void run() { - log.info(logPrefix + "Registering CEP publisher for " + thisHostIp + ":" + listeningPort); - - // Infinitely call register. Each register call will act as a heartbeat - while (true) { - if (registerCEPPublisherWithStormMangerService()) { - while (true) { - TTransport transport = null; - try { - transport = new TSocket(managerHost, managerPort); - TProtocol protocol = new TBinaryProtocol(transport); - transport.open(); - - StormManagerService.Client client = new StormManagerService.Client(protocol); - client.registerCEPPublisher(tenantId, executionPlanConfiguration.getName(), thisHostIp, - listeningPort); - if (log.isDebugEnabled()) { - log.debug(logPrefix + "Successfully registered CEP publisher for " + thisHostIp + ":" + - listeningPort); - } - try { - Thread.sleep(heartbeatInterval); - } catch (InterruptedException e1) { - Thread.currentThread().interrupt(); - } - } catch (Exception e) { - log.error(logPrefix + "Error in registering CEP publisher for " + thisHostIp + ":" + - listeningPort + " with manager " + managerHost + ":" + managerPort + ". Trying " + - "next manager after " + heartbeatInterval + "ms", e); - break; - } finally { - if (transport != null) { - transport.close(); - } - } - } - } else { - log.error(logPrefix + "Error registering CEP publisher with current manager. Retrying " + - "after " + heartbeatInterval + "ms"); - } - try { - Thread.sleep(heartbeatInterval); - } catch (InterruptedException e1) { - Thread.currentThread().interrupt(); - } - } - - } - - private boolean registerCEPPublisherWithStormMangerService() { - TTransport transport = null; - for (HostAndPort endpoint : stormDeploymentConfig.getManagers()) { - try { - transport = new TSocket(endpoint.getHostName(), endpoint.getPort()); - TProtocol protocol = new TBinaryProtocol(transport); - transport.open(); - - StormManagerService.Client client = new StormManagerService.Client(protocol); - client.registerCEPPublisher(tenantId, executionPlanConfiguration.getName(), thisHostIp, - listeningPort); - log.info(logPrefix + "Successfully registered CEP publisher for " + thisHostIp + ":" + - listeningPort + " with manager service at" + endpoint.getHostName() + ":" + endpoint.getPort()); - managerHost = endpoint.getHostName(); - managerPort = endpoint.getPort(); - return true; - } catch (Exception e) { - log.error(logPrefix + "Error in registering CEP publisher for " + thisHostIp + ":" + - listeningPort + " with manager " + endpoint.getHostName() + ":" + endpoint.getPort() + "." + - " Trying next manager", e); - continue; - } finally { - if (transport != null) { - transport.close(); - } - } - } - return false; - } - } -} diff --git a/components/event-processor/org.wso2.carbon.event.processor.core/src/main/java/org/wso2/carbon/event/processor/core/internal/storm/StormTopologyManager.java b/components/event-processor/org.wso2.carbon.event.processor.core/src/main/java/org/wso2/carbon/event/processor/core/internal/storm/StormTopologyManager.java deleted file mode 100644 index ed50c2f66..000000000 --- a/components/event-processor/org.wso2.carbon.event.processor.core/src/main/java/org/wso2/carbon/event/processor/core/internal/storm/StormTopologyManager.java +++ /dev/null @@ -1,397 +0,0 @@ -/* - * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.wso2.carbon.event.processor.core.internal.storm; - -import backtype.storm.StormSubmitter; -import backtype.storm.generated.*; -import backtype.storm.topology.TopologyBuilder; -import backtype.storm.utils.NimbusClient; -import backtype.storm.utils.Utils; -import com.hazelcast.core.HazelcastInstance; -import com.hazelcast.core.IMap; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.thrift7.TException; -import org.json.simple.JSONValue; -import org.w3c.dom.Document; -import org.wso2.carbon.event.processor.core.ExecutionPlanConfiguration; -import org.wso2.carbon.event.processor.core.exception.ExecutionPlanConfigurationException; -import org.wso2.carbon.event.processor.core.exception.ServerUnavailableException; -import org.wso2.carbon.event.processor.core.exception.StormDeploymentException; -import org.wso2.carbon.event.processor.core.exception.StormQueryConstructionException; -import org.wso2.carbon.event.processor.core.internal.ds.EventProcessorValueHolder; -import org.wso2.carbon.event.processor.core.internal.storm.util.StormQueryPlanBuilder; -import org.wso2.carbon.event.processor.core.internal.storm.util.StormTopologyConstructor; -import org.wso2.carbon.event.processor.core.util.DistributedModeConstants; -import org.wso2.carbon.event.processor.core.util.ExecutionPlanStatusHolder; -import org.wso2.carbon.event.processor.manager.core.config.DistributedConfiguration; -import org.wso2.carbon.utils.CarbonUtils; -import org.yaml.snakeyaml.Yaml; - -import javax.xml.XMLConstants; -import javax.xml.stream.XMLStreamException; -import javax.xml.transform.OutputKeys; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerException; -import javax.xml.transform.TransformerFactory; -import javax.xml.transform.dom.DOMSource; -import javax.xml.transform.stream.StreamResult; -import java.io.*; -import java.util.List; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ThreadFactory; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicInteger; - -/** - * The Siddhi Topology Manager - */ -public class StormTopologyManager { - - private Map stormConfig; - private String jarLocation; - private static final Log log = LogFactory.getLog(StormTopologyManager.class); - private final ConcurrentHashMap toDeployTopologies = new ConcurrentHashMap(); - private TopologyManagerThreadFactory topologyManagerThreadFactory = new TopologyManagerThreadFactory("Storm Deployment"); - private final int lockTimeout; - - public StormTopologyManager() { - String stormConfigDirPath = CarbonUtils.getCarbonConfigDirPath() + File.separator + "cep" + File.separator + "storm"; - try { - InputStream stormConf = new FileInputStream(new File(stormConfigDirPath + File.separator + "storm.yaml")); - Yaml yaml = new Yaml(); - Map data = (Map) yaml.load(stormConf); - if (data != null) { //Can be null for a commented out config - stormConfig = Utils.readDefaultConfig(); - stormConfig.putAll(data); - } else { - stormConfig = Utils.readStormConfig(); - } - } catch (FileNotFoundException e) { - log.warn("Error occurred while reading storm configurations using default configurations", e); - } - - DistributedConfiguration stormDeploymentConfiguration = EventProcessorValueHolder.getStormDeploymentConfiguration(); - lockTimeout = stormDeploymentConfiguration.getStatusLockTimeout(); - - jarLocation = stormConfigDirPath + File.separator + EventProcessorValueHolder.getStormDeploymentConfiguration().getJar(); - } - - public List getTopologies() throws StormDeploymentException { - try { - Nimbus.Client client = NimbusClient.getConfiguredClient(stormConfig).getClient(); - return client.getClusterInfo().get_topologies(); - } catch (TException e) { - throw new StormDeploymentException("Cannot get topologies from storm cluster", e); - } - } - - public void submitTopology(ExecutionPlanConfiguration configuration, List importStreams, - List exportStreams, int tenantId, int resubmitRetryInterval) throws - StormDeploymentException, ExecutionPlanConfigurationException { - String executionPlanName = configuration.getName(); - TopologyBuilder builder; - String topologyName = getTopologyName(executionPlanName, tenantId); - - try { - Document document = StormQueryPlanBuilder.constructStormQueryPlanXML(configuration, importStreams, exportStreams); - String stormQueryPlan = getStringQueryPlan(document); - if (log.isDebugEnabled()) { - log.debug("Following is the generated Storm query plan for execution plan: " + configuration.getName() + - "\n" + stormQueryPlan); - } - builder = StormTopologyConstructor.constructTopologyBuilder(stormQueryPlan, executionPlanName, tenantId, - EventProcessorValueHolder.getStormDeploymentConfiguration()); - } catch (XMLStreamException e) { - throw new StormDeploymentException("Invalid Config for Execution Plan " + executionPlanName + " for tenant " + tenantId, e); - } catch (TransformerException e) { - throw new StormDeploymentException("Error while converting to storm query plan string. " + - "Execution plan: " + executionPlanName + " Tenant: " + tenantId, e); - } catch (StormQueryConstructionException e) { - throw new StormDeploymentException("Error while converting to XML storm query plan. " + - "Execution plan: " + executionPlanName + " Tenant: " + tenantId + ". " + e.getMessage(), e); - } - - TopologySubmitter topologySubmitter = new TopologySubmitter(executionPlanName, builder.createTopology(), tenantId, resubmitRetryInterval); - synchronized (toDeployTopologies) { - toDeployTopologies.put(topologyName, topologySubmitter); - } - - Thread deploymentThread = topologyManagerThreadFactory.newThread(topologySubmitter); - deploymentThread.start(); - - } - - public void killTopology(String executionPlanName, int tenantId) throws StormDeploymentException { - try { - synchronized (toDeployTopologies) { - toDeployTopologies.remove(getTopologyName(executionPlanName, tenantId)); - } - log.info("Killing storm topology '" + executionPlanName + "' of tenant '" + tenantId + "'"); - Nimbus.Client client = NimbusClient.getConfiguredClient(stormConfig).getClient(); - client.killTopologyWithOpts(getTopologyName(executionPlanName, tenantId), new KillOptions()); //provide topology name - } catch (NotAliveException e) { - // do nothing - } catch (TException e) { - throw new StormDeploymentException("Error connecting to Storm", e); - } - } - - private String getStringQueryPlan(Document document) throws TransformerException { - TransformerFactory transformerFactory = TransformerFactory.newInstance(); - transformerFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true); - Transformer transformer = transformerFactory.newTransformer(); - transformer.setOutputProperty(OutputKeys.INDENT, "yes"); - StringWriter sw = new StringWriter(); - StreamResult result = new StreamResult(sw); - DOMSource source = new DOMSource(document); - transformer.transform(source, result); - return sw.toString(); //returning the xmlString - } - - public static String getTopologyName(String executionPlanName, int tenantId) { - return (executionPlanName + "[" + tenantId + "]"); - } - - class TopologySubmitter implements Runnable { - private final String topologyName; - StormTopology topology; - int retryInterval; - - public TopologySubmitter(String executionPlanName, StormTopology topology, - int tenantId, int resubmitRetryInterval) { - this.topologyName = getTopologyName(executionPlanName, tenantId); - this.topology = topology; - this.retryInterval = resubmitRetryInterval; - } - - @Override - public void run() { - String jobPrefix = "TopologySubmitterJob:" + Thread.currentThread().getId() + ", "; - log.info(jobPrefix + "Job started to submit storm topology '" + topologyName + "'."); - while (true) { - if (!isToBeDeployed()) { - log.info(jobPrefix + "Aborting Storm deployment of '" + topologyName + "', as current job is outdated."); - return; - } - try { - if (isTopologyExist()) { - updateExecutionPlanStatusInStorm(topologyName, DistributedModeConstants.TopologyState.CLEANING); - log.info(jobPrefix + "Killing already existing storm topology '" + topologyName + "' to re-submit"); - KillOptions options = new KillOptions(); - options.set_wait_secs(10); - try { - Nimbus.Client client = NimbusClient.getConfiguredClient(stormConfig).getClient(); - client.killTopologyWithOpts(topologyName, options); - waitForTopologyToBeRemoved(jobPrefix); - } catch (NotAliveException e) { - log.info(jobPrefix + "Topology '" + topologyName + "' is not alive to kill"); - } catch (TException e) { - log.error(jobPrefix + "Error connecting to storm when trying to kill topology '" + topologyName + "'", e); - log.info(jobPrefix + "Retrying to kill topology '" + topologyName + "' in " + retryInterval + " ms"); - try { - Thread.sleep(retryInterval); - } catch (InterruptedException e1) { - //ignore - } - } - } else { - updateExecutionPlanStatusInStorm(topologyName, DistributedModeConstants.TopologyState.DEPLOYING); - try { - String jsonConf = JSONValue.toJSONString(stormConfig); - synchronized (toDeployTopologies) { - if (isToBeDeployed()) { - String uploadedJarLocation = StormSubmitter.submitJar(stormConfig, jarLocation); - Nimbus.Client client = NimbusClient.getConfiguredClient(stormConfig).getClient(); - client.submitTopology(topologyName, uploadedJarLocation, jsonConf, topology); - toDeployTopologies.remove(topologyName); - log.info(jobPrefix + "Successfully submitted storm topology '" + topologyName + "'"); - waitForTopologyToBeActive(client, jobPrefix, topologyName); - return; - } else { - log.info(jobPrefix + "Aborting Storm deployment of '" + topologyName + "', as current job is outdated."); - return; - } - } - } catch (InvalidTopologyException e) { - log.error(jobPrefix + "Cannot deploy, Invalid Storm topology '" + topologyName + "' found.", e); - return; - } catch (AlreadyAliveException e) { - log.warn(jobPrefix + "Topology '" + topologyName + "' already existing. Trying to kill and re-submit", e); - } catch (TException e) { - log.error(jobPrefix + "Error connecting to storm when trying to submit topology '" + topologyName + "'", e); - log.info(jobPrefix + "Retrying to submit topology '" + topologyName + "' in " + retryInterval + " ms"); - try { - Thread.sleep(retryInterval); - } catch (InterruptedException e1) { - //ignore - } - } - } - } catch (ServerUnavailableException e) { - log.error(jobPrefix + e.getMessage(), e); - log.info(jobPrefix + "Retrying to submit topology '" + topologyName + "' in " + retryInterval + " ms"); - try { - Thread.sleep(retryInterval); - } catch (InterruptedException e1) { - //ignore - } - } - } - } - - private boolean isToBeDeployed() { - synchronized (toDeployTopologies) { - TopologySubmitter existingTopologySubmitter = toDeployTopologies.get(topologyName); - return existingTopologySubmitter != null && existingTopologySubmitter.equals(this); - } - } - - private boolean isTopologyExist() throws ServerUnavailableException { - try { - Nimbus.Client client = NimbusClient.getConfiguredClient(stormConfig).getClient(); - List topologies = client.getClusterInfo().get_topologies(); - for (TopologySummary topologySummary : topologies) { - if (topologySummary.get_name().equals(topologyName)) { - return true; - } - } - return false; - } catch (TException e) { - throw new ServerUnavailableException("Error connecting to storm when trying to check whether topology '" + topologyName + "' exist", e); - } catch (RuntimeException e) { - throw new ServerUnavailableException("Runtime Exception connecting to storm when trying to check whether topology '" + topologyName + "' exist", e); - } - } - - private void waitForTopologyToBeActive(Nimbus.Client client, String jobPrefix, String topologyName) throws TException { - TopologySummary thisTopologySummary = null; - while(thisTopologySummary == null){ - List topologySummaryList = client.getClusterInfo().get_topologies(); - for (TopologySummary topologySummary: topologySummaryList) { - if(topologySummary.get_name().equals(topologyName)){ - thisTopologySummary = topologySummary; - } - } - if(thisTopologySummary == null){ - try { - Thread.sleep(2000); - log.info(jobPrefix + "Waiting until '" + topologyName + "' has been submitted to Storm cluster"); - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); - updateExecutionPlanStatusInStorm(topologyName, DistributedModeConstants.TopologyState.UNKNOWN); - log.error("Could not verify whether " + topologyName + "' has been submitted to Storm cluster or not" + - " as the verifier got interrupted. Setting distributed deployment status as UNKNOWN"); - return; - } - } - } - while (true) { - if (thisTopologySummary.get_status().equals(TopologyInitialStatus.ACTIVE.toString())) { - updateExecutionPlanStatusInStorm(topologyName, DistributedModeConstants.TopologyState.ACTIVE); - log.info(jobPrefix + "Topology '" + topologyName + "' found to be active in Storm cluster"); - return; - } else { - try { - log.info(jobPrefix + "Waiting until '" + topologyName + "' becomes active in Storm cluster"); - Thread.sleep(2000); - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); - } - } - } - } - - private void waitForTopologyToBeRemoved(String jobPrefix) throws TException, ServerUnavailableException { - log.info(jobPrefix + "Waiting for topology '" + topologyName + "' to be removed from Storm cluster"); - try { - while (true) { - if (isTopologyExist()) { - Thread.sleep(5000); - } else { - Thread.sleep(2000); - log.info(jobPrefix + "Topology '" + topologyName + "' removed from Storm cluster"); - return; - } - } - } catch (InterruptedException e) { - } - } - - private void updateExecutionPlanStatusInStorm(String stormTopologyName, - DistributedModeConstants.TopologyState topologyState) { - String executionPlanStatusHolderKey = DistributedModeConstants.STORM_STATUS_MAP + "." + stormTopologyName; - HazelcastInstance hazelcastInstance = EventProcessorValueHolder.getHazelcastInstance(); - if (hazelcastInstance != null && hazelcastInstance.getLifecycleService().isRunning()) { - IMap executionPlanStatusHolderIMap = hazelcastInstance.getMap(DistributedModeConstants.STORM_STATUS_MAP); - try { - if (executionPlanStatusHolderIMap.tryLock(executionPlanStatusHolderKey, lockTimeout, TimeUnit.MILLISECONDS)) { - try { - ExecutionPlanStatusHolder executionPlanStatusHolder = - executionPlanStatusHolderIMap.get(stormTopologyName); - if (executionPlanStatusHolder == null) { - log.error("Couldn't update topology status for topology:" + topologyName + " as status object not initialized by manager."); - } else { - executionPlanStatusHolder.setStormTopologyStatus(topologyState); - executionPlanStatusHolderIMap.replace(stormTopologyName, executionPlanStatusHolder); - } - } finally { - executionPlanStatusHolderIMap.unlock(executionPlanStatusHolderKey); - } - } else { - log.error("Couldn't update topology status for topology:" + topologyName - + " as the hazelcast lock acquisition failed."); - } - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); - log.error("Couldn't update topology status for topology:" + topologyName - + " as the hazelcast lock acquisition was interrupted.", e); - } - } else { - log.error("Couldn't update topology status for topology:" + topologyName - + " as the hazelcast instance is not active or not available."); - } - } - } - - class TopologyManagerThreadFactory implements ThreadFactory { - final AtomicInteger poolNumber = new AtomicInteger(1); - final ThreadGroup group; - final AtomicInteger threadNumber = new AtomicInteger(1); - final String namePrefix; - - public TopologyManagerThreadFactory(String threadPoolExecutorName) { - SecurityManager s = System.getSecurityManager(); - this.group = s != null ? s.getThreadGroup() : Thread.currentThread().getThreadGroup(); - this.namePrefix = "TopologyManager-" + threadPoolExecutorName + "-pool-" + poolNumber.getAndIncrement() + "-thread-"; - } - - public Thread newThread(Runnable r) { - Thread t = new Thread(this.group, r, this.namePrefix + this.threadNumber.getAndIncrement(), 0L); - if (t.isDaemon()) { - t.setDaemon(false); - } - - if (t.getPriority() != 5) { - t.setPriority(5); - } - - return t; - } - } - -} diff --git a/components/event-processor/org.wso2.carbon.event.processor.core/src/main/java/org/wso2/carbon/event/processor/core/internal/storm/compiler/SiddhiQLStormQuerySplitter.java b/components/event-processor/org.wso2.carbon.event.processor.core/src/main/java/org/wso2/carbon/event/processor/core/internal/storm/compiler/SiddhiQLStormQuerySplitter.java deleted file mode 100644 index 3f3704ab3..000000000 --- a/components/event-processor/org.wso2.carbon.event.processor.core/src/main/java/org/wso2/carbon/event/processor/core/internal/storm/compiler/SiddhiQLStormQuerySplitter.java +++ /dev/null @@ -1,150 +0,0 @@ -/* - * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.wso2.carbon.event.processor.core.internal.storm.compiler; - -import org.antlr.v4.runtime.ANTLRInputStream; -import org.antlr.v4.runtime.CommonTokenStream; -import org.antlr.v4.runtime.misc.Interval; -import org.antlr.v4.runtime.misc.NotNull; -import org.antlr.v4.runtime.tree.ParseTree; -import org.wso2.siddhi.query.compiler.SiddhiQLBaseVisitor; -import org.wso2.siddhi.query.compiler.SiddhiQLLexer; -import org.wso2.siddhi.query.compiler.SiddhiQLParser; -import org.wso2.siddhi.query.compiler.SiddhiQLVisitor; -import org.wso2.siddhi.query.compiler.internal.SiddhiErrorListener; - -import java.util.ArrayList; -import java.util.List; - -/** - * Visitor implementation for Storm Compiler - */ -public class SiddhiQLStormQuerySplitter extends SiddhiQLBaseVisitor { - - - public static List split(String source) { - ANTLRInputStream input = new ANTLRInputStream(source); - SiddhiQLLexer lexer = new SiddhiQLLexer(input); - lexer.removeErrorListeners(); - lexer.addErrorListener(SiddhiErrorListener.INSTANCE); - - CommonTokenStream tokens = new CommonTokenStream(lexer); - SiddhiQLParser parser = new SiddhiQLParser(tokens); - parser.removeErrorListeners(); - parser.addErrorListener(SiddhiErrorListener.INSTANCE); - ParseTree tree = parser.parse(); - - SiddhiQLVisitor eval = new SiddhiQLStormQuerySplitter(); - List queryList = (List) eval.visit(tree); - return queryList; - } - - - - public static List getEventTableList(String source) { - ANTLRInputStream input = new ANTLRInputStream(source); - SiddhiQLLexer lexer = new SiddhiQLLexer(input); - lexer.removeErrorListeners(); - lexer.addErrorListener(SiddhiErrorListener.INSTANCE); - - CommonTokenStream tokens = new CommonTokenStream(lexer); - SiddhiQLParser parser = new SiddhiQLParser(tokens); - parser.removeErrorListeners(); - parser.addErrorListener(SiddhiErrorListener.INSTANCE); - ParseTree tree = parser.parse(); - - SiddhiQLVisitor eval = new SiddhiQLStormQuerySplitter(); - List eventTableList = new ArrayList<>(); - SiddhiQLParser.Execution_planContext ctx = (((SiddhiQLParser.ParseContext)tree).execution_plan()); - - for (SiddhiQLParser.Definition_tableContext executionElementContext : ctx.definition_table()) { - String query = (String) eval.visit(executionElementContext); - eventTableList.add(query); - } - - return eventTableList; - } - - /** - * {@inheritDoc} - *

- *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- * - * @param ctx - */ - @Override - public Object visitParse(@NotNull SiddhiQLParser.ParseContext ctx) { - return visit(ctx.execution_plan()); - } - - /** - * {@inheritDoc} - *

- *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- * - * @param ctx - */ - @Override - public List visitExecution_plan(@NotNull SiddhiQLParser.Execution_planContext ctx) { - List stringQueryList = new ArrayList(); - for (SiddhiQLParser.Execution_elementContext executionElementContext : ctx.execution_element()) { - String query = (String) visit(executionElementContext); - stringQueryList.add(query); - } - return stringQueryList; - } - - /** - * {@inheritDoc} - *

- *

Returns the string rule related for this section.

- * - * @param ctx - */ - @Override - public String visitQuery(@NotNull SiddhiQLParser.QueryContext ctx) { - int a = ctx.start.getStartIndex(); - int b = ctx.stop.getStopIndex(); - Interval interval = new Interval(a,b); - return ctx.start.getInputStream().getText(interval); - } - - /** - * {@inheritDoc} - *

- *

Returns the string rule related for this section.

- * - * @param ctx - */ - @Override - public String visitPartition(@NotNull SiddhiQLParser.PartitionContext ctx) { - int a = ctx.start.getStartIndex(); - int b = ctx.stop.getStopIndex(); - Interval interval = new Interval(a,b); - return ctx.start.getInputStream().getText(interval); - } - - @Override - public String visitDefinition_table(@NotNull SiddhiQLParser.Definition_tableContext ctx){ - int a = ctx.start.getStartIndex(); - int b = ctx.stop.getStopIndex(); - Interval interval = new Interval(a,b); - return ctx.start.getInputStream().getText(interval); - - } -} diff --git a/components/event-processor/org.wso2.carbon.event.processor.core/src/main/java/org/wso2/carbon/event/processor/core/internal/storm/manager/StormManagerServer.java b/components/event-processor/org.wso2.carbon.event.processor.core/src/main/java/org/wso2/carbon/event/processor/core/internal/storm/manager/StormManagerServer.java deleted file mode 100644 index c7ff33c99..000000000 --- a/components/event-processor/org.wso2.carbon.event.processor.core/src/main/java/org/wso2/carbon/event/processor/core/internal/storm/manager/StormManagerServer.java +++ /dev/null @@ -1,159 +0,0 @@ -/* - * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.wso2.carbon.event.processor.core.internal.storm.manager; - -import com.google.common.util.concurrent.ThreadFactoryBuilder; -import com.hazelcast.core.HazelcastInstance; -import com.hazelcast.core.ILock; -import com.hazelcast.core.IMap; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.thrift.server.TServer; -import org.apache.thrift.server.TThreadPoolServer; -import org.apache.thrift.transport.TServerSocket; -import org.apache.thrift.transport.TTransportException; -import org.wso2.carbon.event.processor.common.storm.manager.service.StormManagerService; -import org.wso2.carbon.event.processor.core.internal.ds.EventProcessorValueHolder; - -import java.net.InetSocketAddress; -import java.util.concurrent.Future; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.ScheduledThreadPoolExecutor; -import java.util.concurrent.TimeUnit; - -public class StormManagerServer { - - private static final String STORM_HZ_MAP_ACTIVE_MANAGER_KEY = "storm.hazelcast.map.active.manager.key"; - private static final String STORM_ROLE_TO_MEMBERSHIP_HZ_MAP = "storm.role.membership.hazelcast.map"; - - private static Log log = LogFactory.getLog(StormManagerServer.class); - private TThreadPoolServer stormManagerServer; - private StormManagerServiceImpl stormManagerService; - private IMap roleToMembershipMap; - HazelcastInstance hazelcastInstance; - private String myHazelcastId; - private Future stateChecker = null; - private ScheduledExecutorService executorService; - - public StormManagerServer(String hostName, int port) { - - try { - stormManagerService = new StormManagerServiceImpl(hostName + ":" + port); - TServerSocket serverTransport = new TServerSocket( - new InetSocketAddress(hostName, port)); - StormManagerService.Processor processor = - new StormManagerService.Processor(stormManagerService); - stormManagerServer = new TThreadPoolServer( - new TThreadPoolServer.Args(serverTransport).processor(processor)); - Thread thread = new Thread(new ServerThread(stormManagerServer)); - thread.start(); - - log.info("CEP Storm Management Thrift Server started on " + hostName + ":" + port); - executorService = new ScheduledThreadPoolExecutor(3,new ThreadFactoryBuilder(). - setNameFormat("Thread pool- component - StormManagerServer.executorService").build()); - } catch (TTransportException e) { - log.error("Cannot start Storm Manager Server on " + hostName + ":" + port, e); - } - } - - public void setHzaelCastInstance(HazelcastInstance hazelcastInstance){ - this.hazelcastInstance = hazelcastInstance; - this.roleToMembershipMap = hazelcastInstance.getMap(STORM_ROLE_TO_MEMBERSHIP_HZ_MAP); - myHazelcastId = hazelcastInstance.getCluster().getLocalMember().getUuid(); - - } - - /** - * To stop the server - */ - public void stop() { - stormManagerServer.stop(); - executorService.shutdown(); - - if (stateChecker != null){ - stateChecker.cancel(false); - } - } - - public void onExecutionPlanRemove(String excPlanName, int tenantId){ - // Delete all end points of the removed execution plan from manager service. - stormManagerService.deleteExecPlanEndpoints(tenantId, excPlanName); - } - - public void setStormCoordinator(boolean isCoordinator) { - stormManagerService.setStormCoordinator(isCoordinator); - - if (!isCoordinator){ - stateChecker = executorService.schedule(new PeriodicStateChanger(), 10000, TimeUnit.MILLISECONDS); - } - } - - public boolean isStormCoordinator() { - return stormManagerService.isStormCoordinator(); - } - - static class ServerThread implements Runnable { - private TServer server; - - ServerThread(TServer server) { - this.server = server; - } - - public void run() { - this.server.serve(); - } - } - - public void verifyState(){ - if (isStormCoordinator() && roleToMembershipMap != null && - roleToMembershipMap.get(STORM_HZ_MAP_ACTIVE_MANAGER_KEY) != null && - !roleToMembershipMap.get(STORM_HZ_MAP_ACTIVE_MANAGER_KEY).equals(myHazelcastId)){ - - log.info("Resigning as storm coordinator as there's another storm coordinator available in the cluster with member id " - + roleToMembershipMap.get(STORM_HZ_MAP_ACTIVE_MANAGER_KEY)); - - setStormCoordinator(false); - } - } - - public synchronized void tryBecomeCoordinator() { - HazelcastInstance hazelcastInstance = EventProcessorValueHolder.getHazelcastInstance(); - if (hazelcastInstance != null) { - if(!isStormCoordinator()) { - ILock lock = hazelcastInstance.getLock("StormCoordinator"); - boolean isCoordinator = lock.tryLock(); - setStormCoordinator(isCoordinator); - if (isCoordinator) { - log.info("Node became the Storm coordinator with member id " + myHazelcastId); - if (roleToMembershipMap != null){ - roleToMembershipMap.put(STORM_HZ_MAP_ACTIVE_MANAGER_KEY, myHazelcastId); - } - } - } - } - } - - class PeriodicStateChanger implements Runnable { - - @Override - public void run() { - tryBecomeCoordinator(); - } - } - - -} diff --git a/components/event-processor/org.wso2.carbon.event.processor.core/src/main/java/org/wso2/carbon/event/processor/core/internal/storm/manager/StormManagerServiceImpl.java b/components/event-processor/org.wso2.carbon.event.processor.core/src/main/java/org/wso2/carbon/event/processor/core/internal/storm/manager/StormManagerServiceImpl.java deleted file mode 100644 index 52e948e41..000000000 --- a/components/event-processor/org.wso2.carbon.event.processor.core/src/main/java/org/wso2/carbon/event/processor/core/internal/storm/manager/StormManagerServiceImpl.java +++ /dev/null @@ -1,227 +0,0 @@ -/* - * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.wso2.carbon.event.processor.core.internal.storm.manager; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.thrift.TException; -import org.wso2.carbon.event.processor.common.storm.manager.service.StormManagerService; -import org.wso2.carbon.event.processor.common.storm.manager.service.exception.EndpointNotFoundException; -import org.wso2.carbon.event.processor.common.storm.manager.service.exception.NotStormCoordinatorException; - -import java.util.HashSet; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; - -public class StormManagerServiceImpl implements StormManagerService.Iface { - private static Log log = LogFactory.getLog(StormManagerServiceImpl.class); - public static final long MILLISECONDS_PER_MINUTE = 60000; - private ConcurrentHashMap> stormReceivers = new ConcurrentHashMap>(); - private ConcurrentHashMap> cepPublishers = new ConcurrentHashMap>(); - private boolean isStormCoordinator; - private String hostPort; - - public StormManagerServiceImpl(String hostPort) { - this.hostPort = hostPort; - } - - @Override - public void registerStormReceiver(int tenantId, String executionPlanName, String hostName, int port) throws NotStormCoordinatorException, TException { - if (!isStormCoordinator) { - throw new NotStormCoordinatorException(hostPort + " not a storm coordinator"); - } - insertToCollection(stormReceivers, constructKey(tenantId, executionPlanName), new Endpoint(port, hostName)); - } - - @Override - public void registerCEPPublisher(int tenantId, String executionPlanName, String hostName, int port) throws NotStormCoordinatorException, TException { - if (!isStormCoordinator) { - throw new NotStormCoordinatorException(hostPort + " not a storm coordinator"); - } - insertToCollection(cepPublishers, constructKey(tenantId, executionPlanName), new Endpoint(port, hostName)); - } - - @Override - public synchronized String getStormReceiver(int tenantId, String executionPlanName, String cepReceiverHostName) throws NotStormCoordinatorException, EndpointNotFoundException, TException { - if (!isStormCoordinator) { - throw new NotStormCoordinatorException(hostPort + " not a storm coordinator"); - } - Set endpointSet = stormReceivers.get(constructKey(tenantId, executionPlanName)); - Endpoint selectedEndpoint = getEndpoint(endpointSet, cepReceiverHostName); - - if (null != selectedEndpoint) { - return selectedEndpoint.getHostName() + ":" + selectedEndpoint.getPort(); - } else { - throw new EndpointNotFoundException("No Storm Receiver for executionPlanName: " + executionPlanName + " of tenantId:" + tenantId + " for CEP Receiver form:" + cepReceiverHostName); - } - - } - - @Override - public synchronized String getCEPPublisher(int tenantId, String executionPlanName, String stormPublisherHostName) throws NotStormCoordinatorException, EndpointNotFoundException, TException { - if (!isStormCoordinator) { - throw new NotStormCoordinatorException(hostPort + " not a storm coordinator"); - } - Set endpointSet = cepPublishers.get(constructKey(tenantId, executionPlanName)); - Endpoint selectedEndpoint = getEndpoint(endpointSet, stormPublisherHostName); - - if (null != selectedEndpoint) { - return selectedEndpoint.getHostName() + ":" + selectedEndpoint.getPort(); - } else { - throw new EndpointNotFoundException("No CEP Publisher for executionPlanName: " + executionPlanName + " of tenantId:" + tenantId + " for Storm Publisher form:" + stormPublisherHostName); - } - } - - public synchronized void deleteExecPlanEndpoints(int tenantId, String executionPlanName){ - Set endpointSet = cepPublishers.get(constructKey(tenantId, executionPlanName)); - if (endpointSet != null){ - cepPublishers.remove(constructKey(tenantId, executionPlanName)); - } - - endpointSet = stormReceivers.get(constructKey(tenantId, executionPlanName)); - if (endpointSet != null){ - stormReceivers.remove(constructKey(tenantId, executionPlanName)); - } - - log.info("Removed all end point details related to '" + constructKey(tenantId, executionPlanName) + "' from Manager service."); - } - - private synchronized Endpoint getEndpoint(Set endpointSet, String requesterIp) { - Endpoint selectedEndpoint = null; - - Set sameHostEndpoints = new HashSet(); - if (endpointSet != null && !endpointSet.isEmpty()) { - - if (!"".equals(requesterIp)) { - for (Endpoint endpoint : endpointSet) { - if (endpoint.getHostName().equals(requesterIp)) { - sameHostEndpoints.add(endpoint); - } - } - } - - // If there's a storm receivers/cep publishers in the same host as requester IP select among them - if (!sameHostEndpoints.isEmpty()) { - selectedEndpoint = selectEndpoint(sameHostEndpoints); - }else{ - selectedEndpoint = selectEndpoint(endpointSet); - } - - if (selectedEndpoint != null) { - selectedEndpoint.setConnectionCount(selectedEndpoint.getConnectionCount() + 1); - } - } - return selectedEndpoint; - } - - private synchronized Endpoint selectEndpoint(Set endpointSet) { - Endpoint selectedEndpoint = null; - int minConnectionCount = Integer.MAX_VALUE; - for (Endpoint endpoint : endpointSet) { - if (endpoint.getConnectionCount() < minConnectionCount){ - if (endpoint.getLastRegisterTimestamp() >= (System.currentTimeMillis() - MILLISECONDS_PER_MINUTE)){ - minConnectionCount = endpoint.getConnectionCount(); - selectedEndpoint = endpoint; - }else{ - - log.warn("Ignoring endpoint " + endpoint.getHostName() + ":" + endpoint.getPort() + " because it has not sent a heart beat for " - + (int) Math.floor((System.currentTimeMillis() - endpoint.getLastRegisterTimestamp()) / MILLISECONDS_PER_MINUTE) + " min(s)"); - } - } - } - return selectedEndpoint; - } - - private static synchronized void insertToCollection(ConcurrentHashMap> collection, String key, Endpoint endpoint) { - Set endpointSet = collection.get(key); - boolean isHeartbeat = false; - - if (endpointSet == null) { - endpointSet = new HashSet(); - collection.put(key, endpointSet); - }else{ - for (Endpoint currentEndpoint : endpointSet){ - if (currentEndpoint.equals(endpoint)){ - isHeartbeat = true; - currentEndpoint.updateLastRegisteredTimestamp(); - break; - } - } - } - - if (!isHeartbeat){ - endpointSet.add(endpoint); - } - } - - private static String constructKey(int tenantId, String executionPlanName) { - return tenantId + ":" + executionPlanName; - } - - public void setStormCoordinator(boolean isStormCoordinator) { - this.isStormCoordinator = isStormCoordinator; - } - - private class Endpoint { - private int port; - private String hostName; - private int connectionCount = 0; - private long lastRegisterTimestamp; - - Endpoint(int port, String hostName) { - this.port = port; - this.hostName = hostName; - this.lastRegisterTimestamp = System.currentTimeMillis(); - } - - public long getLastRegisterTimestamp(){return lastRegisterTimestamp;} - - public void updateLastRegisteredTimestamp(){ - lastRegisterTimestamp = System.currentTimeMillis(); - } - - public String getHostName() { - return hostName; - } - - public int getPort() { - return port; - } - - public void setConnectionCount(int connections) { - connectionCount = connections; - } - - public int getConnectionCount() { - return connectionCount; - } - - @Override - public boolean equals(Object object){ - if (object == null || (this.getClass() != object.getClass())){ - return false; - } - final Endpoint argument = (Endpoint)object; - - return ((this.hostName.equals(argument.getHostName())) && (this.port == argument.getPort())); - } - } - - public boolean isStormCoordinator() { - return isStormCoordinator; - } -} diff --git a/components/event-processor/org.wso2.carbon.event.processor.core/src/main/java/org/wso2/carbon/event/processor/core/internal/storm/status/monitor/StormStatusHolderInitializer.java b/components/event-processor/org.wso2.carbon.event.processor.core/src/main/java/org/wso2/carbon/event/processor/core/internal/storm/status/monitor/StormStatusHolderInitializer.java deleted file mode 100644 index 1feb2c6f9..000000000 --- a/components/event-processor/org.wso2.carbon.event.processor.core/src/main/java/org/wso2/carbon/event/processor/core/internal/storm/status/monitor/StormStatusHolderInitializer.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.wso2.carbon.event.processor.core.internal.storm.status.monitor; - -import com.hazelcast.core.HazelcastInstance; -import com.hazelcast.core.IMap; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.event.processor.core.internal.ds.EventProcessorValueHolder; -import org.wso2.carbon.event.processor.core.internal.storm.StormTopologyManager; -import org.wso2.carbon.event.processor.core.util.DistributedModeConstants; -import org.wso2.carbon.event.processor.core.util.ExecutionPlanStatusHolder; - -/** - * Utility to initialize the statusHolder. - */ -public class StormStatusHolderInitializer { - private static Log log = LogFactory.getLog(StormStatusHolderInitializer.class); - - public static void initializeStatusHolder(String executionPlanName, int tenantId, - int parallel) { - String stormTopologyName = StormTopologyManager.getTopologyName(executionPlanName, tenantId); - - HazelcastInstance hazelcastInstance = EventProcessorValueHolder.getHazelcastInstance(); - if (hazelcastInstance != null && hazelcastInstance.getLifecycleService().isRunning()) { - IMap executionPlanStatusHolderIMap = hazelcastInstance.getMap(DistributedModeConstants.STORM_STATUS_MAP); - ExecutionPlanStatusHolder executionPlanStatusHolder = new ExecutionPlanStatusHolder(parallel); - executionPlanStatusHolderIMap.put(stormTopologyName, executionPlanStatusHolder); - } else { - log.error("Couldn't initialize status info object for execution plan: " + executionPlanName + - ", for tenant-ID: " + tenantId - + " as the hazelcast instance is not active or not available."); - } - } -} diff --git a/components/event-processor/org.wso2.carbon.event.processor.core/src/main/java/org/wso2/carbon/event/processor/core/internal/storm/status/monitor/StormStatusMapListener.java b/components/event-processor/org.wso2.carbon.event.processor.core/src/main/java/org/wso2/carbon/event/processor/core/internal/storm/status/monitor/StormStatusMapListener.java deleted file mode 100644 index 779adb1d7..000000000 --- a/components/event-processor/org.wso2.carbon.event.processor.core/src/main/java/org/wso2/carbon/event/processor/core/internal/storm/status/monitor/StormStatusMapListener.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.wso2.carbon.event.processor.core.internal.storm.status.monitor; - -import com.hazelcast.core.EntryEvent; -import com.hazelcast.core.HazelcastInstance; -import com.hazelcast.map.listener.EntryAddedListener; -import com.hazelcast.map.listener.EntryUpdatedListener; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.event.processor.core.internal.ds.EventProcessorValueHolder; -import org.wso2.carbon.event.processor.core.internal.storm.StormTopologyManager; -import org.wso2.carbon.event.processor.core.internal.storm.status.monitor.exception.DeploymentStatusMonitorException; -import org.wso2.carbon.event.processor.core.util.DistributedModeConstants; - -public class StormStatusMapListener { - - private static final Log log = LogFactory.getLog(StormStatusMapListener.class); - - private final String listenerId; - private final HazelcastInstance hazelcastInstance; - private final StormStatusMonitor stormStatusMonitor; - private String executionPlanName; - private int tenantId; - - public StormStatusMapListener(String executionPlanName, int tenantId, - StormStatusMonitor stormStatusMonitor) - throws DeploymentStatusMonitorException { - hazelcastInstance = EventProcessorValueHolder.getHazelcastInstance(); - if (hazelcastInstance == null) { - throw new DeploymentStatusMonitorException("Couldn't initialize Distributed Deployment Status monitor as" + - " the hazelcast instance is not available. Enable clustering and restart the server"); //not giving context info, since this is not a per execution plan or tenant specific exception. - } else if (!hazelcastInstance.getLifecycleService().isRunning()) { - throw new DeploymentStatusMonitorException("Couldn't initialize Distributed Deployment Status monitor as" + - " the hazelcast instance is not active."); //not giving context info, since this is not a per execution plan or tenant specific exception. - } - this.executionPlanName = executionPlanName; - this.tenantId = tenantId; - String stormTopologyName = StormTopologyManager.getTopologyName(executionPlanName, tenantId); - listenerId = hazelcastInstance.getMap(DistributedModeConstants.STORM_STATUS_MAP). - addEntryListener(new MapListenerImpl(), stormTopologyName, true); - this.stormStatusMonitor = stormStatusMonitor; - } - - /** - * Clean up method, removing the entry listener. - */ - public void removeEntryListener() { - if (hazelcastInstance == null) { - log.error("Couldn't unregister entry listener for execution plan: " + executionPlanName + - ", for tenant-ID: " + tenantId - + " as the hazelcast instance is not available."); - } else if (hazelcastInstance.getLifecycleService().isRunning()) { - log.error("Couldn't unregister entry listener for execution plan: " + executionPlanName + - ", for tenant-ID: " + tenantId - + " as the hazelcast instance is not active."); - } else { - hazelcastInstance.getMap(DistributedModeConstants.STORM_STATUS_MAP).removeEntryListener(listenerId); - } - } - - private class MapListenerImpl implements EntryAddedListener, EntryUpdatedListener { - @Override - public void entryAdded(EntryEvent entryEvent) { - if (!entryEvent.getMember().localMember()) { - stormStatusMonitor.hazelcastListenerCallback(); - } - } - - @Override - public void entryUpdated(EntryEvent entryEvent) { - if (!entryEvent.getMember().localMember()) { - stormStatusMonitor.hazelcastListenerCallback(); - } - } - } -} diff --git a/components/event-processor/org.wso2.carbon.event.processor.core/src/main/java/org/wso2/carbon/event/processor/core/internal/storm/status/monitor/StormStatusMonitor.java b/components/event-processor/org.wso2.carbon.event.processor.core/src/main/java/org/wso2/carbon/event/processor/core/internal/storm/status/monitor/StormStatusMonitor.java deleted file mode 100644 index 9af4fcf50..000000000 --- a/components/event-processor/org.wso2.carbon.event.processor.core/src/main/java/org/wso2/carbon/event/processor/core/internal/storm/status/monitor/StormStatusMonitor.java +++ /dev/null @@ -1,426 +0,0 @@ -/* - * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.wso2.carbon.event.processor.core.internal.storm.status.monitor; - -import com.google.common.util.concurrent.ThreadFactoryBuilder; -import com.hazelcast.core.HazelcastInstance; -import com.hazelcast.core.IMap; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.context.PrivilegedCarbonContext; -import org.wso2.carbon.databridge.commons.thrift.utils.HostAddressFinder; -import org.wso2.carbon.event.processor.core.internal.ds.EventProcessorValueHolder; -import org.wso2.carbon.event.processor.core.internal.storm.StormTopologyManager; -import org.wso2.carbon.event.processor.core.internal.storm.status.monitor.exception.DeploymentStatusMonitorException; -import org.wso2.carbon.event.processor.core.util.DistributedModeConstants; -import org.wso2.carbon.event.processor.core.util.ExecutionPlanStatusHolder; -import org.wso2.carbon.event.processor.manager.commons.transport.server.ConnectionCallback; - -import java.net.SocketException; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicInteger; - -public class StormStatusMonitor implements ConnectionCallback { - - private static final Log log = LogFactory.getLog(StormStatusMonitor.class); - - private final String stormTopologyName; - private final String executionPlanName; - private final String executionPlanStatusHolderKey; - private final ExecutorService executorService; - private final int lockTimeout; - private final String tenantDomain; - private String hostIp = null; - private AtomicInteger connectedCepReceiversCount; - private int importedStreamsCount = 0; - private AtomicInteger connectedPublisherBoltsCount; - - public StormStatusMonitor(int tenantId, String executionPlanName, int importedStreamsCount) - throws DeploymentStatusMonitorException { - if (EventProcessorValueHolder.getHazelcastInstance() == null) { - throw new DeploymentStatusMonitorException("Couldn't initialize Distributed Deployment Status monitor as" + - " the hazelcast instance is null. Enable clustering and restart the server"); - } - executorService = Executors.newSingleThreadExecutor(new ThreadFactoryBuilder(). - setNameFormat("Thread pool- component - StormStatusMonitor.executorService;tenantId - " + - tenantId + ";executionPlanName - " + executionPlanName).build()); - tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(); - connectedCepReceiversCount = new AtomicInteger(0); - connectedPublisherBoltsCount = new AtomicInteger(0); - try { - hostIp = HostAddressFinder.findAddress("localhost"); - } catch (SocketException e) { - //do nothing. Let this be retried in the callbacks. - } - this.importedStreamsCount = importedStreamsCount; - this.executionPlanName = executionPlanName; - this.stormTopologyName = StormTopologyManager.getTopologyName(executionPlanName, tenantId); - this.executionPlanStatusHolderKey = DistributedModeConstants.STORM_STATUS_MAP + "." + stormTopologyName; - lockTimeout = EventProcessorValueHolder.getStormDeploymentConfiguration().getStatusLockTimeout(); - executorService.execute(new GlobalStatUpdater()); - } - - @Override - public void onCepReceiverConnect() { - HazelcastInstance hazelcastInstance = EventProcessorValueHolder.getHazelcastInstance(); - if (hazelcastInstance != null && hazelcastInstance.getLifecycleService().isRunning()) { - IMap executionPlanStatusHolderIMap = hazelcastInstance.getMap(DistributedModeConstants.STORM_STATUS_MAP); - try { - if (hostIp == null) { - hostIp = HostAddressFinder.findAddress("localhost"); - } - if (executionPlanStatusHolderIMap.tryLock(executionPlanStatusHolderKey, lockTimeout, TimeUnit.MILLISECONDS)) { - try { - ExecutionPlanStatusHolder executionPlanStatusHolder = - executionPlanStatusHolderIMap.get(stormTopologyName); - if (executionPlanStatusHolder == null) { - log.error("Couldn't increment connected CEP receivers count for execution plan: " + executionPlanName + - ", for tenant-domain: " + tenantDomain - + " as status object not initialized by manager."); - } else { - executionPlanStatusHolder.setCEPReceiverStatus(hostIp, connectedCepReceiversCount.incrementAndGet(), importedStreamsCount); - executionPlanStatusHolderIMap.replace(stormTopologyName, executionPlanStatusHolder); - if (log.isDebugEnabled()) { - log.debug("Incremented connected CEP receiver count as " + connectedCepReceiversCount.get() + - " for execution plan: " + executionPlanName + ", for tenant-domain: " + tenantDomain - + ", for IP address: " + hostIp); - } - } - } finally { - executionPlanStatusHolderIMap.unlock(executionPlanStatusHolderKey); - } - } else { - log.error("Couldn't increment connected CEP receivers count for execution plan: " + executionPlanName + - ", for tenant-domain: " + tenantDomain - + " as the hazelcast lock acquisition failed."); - } - } catch (InterruptedException e) { - log.error("Couldn't increment connected CEP receivers count for execution plan: " + executionPlanName + - ", for tenant-domain: " + tenantDomain - + " as the hazelcast lock acquisition was interrupted.", e); - Thread.currentThread().interrupt(); - } catch (SocketException e) { - log.error("Couldn't increment connected CEP receivers count for execution plan: " + executionPlanName + - ", for tenant-domain: " + tenantDomain - + " as the host IP couldn't be found for this node.", e); - } - } else { - log.error("Couldn't increment connected CEP receivers count for execution plan: " + executionPlanName + - ", for tenant-domain: " + tenantDomain - + " as the hazelcast instance is not active or not available."); - } - } - - @Override - public void onCepReceiverDisconnect() { - HazelcastInstance hazelcastInstance = EventProcessorValueHolder.getHazelcastInstance(); - if (hazelcastInstance != null && hazelcastInstance.getLifecycleService().isRunning()) { - IMap executionPlanStatusHolderIMap = hazelcastInstance.getMap(DistributedModeConstants.STORM_STATUS_MAP); - try { - if (hostIp == null) { - hostIp = HostAddressFinder.findAddress("localhost"); - } - if (executionPlanStatusHolderIMap.tryLock(executionPlanStatusHolderKey, lockTimeout, TimeUnit.MILLISECONDS)) { - try { - ExecutionPlanStatusHolder executionPlanStatusHolder = - executionPlanStatusHolderIMap.get(stormTopologyName); - if (executionPlanStatusHolder == null) { - log.error("Couldn't decrement connected CEP receivers count for execution plan: " + executionPlanName + - ", for tenant-domain: " + tenantDomain - + " as status object not initialized by manager."); - } else { - executionPlanStatusHolder.setCEPReceiverStatus(hostIp, connectedCepReceiversCount.decrementAndGet(), importedStreamsCount); - executionPlanStatusHolderIMap.replace(stormTopologyName, executionPlanStatusHolder); - if (log.isDebugEnabled()) { - log.debug("Decremented connected CEP receiver count as " + connectedCepReceiversCount.get() + - " for execution plan: " + executionPlanName + ", for tenant-domain: " + tenantDomain - + ", for IP address: " + hostIp); - } - } - } finally { - executionPlanStatusHolderIMap.unlock(executionPlanStatusHolderKey); - } - } else { - log.error("Couldn't decrement connected CEP receivers count for execution plan: " + executionPlanName + - ", for tenant-domain: " + tenantDomain - + " as the hazelcast lock acquisition failed."); - } - } catch (InterruptedException e) { - log.error("Couldn't decrement connected CEP receivers count for execution plan: " + executionPlanName + - ", for tenant-domain: " + tenantDomain - + " as the hazelcast lock acquisition was interrupted.", e); - Thread.currentThread().interrupt(); - } catch (SocketException e) { - log.error("Couldn't decrement connected CEP receivers count for execution plan: " + executionPlanName + - ", for tenant-domain: " + tenantDomain - + " as the host IP couldn't be found for this node.", e); - } - } else { - log.error("Couldn't decrement connected CEP receivers count for execution plan: " + executionPlanName + - ", for tenant-domain: " + tenantDomain - + " as the hazelcast instance is not active or not available."); - } - } - - @Override - public void onPublisherBoltConnect() { - HazelcastInstance hazelcastInstance = EventProcessorValueHolder.getHazelcastInstance(); - if (hazelcastInstance != null && hazelcastInstance.getLifecycleService().isRunning()) { - IMap executionPlanStatusHolderIMap = hazelcastInstance.getMap(DistributedModeConstants.STORM_STATUS_MAP); - try { - if (hostIp == null) { - hostIp = HostAddressFinder.findAddress("localhost"); - } - if (executionPlanStatusHolderIMap.tryLock(executionPlanStatusHolderKey, lockTimeout, TimeUnit.MILLISECONDS)) { - try { - ExecutionPlanStatusHolder executionPlanStatusHolder = - executionPlanStatusHolderIMap.get(stormTopologyName); - if (executionPlanStatusHolder == null) { - log.error("Couldn't increment connected publisher bolts count for execution plan: " + executionPlanName + - ", for tenant-domain: " + tenantDomain - + " as status object not initialized by manager."); - } else { - executionPlanStatusHolder.setConnectedPublisherBoltsCount(hostIp, connectedPublisherBoltsCount.incrementAndGet()); - executionPlanStatusHolderIMap.replace(stormTopologyName, executionPlanStatusHolder); - if (log.isDebugEnabled()) { - log.debug("Incremented connected publisher bolt count as " + connectedPublisherBoltsCount.get() + - " for execution plan: " + executionPlanName + ", for tenant-domain: " + tenantDomain - + ", for IP address: " + hostIp); - } - } - } finally { - executionPlanStatusHolderIMap.unlock(executionPlanStatusHolderKey); - } - } else { - log.error("Couldn't increment connected publisher bolts count for execution plan: " + executionPlanName + - ", for tenant-domain: " + tenantDomain - + " as the hazelcast lock acquisition failed."); - } - } catch (InterruptedException e) { - log.error("Couldn't increment connected publisher bolts count for execution plan: " + executionPlanName + - ", for tenant-domain: " + tenantDomain - + " as the hazelcast lock acquisition was interrupted.", e); - Thread.currentThread().interrupt(); - } catch (SocketException e) { - log.error("Couldn't increment connected publisher bolts count for execution plan: " + executionPlanName + - ", for tenant-domain: " + tenantDomain - + " as the host IP couldn't be found for this node.", e); - } - } else { - log.error("Couldn't increment connected publisher bolts count for execution plan: " + executionPlanName + - ", for tenant-domain: " + tenantDomain - + " as the hazelcast instance is not active or not available."); - } - } - - @Override - public void onPublisherBoltDisconnect() { - HazelcastInstance hazelcastInstance = EventProcessorValueHolder.getHazelcastInstance(); - if (hazelcastInstance != null && hazelcastInstance.getLifecycleService().isRunning()) { - IMap executionPlanStatusHolderIMap = hazelcastInstance.getMap(DistributedModeConstants.STORM_STATUS_MAP); - try { - if (hostIp == null) { - hostIp = HostAddressFinder.findAddress("localhost"); - } - if (executionPlanStatusHolderIMap.tryLock(executionPlanStatusHolderKey, lockTimeout, TimeUnit.MILLISECONDS)) { - try { - ExecutionPlanStatusHolder executionPlanStatusHolder = - executionPlanStatusHolderIMap.get(stormTopologyName); - if (executionPlanStatusHolder == null) { - log.error("Couldn't decrement connected publisher bolts count for execution plan: " + executionPlanName + - ", for tenant-domain: " + tenantDomain - + " as status object not initialized by manager."); - } else { - executionPlanStatusHolder.setConnectedPublisherBoltsCount(hostIp, connectedPublisherBoltsCount.decrementAndGet()); - executionPlanStatusHolderIMap.replace(stormTopologyName, executionPlanStatusHolder); - if (log.isDebugEnabled()) { - log.debug("Decremented connected publisher bolt count as " + connectedPublisherBoltsCount.get() + - " for execution plan: " + executionPlanName + ", for tenant-domain: " + tenantDomain - + ", for IP address: " + hostIp); - } - } - } finally { - executionPlanStatusHolderIMap.unlock(executionPlanStatusHolderKey); - } - } else { - log.error("Couldn't decrement connected publisher bolts count for execution plan: " + executionPlanName + - ", for tenant-domain: " + tenantDomain - + " as the hazelcast lock acquisition failed."); - } - } catch (InterruptedException e) { - log.error("Couldn't decrement connected publisher bolts count for execution plan: " + executionPlanName + - ", for tenant-domain: " + tenantDomain - + " as the hazelcast lock acquisition was interrupted.", e); - Thread.currentThread().interrupt(); - } catch (SocketException e) { - log.error("Couldn't decrement connected publisher bolts count for execution plan: " + executionPlanName + - ", for tenant-domain: " + tenantDomain - + " as the host IP couldn't be found for this node.", e); - } - } else { - log.error("Couldn't decrement connected publisher bolts count for execution plan: " + executionPlanName + - ", for tenant-domain: " + tenantDomain - + " as the hazelcast instance is not active or not available."); - } - } - - public void hazelcastListenerCallback() { - HazelcastInstance hazelcastInstance = EventProcessorValueHolder.getHazelcastInstance(); - if (hazelcastInstance != null && hazelcastInstance.getLifecycleService().isRunning()) { - IMap executionPlanStatusHolderIMap = hazelcastInstance.getMap(DistributedModeConstants.STORM_STATUS_MAP); - try { - if (hostIp == null) { - hostIp = HostAddressFinder.findAddress("localhost"); - } - if (executionPlanStatusHolderIMap.tryLock(executionPlanStatusHolderKey, lockTimeout, TimeUnit.MILLISECONDS)) { - try { - ExecutionPlanStatusHolder executionPlanStatusHolder = - executionPlanStatusHolderIMap.get(stormTopologyName); - if (executionPlanStatusHolder == null) { - log.error("Couldn't update distributed deployment status for execution plan: " + executionPlanName + - ", for tenant-domain: " + tenantDomain - + " as status object not initialized by manager."); - } else { - executionPlanStatusHolder.setCEPReceiverStatus(hostIp, connectedCepReceiversCount.get(), importedStreamsCount); - executionPlanStatusHolder.setConnectedPublisherBoltsCount(hostIp, connectedPublisherBoltsCount.get()); - executionPlanStatusHolderIMap.replace(stormTopologyName, executionPlanStatusHolder); - if (log.isDebugEnabled()) { - log.debug("Updated distributed deployment status as follows. " + - "\nConnected CEP receivers count: " + connectedCepReceiversCount.get() + - "\nConnected publisher bolts count: " + connectedPublisherBoltsCount.get() + - "\nfor execution plan: " + executionPlanName + ", for tenant-domain: " + tenantDomain - + ", for IP address: " + hostIp); - } - } - } finally { - executionPlanStatusHolderIMap.unlock(executionPlanStatusHolderKey); - } - } else { - log.error("Couldn't update distributed deployment status for execution plan: " + executionPlanName + - ", for tenant-domain: " + tenantDomain - + " as the hazelcast lock acquisition failed."); - } - } catch (InterruptedException e) { - log.error("Couldn't update distributed deployment status for execution plan: " + executionPlanName + - ", for tenant-domain: " + tenantDomain - + " as the hazelcast lock acquisition was interrupted.", e); - Thread.currentThread().interrupt(); - } catch (SocketException e) { - log.error("Couldn't update distributed deployment status for execution plan: " + executionPlanName + - ", for tenant-domain: " + tenantDomain - + " as the host IP couldn't be found for this node.", e); - } - } else { - log.error("Couldn't update distributed deployment status for execution plan: " + executionPlanName + - ", for tenant-domain: " + tenantDomain - + " as the hazelcast instance is not active or not available."); - } - } - - public void shutdown() { - executorService.shutdownNow(); - } - - /** - * Updates the ExecutionPlanStatusHolder periodically. - */ - class GlobalStatUpdater implements Runnable { - - private final int updateRate; - - GlobalStatUpdater() { - updateRate = EventProcessorValueHolder.getStormDeploymentConfiguration().getStatusUpdateInterval(); - } - - @Override - public void run() { - while (true) { - - /** - * Update - */ - HazelcastInstance hazelcastInstance = EventProcessorValueHolder.getHazelcastInstance(); - if (hazelcastInstance != null && hazelcastInstance.getLifecycleService().isRunning()) { - IMap executionPlanStatusHolderIMap = hazelcastInstance.getMap(DistributedModeConstants.STORM_STATUS_MAP); - try { - if (hostIp == null) { - hostIp = HostAddressFinder.findAddress("localhost"); - } - if (executionPlanStatusHolderIMap.tryLock(executionPlanStatusHolderKey, lockTimeout, TimeUnit.MILLISECONDS)) { - try { - ExecutionPlanStatusHolder executionPlanStatusHolder = - executionPlanStatusHolderIMap.get(stormTopologyName); - if (executionPlanStatusHolder == null) { - log.error("Couldn't update distributed deployment status for execution plan: " + executionPlanName + - ", for tenant-domain: " + tenantDomain - + " as status object not initialized by manager."); - } else { - executionPlanStatusHolder.setCEPReceiverStatus(hostIp, connectedCepReceiversCount.get(), importedStreamsCount); - executionPlanStatusHolder.setConnectedPublisherBoltsCount(hostIp, connectedPublisherBoltsCount.get()); - executionPlanStatusHolderIMap.replace(stormTopologyName, executionPlanStatusHolder); - if (log.isDebugEnabled()) { - log.debug("Updated distributed deployment status as follows. " + - "\nConnected CEP receivers count: " + connectedCepReceiversCount.get() + - "\nConnected publisher bolts count: " + connectedPublisherBoltsCount.get() + - "\nfor execution plan: " + executionPlanName + ", for tenant-domain: " + tenantDomain - + ", for IP address: " + hostIp); - } - } - } finally { - executionPlanStatusHolderIMap.unlock(executionPlanStatusHolderKey); - } - } else { - log.error("Couldn't update distributed deployment status for execution plan: " + executionPlanName + - ", for tenant-domain: " + tenantDomain - + " as the hazelcast lock acquisition failed."); - } - } catch (InterruptedException e) { - log.error("Couldn't update distributed deployment status for execution plan: " + executionPlanName + - ", for tenant-domain: " + tenantDomain - + " as the hazelcast lock acquisition was interrupted.", e); - Thread.currentThread().interrupt(); - return; - } catch (SocketException e) { - log.error("Couldn't update distributed deployment status for execution plan: " + executionPlanName + - ", for tenant-domain: " + tenantDomain - + " as the host IP couldn't be found for this node.", e); - } - } else { - log.error("Couldn't update distributed deployment status for execution plan: " + executionPlanName + - ", for tenant-domain: " + tenantDomain - + " as the hazelcast instance is not active or not available."); - } - - /** - * Sleep - */ - try { - Thread.sleep(updateRate); - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); - if (log.isDebugEnabled()) { - log.debug("GlobalStatUpdater was interrupted, hence returning. " + - "Details: execution plan name: " + executionPlanName + ", tenant domain: " + tenantDomain); - } - return; - } - } - } - } -} diff --git a/components/event-processor/org.wso2.carbon.event.processor.core/src/main/java/org/wso2/carbon/event/processor/core/internal/storm/status/monitor/exception/DeploymentStatusMonitorException.java b/components/event-processor/org.wso2.carbon.event.processor.core/src/main/java/org/wso2/carbon/event/processor/core/internal/storm/status/monitor/exception/DeploymentStatusMonitorException.java deleted file mode 100644 index 860d1a7bc..000000000 --- a/components/event-processor/org.wso2.carbon.event.processor.core/src/main/java/org/wso2/carbon/event/processor/core/internal/storm/status/monitor/exception/DeploymentStatusMonitorException.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.wso2.carbon.event.processor.core.internal.storm.status.monitor.exception; - -public class DeploymentStatusMonitorException extends Exception{ - - public DeploymentStatusMonitorException(){ - } - - public DeploymentStatusMonitorException(String message){ - super(message); - } -} diff --git a/components/event-processor/org.wso2.carbon.event.processor.core/src/main/java/org/wso2/carbon/event/processor/core/internal/storm/util/ComponentInfoHolder.java b/components/event-processor/org.wso2.carbon.event.processor.core/src/main/java/org/wso2/carbon/event/processor/core/internal/storm/util/ComponentInfoHolder.java deleted file mode 100644 index ad1663fe3..000000000 --- a/components/event-processor/org.wso2.carbon.event.processor.core/src/main/java/org/wso2/carbon/event/processor/core/internal/storm/util/ComponentInfoHolder.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.wso2.carbon.event.processor.core.internal.storm.util; - -import org.wso2.siddhi.query.api.definition.StreamDefinition; -import org.wso2.siddhi.query.compiler.SiddhiCompiler; - -import java.util.HashMap; -import java.util.Map; - -public class ComponentInfoHolder { - - - - public enum ComponentType {EVENT_RECEIVER_SPOUT, SIDDHI_BOLT, EVENT_PUBLISHER_BOLT, TRIGGER_SPOUT;} - - private ComponentType componentType; - private String componentName = null; - private Object declarer; - private Map inputStreams = new HashMap(); - private Map inputStreamPartitoningFields = new HashMap(); - private Map outputStreams = new HashMap(); - private int parallelism = 1; - private String query; - - public ComponentInfoHolder(String componentName, ComponentType componentType) { - this.componentName = componentName; - this.componentType = componentType; - } - - public void addSiddhiQuery(String query){ - this.query = query; - } - - public void setParallelism(int parallelism) { - this.parallelism = parallelism; - } - - public void addInputStream(String streamDefinition) { - StreamDefinition siddhiStreamDefinition = SiddhiCompiler.parseStreamDefinition(streamDefinition); - inputStreams.put(siddhiStreamDefinition.getId(), siddhiStreamDefinition); - } - - public void addStreamPartitioningField(String streamId, String partitioningField){ - if (this.componentType != ComponentType.EVENT_RECEIVER_SPOUT){ - inputStreamPartitoningFields.put(streamId, partitioningField); - } - } - - public void addOutputStream(String streamDefinition) { - StreamDefinition siddhiStreamDefinition = SiddhiCompiler.parseStreamDefinition(streamDefinition); - outputStreams.put(siddhiStreamDefinition.getId(), siddhiStreamDefinition); - } - - public String[] getInputStreamIds() { - return inputStreams.keySet().toArray(new String[inputStreams.size()]); - } - - public String[] getOutputStreamIds() { - return outputStreams.keySet().toArray(new String[inputStreams.size()]); - } - - public String getPartionenedField(String streamId){ - return inputStreamPartitoningFields.get(streamId); - } - - public int getParallelism() { - return parallelism; - } - - public String getComponentName() { - return componentName; - } - - public ComponentType getComponentType() { - return componentType; - } - - public void setDeclarer(Object declarer) { - this.declarer = declarer; - } - - public Object getDeclarer() { - return declarer; - } - -} diff --git a/components/event-processor/org.wso2.carbon.event.processor.core/src/main/java/org/wso2/carbon/event/processor/core/internal/storm/util/ExecutionElementInfoHolder.java b/components/event-processor/org.wso2.carbon.event.processor.core/src/main/java/org/wso2/carbon/event/processor/core/internal/storm/util/ExecutionElementInfoHolder.java deleted file mode 100644 index 7e2392aa8..000000000 --- a/components/event-processor/org.wso2.carbon.event.processor.core/src/main/java/org/wso2/carbon/event/processor/core/internal/storm/util/ExecutionElementInfoHolder.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.wso2.carbon.event.processor.core.internal.storm.util; - -import org.wso2.siddhi.query.api.execution.ExecutionElement; - -/** - * Class to store execution element info - */ -public class ExecutionElementInfoHolder { - private ExecutionElement executionElement; - private ParallelismInfoHolder parallelismInfoHolder; - - public ExecutionElementInfoHolder(ExecutionElement executionElement, int parallelism, Boolean isParallelismEnforced) { - this.executionElement = executionElement; - this.parallelismInfoHolder = new ParallelismInfoHolder(parallelism, isParallelismEnforced); - } - - public ExecutionElement getExecutionElement() { - return executionElement; - } - - public ParallelismInfoHolder getParallelismInfoHolder() { - return parallelismInfoHolder; - } -} diff --git a/components/event-processor/org.wso2.carbon.event.processor.core/src/main/java/org/wso2/carbon/event/processor/core/internal/storm/util/ParallelismInfoHolder.java b/components/event-processor/org.wso2.carbon.event.processor.core/src/main/java/org/wso2/carbon/event/processor/core/internal/storm/util/ParallelismInfoHolder.java deleted file mode 100644 index 010129263..000000000 --- a/components/event-processor/org.wso2.carbon.event.processor.core/src/main/java/org/wso2/carbon/event/processor/core/internal/storm/util/ParallelismInfoHolder.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.wso2.carbon.event.processor.core.internal.storm.util; - -/** - * Class to store storm parallelism info - */ -public class ParallelismInfoHolder { - private int parallelism; - private Boolean isEnforced; - - public ParallelismInfoHolder(int parallelism, Boolean isEnforced) { - this.parallelism = parallelism; - this.isEnforced = isEnforced; - } - - public int getParallelism() { - return parallelism; - } - - public Boolean getIsEnforced() { - return isEnforced; - } -} diff --git a/components/event-processor/org.wso2.carbon.event.processor.core/src/main/java/org/wso2/carbon/event/processor/core/internal/storm/util/QueryGroupInfoHolder.java b/components/event-processor/org.wso2.carbon.event.processor.core/src/main/java/org/wso2/carbon/event/processor/core/internal/storm/util/QueryGroupInfoHolder.java deleted file mode 100644 index 2ad56f9b1..000000000 --- a/components/event-processor/org.wso2.carbon.event.processor.core/src/main/java/org/wso2/carbon/event/processor/core/internal/storm/util/QueryGroupInfoHolder.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.wso2.carbon.event.processor.core.internal.storm.util; - -import org.wso2.carbon.event.processor.core.exception.StormQueryConstructionException; -import org.wso2.siddhi.query.api.execution.partition.Partition; -import org.wso2.siddhi.query.api.execution.partition.PartitionType; -import org.wso2.siddhi.query.api.execution.partition.RangePartitionType; -import org.wso2.siddhi.query.api.execution.partition.ValuePartitionType; -import org.wso2.siddhi.query.api.execution.query.Query; -import org.wso2.siddhi.query.api.expression.Variable; - -import java.util.HashMap; -import java.util.HashSet; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Set; - - -/** - * Class to hold necessary information regarding query grouping which is needed - * for Storm query plan generation. Here single query is treated as a query group - * with group id = query name. Also a Partition is considered as a group. - */ -public class QueryGroupInfoHolder { - private String groupId; - private List stringQueries; - private List executionElements; - private Set inputDefinitionIds; - private Set outputDefinitionIds; - private Map partitionFieldMap = null; - - public QueryGroupInfoHolder(String groupId) { - this.groupId = groupId; - stringQueries = new ArrayList(); - executionElements = new ArrayList(); - inputDefinitionIds = new HashSet(); - outputDefinitionIds = new HashSet(); - } - - public void addQueryString(String query) { - stringQueries.add(query); - } - - public void addExecutionElement(ExecutionElementInfoHolder infoHolder) throws StormQueryConstructionException { - if (infoHolder.getExecutionElement() instanceof Query) { - inputDefinitionIds.addAll(((Query) infoHolder.getExecutionElement()).getInputStream().getUniqueStreamIds()); - outputDefinitionIds.add(((Query) infoHolder.getExecutionElement()).getOutputStream().getId()); - } else { - Partition partition = (Partition) infoHolder.getExecutionElement(); - for (Query query : partition.getQueryList()) { - for (String id : query.getInputStream().getUniqueStreamIds()) { - if (!id.contains("#")) { //if not an inner stream - inputDefinitionIds.add(id); - } - } - outputDefinitionIds.add(query.getOutputStream().getId()); - } - for (PartitionType type : partition.getPartitionTypeMap().values()) { - if (type instanceof RangePartitionType) { - throw new StormQueryConstructionException("Error in deploying Partition:" + this.getStringQueries - ().get(0) + " Range partitioning is not supported in distributed deployment"); - } else if (type instanceof ValuePartitionType) { - if (partitionFieldMap == null) { - partitionFieldMap = new HashMap(); - } - if (((ValuePartitionType) type).getExpression() instanceof Variable) { - Variable variable = (Variable) ((ValuePartitionType) type).getExpression(); - partitionFieldMap.put(type.getStreamId(), variable.getAttributeName()); - } else { - throw new StormQueryConstructionException("Error in deploying partition:" + this - .getStringQueries().get(0) + ". Only Expressions of Type Variable will be admitted" + - " for distributed processing"); - } - } - } - } - executionElements.add(infoHolder); - } - - public List getStringQueries() { - return stringQueries; - } - - public List getExecutionElements() { - return executionElements; - } - - public Set getInputDefinitionIds() { - return inputDefinitionIds; - } - - public Set getOutputDefinitionIds() { - return outputDefinitionIds; - } - - public Map getPartitionFieldMap() { - return partitionFieldMap; - } -} diff --git a/components/event-processor/org.wso2.carbon.event.processor.core/src/main/java/org/wso2/carbon/event/processor/core/internal/storm/util/StormQueryPlanBuilder.java b/components/event-processor/org.wso2.carbon.event.processor.core/src/main/java/org/wso2/carbon/event/processor/core/internal/storm/util/StormQueryPlanBuilder.java deleted file mode 100644 index 052494373..000000000 --- a/components/event-processor/org.wso2.carbon.event.processor.core/src/main/java/org/wso2/carbon/event/processor/core/internal/storm/util/StormQueryPlanBuilder.java +++ /dev/null @@ -1,575 +0,0 @@ -/* - * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.wso2.carbon.event.processor.core.internal.storm.util; - -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.wso2.carbon.event.processor.core.ExecutionPlanConfiguration; -import org.wso2.carbon.event.processor.core.exception.StormQueryConstructionException; -import org.wso2.carbon.event.processor.core.internal.ds.EventProcessorValueHolder; -import org.wso2.carbon.event.processor.core.internal.storm.compiler.SiddhiQLStormQuerySplitter; -import org.wso2.carbon.event.processor.core.internal.util.EventProcessorConstants; -import org.wso2.carbon.event.processor.core.internal.util.EventProcessorUtil; -import org.wso2.carbon.event.stream.core.exception.EventStreamConfigurationException; -import org.wso2.siddhi.core.ExecutionPlanRuntime; -import org.wso2.siddhi.query.api.ExecutionPlan; -import org.wso2.siddhi.query.api.annotation.Annotation; -import org.wso2.siddhi.query.api.definition.AbstractDefinition; -import org.wso2.siddhi.query.api.definition.StreamDefinition; -import org.wso2.siddhi.query.api.definition.TriggerDefinition; -import org.wso2.siddhi.query.api.execution.ExecutionElement; -import org.wso2.siddhi.query.api.execution.partition.Partition; -import org.wso2.siddhi.query.api.execution.query.Query; -import org.wso2.siddhi.query.api.execution.query.input.stream.BasicSingleInputStream; -import org.wso2.siddhi.query.compiler.SiddhiCompiler; -import org.wso2.siddhi.query.compiler.exception.SiddhiParserException; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; -import java.util.*; - -public class StormQueryPlanBuilder { - - /** - * Gets Siddhi queries and construct storm query plan which can be used to build a storm topology. - * query plan essentially comprise of three main elements. Receiver element, event processor element and - * publisher element. Each of that will be constructed in separate methods and integrated here. - * - * @param configuration Execution plan configuration - * @return - * @throws StormQueryConstructionException - */ - public static Document constructStormQueryPlanXML(ExecutionPlanConfiguration configuration, - List importStreams, List exportStreams) - throws StormQueryConstructionException { - Document document; - try { - DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); - DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder(); - document = documentBuilder.newDocument(); - Element rootElement = document.createElement(EventProcessorConstants.STORM_QUERY_PLAN); - document.appendChild(rootElement); - - Element receiverElement; - List processorElements; - List triggerProcessorElements; - Element publisherElement; - - receiverElement = constructReceiverElement(document, configuration.getExecutionPlan(), importStreams); - publisherElement = constructPublisherElement(document, configuration.getExecutionPlan(), exportStreams); - triggerProcessorElements = constructTriggerElement(document, configuration.getExecutionPlan()); - processorElements = constructProcessorElement(document, configuration.getExecutionPlan(), importStreams, - exportStreams); - - - rootElement.appendChild(receiverElement); - for (Element processorElement : processorElements) { - rootElement.appendChild(processorElement); - } - for (Element triggerProcessorElement : triggerProcessorElements){ - rootElement.appendChild(triggerProcessorElement); - } - rootElement.appendChild(publisherElement); - - StormQueryPlanValidator.validateQueryPlan(document); - } catch (ParserConfigurationException e) { - throw new StormQueryConstructionException("Error when creating storm query configuration.", e); - } catch (EventStreamConfigurationException e) { - throw new StormQueryConstructionException("Error when retrieving stream definitions in order to create storm " + - "query configuration", e); - } catch (SiddhiParserException e) { - throw new StormQueryConstructionException("Provided Siddhi query contains errors", e); - } - return document; - } - - /** - * Create receiver element. Assume that imported streams contains all the receiver elements. - * - * @param document - * @param queryExpressions - * @param importedStreams @return - * @throws EventStreamConfigurationException - */ - private static Element constructReceiverElement(Document document, String queryExpressions, List importedStreams) - throws EventStreamConfigurationException { - Element receiverElement = document.createElement(EventProcessorConstants.EVENT_RECEIVER); - receiverElement.setAttribute(EventProcessorConstants.NAME, EventProcessorConstants.EVENT_RECEIVER_SPOUT); - ExecutionPlan executionPlan = SiddhiCompiler.parse(queryExpressions); - receiverElement.setAttribute(EventProcessorConstants.PARALLEL, String.valueOf(getParallelism(executionPlan.getAnnotations(), - EventProcessorConstants.RECEIVER_PARALLELISM))); - Element streams = document.createElement(EventProcessorConstants.STREAMS); - for (String definition : importedStreams) { - Element stream = getStreamElement(document, definition); - streams.appendChild(stream); - } - receiverElement.appendChild(streams); - return receiverElement; - } - - /** - * Create publisher element. Assumes that exported streams contains all publisher streams. - * - * @param exportedStreams - * @return - * @throws EventStreamConfigurationException - */ - private static Element constructPublisherElement(Document document, String queryExpressions, List exportedStreams) - throws EventStreamConfigurationException { - Element publisherElement = document.createElement(EventProcessorConstants.EVENT_PUBLISHER); - Element publisherInputStream = document.createElement(EventProcessorConstants.INPUT_STREAMS); - Element publisherOutputStream = document.createElement(EventProcessorConstants.OUTPUT_STREAMS); - publisherElement.setAttribute(EventProcessorConstants.NAME, EventProcessorConstants.EVENT_PUBLISHER_BOLT); - ExecutionPlan executionPlan = SiddhiCompiler.parse(queryExpressions); - publisherElement.setAttribute(EventProcessorConstants.PARALLEL, String.valueOf(getParallelism(executionPlan.getAnnotations(), - EventProcessorConstants.PUBLISHER_PARALLELISM))); - for (String definition : exportedStreams) { - Element stream = getStreamElement(document, definition); - publisherOutputStream.appendChild(stream); - Element clonedStream = (Element) stream.cloneNode(true); - publisherInputStream.appendChild(clonedStream); - } - publisherElement.appendChild(publisherInputStream); - publisherElement.appendChild(publisherOutputStream); - return publisherElement; - } - - private static List constructTriggerElement(Document document, String queryExpression) throws StormQueryConstructionException { - ExecutionPlanRuntime executionPlanRuntime = EventProcessorValueHolder.getSiddhiManager().createExecutionPlanRuntime(queryExpression); - Map streamDefinitionMap = executionPlanRuntime.getStreamDefinitionMap(); - executionPlanRuntime.shutdown(); - - ExecutionPlan executionPlan = SiddhiCompiler.parse(queryExpression); - List triggerElementList = new ArrayList(); - - for (Map.Entry entry : executionPlan.getTriggerDefinitionMap().entrySet()){ - Element triggerElement = document.createElement(EventProcessorConstants.TRIGGER_TAG); - ParallelismInfoHolder holder = new ParallelismInfoHolder(1, false); - setAttributes(triggerElement, (String)entry.getKey() , holder); - - String getTriggerDefinition = EventProcessorUtil.getTriggerDefinitionString((TriggerDefinition) entry.getValue()); - Element triggerDefinitionElement = document.createElement(EventProcessorConstants.TRIGGER_DEFINITION); - triggerDefinitionElement.setTextContent(getTriggerDefinition); - triggerElement.appendChild(triggerDefinitionElement); - - String outputStreamDefinition = EventProcessorUtil.getDefinitionString(streamDefinitionMap.get(entry.getKey())); - Element outputStreamElement = document.createElement(EventProcessorConstants.OUTPUT_STREAM); - outputStreamElement.setTextContent(outputStreamDefinition); - triggerElement.appendChild(outputStreamElement); - - triggerElementList.add(triggerElement); - } - - return triggerElementList; - } - - /** - * Construct and return a list of event-processor elements. Method can handle even if there are definitions - * in the query string. queryList is used to get the map between query object and query string. - * - * @param document - * @param queryExpressions user provided query string - * @return - */ - private static List constructProcessorElement(Document document, String queryExpressions, - List importedStreams, List exportedStreams) - throws SiddhiParserException, StormQueryConstructionException { - - ExecutionPlanRuntime executionPlanRuntime = EventProcessorValueHolder.getSiddhiManager().createExecutionPlanRuntime(queryExpressions); - Map streamDefinitionMap = executionPlanRuntime.getStreamDefinitionMap(); - executionPlanRuntime.shutdown(); - - List processorElementList = new ArrayList(); - List stringQueryList = SiddhiQLStormQuerySplitter.split(queryExpressions); - List eventTableDefinitionList = SiddhiQLStormQuerySplitter.getEventTableList(queryExpressions); - ExecutionPlan executionPlan = SiddhiCompiler.parse(queryExpressions); - List executionElements = executionPlan.getExecutionElementList(); - Set eventTableIdSet = executionPlan.getTableDefinitionMap().keySet(); - Map groupIdToQueryMap = getGroupIdToQueryMap(eventTableIdSet, executionElements, - stringQueryList, exportedStreams); - - for (Map.Entry entry : groupIdToQueryMap.entrySet()) { - String name = (String) entry.getKey(); - QueryGroupInfoHolder infoHolder = (QueryGroupInfoHolder) entry.getValue(); - ParallelismInfoHolder holder = getParallelismForGroup((String) entry.getKey(), - infoHolder.getExecutionElements()); - Element processor = document.createElement(EventProcessorConstants.EVENT_PROCESSOR_TAG); - setAttributes(processor, name, holder); - - //tables - Element tableDefinitions = document.createElement(EventProcessorConstants.TABLE_DEFINITIONS); - List querySpecificEventTableDefinitionList = new ArrayList<>(); - List querySpecificEventTableIdList = new ArrayList<>(); - String stringQueries = getQueryString(((QueryGroupInfoHolder) entry.getValue()).getStringQueries()); - for (String evenTableId : eventTableIdSet) { - if (stringQueries.contains(evenTableId)) { - for (String evenTableDefinition : eventTableDefinitionList) { - if (evenTableDefinition.contains(evenTableId)) { - querySpecificEventTableDefinitionList.add(evenTableDefinition); - querySpecificEventTableIdList.add(evenTableId); - } - } - } - } - String stringTableDefinitions = getEventTableDefinitionString(querySpecificEventTableDefinitionList); - tableDefinitions.setTextContent(stringTableDefinitions); - processor.appendChild(tableDefinitions); - - //input streams - List inputDefinitionIds = new ArrayList(infoHolder.getInputDefinitionIds()); - inputDefinitionIds.removeAll(querySpecificEventTableIdList); - Element inputStream = getProcessorInputStream(document, inputDefinitionIds, streamDefinitionMap, infoHolder.getPartitionFieldMap()); - processor.appendChild(inputStream); - - //queries - Element queries = document.createElement(EventProcessorConstants.QUERIES); - queries.setTextContent(stringQueries); - processor.appendChild(queries); - - //output streams - Element outputStream = getProcessorOutputStream(document, new ArrayList(((QueryGroupInfoHolder) - entry.getValue()).getOutputDefinitionIds()), streamDefinitionMap); - processor.appendChild(outputStream); - processorElementList.add(processor); - } - return processorElementList; - } - - /** - * Method to add attributes to processor element - * - * @param processor - * @param name - * @param holder - */ - private static void setAttributes(Element processor, String name, ParallelismInfoHolder holder) throws - StormQueryConstructionException { - - if (name.matches(".*\\s+.*")) { - // Storm UI gives an error when trying to show information of bolts which contains spaces. - throw new StormQueryConstructionException("Query name '" + name + "' is not valid, it must not contain spaces."); - } - - String parallel = String.valueOf(holder.getParallelism()); - Boolean enforceParallelism = holder.getIsEnforced(); - processor.setAttribute(EventProcessorConstants.NAME, name); - processor.setAttribute(EventProcessorConstants.PARALLEL, parallel); - processor.setAttribute(EventProcessorConstants.ENFORCE_PARALLELISM, String.valueOf(enforceParallelism)); - } - - /** - * Creates query group id to queries map where queries with same group id will be put into single - * QueryGroupInfoHolder. Also duplicate and inner stream definitions of each query group will be removed. - * - * @param executionElements - * @param stringQueryList - * @param exportedStreams - * @return - */ - private static Map getGroupIdToQueryMap(Set eventTableIdSet, List executionElements, - List stringQueryList, - List exportedStreams) throws - StormQueryConstructionException { - Map groupIdToQueryMap = new HashMap(); - for (int i = 0; i < executionElements.size(); i++) { - String name = getName(executionElements.get(i).getAnnotations()); - String groupId = getExecuteGroup(executionElements.get(i).getAnnotations()); - if (groupId == null) { - groupId = name; - } - int parallel = getParallelism(executionElements.get(i).getAnnotations(), EventProcessorConstants.PARALLEL); - - if (executionElements.get(i) instanceof Query) { - Query query = (Query) executionElements.get(i); - Boolean enforceParallelism = validateParallelism(query, parallel, stringQueryList.get(i)); - QueryGroupInfoHolder infoHolder = groupIdToQueryMap.get(groupId); - if (infoHolder != null) { - infoHolder.addExecutionElement(new ExecutionElementInfoHolder(query, parallel, enforceParallelism)); - infoHolder.addQueryString(stringQueryList.get(i)); - } else { - infoHolder = new QueryGroupInfoHolder(groupId); - infoHolder.addQueryString(stringQueryList.get(i)); - infoHolder.addExecutionElement(new ExecutionElementInfoHolder(query, parallel, enforceParallelism)); - groupIdToQueryMap.put(groupId, infoHolder); - } - infoHolder.getOutputDefinitionIds().removeAll(eventTableIdSet); - - } else { - Partition partition = (Partition) executionElements.get(i); - for (Query query : partition.getQueryList()) { - validateParallelism(query, -1, stringQueryList.get(i)); - } - QueryGroupInfoHolder infoHolder = groupIdToQueryMap.get(groupId); - if (infoHolder != null) { - throw new StormQueryConstructionException("Error deploying partition " + groupId + ". Query, " + - "Partition or execute group of same name has been defined earlier"); - } else { - infoHolder = new QueryGroupInfoHolder(groupId); - infoHolder.addExecutionElement(new ExecutionElementInfoHolder(partition, parallel, false)); - infoHolder.addQueryString(stringQueryList.get(i)); - groupIdToQueryMap.put(groupId, infoHolder); - } - } - } - - exportedStreams.removeAll(eventTableIdSet); - List exportedStreamIds = new ArrayList(exportedStreams.size()); - for (String definitionString : exportedStreams) { - StreamDefinition definition = SiddhiCompiler.parseStreamDefinition(definitionString); - exportedStreamIds.add(definition.getId()); - } - removeUnusedStreams(groupIdToQueryMap, exportedStreamIds); - return groupIdToQueryMap; - } - - /** - * Queries like window and joins can not operate in parallel since they are stateful queries. So we are - * validating parallelism of those stateful queries. - * - * @param query query to be validated - * @param parallel user defined parallelism hint - * @param queryString - * @throws StormQueryConstructionException - */ - private static Boolean validateParallelism(Query query, int parallel, - String queryString) throws StormQueryConstructionException { - if (parallel != -1) { //if not a partition - if (!(query.getInputStream() instanceof BasicSingleInputStream)) { //if window/join/pattern query - if (parallel > 1) { - throw new StormQueryConstructionException("Error in deploying query: " + queryString + " Parallelism has " + - "to be 1 for window, join and pattern queries. Partitioning can be used to facilitate such scenarios"); - } else { - return true; - } - } else { //if simple filter query - return false; - } - } else { //if partition - for (Annotation annotation : query.getAnnotations()) { - if (annotation.getName().equals(EventProcessorConstants.DIST)) { - throw new StormQueryConstructionException("Error in deploying query: " + queryString + ". Query level" + - " @dist type annotations are not supported for queries inside partitions. Please resubmit" + - " the execution plan moving those annotation to Partition level."); - } - } - return false; - } - } - - /** - * Remove output streams which are only inner streams. - * - * @param groupIdToQueryMap - * @param exportedStreams - */ - private static void removeUnusedStreams(Map groupIdToQueryMap, - List exportedStreams) { - for (Map.Entry entry : groupIdToQueryMap.entrySet()) { - QueryGroupInfoHolder holder = (QueryGroupInfoHolder) entry.getValue(); - if (holder.getInputDefinitionIds().size() > 1) { - Iterator iterator = holder.getInputDefinitionIds().iterator(); - while (iterator.hasNext()) { - String streamId = iterator.next(); - if (holder.getOutputDefinitionIds().contains(streamId)) { - iterator.remove(); - continue; - } - } - } - if (holder.getOutputDefinitionIds().size() > 1) { - Iterator iterator = holder.getOutputDefinitionIds().iterator(); - while (iterator.hasNext()) { - Boolean isUnused = true; - String streamId = iterator.next(); - if (exportedStreams.contains(streamId)) { - continue; - } - for (Map.Entry entry2 : groupIdToQueryMap.entrySet()) { - //If any other query group does not use this output stream as an input stream - if ((!entry.getKey().equals(entry2.getKey())) && (((QueryGroupInfoHolder) entry2.getValue()) - .getInputDefinitionIds().contains(streamId))) { - isUnused = false; - break; - } - } - if (isUnused) { - iterator.remove(); - } - } - } - } - } - - /** - * Traverse annotations and returns the name - * - * @param annotations - * @return - */ - private static String getName(List annotations) { - String name = UUID.randomUUID().toString(); - if (annotations != null) { - for (Annotation annotation : annotations) { - if (annotation.getName().equals(EventProcessorConstants.NAME)) { - name = annotation.getElements().get(0).getValue(); - } - } - } - return name; - } - - /** - * Traverse the annotation and returns the parallelism hint - * - * @param annotations - * @return - */ - private static int getParallelism(List annotations, String elementKey) { - int parallelism = 1; - if (annotations != null) { - for (Annotation annotation : annotations) { - if (annotation.getName().equals(EventProcessorConstants.DIST)) { - if (annotation.getElement(elementKey) != null) { - parallelism = Integer.parseInt(annotation.getElement(elementKey)); - if (parallelism == 0) { - parallelism = 1; - } - return parallelism; - } - } - } - } - return parallelism; - } - - /** - * Traverse the annotation and returns the execute group id - * - * @param annotations - * @return - */ - private static String getExecuteGroup(List annotations) { - String id = null; - if (annotations != null) { - for (Annotation annotation : annotations) { - if (annotation.getName().equals(EventProcessorConstants.DIST)) { - if (annotation.getElement(EventProcessorConstants.EXEC_GROUP) != null) { - id = annotation.getElement(EventProcessorConstants.EXEC_GROUP); - } - } - } - } - return id; - } - - private static String getQueryString(List stringQueries) { - StringBuilder builder = new StringBuilder(); - for (String query : stringQueries) { - builder.append(query.trim()).append(";"); - } - return builder.toString(); - } - - - private static String getEventTableDefinitionString(List eventTableDefinitionList) { - StringBuilder builder = new StringBuilder(); - for (String eventTableDefinition : eventTableDefinitionList) { - builder.append(eventTableDefinition.trim()).append(";"); - } - return builder.toString(); - } - - /** - * Method to define and validate group parallelism. - * - * @param groupId - * @param executionElementHolders - * @return - * @throws StormQueryConstructionException - */ - private static ParallelismInfoHolder getParallelismForGroup(String groupId, List - executionElementHolders) throws StormQueryConstructionException { - Boolean isEnforced = false; - Set parallelism = new HashSet(); - for (ExecutionElementInfoHolder element : executionElementHolders) { - parallelism.add(element.getParallelismInfoHolder().getParallelism()); - if (element.getParallelismInfoHolder().getIsEnforced()) { - isEnforced = true; - } - } - if (parallelism.size() == 1) { - return new ParallelismInfoHolder(parallelism.iterator().next(), isEnforced); - } else { - throw new StormQueryConstructionException("Parallelism for each query in a query group should be same. " + - "Multiple parallel values encountered in query group " + groupId); - } - } - - /** - * Create output stream element for event processor element - * - * @param streamIds - * @param streamDefinitionMap - * @return - */ - private static Element getProcessorOutputStream(Document document, List streamIds, - Map streamDefinitionMap) { - Element outputStream = document.createElement(EventProcessorConstants.OUTPUT_STREAMS); - for (String streamId : streamIds) { - Element stream = getStreamElement(document, EventProcessorUtil.getDefinitionString(streamDefinitionMap - .get(streamId))); - outputStream.appendChild(stream); - } - return outputStream; - } - - /** - * Create input stream element for event processor element - * - * @param streamIds - * @param streamDefinitionMap - * @param partitionFieldMap - */ - private static Element getProcessorInputStream(Document document, List streamIds, - Map streamDefinitionMap, Map partitionFieldMap) { - Element inputStream = document.createElement(EventProcessorConstants.INPUT_STREAMS); - for (String streamId : streamIds) { - Element stream = getStreamElement(document, EventProcessorUtil.getDefinitionString(streamDefinitionMap.get(streamId))); - if (partitionFieldMap != null) { - String attribute = partitionFieldMap.get(streamId); - if (attribute != null) { - stream.setAttribute(EventProcessorConstants.PARTITION, attribute); - } - } - inputStream.appendChild(stream); - } - return inputStream; - } - - /** - * Create stream element when provided with a stream definition - * - * @return - */ - private static Element getStreamElement(Document document, String definitionQuery) { - Element stream = document.createElement(EventProcessorConstants.STREAM); - stream.setTextContent(definitionQuery); - return stream; - } - -} diff --git a/components/event-processor/org.wso2.carbon.event.processor.core/src/main/java/org/wso2/carbon/event/processor/core/internal/storm/util/StormQueryPlanValidator.java b/components/event-processor/org.wso2.carbon.event.processor.core/src/main/java/org/wso2/carbon/event/processor/core/internal/storm/util/StormQueryPlanValidator.java deleted file mode 100644 index cbebe1951..000000000 --- a/components/event-processor/org.wso2.carbon.event.processor.core/src/main/java/org/wso2/carbon/event/processor/core/internal/storm/util/StormQueryPlanValidator.java +++ /dev/null @@ -1,138 +0,0 @@ -package org.wso2.carbon.event.processor.core.internal.storm.util; - -import org.w3c.dom.Document; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.wso2.carbon.event.processor.core.exception.StormQueryConstructionException; -import org.wso2.carbon.event.processor.core.internal.util.EventProcessorConstants; - -import javax.xml.xpath.*; -import java.util.HashSet; -import java.util.Set; - -/* - * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -public class StormQueryPlanValidator { - - private static XPathFactory xPathfactory = XPathFactory.newInstance(); - - /** - * Validate the query plan - * @param queryPlan XML document of query plan - * @throws StormQueryConstructionException - */ - public static void validateQueryPlan(Document queryPlan) throws StormQueryConstructionException { - validatePublishingStreams(queryPlan); - } - - /** - * Validates input streams of event-publisher. Each input stream of event-publisher MUST must be emitted by at least one spout or bolt. - * Therefore, each input stream MUST be listed under output-streams of at least one event-processor or under event-receiver - * @param queryPlan XML document of query plan - * @throws StormQueryConstructionException - */ - private static void validatePublishingStreams(Document queryPlan) throws StormQueryConstructionException { - try { - Set allEmittedStreams = new HashSet<>(); - allEmittedStreams.addAll(extractStreamIds(getEventProcessorOutputStreams(queryPlan))); - allEmittedStreams.addAll(extractStreamIds(getEventReceiverStreams(queryPlan))); - - for (String publisherInputStream : extractStreamIds(getEventPublisherInputStreams(queryPlan))){ - - if (!allEmittedStreams.contains(publisherInputStream)){ - throw new StormQueryConstructionException("Event publisher bolt(s) trying to consume stream '" + publisherInputStream + "', but it's " + - "not produced by any bolt/spout."); - } - } - } catch (XPathExpressionException e) { - throw new StormQueryConstructionException("Failed to validate query plan. Error :" + e.getMessage()); - } - } - - /** - * Fetch stream definitions of event-receiver element - */ - private static Set getEventReceiverStreams(Document queryPlan) throws XPathExpressionException { - XPath xpath = xPathfactory.newXPath(); - String xPathExpression = "/" + EventProcessorConstants.STORM_QUERY_PLAN + "/" + EventProcessorConstants.EVENT_RECEIVER - + "/" + EventProcessorConstants.STREAMS + "/" + EventProcessorConstants.STREAM; - - XPathExpression expr = xpath.compile(xPathExpression); - NodeList list = (NodeList) expr.evaluate(queryPlan, XPathConstants.NODESET); - - Set result = new HashSet<>(); - for (int i = 0; i < list.getLength(); i++){ - Node node = list.item(i); - result.add(node.getTextContent()); - } - - return result; - } - - /** - * Fetch all output stream definitions of all event-processor's elements - */ - private static Set getEventProcessorOutputStreams(Document queryPlan) throws XPathExpressionException { - XPath xpath = xPathfactory.newXPath(); - String xPathExpression = "/" + EventProcessorConstants.STORM_QUERY_PLAN + "/" + EventProcessorConstants.EVENT_PROCESSOR_TAG - + "/" + EventProcessorConstants.OUTPUT_STREAMS + "/" + EventProcessorConstants.STREAM; - - XPathExpression expr = xpath.compile(xPathExpression); - NodeList list = (NodeList) expr.evaluate(queryPlan, XPathConstants.NODESET); - - Set result = new HashSet<>(); - for (int i = 0; i < list.getLength(); i++){ - Node node = list.item(i); - result.add(node.getTextContent()); - } - - return result; - } - - - /** - * Fetch input stream definitions of event-publisher element - */ - private static Set getEventPublisherInputStreams(Document queryPlan) throws XPathExpressionException { - XPath xpath = xPathfactory.newXPath(); - String xPathExpression = "/" + EventProcessorConstants.STORM_QUERY_PLAN + "/" + EventProcessorConstants.EVENT_PUBLISHER - + "/" + EventProcessorConstants.INPUT_STREAMS + "/" + EventProcessorConstants.STREAM; - - XPathExpression expr = xpath.compile(xPathExpression); - NodeList list = (NodeList) expr.evaluate(queryPlan, XPathConstants.NODESET); - - Set result = new HashSet<>(); - for (int i = 0; i < list.getLength(); i++){ - Node node = list.item(i); - result.add(node.getTextContent()); - } - - return result; - } - - private static Set extractStreamIds(Set streamDefinitions){ - Set streamIds = new HashSet<>(); - for (String streamDefinition : streamDefinitions){ - streamIds.add(extractStreamId(streamDefinition)); - } - - return streamIds; - } - - private static String extractStreamId(String streamDefinition){ - return streamDefinition.split(" ")[2]; - } -} diff --git a/components/event-processor/org.wso2.carbon.event.processor.core/src/main/java/org/wso2/carbon/event/processor/core/internal/storm/util/StormTopologyConstructor.java b/components/event-processor/org.wso2.carbon.event.processor.core/src/main/java/org/wso2/carbon/event/processor/core/internal/storm/util/StormTopologyConstructor.java deleted file mode 100644 index ed87d4a61..000000000 --- a/components/event-processor/org.wso2.carbon.event.processor.core/src/main/java/org/wso2/carbon/event/processor/core/internal/storm/util/StormTopologyConstructor.java +++ /dev/null @@ -1,273 +0,0 @@ -/* - * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.wso2.carbon.event.processor.core.internal.storm.util; - -import backtype.storm.topology.BoltDeclarer; -import backtype.storm.topology.TopologyBuilder; -import backtype.storm.tuple.Fields; -import org.apache.axiom.om.OMAttribute; -import org.apache.axiom.om.OMElement; -import org.apache.axiom.om.util.AXIOMUtil; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.event.processor.common.storm.component.EventPublisherBolt; -import org.wso2.carbon.event.processor.common.storm.component.EventReceiverSpout; -import org.wso2.carbon.event.processor.common.storm.component.SiddhiBolt; -import org.wso2.carbon.event.processor.common.storm.component.TriggerSpout; -import org.wso2.carbon.event.processor.core.exception.StormQueryConstructionException; -import org.wso2.carbon.event.processor.core.internal.storm.status.monitor.StormStatusHolderInitializer; -import org.wso2.carbon.event.processor.core.internal.util.EventProcessorConstants; -import org.wso2.carbon.event.processor.manager.core.config.DistributedConfiguration; -import org.wso2.siddhi.query.api.definition.StreamDefinition; -import org.wso2.siddhi.query.compiler.SiddhiCompiler; - -import javax.xml.namespace.QName; -import javax.xml.stream.XMLStreamException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Iterator; -import java.util.List; - -/** - * Reads the execution plan xml file and construct the Storm topology - */ -public class StormTopologyConstructor { - - private static Log log = LogFactory.getLog(StormTopologyConstructor.class); - - public static TopologyBuilder constructTopologyBuilder(String queryPlanString, String executionPlanName, int tenantId, - DistributedConfiguration stormDeploymentConfig) - throws XMLStreamException, StormQueryConstructionException { - - OMElement queryPlanElement = AXIOMUtil.stringToOM(queryPlanString); - TopologyInfoHolder topologyInfoHolder = new TopologyInfoHolder(); - TopologyBuilder builder = new TopologyBuilder(); - - /* - Receiver section - */ - Iterator iterator = queryPlanElement.getChildrenWithName(new QName("event-receiver")); - while (iterator.hasNext()) { - OMElement eventReceiverElement = iterator.next(); - String name = eventReceiverElement.getAttributeValue(new QName("name")); - String parallel = eventReceiverElement.getAttributeValue(new QName("parallel")); - ComponentInfoHolder componentInfoHolder = new ComponentInfoHolder(name, ComponentInfoHolder.ComponentType.EVENT_RECEIVER_SPOUT); - - List streamDefinitions = getStreamDefinitions(eventReceiverElement.getFirstChildWithName(new QName - ("streams"))); - for (String streamDefinition : streamDefinitions) { - //Receiver only passes through incoming events. Therefore, input all input streams are output streams - componentInfoHolder.addInputStream(streamDefinition); - componentInfoHolder.addOutputStream(streamDefinition); - } - - componentInfoHolder.setDeclarer(builder.setSpout(name, new EventReceiverSpout(stormDeploymentConfig, - streamDefinitions, executionPlanName, tenantId, stormDeploymentConfig.getManagementHeartbeatInterval()), - Integer.parseInt(parallel))); - topologyInfoHolder.addComponent(componentInfoHolder); - } - - /* - Processor Section - */ - iterator = queryPlanElement.getChildrenWithName(new QName("event-processor")); - while (iterator.hasNext()) { - OMElement eventProcessorElement = iterator.next(); - String name = eventProcessorElement.getAttributeValue(new QName(EventProcessorConstants.NAME)); - String parallel = eventProcessorElement.getAttributeValue(new QName(EventProcessorConstants.PARALLEL)); - String isEnforced = eventProcessorElement.getAttributeValue(new QName(EventProcessorConstants - .ENFORCE_PARALLELISM)); - ComponentInfoHolder componentInfoHolder = new ComponentInfoHolder(name, ComponentInfoHolder.ComponentType.SIDDHI_BOLT); - - OMElement inputStreamsElement = eventProcessorElement.getFirstChildWithName(new QName("input-streams")); - List inputStreamDefinitions = getStreamDefinitions(inputStreamsElement); - for (String streamDefinition : inputStreamDefinitions) { - componentInfoHolder.addInputStream(streamDefinition); - } - // Adding partitioning fields of input streams - addPartitionFields(inputStreamsElement, componentInfoHolder); - - OMElement queryElement = eventProcessorElement.getFirstChildWithName(new QName("queries")); - OMElement tableDefinitionElement = eventProcessorElement.getFirstChildWithName(new QName("table-definitions")); - String queryWithEventTable = ""; - if (tableDefinitionElement != null) { - queryWithEventTable = tableDefinitionElement.getText() + queryElement.getText(); - } - componentInfoHolder.addSiddhiQuery(queryWithEventTable); - - List outputStreamDefinitions = getStreamDefinitions(eventProcessorElement.getFirstChildWithName(new - QName("output-streams"))); - for (String streamDefinition : outputStreamDefinitions) { - componentInfoHolder.addOutputStream(streamDefinition); - } - BoltDeclarer declarer = builder.setBolt(name, new SiddhiBolt(name, inputStreamDefinitions, - queryWithEventTable, outputStreamDefinitions, executionPlanName, tenantId), - Integer.parseInt(parallel)); - //enforcing parallelism - if (isEnforced.equals("true")) { - declarer.setMaxTaskParallelism(Integer.parseInt(parallel)); - } - componentInfoHolder.setDeclarer(declarer); - topologyInfoHolder.addComponent(componentInfoHolder); - } - - - /* - Publisher Section - */ - iterator = queryPlanElement.getChildrenWithName(new QName("event-publisher")); - while (iterator.hasNext()) { - OMElement eventProcessorElement = iterator.next(); - String name = eventProcessorElement.getAttributeValue(new QName("name")); - int parallel = Integer.parseInt(eventProcessorElement.getAttributeValue(new QName("parallel"))); - ComponentInfoHolder componentInfoHolder = new ComponentInfoHolder(name, ComponentInfoHolder.ComponentType.EVENT_PUBLISHER_BOLT); - - OMElement inputStreamsElement = eventProcessorElement.getFirstChildWithName(new QName("input-streams")); - List inputStreamDefinitions = getStreamDefinitions(inputStreamsElement); - for (String streamDefinition : inputStreamDefinitions) { - componentInfoHolder.addInputStream(streamDefinition); - } - // Publisher might also partition the output. Adding partitioning fields of input streams. - addPartitionFields(inputStreamsElement, componentInfoHolder); - - OMElement queryElement = eventProcessorElement.getFirstChildWithName(new QName("queries")); - OMElement tableDefinitionElement = eventProcessorElement.getFirstChildWithName(new QName("table-definitions")); - String query = ""; - if (tableDefinitionElement != null) { - query = tableDefinitionElement.getText(); - } - if (queryElement != null) { - query = query + queryElement.getText(); - componentInfoHolder.addSiddhiQuery(query); - } - - List outputStreamDefinitions = getStreamDefinitions(eventProcessorElement.getFirstChildWithName(new - QName("output-streams"))); - for (String streamDefinition : outputStreamDefinitions) { - componentInfoHolder.addOutputStream(streamDefinition); - } - componentInfoHolder.setDeclarer(builder.setBolt(name, new EventPublisherBolt(stormDeploymentConfig, - inputStreamDefinitions, outputStreamDefinitions, query, executionPlanName, tenantId), - parallel)); - topologyInfoHolder.addComponent(componentInfoHolder); - StormStatusHolderInitializer.initializeStatusHolder(executionPlanName, tenantId, parallel); - } - - /* - Triggers - */ - iterator = queryPlanElement.getChildrenWithName(new QName(EventProcessorConstants.TRIGGER_TAG)); - while (iterator.hasNext()) { - OMElement triggerElement = iterator.next(); - String name = triggerElement.getAttributeValue(new QName(EventProcessorConstants.NAME)); - ComponentInfoHolder componentInfoHolder = new ComponentInfoHolder(EventProcessorConstants.TRIGGER_SPOUT + "_" + name, - ComponentInfoHolder.ComponentType.TRIGGER_SPOUT); - - OMElement triggerDefinitionElement = triggerElement.getFirstChildWithName(new QName(EventProcessorConstants.TRIGGER_DEFINITION)); - String triggerDefinition = triggerDefinitionElement.getText(); - - OMElement outputStreamElement = triggerElement.getFirstChildWithName(new QName(EventProcessorConstants.OUTPUT_STREAM)); - String outputStream = outputStreamElement.getText(); - - componentInfoHolder.addOutputStream(outputStream); - componentInfoHolder.setDeclarer(builder.setSpout(EventProcessorConstants.TRIGGER_SPOUT + "_" + name - , new TriggerSpout(name, triggerDefinition, executionPlanName, tenantId), 1)); - - topologyInfoHolder.addComponent(componentInfoHolder); - - } - - topologyInfoHolder.indexComponents(); - - /** - * Connecting components together. - * 1) Get each component - * 2) Get input streams of that component - * 3) Find publishers who publishes each input stream - * 4) Connect with producer of input stream - */ - for (ComponentInfoHolder componentInfoHolder : topologyInfoHolder.getComponents()) { - - if (componentInfoHolder.getComponentType() != ComponentInfoHolder.ComponentType.EVENT_RECEIVER_SPOUT && - componentInfoHolder.getComponentType() != ComponentInfoHolder.ComponentType.TRIGGER_SPOUT) { - - BoltDeclarer boltDeclarer = (BoltDeclarer) componentInfoHolder.getDeclarer(); - for (String inputStreamId : componentInfoHolder.getInputStreamIds()) { - if (topologyInfoHolder.getPublishingComponents(inputStreamId) != null) { - for (ComponentInfoHolder pubComponent : topologyInfoHolder.getPublishingComponents(inputStreamId)) { - - if (pubComponent.getComponentType() != ComponentInfoHolder.ComponentType.EVENT_PUBLISHER_BOLT && - !pubComponent.getComponentName().equals(componentInfoHolder.getComponentName())) { - String partitionedField = componentInfoHolder.getPartionenedField(inputStreamId); - String groupingType = "ShuffleGrouping"; - if (partitionedField == null) { - boltDeclarer.shuffleGrouping(pubComponent.getComponentName(), inputStreamId); - } else { - groupingType = "FieldGrouping"; - boltDeclarer.fieldsGrouping(pubComponent.getComponentName(), inputStreamId, new Fields(partitionedField)); - } - - if (log.isDebugEnabled()) { - log.debug("Connecting storm components [Consumer:" + componentInfoHolder.getComponentName() - + ", Stream:" + inputStreamId - + ", Publisher:" + pubComponent.getComponentName() - + ", Grouping:" + groupingType + "]"); - } - } - } - } else { - throw new StormQueryConstructionException("No corresponding stream imported for Siddhi stream" + - " : " + inputStreamId); - } - } - } - } - - return builder; - } - - private static List getStreamDefinitions(OMElement streamsElement) { - List streamDefinitions = new ArrayList(); - Iterator streamIterator = streamsElement.getChildrenWithName(new QName("stream")); - while (streamIterator.hasNext()) { - OMElement streamElement = streamIterator.next(); - String streamDefinition = streamElement.getText(); - streamDefinitions.add(streamDefinition); - } - return streamDefinitions; - } - - /** - * Adding stream partitioned fields - */ - private static void addPartitionFields(OMElement streamsElement, ComponentInfoHolder componentInfoHolder) throws - StormQueryConstructionException { - Iterator streamIterator = streamsElement.getChildrenWithName(new QName(EventProcessorConstants.STREAM)); - while (streamIterator.hasNext()) { - OMElement streamElement = streamIterator.next(); - OMAttribute partitionAttribute = streamElement.getAttribute(new QName("partition")); - if (partitionAttribute != null) { - StreamDefinition streamDefinition = SiddhiCompiler.parseStreamDefinition(streamElement.getText()); - if (!Arrays.asList(streamDefinition.getAttributeNameArray()).contains(partitionAttribute - .getAttributeValue())) { - throw new StormQueryConstructionException("All input streams of the partition should have the " + - "partitioning attribute."); - } - componentInfoHolder.addStreamPartitioningField(streamDefinition.getId(), partitionAttribute.getAttributeValue()); - } - } - } -} \ No newline at end of file diff --git a/components/event-processor/org.wso2.carbon.event.processor.core/src/main/java/org/wso2/carbon/event/processor/core/internal/storm/util/TopologyInfoHolder.java b/components/event-processor/org.wso2.carbon.event.processor.core/src/main/java/org/wso2/carbon/event/processor/core/internal/storm/util/TopologyInfoHolder.java deleted file mode 100644 index 87e0d23e9..000000000 --- a/components/event-processor/org.wso2.carbon.event.processor.core/src/main/java/org/wso2/carbon/event/processor/core/internal/storm/util/TopologyInfoHolder.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.wso2.carbon.event.processor.core.internal.storm.util; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Set; - -public class TopologyInfoHolder { - /** - * List of wiring information of all the components - */ - private ArrayList components = new ArrayList(); - - /** - * Indexing Bolts against input stream name to enable retrieving all the components which consumes a given - * stream. - */ - HashMap> inputStreamToPublishingComponents = new HashMap>(); - - - public void addComponent(ComponentInfoHolder componentInfoHolder){ - components.add(componentInfoHolder); - } - - /** - * Index all the storm components(i.e. spouts and bolts) of the topology against input stream definitions, - * to make it possible to retrieve which components consumes a given stream - */ - public void indexComponents(){ - for (ComponentInfoHolder component: components){ - for (String inputStream : component.getOutputStreamIds()) { - Set publishingComponents = inputStreamToPublishingComponents.get(inputStream); - - if (publishingComponents == null) { - publishingComponents = new HashSet(); - inputStreamToPublishingComponents.put(inputStream, publishingComponents); - } - - publishingComponents.add(component); - } - } - } - - /** - * Return the set of components which consumes a given stream. - * @param streamId Siddhi stream id - * @return Set of objects containing metadata of components which consumes the given stream - */ - public Set getPublishingComponents(String streamId){ - return inputStreamToPublishingComponents.get(streamId); - } - - public ArrayList getComponents(){ - return components; - } -} diff --git a/components/event-processor/org.wso2.carbon.event.processor.core/src/test/java/org/wso2/event/processor/core/test/StormQueryPlanBuilderTestCase.java b/components/event-processor/org.wso2.carbon.event.processor.core/src/test/java/org/wso2/event/processor/core/test/StormQueryPlanBuilderTestCase.java deleted file mode 100644 index a730e7ded..000000000 --- a/components/event-processor/org.wso2.carbon.event.processor.core/src/test/java/org/wso2/event/processor/core/test/StormQueryPlanBuilderTestCase.java +++ /dev/null @@ -1,547 +0,0 @@ -/* - * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.wso2.event.processor.core.test; - -import junit.framework.Assert; -import org.apache.axiom.om.OMElement; -import org.apache.axis2.util.XMLUtils; -import org.junit.Before; -import org.junit.Test; -import org.w3c.dom.Document; -import org.wso2.carbon.event.processor.core.ExecutionPlanConfiguration; -import org.wso2.carbon.event.processor.core.StreamConfiguration; -import org.wso2.carbon.event.processor.core.exception.StormQueryConstructionException; -import org.wso2.carbon.event.processor.core.internal.ds.EventProcessorValueHolder; -import org.wso2.carbon.event.processor.core.internal.storm.util.StormQueryPlanBuilder; -import org.wso2.carbon.event.processor.core.internal.util.EventProcessorConstants; -import org.wso2.siddhi.core.SiddhiManager; - -import javax.xml.namespace.QName; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Iterator; -import java.util.List; - -public class StormQueryPlanBuilderTestCase { - - //private static final String singleQuery = - - @Before - public void init() { - EventProcessorValueHolder.registerSiddhiManager(new SiddhiManager()); - } - - @Test - public void testSingleQuery() throws Exception { - - List importedDefinition = new ArrayList(1); - List exportedDefinition = new ArrayList(1); - String analyticStats = "define stream analyticsStats ( meta_ipAdd string, meta_index long, " + - "meta_timestamp long, meta_nanoTime long, userID string, searchTerms string );"; - String filteredAnalyticStats = "define stream filteredStatStream ( meta_ipAdd string, meta_index long, " + - "meta_timestamp long, meta_nanoTime long, userID string );"; - ExecutionPlanConfiguration configuration = new ExecutionPlanConfiguration(); - configuration.addImportedStream(new StreamConfiguration("test1", "1.0.0", "analyticsStats")); - configuration.addExportedStream(new StreamConfiguration("test2", "1.0.0", "filteredStatStream")); - configuration.setExecutionPlan("@Plan:name('ExecutionPlan') " + analyticStats + filteredAnalyticStats + - "@name('query1') @dist(parallel='1') from analyticsStats[meta_ipAdd != '192" + - ".168.1.1']#window.time(5 min) " + - "select meta_ipAdd, meta_index, meta_timestamp, meta_nanoTime, userID " + - "insert into filteredStatStream;"); - importedDefinition.add(analyticStats); - exportedDefinition.add(filteredAnalyticStats); - Document document = StormQueryPlanBuilder.constructStormQueryPlanXML(configuration, importedDefinition, - exportedDefinition); - OMElement queryElement = XMLUtils.toOM(document.getDocumentElement()); - - Iterator iterator = queryElement.getChildrenWithName(new QName("event-receiver")); - while (iterator.hasNext()) { - OMElement eventReceiverElement = iterator.next(); - List streamDefinitions = getStreamDefinitions(eventReceiverElement.getFirstChildWithName(new QName - ("streams"))); - Assert.assertTrue(streamDefinitions.size() == 1); - Assert.assertEquals(streamDefinitions.get(0), "define stream analyticsStats ( meta_ipAdd string, " + - "meta_index long, " + - "meta_timestamp long, meta_nanoTime long, userID string, searchTerms string );"); - } - iterator = queryElement.getChildrenWithName(new QName("event-publisher")); - while (iterator.hasNext()) { - OMElement eventPublisherElement = iterator.next(); - List streamDefinitions = getStreamDefinitions(eventPublisherElement.getFirstChildWithName(new QName - ("input-streams"))); - Assert.assertTrue(streamDefinitions.size() == 1); - Assert.assertEquals(streamDefinitions.get(0), "define stream filteredStatStream ( meta_ipAdd string, " + - "meta_index long, meta_timestamp long, meta_nanoTime long, userID string );"); - } - iterator = queryElement.getChildrenWithName(new QName("event-processor")); - while (iterator.hasNext()) { - OMElement eventProcessorElement = iterator.next(); - String name = eventProcessorElement.getAttributeValue(new QName(EventProcessorConstants.NAME)); - Assert.assertEquals("query1", name); - String parallelism = eventProcessorElement.getAttributeValue(new QName(EventProcessorConstants.PARALLEL)); - Assert.assertEquals("1", parallelism); - String isEnforced = eventProcessorElement.getAttributeValue(new QName(EventProcessorConstants - .ENFORCE_PARALLELISM)); - Assert.assertEquals("true", isEnforced); - String query = eventProcessorElement.getFirstChildWithName(new QName - ("queries")).getText(); - Assert.assertEquals(query, "@name('query1') @dist(parallel='1') from analyticsStats[meta_ipAdd != '192" + - ".168.1.1']#window.time(5 min) " + - "select meta_ipAdd, meta_index, meta_timestamp, meta_nanoTime, userID " + - "insert into filteredStatStream;"); - } - } - - @Test - public void testMultipleQueryWithAnnotations() throws Exception { - List importedDefinition = new ArrayList(2); - List exportedDefinition = new ArrayList(1); - - String analyticStats = "define stream analyticsStats ( meta_ipAdd string, meta_index long, " + - "meta_timestamp long, meta_nanoTime long, userID string, searchTerms string );"; - String stockQuotes = "define stream stockQuote ( price int, symbol string );"; - String filteredAnalyticStats = "define stream fortuneCompanyStream ( price int, symbol string, count long );"; - - ExecutionPlanConfiguration configuration = new ExecutionPlanConfiguration(); - configuration.addImportedStream(new StreamConfiguration("test1", "1.0.0", "analyticsStats")); - configuration.addImportedStream(new StreamConfiguration("test2", "1.0.0", "stockQuote")); - configuration.addExportedStream(new StreamConfiguration("test3", "1.0.0", "fortuneCompanyStream")); - String queryExpression = "@name('query1') @dist(parallel='2') from analyticsStats[searchTerms==\"google\" or " + - "searchTerms==\"wso2\" or " + - "searchTerms==\"msft\" or searchTerms==\"oracle\"]\n" + - "select userID, searchTerms as symbol\n" + - "insert into filteredStatStream;\n" + - "\n" + - "@name('query2') @dist(parallel='2') from stockQuote[price>100]\n" + - "select price, symbol\n" + - "insert into highStockQuote;\n" + - "\n" + - "@name('query3') @dist(parallel='1') from highStockQuote#window.time(5 min) as h join " + - "filteredStatStream#window.time(5 min) as f \n" + - "on h.symbol==f.symbol\n" + - "select h.price as price, h.symbol as symbol, f.userID as userid\n" + - "insert into joinStream;\n" + - "\n" + - "@name('query4') @dist(parallel='1') from joinStream#window.time(5 min)\n" + - "select price, symbol, count(userid) as count\n" + - "insert into countedStream;\n" + - "\n" + - "@name('query5') @dist(parallel='5') from countedStream[count>10] \n" + - "select price, symbol, count\n" + - "insert into fortuneCompanyStream;\n"; - configuration.setExecutionPlan(analyticStats + stockQuotes + filteredAnalyticStats + queryExpression); - - importedDefinition.add(analyticStats); - importedDefinition.add(stockQuotes); - exportedDefinition.add(filteredAnalyticStats); - Document document = StormQueryPlanBuilder.constructStormQueryPlanXML(configuration, importedDefinition, - exportedDefinition); - OMElement queryElement = XMLUtils.toOM(document.getDocumentElement()); - - //Assert receiver element - Iterator iterator = queryElement.getChildrenWithName(new QName("event-receiver")); - while (iterator.hasNext()) { - OMElement eventReceiverElement = iterator.next(); - List streamDefinitions = getStreamDefinitions(eventReceiverElement.getFirstChildWithName(new QName - ("streams"))); - Assert.assertTrue(streamDefinitions.size() == 2); - Assert.assertEquals(streamDefinitions.get(0), "define stream analyticsStats ( meta_ipAdd string, " + - "meta_index long, " + - "meta_timestamp long, meta_nanoTime long, userID string, searchTerms string );"); - Assert.assertEquals(streamDefinitions.get(1), "define stream stockQuote ( price int, symbol string );"); - } - - //Assert publisher element - iterator = queryElement.getChildrenWithName(new QName("event-publisher")); - while (iterator.hasNext()) { - OMElement eventPublisherElement = iterator.next(); - List streamDefinitions = getStreamDefinitions(eventPublisherElement.getFirstChildWithName(new QName - ("input-streams"))); - Assert.assertTrue(streamDefinitions.size() == 1); - Assert.assertEquals(streamDefinitions.get(0), "define stream fortuneCompanyStream ( price int, " + - "symbol string, count long );"); - } - - //Assert event processor elements - List queryList = Arrays.asList(queryExpression.split(";")); - iterator = queryElement.getChildrenWithName(new QName("event-processor")); - while (iterator.hasNext()) { - OMElement eventProcessorElement = iterator.next(); - String query = eventProcessorElement.getFirstChildWithName(new QName - ("queries")).getText(); - int index = Integer.parseInt(eventProcessorElement.getAttributeValue(new QName("name")).substring("query" - .length())); - Assert.assertEquals(query, queryList.get(index - 1).trim() + ";"); - } - } - - @Test - public void testQueryGrouping() throws Exception { - List importedDefinition = new ArrayList(2); - List exportedDefinition = new ArrayList(1); - - String analyticStats = "define stream analyticsStats ( meta_ipAdd string, meta_index long, " + - "meta_timestamp long, meta_nanoTime long, userID string, searchTerms string );"; - String stockQuotes = "define stream stockQuote ( price int, symbol string );"; - String filteredAnalyticStats = "define stream fortuneCompanyStream ( price int, symbol string, count long );"; - - ExecutionPlanConfiguration configuration = new ExecutionPlanConfiguration(); - configuration.addImportedStream(new StreamConfiguration("test1", "1.0.0", "analyticsStats")); - configuration.addImportedStream(new StreamConfiguration("test2", "1.0.0", "stockQuote")); - configuration.addExportedStream(new StreamConfiguration("test3", "1.0.0", "fortuneCompanyStream")); - String queryExpression = "@name('query1') @dist(parallel='1') from analyticsStats[searchTerms==\"google\" or " + - "searchTerms==\"wso2\" or " + - "searchTerms==\"msft\" or searchTerms==\"oracle\"]\n" + - "select userID, searchTerms as symbol\n" + - "insert into filteredStatStream;\n" + - "\n" + - "@name('query2') @dist(parallel='1', execGroup='1') from stockQuote[price>100]\n" + - "select price, symbol\n" + - "insert into highStockQuote;\n" + - "\n" + - "@name('query3') @dist(parallel='1', execGroup='1') from highStockQuote#window.time(5 min) as h join " + - "filteredStatStream#window.time(5 min) as f \n" + - "on h.symbol==f.symbol\n" + - "select h.price as price, h.symbol as symbol, f.userID as userid\n" + - "insert into joinStream;\n" + - "\n" + - "@name('query4') @dist(parallel='1') from joinStream#window.time(5 min)\n" + - "select price, symbol, count(userid) as count\n" + - "insert into countedStream;\n" + - "\n" + - "@name('query5') @dist(parallel='5') from countedStream[count>10] \n" + - "select price, symbol, count\n" + - "insert into fortuneCompanyStream;\n"; - configuration.setExecutionPlan(analyticStats + stockQuotes + filteredAnalyticStats + queryExpression); - - importedDefinition.add(analyticStats); - importedDefinition.add(stockQuotes); - exportedDefinition.add(filteredAnalyticStats); - Document document = StormQueryPlanBuilder.constructStormQueryPlanXML(configuration, importedDefinition, - exportedDefinition); - OMElement queryElement = XMLUtils.toOM(document.getDocumentElement()); - - //Assert receiver element - Iterator iterator = queryElement.getChildrenWithName(new QName("event-receiver")); - while (iterator.hasNext()) { - OMElement eventReceiverElement = iterator.next(); - List streamDefinitions = getStreamDefinitions(eventReceiverElement.getFirstChildWithName(new QName - ("streams"))); - Assert.assertTrue(streamDefinitions.size() == 2); - Assert.assertEquals(streamDefinitions.get(0), "define stream analyticsStats ( meta_ipAdd string, " + - "meta_index long, " + - "meta_timestamp long, meta_nanoTime long, userID string, searchTerms string );"); - Assert.assertEquals(streamDefinitions.get(1), "define stream stockQuote ( price int, symbol string );"); - } - - //Assert publisher element - iterator = queryElement.getChildrenWithName(new QName("event-publisher")); - while (iterator.hasNext()) { - OMElement eventPublisherElement = iterator.next(); - List streamDefinitions = getStreamDefinitions(eventPublisherElement.getFirstChildWithName(new QName - ("input-streams"))); - Assert.assertTrue(streamDefinitions.size() == 1); - Assert.assertEquals(streamDefinitions.get(0), "define stream fortuneCompanyStream ( price int, " + - "symbol string, count long );"); - } - - //Assert event processor elements - iterator = queryElement.getChildrenWithName(new QName("event-processor")); - int count = 0; - while (iterator.hasNext()) { - OMElement eventProcessorElement = iterator.next(); - String name = eventProcessorElement.getAttributeValue(new QName(EventProcessorConstants.NAME)); - if (name.equals("1")) { - String isEnforced = eventProcessorElement.getAttributeValue(new QName(EventProcessorConstants - .ENFORCE_PARALLELISM)); - Assert.assertEquals("true", isEnforced); - } - count++; - } - Assert.assertEquals("There should be only 4 processor elements", 4, count); - } - - - @Test(expected = StormQueryConstructionException.class) - public void testMultipleParallelismInSingleGroup() throws Exception { - List importedDefinition = new ArrayList(2); - List exportedDefinition = new ArrayList(1); - - String analyticStats = "define stream analyticsStats ( meta_ipAdd string, meta_index long, " + - "meta_timestamp long, meta_nanoTime long, userID string, searchTerms string );"; - String stockQuotes = "define stream stockQuote ( price int, symbol string );"; - String filteredAnalyticStats = "define stream fortuneCompanyStream ( price int, symbol string, count long );"; - - ExecutionPlanConfiguration configuration = new ExecutionPlanConfiguration(); - configuration.addImportedStream(new StreamConfiguration("test1", "1.0.0", "analyticsStats")); - configuration.addImportedStream(new StreamConfiguration("test2", "1.0.0", "stockQuote")); - configuration.addExportedStream(new StreamConfiguration("test3", "1.0.0", "fortuneCompanyStream")); - String queryExpression = "@name('query1') @dist(parallel='1') from analyticsStats[searchTerms==\"google\" or " + - "searchTerms==\"wso2\" or " + - "searchTerms==\"msft\" or searchTerms==\"oracle\"]\n" + - "select userID, searchTerms as symbol\n" + - "insert into filteredStatStream;\n" + - "\n" + - "@name('query2') @dist(parallel='2', execGroup='1') from stockQuote[price>100]\n" + - "select price, symbol\n" + - "insert into highStockQuote;\n" + - "\n" + - "@name('query3') @dist(parallel='1', execGroup='1') from highStockQuote#window.time(5 min) as h join " + - "filteredStatStream#window.time(5 min) as f \n" + - "on h.symbol==f.symbol\n" + - "select h.price as price, h.symbol as symbol, f.userID as userid\n" + - "insert into joinStream;\n" + - "\n" + - "@name('query4') @dist(parallel='1') from joinStream#window.time(5 min)\n" + - "select price, symbol, count(userid) as count\n" + - "insert into countedStream;\n" + - "\n" + - "@name('query5') @dist(parallel='5') from countedStream[count>10] \n" + - "select price, symbol, count\n" + - "insert into fortuneCompanyStream;\n"; - configuration.setExecutionPlan(analyticStats + stockQuotes + filteredAnalyticStats + queryExpression); - - importedDefinition.add(analyticStats); - importedDefinition.add(stockQuotes); - exportedDefinition.add(filteredAnalyticStats); - StormQueryPlanBuilder.constructStormQueryPlanXML(configuration, importedDefinition, exportedDefinition); - } - - @Test(expected = StormQueryConstructionException.class) - public void testMultipleParallelismInStateQueries() throws Exception { - List importedDefinition = new ArrayList(2); - List exportedDefinition = new ArrayList(1); - - String analyticStats = "define stream analyticsStats ( meta_ipAdd string, meta_index long, " + - "meta_timestamp long, meta_nanoTime long, userID string, searchTerms string );"; - String stockQuotes = "define stream stockQuote ( price int, symbol string );"; - String filteredAnalyticStats = "define stream fortuneCompanyStream ( price int, symbol string, count long );"; - - ExecutionPlanConfiguration configuration = new ExecutionPlanConfiguration(); - configuration.addImportedStream(new StreamConfiguration("test1", "1.0.0", "analyticsStats")); - configuration.addImportedStream(new StreamConfiguration("test2", "1.0.0", "stockQuote")); - configuration.addExportedStream(new StreamConfiguration("test3", "1.0.0", "fortuneCompanyStream")); - String queryExpression = "@name('query1') @dist(parallel='1') from analyticsStats[searchTerms==\"google\" or " + - "searchTerms==\"wso2\" or " + - "searchTerms==\"msft\" or searchTerms==\"oracle\"]\n" + - "select userID, searchTerms as symbol\n" + - "insert into filteredStatStream;\n" + - "\n" + - "@name('query2') @dist(parallel='1', execGroup='1') from stockQuote[price>100]\n" + - "select price, symbol\n" + - "insert into highStockQuote;\n" + - "\n" + - "@name('query3') @dist(parallel='1', execGroup='1') from highStockQuote#window.time(5 min) as h join " + - "filteredStatStream#window.time(5 min) as f \n" + - "on h.symbol==f.symbol\n" + - "select h.price as price, h.symbol as symbol, f.userID as userid\n" + - "insert into joinStream;\n" + - "\n" + - "@name('query4') @dist(parallel='2') from joinStream#window.time(5 min)\n" + - "select price, symbol, count(userid) as count\n" + - "insert into countedStream;\n" + - "\n" + - "@name('query5') @dist(parallel='5') from countedStream[count>10] \n" + - "select price, symbol, count\n" + - "insert into fortuneCompanyStream;\n"; - configuration.setExecutionPlan(analyticStats + stockQuotes + filteredAnalyticStats + queryExpression); - - importedDefinition.add(analyticStats); - importedDefinition.add(stockQuotes); - exportedDefinition.add(filteredAnalyticStats); - StormQueryPlanBuilder.constructStormQueryPlanXML(configuration, importedDefinition, exportedDefinition); - } - - @Test - public void testPartitioningQuery() throws Exception { - List importedDefinition = new ArrayList(2); - List exportedDefinition = new ArrayList(1); - - String analyticStats = "define stream analyticsStats ( meta_ipAdd string, meta_index long, " + - "meta_timestamp long, meta_nanoTime long, userID string, searchTerms string );"; - String stockQuotes = "define stream stockQuote ( price int, symbol string );"; - String filteredAnalyticStats = "define stream fortuneCompanyStream ( price int, symbol string, count long );"; - - ExecutionPlanConfiguration configuration = new ExecutionPlanConfiguration(); - configuration.addImportedStream(new StreamConfiguration("test1", "1.0.0", "analyticsStats")); - configuration.addImportedStream(new StreamConfiguration("test2", "1.0.0", "stockQuote")); - configuration.addExportedStream(new StreamConfiguration("test3", "1.0.0", "fortuneCompanyStream")); - String queryExpression = "@name('query1') @dist(parallel='1') from analyticsStats[searchTerms==\"google\" or " + - "searchTerms==\"wso2\" or " + - "searchTerms==\"msft\" or searchTerms==\"oracle\"]\n" + - "select userID, searchTerms as symbol\n" + - "insert into filteredStatStream;\n" + - "\n" + - "@name('query2') @dist(parallel='1', execGroup='1') from stockQuote[price>100]\n" + - "select price, symbol\n" + - "insert into highStockQuote;\n" + - "\n" + - "@name('query3') @dist(parallel='1', execGroup='1') from highStockQuote#window.time(5 min) as h join " + - "filteredStatStream#window.time(5 min) as f \n" + - "on h.symbol==f.symbol\n" + - "select h.price as price, h.symbol as symbol, f.userID as userid\n" + - "insert into joinStream;\n" + - "\n" + - "partition with (symbol of joinStream) begin " + - "@name('query4') from joinStream#window.time(5 min)\n" + - "select price, symbol, count(userid) as count\n" + - "insert into countedStream;\n" + - "\n" + - "@name('query5') from countedStream[count>10] \n" + - "select price, symbol, count\n" + - "insert into fortuneCompanyStream;\n" + - "end;"; - configuration.setExecutionPlan(analyticStats + stockQuotes + filteredAnalyticStats + queryExpression); - - importedDefinition.add(analyticStats); - importedDefinition.add(stockQuotes); - exportedDefinition.add(filteredAnalyticStats); - Document document = StormQueryPlanBuilder.constructStormQueryPlanXML(configuration, importedDefinition, - exportedDefinition); - OMElement queryElement = XMLUtils.toOM(document.getDocumentElement()); - Iterator iterator = queryElement.getChildrenWithName(new QName("event-processor")); - int count = 0; - int partitionCount = 0; - String partitionAttribute = null; - while (iterator.hasNext()) { - count++; - OMElement eventProcessorElement = iterator.next(); - OMElement inputStreams = eventProcessorElement.getFirstChildWithName(new QName(EventProcessorConstants.INPUT_STREAMS)); - Iterator iterator2 = inputStreams.getChildrenWithName(new QName(EventProcessorConstants.STREAM)); - while (iterator2.hasNext()) { - OMElement streamElement = iterator2.next(); - if (streamElement.getAttribute(new QName(EventProcessorConstants.PARTITION)) != null) { - partitionCount++; - partitionAttribute = streamElement.getAttribute(new QName(EventProcessorConstants.PARTITION)) - .getAttributeValue(); - } - } - } - Assert.assertEquals("There should be only 4 processor elements", 3, count); - Assert.assertEquals("There should be only 1 partition", 1, partitionCount); - Assert.assertNotNull("Partition attribute should not be null", partitionAttribute); - Assert.assertEquals("Partition attribute should be correctly set", "symbol", partitionAttribute); - } - - @Test(expected = StormQueryConstructionException.class) - public void testPartitioningWithDistAnnotationsQuery() throws Exception { - List importedDefinition = new ArrayList(2); - List exportedDefinition = new ArrayList(1); - - String analyticStats = "define stream analyticsStats ( meta_ipAdd string, meta_index long, " + - "meta_timestamp long, meta_nanoTime long, userID string, searchTerms string );"; - String stockQuotes = "define stream stockQuote ( price int, symbol string );"; - String filteredAnalyticStats = "define stream fortuneCompanyStream ( price int, symbol string, count long );"; - - ExecutionPlanConfiguration configuration = new ExecutionPlanConfiguration(); - configuration.addImportedStream(new StreamConfiguration("test1", "1.0.0", "analyticsStats")); - configuration.addImportedStream(new StreamConfiguration("test2", "1.0.0", "stockQuote")); - configuration.addExportedStream(new StreamConfiguration("test3", "1.0.0", "fortuneCompanyStream")); - String queryExpression = "@name('query1') @dist(parallel='1') from analyticsStats[searchTerms==\"google\" or " + - "searchTerms==\"wso2\" or " + - "searchTerms==\"msft\" or searchTerms==\"oracle\"]\n" + - "select userID, searchTerms as symbol\n" + - "insert into filteredStatStream;\n" + - "\n" + - "@name('query2') @dist(parallel='1', execGroup='1') from stockQuote[price>100]\n" + - "select price, symbol\n" + - "insert into highStockQuote;\n" + - "\n" + - "@name('query3') @dist(parallel='1', execGroup='1') from highStockQuote#window.time(5 min) as h join " + - "filteredStatStream#window.time(5 min) as f \n" + - "on h.symbol==f.symbol\n" + - "select h.price as price, h.symbol as symbol, f.userID as userid\n" + - "insert into joinStream;\n" + - "\n" + - "partition with (symbol of joinStream) begin " + - "@name('query4') @dist(parallel='2') from joinStream#window.time(5 min)\n" + - "select price, symbol, count(userid) as count\n" + - "insert into countedStream;\n" + - "\n" + - "@name('query5') @dist(parallel='5') from countedStream[count>10] \n" + - "select price, symbol, count\n" + - "insert into fortuneCompanyStream;\n" + - "end;"; - configuration.setExecutionPlan(analyticStats + stockQuotes + filteredAnalyticStats + queryExpression); - - importedDefinition.add(analyticStats); - importedDefinition.add(stockQuotes); - exportedDefinition.add(filteredAnalyticStats); - StormQueryPlanBuilder.constructStormQueryPlanXML(configuration, importedDefinition, exportedDefinition); - - } - - @Test(expected = StormQueryConstructionException.class) - public void testPartitioningWithGroupingQuery() throws Exception { - List importedDefinition = new ArrayList(2); - List exportedDefinition = new ArrayList(1); - - String analyticStats = "define stream analyticsStats ( meta_ipAdd string, meta_index long, " + - "meta_timestamp long, meta_nanoTime long, userID string, searchTerms string );"; - String stockQuotes = "define stream stockQuote ( price int, symbol string );"; - String filteredAnalyticStats = "define stream fortuneCompanyStream ( price int, symbol string, count long );"; - - ExecutionPlanConfiguration configuration = new ExecutionPlanConfiguration(); - configuration.addImportedStream(new StreamConfiguration("test1", "1.0.0", "analyticsStats")); - configuration.addImportedStream(new StreamConfiguration("test2", "1.0.0", "stockQuote")); - configuration.addExportedStream(new StreamConfiguration("test3", "1.0.0", "fortuneCompanyStream")); - String queryExpression = "@name('query1') @dist(parallel='1') from analyticsStats[searchTerms==\"google\" or " + - "searchTerms==\"wso2\" or " + - "searchTerms==\"msft\" or searchTerms==\"oracle\"]\n" + - "select userID, searchTerms as symbol\n" + - "insert into filteredStatStream;\n" + - "\n" + - "@name('query2') @dist(parallel='1', execGroup='1') from stockQuote[price>100]\n" + - "select price, symbol\n" + - "insert into highStockQuote;\n" + - "\n" + - "@name('query3') @dist(parallel='1', execGroup='1') from highStockQuote#window.time(5 min) as h join " + - "filteredStatStream#window.time(5 min) as f \n" + - "on h.symbol==f.symbol\n" + - "select h.price as price, h.symbol as symbol, f.userID as userid\n" + - "insert into joinStream;\n" + - "\n" + - "@dist(execGroup='1') partition with (symbol of joinStream) begin " + - "@name('query4') from joinStream#window.time(5 min)\n" + - "select price, symbol, count(userid) as count\n" + - "insert into countedStream;\n" + - "\n" + - "@name('query5') from countedStream[count>10] \n" + - "select price, symbol, count\n" + - "insert into fortuneCompanyStream;\n" + - "end;"; - configuration.setExecutionPlan(analyticStats + stockQuotes + filteredAnalyticStats + queryExpression); - - importedDefinition.add(analyticStats); - importedDefinition.add(stockQuotes); - exportedDefinition.add(filteredAnalyticStats); - StormQueryPlanBuilder.constructStormQueryPlanXML(configuration, importedDefinition, exportedDefinition); - - } - - private static List getStreamDefinitions(OMElement streamsElement) { - List inputStreamDefinitions = new ArrayList(); - Iterator inputStreamIterator = streamsElement.getChildrenWithName(new QName("stream")); - while (inputStreamIterator.hasNext()) { - OMElement inputStreamElement = inputStreamIterator.next(); - String streamDefinition = inputStreamElement.getText(); - inputStreamDefinitions.add(streamDefinition); - } - return inputStreamDefinitions; - } - - -} \ No newline at end of file diff --git a/components/event-processor/org.wso2.carbon.event.processor.core/src/test/java/org/wso2/event/processor/core/test/StormQuerySplitterTestCase.java b/components/event-processor/org.wso2.carbon.event.processor.core/src/test/java/org/wso2/event/processor/core/test/StormQuerySplitterTestCase.java deleted file mode 100644 index e1bea49bc..000000000 --- a/components/event-processor/org.wso2.carbon.event.processor.core/src/test/java/org/wso2/event/processor/core/test/StormQuerySplitterTestCase.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.wso2.event.processor.core.test; - -import org.antlr.v4.runtime.ANTLRInputStream; -import org.antlr.v4.runtime.CommonTokenStream; -import org.antlr.v4.runtime.tree.ParseTree; -import org.junit.Assert; -import org.junit.Test; -import org.wso2.carbon.event.processor.core.internal.storm.compiler.SiddhiQLStormQuerySplitter; -import org.wso2.siddhi.query.compiler.SiddhiQLLexer; -import org.wso2.siddhi.query.compiler.SiddhiQLParser; -import org.wso2.siddhi.query.compiler.SiddhiQLVisitor; -import org.wso2.siddhi.query.compiler.internal.SiddhiErrorListener; - -import java.util.List; - -public class StormQuerySplitterTestCase { - - @Test - public void testSplitting() { - String source = "from StockStream[price>3]#window.length(50) select symbol, avg(price) as avgPrice " + - "group by symbol having (price >= 20) insert all events into StockQuote; " + - "from StockStream[symbol==IBM] select * insert into testStream;"; - ANTLRInputStream input = new ANTLRInputStream(source); - SiddhiQLLexer lexer = new SiddhiQLLexer(input); - lexer.removeErrorListeners(); - lexer.addErrorListener(SiddhiErrorListener.INSTANCE); - - CommonTokenStream tokens = new CommonTokenStream(lexer); - SiddhiQLParser parser = new SiddhiQLParser(tokens); - parser.removeErrorListeners(); - parser.addErrorListener(SiddhiErrorListener.INSTANCE); - ParseTree tree = parser.parse(); - - SiddhiQLVisitor eval = new SiddhiQLStormQuerySplitter(); - List queryList = (List) eval.visit(tree); - Assert.assertEquals("Two separate queries should return", 2, queryList.size()); - - } - - @Test - public void testPartitionSplitting() { - String executionPlan = "@config(async = 'true')define stream streamA (symbol string, price int);" + - "partition with (symbol of streamA) begin @info(name = 'query1') from streamA select symbol,price insert into StockQuote ; " + - "from StockQuote select symbol,price insert into dummyStock; end; from StockStream[symbol==IBM] select * insert into testStream;"; - - ANTLRInputStream input = new ANTLRInputStream(executionPlan); - SiddhiQLLexer lexer = new SiddhiQLLexer(input); - lexer.removeErrorListeners(); - lexer.addErrorListener(SiddhiErrorListener.INSTANCE); - - CommonTokenStream tokens = new CommonTokenStream(lexer); - SiddhiQLParser parser = new SiddhiQLParser(tokens); - parser.removeErrorListeners(); - parser.addErrorListener(SiddhiErrorListener.INSTANCE); - ParseTree tree = parser.parse(); - - SiddhiQLVisitor eval = new SiddhiQLStormQuerySplitter(); - List queryList = (List) eval.visit(tree); - Assert.assertEquals("Two separate queries should return", 2, queryList.size()); - } -} diff --git a/components/event-processor/org.wso2.carbon.event.processor.template.deployer/pom.xml b/components/event-processor/org.wso2.carbon.event.processor.template.deployer/pom.xml index 6ad359219..805e70bde 100644 --- a/components/event-processor/org.wso2.carbon.event.processor.template.deployer/pom.xml +++ b/components/event-processor/org.wso2.carbon.event.processor.template.deployer/pom.xml @@ -1,5 +1,4 @@ - - - + --> org.wso2.carbon.event-processing event-processor - 2.2.14 + 2.2.17-SNAPSHOT ../pom.xml @@ -96,4 +94,4 @@ - + \ No newline at end of file diff --git a/components/event-processor/org.wso2.carbon.event.processor.ui/pom.xml b/components/event-processor/org.wso2.carbon.event.processor.ui/pom.xml index 140856d55..75fb9b41a 100644 --- a/components/event-processor/org.wso2.carbon.event.processor.ui/pom.xml +++ b/components/event-processor/org.wso2.carbon.event.processor.ui/pom.xml @@ -1,5 +1,4 @@ - - - + --> org.wso2.carbon.event-processing event-processor - 2.2.14 + 2.2.17-SNAPSHOT ../pom.xml @@ -107,5 +105,4 @@ - - + \ No newline at end of file diff --git a/components/event-processor/pom.xml b/components/event-processor/pom.xml index d30209076..0d69a33a7 100644 --- a/components/event-processor/pom.xml +++ b/components/event-processor/pom.xml @@ -1,5 +1,4 @@ - - - + --> org.wso2.carbon.event-processing carbon-event-processing - 2.2.14 + 2.2.17-SNAPSHOT ../../pom.xml @@ -39,6 +37,4 @@ org.wso2.carbon.event.processor.template.deployer - - - + \ No newline at end of file diff --git a/components/event-simulator/org.wso2.carbon.event.simulator.admin/pom.xml b/components/event-simulator/org.wso2.carbon.event.simulator.admin/pom.xml index 551bcb455..dbd697f2d 100644 --- a/components/event-simulator/org.wso2.carbon.event.simulator.admin/pom.xml +++ b/components/event-simulator/org.wso2.carbon.event.simulator.admin/pom.xml @@ -1,5 +1,4 @@ - - - + --> org.wso2.carbon.event-processing event-simulator - 2.2.14 + 2.2.17-SNAPSHOT 4.0.0 @@ -92,4 +90,4 @@ - + \ No newline at end of file diff --git a/components/event-simulator/org.wso2.carbon.event.simulator.core/pom.xml b/components/event-simulator/org.wso2.carbon.event.simulator.core/pom.xml index f415145a7..bb4943e9a 100644 --- a/components/event-simulator/org.wso2.carbon.event.simulator.core/pom.xml +++ b/components/event-simulator/org.wso2.carbon.event.simulator.core/pom.xml @@ -1,5 +1,4 @@ - - - + --> org.wso2.carbon.event-processing event-simulator - 2.2.14 + 2.2.17-SNAPSHOT 4.0.0 @@ -99,4 +97,4 @@ - + \ No newline at end of file diff --git a/components/event-simulator/org.wso2.carbon.event.simulator.ui/pom.xml b/components/event-simulator/org.wso2.carbon.event.simulator.ui/pom.xml index 01efd3254..574d6dc0c 100644 --- a/components/event-simulator/org.wso2.carbon.event.simulator.ui/pom.xml +++ b/components/event-simulator/org.wso2.carbon.event.simulator.ui/pom.xml @@ -1,5 +1,4 @@ - - - + --> event-simulator org.wso2.carbon.event-processing - 2.2.14 + 2.2.17-SNAPSHOT ../pom.xml @@ -95,4 +93,4 @@ - + \ No newline at end of file diff --git a/components/event-simulator/pom.xml b/components/event-simulator/pom.xml index a91780f2e..2d1e54a54 100644 --- a/components/event-simulator/pom.xml +++ b/components/event-simulator/pom.xml @@ -1,4 +1,4 @@ - - + --> org.wso2.carbon.event-processing carbon-event-processing - 2.2.14 + 2.2.17-SNAPSHOT ../../pom.xml @@ -36,4 +35,4 @@ - + \ No newline at end of file diff --git a/components/geo-dashboard/org.wso2.carbon.siddhi.geo.event.fuser/pom.xml b/components/geo-dashboard/org.wso2.carbon.siddhi.geo.event.fuser/pom.xml index 0b484622b..bd1027c10 100644 --- a/components/geo-dashboard/org.wso2.carbon.siddhi.geo.event.fuser/pom.xml +++ b/components/geo-dashboard/org.wso2.carbon.siddhi.geo.event.fuser/pom.xml @@ -1,9 +1,8 @@ - - + geo-dashboard org.wso2.carbon.event-processing - 2.2.14 + 2.2.17-SNAPSHOT ../pom.xml diff --git a/components/geo-dashboard/org.wso2.carbon.siddhi.geo.event.notifier/pom.xml b/components/geo-dashboard/org.wso2.carbon.siddhi.geo.event.notifier/pom.xml index c3cd2ad18..d2c08afe7 100644 --- a/components/geo-dashboard/org.wso2.carbon.siddhi.geo.event.notifier/pom.xml +++ b/components/geo-dashboard/org.wso2.carbon.siddhi.geo.event.notifier/pom.xml @@ -1,5 +1,4 @@ - - - - + --> org.wso2.carbon.event-processing geo-dashboard - 2.2.14 + 2.2.17-SNAPSHOT ../pom.xml diff --git a/components/geo-dashboard/pom.xml b/components/geo-dashboard/pom.xml index d014555d8..ec95fe7d8 100644 --- a/components/geo-dashboard/pom.xml +++ b/components/geo-dashboard/pom.xml @@ -1,5 +1,4 @@ - - - - + --> org.wso2.carbon.event-processing carbon-event-processing - 2.2.14 + 2.2.17-SNAPSHOT ../../pom.xml @@ -39,4 +36,4 @@ - + \ No newline at end of file diff --git a/components/siddhi-metrics/org.wso2.carbon.siddhi.metrics.core/pom.xml b/components/siddhi-metrics/org.wso2.carbon.siddhi.metrics.core/pom.xml index 3877f8879..f8ac6acb4 100644 --- a/components/siddhi-metrics/org.wso2.carbon.siddhi.metrics.core/pom.xml +++ b/components/siddhi-metrics/org.wso2.carbon.siddhi.metrics.core/pom.xml @@ -1,5 +1,4 @@ - - - + --> org.wso2.carbon.event-processing siddhi-metrics - 2.2.14 + 2.2.17-SNAPSHOT ../pom.xml @@ -81,4 +79,4 @@ - + \ No newline at end of file diff --git a/components/siddhi-metrics/pom.xml b/components/siddhi-metrics/pom.xml index fa6330736..7f75a8d18 100644 --- a/components/siddhi-metrics/pom.xml +++ b/components/siddhi-metrics/pom.xml @@ -1,5 +1,4 @@ - - - - + --> org.wso2.carbon.event-processing carbon-event-processing - 2.2.14 + 2.2.17-SNAPSHOT ../../pom.xml diff --git a/components/siddhi-tryit/org.wso2.carbon.siddhi.tryit.ui/pom.xml b/components/siddhi-tryit/org.wso2.carbon.siddhi.tryit.ui/pom.xml index ae5cc6db0..47d011fbc 100644 --- a/components/siddhi-tryit/org.wso2.carbon.siddhi.tryit.ui/pom.xml +++ b/components/siddhi-tryit/org.wso2.carbon.siddhi.tryit.ui/pom.xml @@ -1,5 +1,4 @@ - - - + --> siddhi-tryit org.wso2.carbon.event-processing - 2.2.14 + 2.2.17-SNAPSHOT 4.0.0 org.wso2.carbon.siddhi.tryit.ui WSO2 Carbon - Siddhi Tryit - 2.2.14 + 2.2.17-SNAPSHOT bundle @@ -95,4 +93,4 @@ - + \ No newline at end of file diff --git a/components/siddhi-tryit/pom.xml b/components/siddhi-tryit/pom.xml index 21b05c478..dcf1ac4ca 100644 --- a/components/siddhi-tryit/pom.xml +++ b/components/siddhi-tryit/pom.xml @@ -1,5 +1,4 @@ - - - - + --> carbon-event-processing org.wso2.carbon.event-processing - 2.2.14 + 2.2.17-SNAPSHOT ../../pom.xml diff --git a/features/event-flow/org.wso2.carbon.event.flow.feature/pom.xml b/features/event-flow/org.wso2.carbon.event.flow.feature/pom.xml index db6ea313d..b66ea12bc 100644 --- a/features/event-flow/org.wso2.carbon.event.flow.feature/pom.xml +++ b/features/event-flow/org.wso2.carbon.event.flow.feature/pom.xml @@ -1,5 +1,4 @@ - - - - + --> org.wso2.carbon.event-processing event-flow-feature - 2.2.14 + 2.2.17-SNAPSHOT ../pom.xml @@ -71,4 +68,4 @@ - + \ No newline at end of file diff --git a/features/event-flow/org.wso2.carbon.event.flow.server.feature/pom.xml b/features/event-flow/org.wso2.carbon.event.flow.server.feature/pom.xml index 6cf862b8d..9687f44dc 100644 --- a/features/event-flow/org.wso2.carbon.event.flow.server.feature/pom.xml +++ b/features/event-flow/org.wso2.carbon.event.flow.server.feature/pom.xml @@ -1,5 +1,4 @@ - - - - + --> org.wso2.carbon.event-processing event-flow-feature - 2.2.14 + 2.2.17-SNAPSHOT ../pom.xml @@ -83,4 +80,4 @@ - + \ No newline at end of file diff --git a/features/event-flow/org.wso2.carbon.event.flow.ui.feature/pom.xml b/features/event-flow/org.wso2.carbon.event.flow.ui.feature/pom.xml index dece37110..21c27b799 100644 --- a/features/event-flow/org.wso2.carbon.event.flow.ui.feature/pom.xml +++ b/features/event-flow/org.wso2.carbon.event.flow.ui.feature/pom.xml @@ -1,5 +1,4 @@ - - - - + --> org.wso2.carbon.event-processing event-flow-feature - 2.2.14 + 2.2.17-SNAPSHOT ../pom.xml @@ -80,4 +77,4 @@ - + \ No newline at end of file diff --git a/features/event-flow/pom.xml b/features/event-flow/pom.xml index d7f7db197..b4856b885 100644 --- a/features/event-flow/pom.xml +++ b/features/event-flow/pom.xml @@ -1,5 +1,4 @@ - - - - + --> carbon-event-processing org.wso2.carbon.event-processing - 2.2.14 + 2.2.17-SNAPSHOT ../../pom.xml 4.0.0 event-flow-feature - 2.2.14 + 2.2.17-SNAPSHOT pom WSO2 Carbon - Event Flow Feature Aggregator Module http://wso2.org @@ -38,5 +35,4 @@ - - + \ No newline at end of file diff --git a/features/event-processor/org.wso2.carbon.event.processor.feature/pom.xml b/features/event-processor/org.wso2.carbon.event.processor.feature/pom.xml index a0df9e391..bb78d12c5 100644 --- a/features/event-processor/org.wso2.carbon.event.processor.feature/pom.xml +++ b/features/event-processor/org.wso2.carbon.event.processor.feature/pom.xml @@ -1,5 +1,4 @@ - - - - + --> org.wso2.carbon.event-processing event-processor-feature - 2.2.14 + 2.2.17-SNAPSHOT ../pom.xml @@ -89,4 +86,4 @@ - + \ No newline at end of file diff --git a/features/event-processor/org.wso2.carbon.event.processor.server.feature/pom.xml b/features/event-processor/org.wso2.carbon.event.processor.server.feature/pom.xml index fa65bf6b8..068a11b01 100644 --- a/features/event-processor/org.wso2.carbon.event.processor.server.feature/pom.xml +++ b/features/event-processor/org.wso2.carbon.event.processor.server.feature/pom.xml @@ -1,5 +1,4 @@ - - - - +--> org.wso2.carbon.event-processing event-processor-feature - 2.2.14 + 2.2.17-SNAPSHOT ../pom.xml @@ -60,10 +57,6 @@ org.wso2.siddhi siddhi-query-compiler - - org.wso2.orbit.org.apache.storm - storm-core - org.wso2.carbon.event-processing org.wso2.carbon.event.processor.common @@ -257,9 +250,6 @@ org.wso2.siddhi:siddhi-query-compiler:${siddhi.version} - - org.wso2.orbit.org.apache.storm:storm-core:${storm.orbit.version} - org.wso2.carbon.event-processing:org.wso2.carbon.event.processor.common:${carbon.event.processing.version} @@ -344,4 +334,4 @@ - + \ No newline at end of file diff --git a/features/event-processor/org.wso2.carbon.event.processor.template.deployer.feature/pom.xml b/features/event-processor/org.wso2.carbon.event.processor.template.deployer.feature/pom.xml index ace86d1fd..1699669e6 100644 --- a/features/event-processor/org.wso2.carbon.event.processor.template.deployer.feature/pom.xml +++ b/features/event-processor/org.wso2.carbon.event.processor.template.deployer.feature/pom.xml @@ -1,9 +1,8 @@ - - + event-processor-feature org.wso2.carbon.event-processing - 2.2.14 + 2.2.17-SNAPSHOT ../pom.xml 4.0.0 diff --git a/features/event-processor/org.wso2.carbon.event.processor.ui.feature/pom.xml b/features/event-processor/org.wso2.carbon.event.processor.ui.feature/pom.xml index 518ff8e91..e2bf8f2e2 100644 --- a/features/event-processor/org.wso2.carbon.event.processor.ui.feature/pom.xml +++ b/features/event-processor/org.wso2.carbon.event.processor.ui.feature/pom.xml @@ -1,5 +1,4 @@ - - - + --> org.wso2.carbon.event-processing event-processor-feature - 2.2.14 + 2.2.17-SNAPSHOT ../pom.xml @@ -77,4 +75,4 @@ - + \ No newline at end of file diff --git a/features/event-processor/pom.xml b/features/event-processor/pom.xml index a7556adae..12eb0cfba 100644 --- a/features/event-processor/pom.xml +++ b/features/event-processor/pom.xml @@ -1,5 +1,4 @@ - - - - + --> carbon-event-processing org.wso2.carbon.event-processing - 2.2.14 + 2.2.17-SNAPSHOT ../../pom.xml @@ -39,4 +36,4 @@ - + \ No newline at end of file diff --git a/features/event-simulator/org.wso2.carbon.event.simulator.feature/pom.xml b/features/event-simulator/org.wso2.carbon.event.simulator.feature/pom.xml index fd7014e7b..93aa15e72 100644 --- a/features/event-simulator/org.wso2.carbon.event.simulator.feature/pom.xml +++ b/features/event-simulator/org.wso2.carbon.event.simulator.feature/pom.xml @@ -1,5 +1,4 @@ - - - - + --> org.wso2.carbon.event-processing event-simulator-feature - 2.2.14 + 2.2.17-SNAPSHOT ../pom.xml @@ -81,4 +78,4 @@ - + \ No newline at end of file diff --git a/features/event-simulator/org.wso2.carbon.event.simulator.server.feature/pom.xml b/features/event-simulator/org.wso2.carbon.event.simulator.server.feature/pom.xml index 860b0dd8f..90ce7ca2b 100644 --- a/features/event-simulator/org.wso2.carbon.event.simulator.server.feature/pom.xml +++ b/features/event-simulator/org.wso2.carbon.event.simulator.server.feature/pom.xml @@ -1,5 +1,4 @@ - - - - + --> org.wso2.carbon.event-processing event-simulator-feature - 2.2.14 + 2.2.17-SNAPSHOT ../pom.xml @@ -91,4 +88,4 @@ - + \ No newline at end of file diff --git a/features/event-simulator/org.wso2.carbon.event.simulator.ui.feature/pom.xml b/features/event-simulator/org.wso2.carbon.event.simulator.ui.feature/pom.xml index da3f50253..b24ce60a4 100644 --- a/features/event-simulator/org.wso2.carbon.event.simulator.ui.feature/pom.xml +++ b/features/event-simulator/org.wso2.carbon.event.simulator.ui.feature/pom.xml @@ -1,5 +1,4 @@ - - - - + --> org.wso2.carbon.event-processing event-simulator-feature - 2.2.14 + 2.2.17-SNAPSHOT ../pom.xml @@ -92,4 +89,4 @@ - + \ No newline at end of file diff --git a/features/event-simulator/pom.xml b/features/event-simulator/pom.xml index dab1ef76f..fbc75d7a3 100644 --- a/features/event-simulator/pom.xml +++ b/features/event-simulator/pom.xml @@ -1,5 +1,4 @@ - - - - + --> carbon-event-processing org.wso2.carbon.event-processing - 2.2.14 + 2.2.17-SNAPSHOT ../../pom.xml @@ -36,4 +33,4 @@ org.wso2.carbon.event.simulator.ui.feature - + \ No newline at end of file diff --git a/features/geo-dashboard/org.wso2.carbon.geo.dashboard.feature/pom.xml b/features/geo-dashboard/org.wso2.carbon.geo.dashboard.feature/pom.xml index a72df8bc4..5b1366de7 100644 --- a/features/geo-dashboard/org.wso2.carbon.geo.dashboard.feature/pom.xml +++ b/features/geo-dashboard/org.wso2.carbon.geo.dashboard.feature/pom.xml @@ -1,6 +1,4 @@ - - - - - + --> org.wso2.carbon.event-processing geo-dashboard-feature - 2.2.14 + 2.2.17-SNAPSHOT ../pom.xml @@ -134,4 +130,4 @@ - + \ No newline at end of file diff --git a/features/geo-dashboard/org.wso2.carbon.geo.dashboard.feature/src/main/resources/org_wso2_carbon_geo_dashboard-1.0.0.car b/features/geo-dashboard/org.wso2.carbon.geo.dashboard.feature/src/main/resources/org_wso2_carbon_geo_dashboard-1.0.0.car index c523469e3..7f44c1694 100644 Binary files a/features/geo-dashboard/org.wso2.carbon.geo.dashboard.feature/src/main/resources/org_wso2_carbon_geo_dashboard-1.0.0.car and b/features/geo-dashboard/org.wso2.carbon.geo.dashboard.feature/src/main/resources/org_wso2_carbon_geo_dashboard-1.0.0.car differ diff --git a/features/geo-dashboard/pom.xml b/features/geo-dashboard/pom.xml index 8ec7cedaa..3ab2343c2 100644 --- a/features/geo-dashboard/pom.xml +++ b/features/geo-dashboard/pom.xml @@ -1,5 +1,4 @@ - - - - + --> carbon-event-processing org.wso2.carbon.event-processing - 2.2.14 + 2.2.17-SNAPSHOT ../../pom.xml @@ -35,4 +32,4 @@ org.wso2.carbon.geo.dashboard.feature - + \ No newline at end of file diff --git a/features/siddhi-tryit/org.wso2.carbon.siddhi.tryit.feature/pom.xml b/features/siddhi-tryit/org.wso2.carbon.siddhi.tryit.feature/pom.xml index cfe8a1314..c52998b60 100644 --- a/features/siddhi-tryit/org.wso2.carbon.siddhi.tryit.feature/pom.xml +++ b/features/siddhi-tryit/org.wso2.carbon.siddhi.tryit.feature/pom.xml @@ -1,5 +1,4 @@ - - - - + --> org.wso2.carbon.event-processing siddhi-tryit-feature - 2.2.14 + 2.2.17-SNAPSHOT ../pom.xml @@ -97,4 +94,4 @@ - + \ No newline at end of file diff --git a/features/siddhi-tryit/pom.xml b/features/siddhi-tryit/pom.xml index 3bbfd096e..fd25dd650 100644 --- a/features/siddhi-tryit/pom.xml +++ b/features/siddhi-tryit/pom.xml @@ -1,5 +1,4 @@ - - - - + --> carbon-event-processing org.wso2.carbon.event-processing - 2.2.14 + 2.2.17-SNAPSHOT ../../pom.xml @@ -35,4 +32,4 @@ org.wso2.carbon.siddhi.tryit.feature - + \ No newline at end of file diff --git a/pom.xml b/pom.xml index 70a8028d5..2420f5813 100644 --- a/pom.xml +++ b/pom.xml @@ -1,5 +1,4 @@ - - - + --> org.wso2 @@ -28,7 +26,7 @@ org.wso2.carbon.event-processing carbon-event-processing pom - 2.2.14 + 2.2.17-SNAPSHOT WSO2 Carbon - Carbon Event Processing Aggregator Module http://wso2.org @@ -61,6 +59,12 @@ org.apache.axis2.wso2 axis2 ${orbit.version.axis2} + + + log4j + log4j + + libthrift.wso2 @@ -76,17 +80,18 @@ org.apache.axis2.wso2 axis2-client ${orbit.version.axis2} + + + log4j + log4j + + org.apache.ws.commons.axiom.wso2 axiom ${orbit.version.axiom} - - org.wso2.orbit.org.apache.storm - storm-core - ${storm.orbit.version} - com.googlecode.json-simple json-simple @@ -640,10 +645,7 @@ true - - org.apache.maven.plugins - maven-deploy-plugin - + org.jvnet.maven.incrementalbuild incremental-build-plugin @@ -825,12 +827,11 @@ - https://github.com/wso2/carbon-event-processing.git scm:git:https://github.com/wso2/carbon-event-processing.git scm:git:https://github.com/wso2/carbon-event-processing.git - v2.2.14 + HEAD @@ -919,29 +920,28 @@ 4.7.19 1.5.4 - 2.2.14 + 2.2.17-SNAPSHOT 5.2.18 [5.2.0, 6.0.0) 3.2.6 1.3.7 - 0.10.1.wso2v1 1.2.11-wso2v16 [1.2.11-wso2v16, 1.3.0) 1.6.1-wso2v40 [1.6.1-wso2v40, 1.7.0) - 0.9.2.wso2v1 + 0.16.0.wso2v1 [0.9.2.wso2v1, 1.0.0) 2.6.0.wso2v1 2.5 4.10 [2.10.0,3.4) - 3.3.2.wso2v2 + 3.3.7.wso2v1 4.5 - 27.0-jre - 1.11 + 32.1.2-jre + 2.0 2.1.1.wso2v1 - 2.7.2.wso2v1 + 2.7.2.wso2v2 1.2.7 3.2 2.11.0 @@ -956,7 +956,7 @@ 5.1.6 UTF-8 - my-scm-server + wso2-scm-server 2.11.0 1.5.3 @@ -968,4 +968,4 @@ [1.2.0,2.0.0) - + \ No newline at end of file diff --git a/service-stubs/org.wso2.carbon.event.flow.stub/pom.xml b/service-stubs/org.wso2.carbon.event.flow.stub/pom.xml index 56045b887..09442c5d3 100644 --- a/service-stubs/org.wso2.carbon.event.flow.stub/pom.xml +++ b/service-stubs/org.wso2.carbon.event.flow.stub/pom.xml @@ -1,5 +1,4 @@ - - - + --> org.wso2.carbon.event-processing carbon-event-processing - 2.2.14 + 2.2.17-SNAPSHOT ../../pom.xml @@ -115,4 +113,4 @@ - + \ No newline at end of file diff --git a/service-stubs/org.wso2.carbon.event.processor.stub/pom.xml b/service-stubs/org.wso2.carbon.event.processor.stub/pom.xml index 062943c5d..b0133f0db 100644 --- a/service-stubs/org.wso2.carbon.event.processor.stub/pom.xml +++ b/service-stubs/org.wso2.carbon.event.processor.stub/pom.xml @@ -1,5 +1,4 @@ - - - + --> org.wso2.carbon.event-processing carbon-event-processing - 2.2.14 + 2.2.17-SNAPSHOT ../../pom.xml @@ -116,5 +114,4 @@ - - + \ No newline at end of file diff --git a/service-stubs/org.wso2.carbon.event.simulator.stub/pom.xml b/service-stubs/org.wso2.carbon.event.simulator.stub/pom.xml index ff8a7fc61..1c9993441 100644 --- a/service-stubs/org.wso2.carbon.event.simulator.stub/pom.xml +++ b/service-stubs/org.wso2.carbon.event.simulator.stub/pom.xml @@ -1,5 +1,4 @@ - - - + --> org.wso2.carbon.event-processing carbon-event-processing - 2.2.14 + 2.2.17-SNAPSHOT ../../pom.xml @@ -117,5 +115,4 @@ - - + \ No newline at end of file diff --git a/service-stubs/pom.xml b/service-stubs/pom.xml index f0216ee8a..eecc0a3a4 100644 --- a/service-stubs/pom.xml +++ b/service-stubs/pom.xml @@ -1,5 +1,4 @@ - - - + --> org.wso2.carbon.event-processing carbon-event-processing ../pom.xml - 2.2.14 + 2.2.17-SNAPSHOT 4.0.0 @@ -37,4 +35,4 @@ org.wso2.carbon.event.simulator.stub - + \ No newline at end of file