diff --git a/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/Geo-Dashboard-WSO2Event-Receiver_1.0.0/Geo-Receiver-WSO2Event-LocationStream.xml b/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/Geo-Dashboard-WSO2Event-Receiver_1.0.0/Geo-Receiver-WSO2Event-LocationStream.xml index bce9c10d4..66ddcc2c4 100644 --- a/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/Geo-Dashboard-WSO2Event-Receiver_1.0.0/Geo-Receiver-WSO2Event-LocationStream.xml +++ b/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/Geo-Dashboard-WSO2Event-Receiver_1.0.0/Geo-Receiver-WSO2Event-LocationStream.xml @@ -19,7 +19,7 @@ - + false diff --git a/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.analytics/src/main/resources/carbonapps/Arduino/arduino_receiver/arduino_receiver.xml b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.analytics/src/main/resources/carbonapps/Arduino/arduino_receiver/arduino_receiver.xml index b20bafc96..35263dc9c 100644 --- a/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.analytics/src/main/resources/carbonapps/Arduino/arduino_receiver/arduino_receiver.xml +++ b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.analytics/src/main/resources/carbonapps/Arduino/arduino_receiver/arduino_receiver.xml @@ -18,9 +18,9 @@ --> - - iot-http - - - + + false + + + diff --git a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/input/adapter/mqtt/MQTTEventAdapterFactory.java b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/input/adapter/mqtt/MQTTEventAdapterFactory.java index 0419d26eb..f5f93b17a 100644 --- a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/input/adapter/mqtt/MQTTEventAdapterFactory.java +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/input/adapter/mqtt/MQTTEventAdapterFactory.java @@ -120,7 +120,7 @@ public class MQTTEventAdapterFactory extends InputEventAdapterFactory { // set clientId Property clientId = new Property(MQTTEventAdapterConstants.ADAPTER_CONF_CLIENTID); clientId.setDisplayName(resourceBundle.getString(MQTTEventAdapterConstants.ADAPTER_CONF_CLIENTID)); - clientId.setRequired(true); + clientId.setRequired(false); clientId.setHint(resourceBundle.getString(MQTTEventAdapterConstants.ADAPTER_CONF_CLIENTID_HINT)); propertyList.add(clientId); diff --git a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/input/adapter/mqtt/util/MQTTEventAdapterConstants.java b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/input/adapter/mqtt/util/MQTTEventAdapterConstants.java index 7d52fb53c..0a0b09e2a 100644 --- a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/input/adapter/mqtt/util/MQTTEventAdapterConstants.java +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/input/adapter/mqtt/util/MQTTEventAdapterConstants.java @@ -46,7 +46,7 @@ public class MQTTEventAdapterConstants { public static final String ADAPTER_CONF_CLEAN_SESSION = "cleanSession"; public static final String ADAPTER_CONF_CLEAN_SESSION_HINT = "cleanSession.hint"; public static final String ADAPTER_CONF_KEEP_ALIVE = "keepAlive"; - public static final int ADAPTER_CONF_DEFAULT_KEEP_ALIVE = 60000; + public static final int ADAPTER_CONF_DEFAULT_KEEP_ALIVE = 20000; public static final int INITIAL_RECONNECTION_DURATION = 4000; public static final int RECONNECTION_PROGRESS_FACTOR = 2; diff --git a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.thrift/pom.xml b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.thrift/pom.xml new file mode 100644 index 000000000..6c1d4d94e --- /dev/null +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.thrift/pom.xml @@ -0,0 +1,134 @@ + + + + + + org.wso2.carbon.devicemgt-plugins + cdmf-transport-adapters + 3.0.37-SNAPSHOT + ../../pom.xml + + + 4.0.0 + org.wso2.carbon.device.mgt.input.adapter.thrift + bundle + WSO2 Carbon - Event Input Thrift Adapter Module + org.wso2.carbon.event.input.adapter.thrift provides the back-end + functionality of input wso2event adapter + + http://wso2.org + + + + org.wso2.carbon.analytics-common + org.wso2.carbon.event.input.adapter.core + + + org.wso2.carbon.analytics-common + org.wso2.carbon.event.input.adapter.wso2event + + + org.wso2.carbon + org.wso2.carbon.logging + + + org.wso2.carbon + org.wso2.carbon.core + + + org.wso2.carbon.analytics-common + org.wso2.carbon.databridge.commons + + + org.wso2.carbon.analytics-common + org.wso2.carbon.databridge.commons.thrift + + + org.wso2.carbon.analytics-common + org.wso2.carbon.databridge.commons.binary + + + org.wso2.carbon.analytics-common + org.wso2.carbon.databridge.core + + + + + + + + org.apache.felix + maven-scr-plugin + + + generate-scr-descriptor + + scr + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + org.apache.felix + maven-bundle-plugin + true + + + ${project.artifactId} + ${project.artifactId} + + org.wso2.carbon.device.mgt.input.adapter.thrift.internal, + org.wso2.carbon.device.mgt.input.adapter.thrift.internal.*, + + + !org.wso2.carbon.device.mgt.input.adapter.thrift.internal, + !org.wso2.carbon.device.mgt.input.adapter.thrift.internal.*, + org.wso2.carbon.device.mgt.input.adapter.thrift.*, + + + org.wso2.carbon.event.input.adapter.core, + org.wso2.carbon.event.input.adapter.core.*, + !javax.xml.namespace, + javax.xml.namespace; version=0.0.0, + org.apache.commons.logging, + org.osgi.framework, + org.osgi.service.component, + org.wso2.carbon.context, + org.wso2.carbon.databridge.commons, + org.wso2.carbon.databridge.core, + org.wso2.carbon.event.input.adapter.wso2event, + org.apache.axis2.context, + org.wso2.carbon.core.multitenancy.utils, + org.wso2.carbon.utils + + + + + + + + + + + + diff --git a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.thrift/src/main/java/org/wso2/carbon/device/mgt/input/adapter/thrift/ThriftAdapter.java b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.thrift/src/main/java/org/wso2/carbon/device/mgt/input/adapter/thrift/ThriftAdapter.java new file mode 100644 index 000000000..5210f2030 --- /dev/null +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.thrift/src/main/java/org/wso2/carbon/device/mgt/input/adapter/thrift/ThriftAdapter.java @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2017, 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.device.mgt.input.adapter.thrift; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.context.PrivilegedCarbonContext; +import org.wso2.carbon.device.mgt.input.adapter.thrift.internal.ThriftEventAdapterServiceHolder; +import org.wso2.carbon.event.input.adapter.core.EventAdapterConstants; +import org.wso2.carbon.event.input.adapter.core.InputEventAdapter; +import org.wso2.carbon.event.input.adapter.core.InputEventAdapterConfiguration; +import org.wso2.carbon.event.input.adapter.core.InputEventAdapterListener; +import org.wso2.carbon.event.input.adapter.core.exception.InputEventAdapterException; +import org.wso2.carbon.event.input.adapter.core.exception.TestConnectionNotSupportedException; + +import java.util.Map; + +public final class ThriftAdapter implements InputEventAdapter { + + private static final Log log = LogFactory.getLog(ThriftAdapter.class); + private final InputEventAdapterConfiguration eventAdapterConfiguration; + private final Map globalProperties; + private InputEventAdapterListener eventAdaptorListener; + + public ThriftAdapter(InputEventAdapterConfiguration eventAdapterConfiguration, + Map globalProperties) { + this.eventAdapterConfiguration = eventAdapterConfiguration; + this.globalProperties = globalProperties; + } + + @Override + public void init(InputEventAdapterListener eventAdaptorListener) throws InputEventAdapterException { + this.eventAdaptorListener = eventAdaptorListener; + } + + @Override + public void testConnect() throws TestConnectionNotSupportedException { + throw new TestConnectionNotSupportedException("not-supported"); + } + + @Override + public void connect() { + String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(true); + String streamId = eventAdapterConfiguration.getInputStreamIdOfWso2eventMessageFormat(); + ThriftEventAdapterServiceHolder.registerAdapterService(tenantDomain, streamId, this); + } + + @Override + public void disconnect() { + String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(true); + String streamId = eventAdapterConfiguration.getInputStreamIdOfWso2eventMessageFormat(); + ThriftEventAdapterServiceHolder.unregisterAdapterService(tenantDomain, streamId, this); + } + + @Override + public void destroy() { + + } + + @Override + public boolean isEventDuplicatedInCluster() { + return Boolean.parseBoolean(eventAdapterConfiguration.getProperties().get( + EventAdapterConstants.EVENTS_DUPLICATED_IN_CLUSTER)); + } + + @Override + public boolean isPolling() { + return false; + } + + public String getEventAdapterName() { + return eventAdapterConfiguration.getName(); + } + + public InputEventAdapterListener getEventAdaptorListener() { + return eventAdaptorListener; + } +} diff --git a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.thrift/src/main/java/org/wso2/carbon/device/mgt/input/adapter/thrift/ThriftEventAdapterFactory.java b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.thrift/src/main/java/org/wso2/carbon/device/mgt/input/adapter/thrift/ThriftEventAdapterFactory.java new file mode 100644 index 000000000..b6a421718 --- /dev/null +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.thrift/src/main/java/org/wso2/carbon/device/mgt/input/adapter/thrift/ThriftEventAdapterFactory.java @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2017, 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.device.mgt.input.adapter.thrift; + + +import org.wso2.carbon.event.input.adapter.core.InputEventAdapter; +import org.wso2.carbon.event.input.adapter.core.InputEventAdapterConfiguration; +import org.wso2.carbon.event.input.adapter.wso2event.WSO2EventEventAdapterFactory; + +import java.util.Map; + +/** + * The WSO2Event adapter factory class to create a WSO2Event input adapter + */ +public class ThriftEventAdapterFactory extends WSO2EventEventAdapterFactory { + private static final String ADAPTER_TYPE_THRIFT = "iot-event"; + + @Override + public String getType() { + return ADAPTER_TYPE_THRIFT; + } + + @Override + public InputEventAdapter createEventAdapter(InputEventAdapterConfiguration eventAdapterConfiguration, + Map globalProperties) { + return new ThriftAdapter(eventAdapterConfiguration, globalProperties); + } + +} diff --git a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.thrift/src/main/java/org/wso2/carbon/device/mgt/input/adapter/thrift/internal/ThriftEventAdapterServiceComponent.java b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.thrift/src/main/java/org/wso2/carbon/device/mgt/input/adapter/thrift/internal/ThriftEventAdapterServiceComponent.java new file mode 100644 index 000000000..ad18ff6d1 --- /dev/null +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.thrift/src/main/java/org/wso2/carbon/device/mgt/input/adapter/thrift/internal/ThriftEventAdapterServiceComponent.java @@ -0,0 +1,167 @@ +/* + * Copyright (c) 2017, 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.device.mgt.input.adapter.thrift.internal; + +import org.apache.axis2.context.ConfigurationContext; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.osgi.service.component.ComponentContext; +import org.wso2.carbon.context.PrivilegedCarbonContext; +import org.wso2.carbon.core.multitenancy.utils.TenantAxisUtils; +import org.wso2.carbon.databridge.commons.Credentials; +import org.wso2.carbon.databridge.commons.Event; +import org.wso2.carbon.databridge.commons.StreamDefinition; +import org.wso2.carbon.databridge.core.AgentCallback; +import org.wso2.carbon.databridge.core.DataBridgeSubscriberService; +import org.wso2.carbon.device.mgt.input.adapter.thrift.ThriftAdapter; +import org.wso2.carbon.event.input.adapter.core.InputEventAdapterFactory; +import org.wso2.carbon.device.mgt.input.adapter.thrift.ThriftEventAdapterFactory; +import org.wso2.carbon.utils.ConfigurationContextService; +import org.wso2.carbon.utils.multitenancy.MultitenantConstants; + +import java.util.List; +import java.util.concurrent.ConcurrentHashMap; + + +/** + * @scr.component name="input.wso2EventAdapterService.component" immediate="true" + * @scr.reference name="agentserverservice.service" + * interface="org.wso2.carbon.databridge.core.DataBridgeSubscriberService" cardinality="1..1" + * policy="dynamic" bind="setDataBridgeSubscriberService" unbind="unSetDataBridgeSubscriberService" + * @scr.reference name="config.context.service" + * interface="org.wso2.carbon.utils.ConfigurationContextService" + * cardinality="1..1" policy="dynamic" bind="setConfigurationContextService" + * unbind="unsetConfigurationContextService" + */ + + +public class ThriftEventAdapterServiceComponent { + + private static final Log log = LogFactory.getLog(ThriftEventAdapterServiceComponent.class); + + /** + * initialize the agent service here service here. + * + * @param context + */ + + + protected void activate(ComponentContext context) { + + try { + InputEventAdapterFactory wso2EventEventAdapterFactory = new ThriftEventAdapterFactory(); + context.getBundleContext().registerService(InputEventAdapterFactory.class.getName(), wso2EventEventAdapterFactory, null); + if (log.isDebugEnabled()) { + log.debug("Successfully deployed the input WSO2Event adapter service"); + } + } catch (RuntimeException e) { + log.error("Can not create the input WSO2Event adapter service ", e); + } + } + + protected void setDataBridgeSubscriberService( + DataBridgeSubscriberService dataBridgeSubscriberService) { + if (ThriftEventAdapterServiceHolder.getDataBridgeSubscriberService() == null) { + ThriftEventAdapterServiceHolder.registerDataBridgeSubscriberService(dataBridgeSubscriberService); + + dataBridgeSubscriberService.subscribe(new AgentCallback() { + @Override + public void definedStream(StreamDefinition streamDefinition, int i) { + + } + + @Override + public void removeStream(StreamDefinition streamDefinition, int i) { + + } + + @Override + public void receive(List events, Credentials credentials) { + try { + PrivilegedCarbonContext.startTenantFlow(); + String tenantDomain = getTenantDomain(events, credentials); + PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(tenantDomain, true); + if (!tenantDomain.equalsIgnoreCase(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME)) { + TenantAxisUtils.getTenantConfigurationContext(tenantDomain, ThriftEventAdapterServiceHolder + .getConfigurationContext()); + } + for (Event event : events) { + ConcurrentHashMap adapters = ThriftEventAdapterServiceHolder + .getAdapterService(tenantDomain, event.getStreamId()); + if (adapters != null) { + event = getStrippedEvent(event, credentials); + for (ThriftAdapter adapter : adapters.values()) { + adapter.getEventAdaptorListener().onEvent(event); + } + } + if (log.isDebugEnabled()) { + log.debug("Event received in wso2Event Adapter - " + event); + } + } + } finally { + PrivilegedCarbonContext.endTenantFlow(); + } + } + }); + } + } + + protected void unSetDataBridgeSubscriberService( + DataBridgeSubscriberService dataBridgeSubscriberService) { + + } + + protected void setConfigurationContextService(ConfigurationContextService contextService) { + ConfigurationContext serverConfigContext = contextService.getServerConfigContext(); + ThriftEventAdapterServiceHolder.setConfigurationContext(serverConfigContext); + } + + protected void unsetConfigurationContextService(ConfigurationContextService contextService) { + ThriftEventAdapterServiceHolder.setConfigurationContext(null); + } + + private String getTenantDomain(List events, Credentials credentials) { + Object[] objects = events.get(0).getMetaData(); + String tenantDomain = credentials.getDomainName(); + if (objects != null && objects.length > 0) { + if (tenantDomain.equals(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME)) { + String[] splitValues = ((String) objects[0]).split("@@"); + if (splitValues.length > 1) { + tenantDomain = splitValues[0]; + } + } + } + return tenantDomain; + + } + + private Event getStrippedEvent (Event event, Credentials credentials) { + Object[] objects = event.getMetaData(); + String tenantDomain = credentials.getDomainName(); + if (objects != null && objects.length > 0) { + if (tenantDomain.equals(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME)) { + String[] splitValues = ((String) objects[0]).split("@"); + if (splitValues.length > 1) { + event.getMetaData()[0] = splitValues[1]; + } + } + } + return event; + + } + + + +} diff --git a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.thrift/src/main/java/org/wso2/carbon/device/mgt/input/adapter/thrift/internal/ThriftEventAdapterServiceHolder.java b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.thrift/src/main/java/org/wso2/carbon/device/mgt/input/adapter/thrift/internal/ThriftEventAdapterServiceHolder.java new file mode 100644 index 000000000..330ef86c6 --- /dev/null +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.thrift/src/main/java/org/wso2/carbon/device/mgt/input/adapter/thrift/internal/ThriftEventAdapterServiceHolder.java @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2017, 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.device.mgt.input.adapter.thrift.internal; + +import org.apache.axis2.context.ConfigurationContext; +import org.wso2.carbon.databridge.core.DataBridgeSubscriberService; +import org.wso2.carbon.device.mgt.input.adapter.thrift.ThriftAdapter; + +import java.util.concurrent.ConcurrentHashMap; + +/** + * common place to hold some OSGI bundle references. + */ +public final class ThriftEventAdapterServiceHolder { + + private static DataBridgeSubscriberService dataBridgeSubscriberService; + private static ConfigurationContext configurationContext; + + private static ConcurrentHashMap>> + inputEventAdapterListenerMap = + new ConcurrentHashMap>>(); + + private ThriftEventAdapterServiceHolder() { + } + + public static void registerDataBridgeSubscriberService( + DataBridgeSubscriberService dataBridgeSubscriberService) { + ThriftEventAdapterServiceHolder.dataBridgeSubscriberService = dataBridgeSubscriberService; + } + + public static DataBridgeSubscriberService getDataBridgeSubscriberService() { + return dataBridgeSubscriberService; + } + + public static synchronized void registerAdapterService(String tenantDomain, String streamId, + ThriftAdapter thriftAdapter) { + + ConcurrentHashMap> + tenantSpecificInputEventAdapterListenerMap = inputEventAdapterListenerMap.get(tenantDomain); + + if (tenantSpecificInputEventAdapterListenerMap == null) { + tenantSpecificInputEventAdapterListenerMap = + new ConcurrentHashMap>(); + inputEventAdapterListenerMap.put(tenantDomain, tenantSpecificInputEventAdapterListenerMap); + } + ConcurrentHashMap streamSpecificInputEventAdapterListenerMap = + tenantSpecificInputEventAdapterListenerMap.get(streamId); + if (streamSpecificInputEventAdapterListenerMap == null) { + streamSpecificInputEventAdapterListenerMap = new ConcurrentHashMap(); + tenantSpecificInputEventAdapterListenerMap.put(streamId, streamSpecificInputEventAdapterListenerMap); + } + streamSpecificInputEventAdapterListenerMap.put(thriftAdapter.getEventAdapterName(), thriftAdapter); + + + } + + public static void unregisterAdapterService(String tenantDomain, String streamId, + ThriftAdapter thriftAdapter) { + ConcurrentHashMap> + tenantSpecificInputEventAdapterListenerMap = inputEventAdapterListenerMap.get(tenantDomain); + + if (tenantSpecificInputEventAdapterListenerMap != null) { + ConcurrentHashMap streamSpecificInputEventAdapterListenerMap = + tenantSpecificInputEventAdapterListenerMap.get(streamId); + if (streamSpecificInputEventAdapterListenerMap != null) { + streamSpecificInputEventAdapterListenerMap.remove(thriftAdapter.getEventAdapterName()); + } + } + } + + public static ConcurrentHashMap getAdapterService(String tenantDomain, String streamId) { + ConcurrentHashMap> + tenantSpecificInputEventAdapterListenerMap = inputEventAdapterListenerMap.get(tenantDomain); + if (tenantSpecificInputEventAdapterListenerMap != null) { + return tenantSpecificInputEventAdapterListenerMap.get(streamId); + } + return null; + } + + public static ConfigurationContext getConfigurationContext() { + return configurationContext; + } + + public static void setConfigurationContext(ConfigurationContext configurationContext) { + ThriftEventAdapterServiceHolder.configurationContext = configurationContext; + } +} diff --git a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.thrift/src/main/resources/org/wso2/carbon/device/mgt/input/adapter/thrift/Resources.properties b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.thrift/src/main/resources/org/wso2/carbon/device/mgt/input/adapter/thrift/Resources.properties new file mode 100644 index 000000000..576d9cc65 --- /dev/null +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.thrift/src/main/resources/org/wso2/carbon/device/mgt/input/adapter/thrift/Resources.properties @@ -0,0 +1,25 @@ +# +# Copyright (c) 2005-2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. +# +# WSO2 Inc. licenses this file to you 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. +# + +stream=Stream Name +version=Stream Version +events.duplicated.in.cluster=Is events duplicated in cluster +events.duplicated.in.cluster.hint=This depends on how events are published to the server, 'true' only if multiple receiver URLs are defined in different receiver groups ({}). +wso2event.usage.tips_prefix=Following url formats are used to receive events
For load-balancing: use "," to separate values for multiple endpoints
   Eg: {tcp://<hostname>:<port>,tcp://<hostname>:<port>, ...}

For failover: use "|" to separate multiple endpoints
   Eg: {tcp://<hostname>:<port>|tcp://<hostname>:<port>| ...}

For more than one cluster: use "{}" to separate multiple clusters
   Eg: {tcp://<hostname>:<port>|tcp://<hostname>:<port>| ...},{tcp://<hostname>:<port>}

Ports available for Thrift protocol - TCP port: +wso2event.usage.tips_in_between= or SSL port: +wso2event.usage.tips_postfix=
Ports available for Binary protocol - TCP port: diff --git a/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket.endpoint/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/endpoint/TenantSubscriptionEndpoint.java b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket.endpoint/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/endpoint/TenantSubscriptionEndpoint.java index 099200c46..2e8ec6192 100644 --- a/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket.endpoint/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/endpoint/TenantSubscriptionEndpoint.java +++ b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket.endpoint/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/endpoint/TenantSubscriptionEndpoint.java @@ -77,7 +77,8 @@ public class TenantSubscriptionEndpoint extends SubscriptionEndpoint { if (isAuthorized) { try { PrivilegedCarbonContext.startTenantFlow(); - PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(tdomain, true); + PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(authenticationInfo.getTenantDomain() + , true); ServiceHolder.getInstance().getWebsocketOutputCallbackControllerService().subscribeWebsocket(streamName , version, session); } finally { diff --git a/components/extensions/cdmf-transport-adapters/pom.xml b/components/extensions/cdmf-transport-adapters/pom.xml index 18e368ce2..d5707972e 100644 --- a/components/extensions/cdmf-transport-adapters/pom.xml +++ b/components/extensions/cdmf-transport-adapters/pom.xml @@ -37,6 +37,7 @@ input/org.wso2.carbon.device.mgt.input.adapter.http input/org.wso2.carbon.device.mgt.input.adapter.mqtt input/org.wso2.carbon.device.mgt.input.adapter.xmpp + input/org.wso2.carbon.device.mgt.input.adapter.thrift output/org.wso2.carbon.device.mgt.output.adapter.mqtt output/org.wso2.carbon.device.mgt.output.adapter.xmpp output/org.wso2.carbon.device.mgt.output.adapter.websocket diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.analytics/src/main/resources/carbonapps/Android-Agent-Event-Receiver_1.0.0/android_agent_event_receiver.xml b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.analytics/src/main/resources/carbonapps/Android-Agent-Event-Receiver_1.0.0/android_agent_event_receiver.xml index 977e9a38c..7e4820744 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.analytics/src/main/resources/carbonapps/Android-Agent-Event-Receiver_1.0.0/android_agent_event_receiver.xml +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.analytics/src/main/resources/carbonapps/Android-Agent-Event-Receiver_1.0.0/android_agent_event_receiver.xml @@ -18,7 +18,7 @@ --> - + false diff --git a/features/device-types-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.analytics.feature/src/main/resources/receiver/android_sense_receiver-carbon.super.xml b/features/device-types-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.analytics.feature/src/main/resources/receiver/android_sense_receiver-carbon.super.xml index 727aea028..028b69a41 100644 --- a/features/device-types-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.analytics.feature/src/main/resources/receiver/android_sense_receiver-carbon.super.xml +++ b/features/device-types-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.analytics.feature/src/main/resources/receiver/android_sense_receiver-carbon.super.xml @@ -20,7 +20,6 @@ carbon.super/android_sense/+/data - android_sense_receiver-carbon.super diff --git a/features/device-types-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.backend.feature/src/main/resources/receiver/android_sense_receiver.xml b/features/device-types-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.backend.feature/src/main/resources/receiver/android_sense_receiver.xml index 3faeedaf0..d5bb810bc 100644 --- a/features/device-types-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.backend.feature/src/main/resources/receiver/android_sense_receiver.xml +++ b/features/device-types-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.backend.feature/src/main/resources/receiver/android_sense_receiver.xml @@ -20,7 +20,6 @@ ${tenant-domain}/android_sense/+/data - android_sense_receiver-${tenant-domain} diff --git a/features/device-types-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.analytics.feature/src/main/resources/receiver/raspberrypi_receiver-carbon.super.xml b/features/device-types-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.analytics.feature/src/main/resources/receiver/raspberrypi_receiver-carbon.super.xml index 0d8b2fd7a..11cc1d962 100644 --- a/features/device-types-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.analytics.feature/src/main/resources/receiver/raspberrypi_receiver-carbon.super.xml +++ b/features/device-types-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.analytics.feature/src/main/resources/receiver/raspberrypi_receiver-carbon.super.xml @@ -19,7 +19,6 @@ carbon.super/raspberrypi/+/temperature - raspberrypi_receiver-carbon.super diff --git a/features/device-types-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.backend.feature/src/main/resources/receiver/raspberrypi_receiver.xml b/features/device-types-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.backend.feature/src/main/resources/receiver/raspberrypi_receiver.xml index 331a954e8..aff61431d 100644 --- a/features/device-types-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.backend.feature/src/main/resources/receiver/raspberrypi_receiver.xml +++ b/features/device-types-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.backend.feature/src/main/resources/receiver/raspberrypi_receiver.xml @@ -19,7 +19,6 @@ ${tenant-domain}/raspberrypi/+/temperature - raspberrypi_receiver-${tenant-domain} diff --git a/features/device-types-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.analytics.feature/src/main/resources/receiver/virtualfirealarm_receiver-carbon.super.xml b/features/device-types-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.analytics.feature/src/main/resources/receiver/virtualfirealarm_receiver-carbon.super.xml index efd5dde7b..21910b4b6 100644 --- a/features/device-types-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.analytics.feature/src/main/resources/receiver/virtualfirealarm_receiver-carbon.super.xml +++ b/features/device-types-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.analytics.feature/src/main/resources/receiver/virtualfirealarm_receiver-carbon.super.xml @@ -19,7 +19,6 @@ carbon.super/virtual_firealarm/+/temperature - virtualfirealarm_receiver-carbon.super diff --git a/features/device-types-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.backend.feature/src/main/resources/receiver/virtualfirealarm_receiver.xml b/features/device-types-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.backend.feature/src/main/resources/receiver/virtualfirealarm_receiver.xml index eea9bb117..98ee47d86 100644 --- a/features/device-types-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.backend.feature/src/main/resources/receiver/virtualfirealarm_receiver.xml +++ b/features/device-types-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.backend.feature/src/main/resources/receiver/virtualfirealarm_receiver.xml @@ -19,7 +19,6 @@ ${tenant-domain}/virtual_firealarm/+/temperature - virtualfirealarm_receiver-${tenant-domain} diff --git a/features/extensions-feature/org.wso2.carbon.device.mgt.adapter.feature/pom.xml b/features/extensions-feature/org.wso2.carbon.device.mgt.adapter.feature/pom.xml index 526334471..5e6165737 100644 --- a/features/extensions-feature/org.wso2.carbon.device.mgt.adapter.feature/pom.xml +++ b/features/extensions-feature/org.wso2.carbon.device.mgt.adapter.feature/pom.xml @@ -64,6 +64,14 @@ org.wso2.carbon.devicemgt-plugins org.wso2.carbon.device.mgt.input.adapter.xmpp + + org.wso2.carbon.devicemgt-plugins + org.wso2.carbon.device.mgt.input.adapter.thrift + + + org.wso2.carbon.analytics-common + org.wso2.carbon.event.input.adapter.wso2event + com.jayway.jsonpath json-path @@ -174,12 +182,19 @@ org.wso2.carbon.devicemgt-plugins:org.wso2.carbon.device.mgt.input.adapter.mqtt:${carbon.devicemgt.plugins.version} + + org.wso2.carbon.devicemgt-plugins:org.wso2.carbon.device.mgt.input.adapter.thrift:${carbon.devicemgt.plugins.version} + + + org.wso2.carbon.analytics-common:org.wso2.carbon.event.input.adapter.wso2event:${carbon.analytics.common.version} + org.wso2.carbon.devicemgt-plugins:org.wso2.carbon.device.mgt.input.adapter.xmpp:${carbon.devicemgt.plugins.version} org.wso2.carbon.devicemgt-plugins:org.wso2.carbon.device.mgt.output.adapter.websocket:${carbon.devicemgt.plugins.version} + org.eclipse.paho:org.eclipse.paho.client.mqttv3:${eclipse.paho.version} diff --git a/pom.xml b/pom.xml index 3c5d5b531..b3d7b36fd 100644 --- a/pom.xml +++ b/pom.xml @@ -355,6 +355,11 @@ org.wso2.carbon.event.output.adapter.core ${carbon.analytics.common.version} + + org.wso2.carbon.analytics-common + org.wso2.carbon.event.input.adapter.wso2event + ${carbon.analytics.common.version} + org.wso2.carbon.analytics-common org.wso2.carbon.event.input.adapter.core @@ -365,6 +370,21 @@ org.wso2.carbon.databridge.commons ${carbon.analytics.common.version} + + org.wso2.carbon.analytics-common + org.wso2.carbon.databridge.commons.thrift + ${carbon.analytics.common.version} + + + org.wso2.carbon.analytics-common + org.wso2.carbon.databridge.commons.binary + ${carbon.analytics.common.version} + + + org.wso2.carbon.analytics-common + org.wso2.carbon.databridge.core + ${carbon.analytics.common.version} + org.wso2.carbon.analytics org.wso2.carbon.analytics.api @@ -387,6 +407,11 @@ org.wso2.carbon.device.mgt.output.adapter.mqtt ${carbon.devicemgt.plugins.version} + + org.wso2.carbon.devicemgt-plugins + org.wso2.carbon.device.mgt.input.adapter.thrift + ${carbon.devicemgt.plugins.version} + org.wso2.carbon.devicemgt-plugins org.wso2.carbon.device.mgt.output.adapter.xmpp