diff --git a/.gitignore b/.gitignore index d05f9f2..23d440d 100644 --- a/.gitignore +++ b/.gitignore @@ -44,3 +44,4 @@ mqtt-sn-client-sec/ /mqtt-sn-client/dependency-reduced-pom.xml /mqtt-sn-runtimes/mqtt-sn-gateway/_message-queues-overflow/34643532633864362D323037652D346663342D386531342D333333653366646564646638 /mqtt-sn-runtimes/ +/site diff --git a/mqtt-sn-client/pom.xml b/mqtt-sn-client/pom.xml index 3060bd4..7f7e54f 100644 --- a/mqtt-sn-client/pom.xml +++ b/mqtt-sn-client/pom.xml @@ -31,7 +31,7 @@ org.slj mqtt-sn - 0.2.1 + 0.2.2 jar diff --git a/mqtt-sn-cloud-client/pom.xml b/mqtt-sn-cloud-client/pom.xml index b7eebbd..1748f6e 100644 --- a/mqtt-sn-cloud-client/pom.xml +++ b/mqtt-sn-cloud-client/pom.xml @@ -31,7 +31,7 @@ org.slj mqtt-sn - 0.2.1 + 0.2.2 mqtt-sn-cloud-client diff --git a/mqtt-sn-codec/pom.xml b/mqtt-sn-codec/pom.xml index f300888..7543487 100644 --- a/mqtt-sn-codec/pom.xml +++ b/mqtt-sn-codec/pom.xml @@ -47,11 +47,11 @@ org.slj mqtt-sn - 0.2.1 + 0.2.2 org.mqtt-sn - 0.2.1 + 0.2.2 mqtt-sn-codec diff --git a/mqtt-sn-core/lib/mqtt-tree-0.5.4.jar b/mqtt-sn-core/lib/mqtt-tree-0.5.4.jar deleted file mode 100644 index 833ff54..0000000 Binary files a/mqtt-sn-core/lib/mqtt-tree-0.5.4.jar and /dev/null differ diff --git a/mqtt-sn-core/pom.xml b/mqtt-sn-core/pom.xml index b8f1e56..ad2a0af 100644 --- a/mqtt-sn-core/pom.xml +++ b/mqtt-sn-core/pom.xml @@ -31,7 +31,7 @@ org.slj mqtt-sn - 0.2.1 + 0.2.2 mqtt-sn-core @@ -50,13 +50,6 @@ javax.json 1.1.4 - - org.slj - mqtt-tree - 0.5.4 - system - ${basedir}/lib/mqtt-tree-0.5.4.jar - diff --git a/mqtt-sn-core/src/main/resources/logback.xml b/mqtt-sn-core/src/main/resources/logback.xml index 93b4f4d..58ab83a 100644 --- a/mqtt-sn-core/src/main/resources/logback.xml +++ b/mqtt-sn-core/src/main/resources/logback.xml @@ -47,9 +47,9 @@ - - - + + + diff --git a/mqtt-sn-gateway-connector-aws-iotcore/pom.xml b/mqtt-sn-gateway-connector-aws-iotcore/pom.xml index e69e3df..e99b069 100644 --- a/mqtt-sn-gateway-connector-aws-iotcore/pom.xml +++ b/mqtt-sn-gateway-connector-aws-iotcore/pom.xml @@ -31,7 +31,7 @@ org.slj mqtt-sn - 0.2.1 + 0.2.2 mqtt-sn-gateway-connector-aws-iotcore diff --git a/mqtt-sn-gateway-connector-google-iotcore/pom.xml b/mqtt-sn-gateway-connector-google-iotcore/pom.xml deleted file mode 100644 index 5b31e44..0000000 --- a/mqtt-sn-gateway-connector-google-iotcore/pom.xml +++ /dev/null @@ -1,115 +0,0 @@ - - - - - 4.0.0 - - - org.slj - mqtt-sn - 0.2.1 - - - mqtt-sn-gateway-connector-google-iotcore - - - 2.4.3 - - - - - org.slj - mqtt-sn-core - ${mqtt-sn.version} - - - org.mqtt-sn - mqtt-sn-codec - ${mqtt-sn.version} - - - org.slj - mqtt-sn-gateway - ${mqtt-sn.version} - - - org.slj - mqtt-sn-gateway-connector-paho - ${mqtt-sn.version} - - - io.jsonwebtoken - jjwt - 0.9.1 - - - joda-time - joda-time - 2.10.13 - - - - - mqtt-sn-google-iotcore-gateway-${version} - - - - org.apache.maven.plugins - maven-shade-plugin - 2.3 - - - - package - - shade - - - - - org.slj.mqtt.sn.gateway.connector.google.iotcore.GoogleIoTCoreAggregatingGatewayInteractiveMain - - - - - - *:* - - META-INF/*.SF - META-INF/*.DSA - META-INF/*.RSA - - - - - - - - - - - \ No newline at end of file diff --git a/mqtt-sn-gateway-connector-google-iotcore/src/main/java/org/slj/mqtt/sn/gateway/connector/google/iotcore/GoogleIoTCoreAggregatingGatewayInteractiveMain.java b/mqtt-sn-gateway-connector-google-iotcore/src/main/java/org/slj/mqtt/sn/gateway/connector/google/iotcore/GoogleIoTCoreAggregatingGatewayInteractiveMain.java deleted file mode 100644 index 93b1995..0000000 --- a/mqtt-sn-gateway-connector-google-iotcore/src/main/java/org/slj/mqtt/sn/gateway/connector/google/iotcore/GoogleIoTCoreAggregatingGatewayInteractiveMain.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2021 Simon Johnson - * - * Find me on GitHub: - * https://github.com/simon622 - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF 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. - */ - -package org.slj.mqtt.sn.gateway.connector.google.iotcore; - -import org.slj.mqtt.sn.gateway.cli.MqttsnInteractiveGatewayLauncher; -import org.slj.mqtt.sn.gateway.cli.MqttsnInteractiveGatewayWithKeystore; -import org.slj.mqtt.sn.gateway.impl.MqttsnGatewayRuntimeRegistry; -import org.slj.mqtt.sn.gateway.impl.gateway.type.MqttsnAggregatingGateway; -import org.slj.mqtt.sn.gateway.spi.connector.MqttsnConnectorOptions; -import org.slj.mqtt.sn.gateway.spi.gateway.MqttsnGatewayOptions; -import org.slj.mqtt.sn.impl.AbstractMqttsnRuntimeRegistry; -import org.slj.mqtt.sn.model.MqttsnOptions; -import org.slj.mqtt.sn.spi.IMqttsnStorageService; -import org.slj.mqtt.sn.spi.IMqttsnTransport; - -public class GoogleIoTCoreAggregatingGatewayInteractiveMain { - public static void main(String[] args) throws Exception { - MqttsnInteractiveGatewayLauncher.launch(new MqttsnInteractiveGatewayWithKeystore() { - protected AbstractMqttsnRuntimeRegistry createRuntimeRegistry(IMqttsnStorageService storageService, MqttsnOptions options, IMqttsnTransport transport) { - - IMqttsnStorageService namespacePreferences = storageService.getPreferenceNamespace(GoogleIoTCoreMqttsnConnector.DESCRIPTOR); - MqttsnConnectorOptions connectorOptions = new MqttsnConnectorOptions(); - storageService.initializeFieldsFromStorage(connectorOptions); - namespacePreferences.initializeFieldsFromStorage(connectorOptions); - - return MqttsnGatewayRuntimeRegistry.defaultConfiguration(storageService, (MqttsnGatewayOptions) options). - withConnector(new GoogleIoTCoreMqttsnConnector(GoogleIoTCoreMqttsnConnector.DESCRIPTOR, connectorOptions)). - withBackendService(new MqttsnAggregatingGateway()). - withTransport(createTransport(storageService)); - } - }, true, "Welcome to the Google IoT Core version of the gateway. You will need to connect your gateway to your Google IoT via the credentials available in your Google console."); - } -} diff --git a/mqtt-sn-gateway-connector-google-iotcore/src/main/java/org/slj/mqtt/sn/gateway/connector/google/iotcore/GoogleIoTCoreMqttsnConnection.java b/mqtt-sn-gateway-connector-google-iotcore/src/main/java/org/slj/mqtt/sn/gateway/connector/google/iotcore/GoogleIoTCoreMqttsnConnection.java deleted file mode 100644 index bf4ba8b..0000000 --- a/mqtt-sn-gateway-connector-google-iotcore/src/main/java/org/slj/mqtt/sn/gateway/connector/google/iotcore/GoogleIoTCoreMqttsnConnection.java +++ /dev/null @@ -1,259 +0,0 @@ -/* - * Copyright (c) 2021 Simon Johnson - * - * Find me on GitHub: - * https://github.com/simon622 - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF 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. - */ - -package org.slj.mqtt.sn.gateway.connector.google.iotcore; - -import io.jsonwebtoken.JwtBuilder; -import io.jsonwebtoken.Jwts; -import io.jsonwebtoken.SignatureAlgorithm; -import org.eclipse.paho.client.mqttv3.MqttClient; -import org.eclipse.paho.client.mqttv3.MqttConnectOptions; -import org.eclipse.paho.client.mqttv3.MqttMessage; -import org.joda.time.DateTime; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.slj.mqtt.sn.gateway.connector.paho.PahoMqttsnBrokerConnection; -import org.slj.mqtt.sn.gateway.spi.ConnectResult; -import org.slj.mqtt.sn.gateway.spi.DisconnectResult; -import org.slj.mqtt.sn.gateway.spi.PublishResult; -import org.slj.mqtt.sn.gateway.spi.Result; -import org.slj.mqtt.sn.gateway.spi.connector.MqttsnConnectorException; -import org.slj.mqtt.sn.gateway.spi.connector.MqttsnConnectorOptions; -import org.slj.mqtt.sn.model.IClientIdentifierContext; -import org.slj.mqtt.sn.spi.IMqttsnMessage; -import org.slj.mqtt.sn.spi.IMqttsnMessageFactory; -import org.slj.mqtt.sn.utils.MqttsnUtils; -import org.slj.mqtt.sn.utils.TopicPath; - -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.security.KeyFactory; -import java.security.NoSuchAlgorithmException; -import java.security.spec.InvalidKeySpecException; -import java.security.spec.PKCS8EncodedKeySpec; - -/** - * @author simonjohnson - * - * Uses the AWS SDK (which in turn uses PAHO) to connect to the AWS IoT Core - */ -public class GoogleIoTCoreMqttsnConnection extends PahoMqttsnBrokerConnection { - - private Logger logger = LoggerFactory.getLogger(GoogleIoTCoreMqttsnConnection.class); - - static final String ALG_RSA = "RS256"; - static final String ALG_ES = "ES256"; - - static final int TOKEN_EXPIRY_MINUTES = 60; - - public GoogleIoTCoreMqttsnConnection(MqttsnConnectorOptions options) { - super(options); - } - - @Override - protected String createClientId(MqttsnConnectorOptions options) { - final String mqttClientId = - String.format( - "projects/%s/locations/%s/registries/%s/devices/%s", - getGoogleIoTProjectId(options), - getGoogleIoTCloudRegion(options), - getGoogleIoTRegistryId(options), - getGoogleIoTGatewayId(options)); - - return mqttClientId; - } - - @Override - public ConnectResult connect(IClientIdentifierContext context, IMqttsnMessage message) throws MqttsnConnectorException { - if(isConnected()){ - logger.info("attaching {} device by clientId", context.getId()); - IMqttsnMessageFactory factory = backendService.getRegistry().getCodec().createMessageFactory(); - //-- tell IoT core we are attaching a device & register for device changes - String topicPath = String.format("/devices/%s/attach", context.getId()); - IMqttsnMessage publish = - factory.createPublish(1, false, false, topicPath, new byte[0]); - if(!super.publish(context, new TopicPath(topicPath), 1, false, new byte[0], publish).isError()){ - logger.info("device {} attached, subscribing or config changes", context.getId()); - topicPath = String.format("/devices/%s/config", context.getId()); - IMqttsnMessage subscribe = factory.createSubscribe(0, topicPath); - subscribe(context, new TopicPath(topicPath), subscribe); - } - return new ConnectResult(Result.STATUS.SUCCESS); - } - return new ConnectResult(Result.STATUS.NOOP); - } - - @Override - public DisconnectResult disconnect(IClientIdentifierContext context, IMqttsnMessage message) throws MqttsnConnectorException { - if(isConnected()){ - logger.info("detaching gateway device " + context.getId()); - IMqttsnMessageFactory factory = backendService.getRegistry().getCodec().createMessageFactory(); - String topicPath = String.format("/devices/%s/detach", context.getId()); - IMqttsnMessage publish = - factory.createPublish(1, false, false, topicPath, new byte[0]); - super.publish(context, new TopicPath(topicPath), 1, false, new byte[0], publish); - return new DisconnectResult(Result.STATUS.SUCCESS); - } - return new DisconnectResult(Result.STATUS.NOOP); - } - - @Override - public PublishResult publish(IClientIdentifierContext context, TopicPath topicPath, int qos, boolean retained, byte[] data, IMqttsnMessage message) throws MqttsnConnectorException { - return super.publish(context, topicPath, qos, retained, data, message); - } - - @Override - public boolean canAccept(IClientIdentifierContext context, TopicPath topicPath, byte[] data, IMqttsnMessage message) { - return MqttsnUtils.in(topicPath.toString(), new String[] { - String.format("/devices/%s/state", context.getId()), - String.format("/devices/%s/events", context.getId()) - }); - } - - @Override - protected void onClientConnected(MqttClient client){ - try { - ///devices/{gateway_ID}/errors - { - String topic = String.format("/devices/%s/errors", getGoogleIoTGatewayId(options)); - logger.info("subscribing to Google gateway error topic {}", topic); - client.subscribe(topic, 0); - } - - ///devices/{gateway_ID}/config - { - String topic = String.format("/devices/%s/config", getGoogleIoTGatewayId(options)); - logger.info("subscribing to Google gateway error topic {}", topic); - client.subscribe(topic, 0); - } - } catch(Exception e){ - logger.error("error subscribing to error topic", e); - } - } - - @Override - protected String createConnectionString(MqttsnConnectorOptions options) { - return "ssl://mqtt.googleapis.com:8883"; - } - - @Override - protected MqttConnectOptions createConnectOptions(MqttsnConnectorOptions options) throws MqttsnConnectorException { - try { - MqttConnectOptions connectOptions = super.createConnectOptions(options); - connectOptions.setUserName("unused"); //per the GGL documents - connectOptions.setMqttVersion(MqttConnectOptions.MQTT_VERSION_3_1_1); - - String alg = System.getProperty("algorithm"); - if(alg == null || alg.equals(ALG_ES)){ - connectOptions.setPassword( - createJwtEs(getGoogleIoTProjectId(options), - options.getPrivateKeyFileLocation()).toCharArray()); - } else { - connectOptions.setPassword( - createJwtRsa(getGoogleIoTProjectId(options), - options.getPrivateKeyFileLocation()).toCharArray()); - } - return connectOptions; - } catch(Exception e){ - throw new MqttsnConnectorException(e); - } - } - - /** Create a Cloud IoT Core JWT for the given project id, signed with the given RSA key. */ - private static String createJwtRsa(String projectId, String privateKeyFile) - throws NoSuchAlgorithmException, IOException, InvalidKeySpecException { - DateTime now = new DateTime(); - // Create a JWT to authenticate this device. The device will be disconnected after the token - // expires, and will have to reconnect with a new token. The audience field should always be set - // to the GCP project id. - JwtBuilder jwtBuilder = - Jwts.builder() - .setIssuedAt(now.toDate()) - .setExpiration(now.plusMinutes(TOKEN_EXPIRY_MINUTES).toDate()) - .setAudience(projectId); - - byte[] keyBytes = Files.readAllBytes(Paths.get(privateKeyFile)); - PKCS8EncodedKeySpec spec = new PKCS8EncodedKeySpec(keyBytes); - KeyFactory kf = KeyFactory.getInstance("RSA"); - return jwtBuilder.signWith(SignatureAlgorithm.RS256, kf.generatePrivate(spec)).compact(); - } - - /** Create a Cloud IoT Core JWT for the given project id, signed with the given ES key. */ - private static String createJwtEs(String projectId, String privateKeyFile) - throws NoSuchAlgorithmException, IOException, InvalidKeySpecException { - DateTime now = new DateTime(); - // Create a JWT to authenticate this device. The device will be disconnected after the token - // expires, and will have to reconnect with a new token. The audience field should always be set - // to the GCP project id. - JwtBuilder jwtBuilder = - Jwts.builder() - .setIssuedAt(now.toDate()) - .setExpiration(now.plusMinutes(TOKEN_EXPIRY_MINUTES).toDate()) - .setAudience(projectId); - - byte[] keyBytes = Files.readAllBytes(Paths.get(privateKeyFile)); - PKCS8EncodedKeySpec spec = new PKCS8EncodedKeySpec(keyBytes); - KeyFactory kf = KeyFactory.getInstance("EC"); - return jwtBuilder.signWith(SignatureAlgorithm.ES256, kf.generatePrivate(spec)).compact(); - } - - protected String getGoogleIoTProjectId(MqttsnConnectorOptions options){ - final String projectId = System.getProperty("projectId"); - if(projectId == null){ - throw new IllegalArgumentException("please specify -DprojectId="); - } - return projectId; - } - - protected String getGoogleIoTGatewayId(MqttsnConnectorOptions options){ - final String gatewayId = System.getProperty("gatewayId"); - if(gatewayId == null){ - throw new IllegalArgumentException("please specify -DprojectId="); - } - return gatewayId; - } - - protected String getGoogleIoTRegistryId(MqttsnConnectorOptions options){ - final String registryId = System.getProperty("registryId"); - if(registryId == null){ - throw new IllegalArgumentException("please specify -DregistryId="); - } - return registryId; - } - - protected String getGoogleIoTCloudRegion(MqttsnConnectorOptions options){ - final String cloudRegion = System.getProperty("cloudRegion"); - if(cloudRegion == null){ - throw new IllegalArgumentException("please specify -DcloudRegion="); - } - return cloudRegion; - } - - @Override - public void messageArrived(String s, MqttMessage mqttMessage) throws Exception { - logger.info("received message from google iot {} -> {}", s, new String(mqttMessage.getPayload())); - super.messageArrived(s, mqttMessage); - } -} diff --git a/mqtt-sn-gateway-connector-google-iotcore/src/main/java/org/slj/mqtt/sn/gateway/connector/google/iotcore/GoogleIoTCoreMqttsnConnector.java b/mqtt-sn-gateway-connector-google-iotcore/src/main/java/org/slj/mqtt/sn/gateway/connector/google/iotcore/GoogleIoTCoreMqttsnConnector.java deleted file mode 100644 index 573958d..0000000 --- a/mqtt-sn-gateway-connector-google-iotcore/src/main/java/org/slj/mqtt/sn/gateway/connector/google/iotcore/GoogleIoTCoreMqttsnConnector.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2021 Simon Johnson - * - * Find me on GitHub: - * https://github.com/simon622 - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF 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. - */ - -package org.slj.mqtt.sn.gateway.connector.google.iotcore; - -import org.slj.mqtt.sn.cloud.MqttsnConnectorDescriptor; -import org.slj.mqtt.sn.gateway.impl.connector.AbstractMqttsnConnector; -import org.slj.mqtt.sn.gateway.spi.connector.MqttsnConnectorException; -import org.slj.mqtt.sn.gateway.spi.connector.MqttsnConnectorOptions; - -public class GoogleIoTCoreMqttsnConnector - extends AbstractMqttsnConnector{ - - public static final MqttsnConnectorDescriptor DESCRIPTOR = new MqttsnConnectorDescriptor(); - static { - DESCRIPTOR.setClassName(GoogleIoTCoreMqttsnConnector.class.getName()); - DESCRIPTOR.setCompanyName("Google"); - DESCRIPTOR.setProtocol("MQTT"); - DESCRIPTOR.setDescription("This connector is deprecated"); - DESCRIPTOR.setName("AWS IoT Core Connector (Deprecated)"); - DESCRIPTOR.setDeveloper("Goodle"); - } - - public GoogleIoTCoreMqttsnConnector(MqttsnConnectorDescriptor descriptor, MqttsnConnectorOptions options) { - super(descriptor, options); - } - - @Override - public GoogleIoTCoreMqttsnConnection createConnection(MqttsnConnectorOptions options, String clientId) throws MqttsnConnectorException { - try { - GoogleIoTCoreMqttsnConnection connection = new GoogleIoTCoreMqttsnConnection(options); - connection.connect(); - return connection; - } catch(Exception e){ - throw new MqttsnConnectorException("error creating connection;", e); - } - } - - @Override - public String getConnectionString() { - return String.format("%s@%s:%s", - options.getClientId(), - options.getHostName(), - options.getPort()); - } -} diff --git a/mqtt-sn-gateway-connector-paho/pom.xml b/mqtt-sn-gateway-connector-paho/pom.xml index 10513d1..9662486 100644 --- a/mqtt-sn-gateway-connector-paho/pom.xml +++ b/mqtt-sn-gateway-connector-paho/pom.xml @@ -31,7 +31,7 @@ org.slj mqtt-sn - 0.2.1 + 0.2.2 mqtt-sn-gateway-connector-paho diff --git a/mqtt-sn-gateway-console/dependency-reduced-pom.xml b/mqtt-sn-gateway-console/dependency-reduced-pom.xml index ee803d0..1fd323a 100644 --- a/mqtt-sn-gateway-console/dependency-reduced-pom.xml +++ b/mqtt-sn-gateway-console/dependency-reduced-pom.xml @@ -3,7 +3,7 @@ mqtt-sn org.slj - 0.2.1 + 0.2.2 4.0.0 mqtt-sn-gateway-console diff --git a/mqtt-sn-gateway-console/pom.xml b/mqtt-sn-gateway-console/pom.xml index c4ad511..63103b2 100644 --- a/mqtt-sn-gateway-console/pom.xml +++ b/mqtt-sn-gateway-console/pom.xml @@ -29,7 +29,7 @@ mqtt-sn org.slj - 0.2.1 + 0.2.2 4.0.0 diff --git a/mqtt-sn-gateway/pom.xml b/mqtt-sn-gateway/pom.xml index b2c3dde..87671c5 100644 --- a/mqtt-sn-gateway/pom.xml +++ b/mqtt-sn-gateway/pom.xml @@ -31,7 +31,7 @@ org.slj mqtt-sn - 0.2.1 + 0.2.2 mqtt-sn-gateway @@ -50,11 +50,11 @@ mqtt-sn-core ${mqtt-sn.version} - - com.google.guava - guava - 32.0.0-jre - + + + + + com.fasterxml.jackson.core jackson-databind diff --git a/mqtt-sn-gateway/src/main/java/org/slj/mqtt/sn/gateway/impl/gateway/type/MqttsnAggregatingGateway.java b/mqtt-sn-gateway/src/main/java/org/slj/mqtt/sn/gateway/impl/gateway/type/MqttsnAggregatingGateway.java index 22399ac..5385ff3 100644 --- a/mqtt-sn-gateway/src/main/java/org/slj/mqtt/sn/gateway/impl/gateway/type/MqttsnAggregatingGateway.java +++ b/mqtt-sn-gateway/src/main/java/org/slj/mqtt/sn/gateway/impl/gateway/type/MqttsnAggregatingGateway.java @@ -24,7 +24,6 @@ package org.slj.mqtt.sn.gateway.impl.gateway.type; -import com.google.common.util.concurrent.RateLimiter; import org.slj.mqtt.sn.cloud.MqttsnConnectorDescriptor; import org.slj.mqtt.sn.gateway.impl.backend.AbstractMqttsnBackendConnection; import org.slj.mqtt.sn.gateway.impl.backend.AbstractMqttsnBackendService; @@ -37,7 +36,10 @@ import org.slj.mqtt.sn.impl.metrics.MqttsnCountingMetric; import org.slj.mqtt.sn.impl.metrics.MqttsnSnapshotMetric; import org.slj.mqtt.sn.model.IClientIdentifierContext; -import org.slj.mqtt.sn.spi.*; +import org.slj.mqtt.sn.spi.IMqttsnMessage; +import org.slj.mqtt.sn.spi.IMqttsnRuntimeRegistry; +import org.slj.mqtt.sn.spi.MqttsnException; +import org.slj.mqtt.sn.spi.MqttsnIllegalFormatException; import org.slj.mqtt.sn.utils.MqttsnUtils; import org.slj.mqtt.sn.utils.TopicPath; @@ -56,7 +58,7 @@ public class MqttsnAggregatingGateway extends AbstractMqttsnBackendService { private Thread publishingThread = null; private final Object monitor = new Object(); private final Queue queue = new LinkedBlockingQueue<>(); - private volatile RateLimiter rateLimiter = null; +// private volatile RateLimiter rateLimiter = null; private static final long PUBLISH_THREAD_MAX_WAIT = 10000; private static final long MANAGED_CONNECTION_VALIDATION_TIME = 10000; private static final long MAX_ERROR_RETRIES = 5; @@ -71,7 +73,7 @@ public void start(IMqttsnRuntimeRegistry runtime) throws MqttsnException { super.start(runtime); double limiter = ((MqttsnGatewayOptions)runtime.getOptions()). getMaxBrokerPublishesPerSecond(); - rateLimiter = limiter == 0d ? null : RateLimiter.create(limiter); +// rateLimiter = limiter == 0d ? null : RateLimiter.create(limiter); stopped = false; connectOnStartup(); initPublisher(); @@ -82,10 +84,10 @@ public void start(IMqttsnRuntimeRegistry runtime) throws MqttsnException { public synchronized boolean initializeConnector(MqttsnConnectorDescriptor descriptor, MqttsnConnectorOptions options) throws MqttsnException { int qps = descriptor.getRateLimit(); if(qps > 0){ - rateLimiter = RateLimiter.create(qps); +// rateLimiter = RateLimiter.create(qps); logger.warn("re-initialising connector rate-limiter with {} permits", qps); } else { - rateLimiter = null; +// rateLimiter = null; } return super.initializeConnector(descriptor, options); } @@ -222,7 +224,7 @@ private void initPublisher(){ BrokerPublishOperation op = queue.poll(); if(op != null){ if(connection.canAccept(op.context, op.topicPath, op.payload, op.initialMessage)){ - if(rateLimiter != null) rateLimiter.acquire(); +// if(rateLimiter != null) rateLimiter.acquire(); logger.debug("de-queuing message to broker from queue, {} remaining", queue.size()); PublishResult res = super.publish(op.context, op.topicPath, op.qos, op.retained, op.payload, op.initialMessage); if(res.isError()){ diff --git a/mqtt-sn-load-test/pom.xml b/mqtt-sn-load-test/pom.xml index 255bd71..6842c32 100644 --- a/mqtt-sn-load-test/pom.xml +++ b/mqtt-sn-load-test/pom.xml @@ -31,7 +31,7 @@ org.slj mqtt-sn - 0.2.1 + 0.2.2 mqtt-sn-load-test diff --git a/mqtt-sn-protection-runtimes/pom.xml b/mqtt-sn-protection-runtimes/pom.xml index 4c0e0d9..b9fb8e9 100644 --- a/mqtt-sn-protection-runtimes/pom.xml +++ b/mqtt-sn-protection-runtimes/pom.xml @@ -6,7 +6,7 @@ org.slj mqtt-sn - 0.2.1 + 0.2.2 mqtt-sn-protection-runtimes diff --git a/mqtt-sn-protection/pom.xml b/mqtt-sn-protection/pom.xml index f23c748..e5a61be 100644 --- a/mqtt-sn-protection/pom.xml +++ b/mqtt-sn-protection/pom.xml @@ -6,7 +6,7 @@ org.slj mqtt-sn - 0.2.1 + 0.2.2 mqtt-sn-protection diff --git a/pom.xml b/pom.xml index 3a16297..7d0b48b 100644 --- a/pom.xml +++ b/pom.xml @@ -29,7 +29,7 @@ org.slj mqtt-sn - 0.2.1 + 0.2.2 pom @@ -60,7 +60,6 @@ mqtt-sn-core mqtt-sn-gateway mqtt-sn-gateway-connector-aws-iotcore - mqtt-sn-gateway-connector-google-iotcore mqtt-sn-gateway-connector-paho mqtt-sn-load-test mqtt-sn-gateway-console @@ -81,7 +80,7 @@ 3.4.1 2.10.2 1.11 - 0.2.1 + 0.2.2