diff --git a/docker/DockerFile b/docker/DockerFile index 0440fd2960..adeb84f6cb 100644 --- a/docker/DockerFile +++ b/docker/DockerFile @@ -43,6 +43,7 @@ RUN set -x \ COPY --from=unpack /opt/hivemq-edge-${HIVEMQ_EDGE_VERSION} /opt/hivemq-edge-${HIVEMQ_EDGE_VERSION} COPY config.xml /opt/hivemq-edge-${HIVEMQ_EDGE_VERSION}/conf/config.xml +COPY config-k8s.xml /opt/hivemq-edge-${HIVEMQ_EDGE_VERSION}/conf-k8s/config.xml COPY docker-entrypoint.sh /opt/docker-entrypoint.sh RUN ln -s /opt/hivemq-edge-${HIVEMQ_EDGE_VERSION} /opt/hivemq \ @@ -50,6 +51,8 @@ RUN ln -s /opt/hivemq-edge-${HIVEMQ_EDGE_VERSION} /opt/hivemq \ && useradd -g hivemq -d /opt/hivemq -s /bin/bash --uid ${HIVEMQ_UID} hivemq \ && chgrp 0 /opt/hivemq-edge-${HIVEMQ_EDGE_VERSION}/conf/config.xml \ && chmod 770 /opt/hivemq-edge-${HIVEMQ_EDGE_VERSION}/conf/config.xml \ + && chgrp 0 /opt/hivemq-edge-${HIVEMQ_EDGE_VERSION}/conf-k8s/config.xml \ + && chmod 770 /opt/hivemq-edge-${HIVEMQ_EDGE_VERSION}/conf-k8s/config.xml \ && chgrp 0 /opt/hivemq \ && chmod 770 /opt/hivemq \ && chmod +x /opt/hivemq/bin/run.sh /opt/docker-entrypoint.sh diff --git a/docker/config-k8s.xml b/docker/config-k8s.xml new file mode 100644 index 0000000000..bec7901cc1 --- /dev/null +++ b/docker/config-k8s.xml @@ -0,0 +1,25 @@ + + + + + 1883 + 0.0.0.0 + + + + + 2442 + 0.0.0.0 + + + + true + + + 0.0.0.0 + 8080 + + + + ${FRAGMENT:/fragment/config} + diff --git a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/DisabledEntity.java b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/DisabledEntity.java index ba58b97329..0675eb158e 100644 --- a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/DisabledEntity.java +++ b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/DisabledEntity.java @@ -18,6 +18,7 @@ import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; +import java.util.Objects; /** * @author Florian Limpöck @@ -37,4 +38,17 @@ public boolean isEnabled() { public void setEnabled(final boolean enabled) { this.enabled = enabled; } + + @Override + public boolean equals(final Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + final DisabledEntity that = (DisabledEntity) o; + return isEnabled() == that.isEnabled(); + } + + @Override + public int hashCode() { + return Objects.hashCode(isEnabled()); + } } diff --git a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/DynamicConfigEntity.java b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/DynamicConfigEntity.java index c0a8ee5d88..95264b2676 100644 --- a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/DynamicConfigEntity.java +++ b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/DynamicConfigEntity.java @@ -19,6 +19,7 @@ import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; +import java.util.Objects; /** * @author Simon L Johnson @@ -41,4 +42,18 @@ public boolean isConfigurationExportEnabled() { public boolean isMutableConfigurationEnabled() { return mutableConfigurationEnabled; } + + @Override + public boolean equals(final Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + final DynamicConfigEntity that = (DynamicConfigEntity) o; + return isConfigurationExportEnabled() == that.isConfigurationExportEnabled() && + isMutableConfigurationEnabled() == that.isMutableConfigurationEnabled(); + } + + @Override + public int hashCode() { + return Objects.hash(isConfigurationExportEnabled(), isMutableConfigurationEnabled()); + } } diff --git a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/EnabledEntity.java b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/EnabledEntity.java index dddba76115..711bcfe5aa 100644 --- a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/EnabledEntity.java +++ b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/EnabledEntity.java @@ -18,6 +18,7 @@ import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; +import java.util.Objects; /** * @author Florian Limpöck @@ -37,4 +38,17 @@ public boolean isEnabled() { public void setEnabled(final boolean enabled) { this.enabled = enabled; } + + @Override + public boolean equals(final Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + final EnabledEntity that = (EnabledEntity) o; + return isEnabled() == that.isEnabled(); + } + + @Override + public int hashCode() { + return Objects.hashCode(isEnabled()); + } } diff --git a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/HiveMQConfigEntity.java b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/HiveMQConfigEntity.java index 827f27a965..03c7ea7716 100644 --- a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/HiveMQConfigEntity.java +++ b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/HiveMQConfigEntity.java @@ -201,4 +201,47 @@ public HiveMQConfigEntity( public int getVersion() { return version; } + + @Override + public boolean equals(final Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + final HiveMQConfigEntity that = (HiveMQConfigEntity) o; + return getVersion() == that.getVersion() && + Objects.equals(mqttListeners, that.mqttListeners) && + Objects.equals(mqttsnListeners, that.mqttsnListeners) && + Objects.equals(mqtt, that.mqtt) && + Objects.equals(mqttsn, that.mqttsn) && + Objects.equals(restrictions, that.restrictions) && + Objects.equals(security, that.security) && + Objects.equals(persistence, that.persistence) && + Objects.equals(mqttBridges, that.mqttBridges) && + Objects.equals(api, that.api) && + Objects.equals(getUns(), that.getUns()) && + Objects.equals(gateway, that.gateway) && + Objects.equals(getUsageTracking(), that.getUsageTracking()) && + Objects.equals(getProtocolAdapterConfig(), that.getProtocolAdapterConfig()) && + Objects.equals(getModuleConfigs(), that.getModuleConfigs()) && + Objects.equals(getInternal(), that.getInternal()); + } + + @Override + public int hashCode() { + return Objects.hash(getVersion(), + mqttListeners, + mqttsnListeners, + mqtt, + mqttsn, + restrictions, + security, + persistence, + mqttBridges, + api, + getUns(), + gateway, + getUsageTracking(), + getProtocolAdapterConfig(), + getModuleConfigs(), + getInternal()); + } } diff --git a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/InternalConfigEntity.java b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/InternalConfigEntity.java index f2ec930f74..eb9e9fdc8c 100644 --- a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/InternalConfigEntity.java +++ b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/InternalConfigEntity.java @@ -24,6 +24,7 @@ import javax.xml.bind.annotation.XmlElements; import javax.xml.bind.annotation.XmlRootElement; import java.util.List; +import java.util.Objects; /** * @author Christoph Schäbel @@ -39,4 +40,17 @@ public class InternalConfigEntity { public @NotNull List getOptions() { return options; } + + @Override + public boolean equals(final Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + final InternalConfigEntity that = (InternalConfigEntity) o; + return Objects.equals(getOptions(), that.getOptions()); + } + + @Override + public int hashCode() { + return Objects.hashCode(getOptions()); + } } diff --git a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/MqttConfigEntity.java b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/MqttConfigEntity.java index d7a96a6abf..ceb3eee18b 100644 --- a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/MqttConfigEntity.java +++ b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/MqttConfigEntity.java @@ -22,6 +22,7 @@ import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElementRef; import javax.xml.bind.annotation.XmlRootElement; +import java.util.Objects; /** * @author Dominik Obermaier @@ -114,4 +115,39 @@ public class MqttConfigEntity { public @NotNull SharedSubscriptionsConfigEntity getSharedSubscriptionsConfigEntity() { return sharedSubscriptionsConfigEntity; } + + @Override + public boolean equals(final Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + final MqttConfigEntity that = (MqttConfigEntity) o; + return Objects.equals(getQueuedMessagesConfigEntity(), that.getQueuedMessagesConfigEntity()) && + Objects.equals(getRetainedMessagesConfigEntity(), that.getRetainedMessagesConfigEntity()) && + Objects.equals(getWildcardSubscriptionsConfigEntity(), that.getWildcardSubscriptionsConfigEntity()) && + Objects.equals(getQoSConfigEntity(), that.getQoSConfigEntity()) && + Objects.equals(getTopicAliasConfigEntity(), that.getTopicAliasConfigEntity()) && + Objects.equals(getMessageExpiryConfigEntity(), that.getMessageExpiryConfigEntity()) && + Objects.equals(getSessionExpiryConfigEntity(), that.getSessionExpiryConfigEntity()) && + Objects.equals(getSubscriptionIdentifierConfigEntity(), that.getSubscriptionIdentifierConfigEntity()) && + Objects.equals(getSharedSubscriptionsConfigEntity(), that.getSharedSubscriptionsConfigEntity()) && + Objects.equals(getKeepAliveConfigEntity(), that.getKeepAliveConfigEntity()) && + Objects.equals(getPacketsConfigEntity(), that.getPacketsConfigEntity()) && + Objects.equals(getReceiveMaximumConfigEntity(), that.getReceiveMaximumConfigEntity()); + } + + @Override + public int hashCode() { + return Objects.hash(getQueuedMessagesConfigEntity(), + getRetainedMessagesConfigEntity(), + getWildcardSubscriptionsConfigEntity(), + getQoSConfigEntity(), + getTopicAliasConfigEntity(), + getMessageExpiryConfigEntity(), + getSessionExpiryConfigEntity(), + getSubscriptionIdentifierConfigEntity(), + getSharedSubscriptionsConfigEntity(), + getKeepAliveConfigEntity(), + getPacketsConfigEntity(), + getReceiveMaximumConfigEntity()); + } } diff --git a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/MqttSnConfigEntity.java b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/MqttSnConfigEntity.java index cdde530d0d..f9f6537208 100644 --- a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/MqttSnConfigEntity.java +++ b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/MqttSnConfigEntity.java @@ -27,6 +27,7 @@ import javax.xml.bind.annotation.*; import java.util.ArrayList; import java.util.List; +import java.util.Objects; /** * @author Simon L Johnson @@ -96,4 +97,33 @@ public int getMaxClientIdentifierLength() { public int getGatewayId() { return gatewayId; } + + @Override + public boolean equals(final Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + final MqttSnConfigEntity that = (MqttSnConfigEntity) o; + return getMaxClientIdentifierLength() == that.getMaxClientIdentifierLength() && + getGatewayId() == that.getGatewayId() && + Objects.equals(getPredefinedTopicAliases(), that.getPredefinedTopicAliases()) && + Objects.equals(getAllowEmptyClientIdentifierEntity(), that.getAllowEmptyClientIdentifierEntity()) && + Objects.equals(getDiscoveryEntity(), that.getDiscoveryEntity()) && + Objects.equals(getAllowAnonymousPublishMinus1Entity(), that.getAllowAnonymousPublishMinus1Entity()) && + Objects.equals(getAllowWakingPingToHijackSessionEntity(), + that.getAllowWakingPingToHijackSessionEntity()) && + Objects.equals(getTopicRegistrationsHeldDuringSleepEntity(), + that.getTopicRegistrationsHeldDuringSleepEntity()); + } + + @Override + public int hashCode() { + return Objects.hash(getPredefinedTopicAliases(), + getAllowEmptyClientIdentifierEntity(), + getDiscoveryEntity(), + getAllowAnonymousPublishMinus1Entity(), + getAllowWakingPingToHijackSessionEntity(), + getTopicRegistrationsHeldDuringSleepEntity(), + getMaxClientIdentifierLength(), + getGatewayId()); + } } diff --git a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/OptionEntity.java b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/OptionEntity.java index aaffca3bf4..a19a39f615 100644 --- a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/OptionEntity.java +++ b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/OptionEntity.java @@ -21,6 +21,7 @@ import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; +import java.util.Objects; /** * @author Christoph Schäbel @@ -43,4 +44,17 @@ public class OptionEntity { public @NotNull String getValue() { return value; } + + @Override + public boolean equals(final Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + final OptionEntity that = (OptionEntity) o; + return Objects.equals(getKey(), that.getKey()) && Objects.equals(getValue(), that.getValue()); + } + + @Override + public int hashCode() { + return Objects.hash(getKey(), getValue()); + } } diff --git a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/PersistenceEntity.java b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/PersistenceEntity.java index 7f6315e915..4705b61b67 100644 --- a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/PersistenceEntity.java +++ b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/PersistenceEntity.java @@ -18,6 +18,7 @@ import org.jetbrains.annotations.NotNull; import javax.xml.bind.annotation.*; +import java.util.Objects; /** * @author Lukas Brandl @@ -53,5 +54,16 @@ public PersistenceMode getMode() { return mode; } + @Override + public boolean equals(final Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + final PersistenceEntity that = (PersistenceEntity) o; + return getMode() == that.getMode(); + } + @Override + public int hashCode() { + return Objects.hashCode(getMode()); + } } diff --git a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/RestrictionsEntity.java b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/RestrictionsEntity.java index e2753537e8..5e4c9cecca 100644 --- a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/RestrictionsEntity.java +++ b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/RestrictionsEntity.java @@ -22,6 +22,8 @@ import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; +import java.util.Objects; + import static com.hivemq.configuration.service.RestrictionsConfigurationService.*; /** @@ -67,4 +69,25 @@ public int getMaxTopicLength() { public long getNoConnectIdleTimeout() { return noConnectIdleTimeout; } + + @Override + public boolean equals(final Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + final RestrictionsEntity that = (RestrictionsEntity) o; + return Objects.equals(getMaxConnections(), that.getMaxConnections()) && + Objects.equals(getMaxClientIdLength(), that.getMaxClientIdLength()) && + Objects.equals(getMaxTopicLength(), that.getMaxTopicLength()) && + Objects.equals(getNoConnectIdleTimeout(), that.getNoConnectIdleTimeout()) && + Objects.equals(getIncomingBandwidthThrottling(), that.getIncomingBandwidthThrottling()); + } + + @Override + public int hashCode() { + return Objects.hash(getMaxConnections(), + getMaxClientIdLength(), + getMaxTopicLength(), + getNoConnectIdleTimeout(), + getIncomingBandwidthThrottling()); + } } diff --git a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/SecurityConfigEntity.java b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/SecurityConfigEntity.java index d51c35ba71..f67dfccde3 100644 --- a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/SecurityConfigEntity.java +++ b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/SecurityConfigEntity.java @@ -25,6 +25,7 @@ import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElementRef; import javax.xml.bind.annotation.XmlRootElement; +import java.util.Objects; /** * @author Florian Limpöck @@ -62,4 +63,24 @@ public class SecurityConfigEntity { public @NotNull RequestProblemInformationEntityConfig getAllowRequestProblemInformationEntity() { return allowRequestProblemInformationEntity; } + + @Override + public boolean equals(final Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + final SecurityConfigEntity that = (SecurityConfigEntity) o; + return Objects.equals(getPayloadFormatValidationEntity(), that.getPayloadFormatValidationEntity()) && + Objects.equals(getUtf8ValidationEntity(), that.getUtf8ValidationEntity()) && + Objects.equals(getAllowEmptyClientIdEntity(), that.getAllowEmptyClientIdEntity()) && + Objects.equals(getAllowRequestProblemInformationEntity(), + that.getAllowRequestProblemInformationEntity()); + } + + @Override + public int hashCode() { + return Objects.hash(getPayloadFormatValidationEntity(), + getUtf8ValidationEntity(), + getAllowEmptyClientIdEntity(), + getAllowRequestProblemInformationEntity()); + } } diff --git a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/UsageTrackingConfigEntity.java b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/UsageTrackingConfigEntity.java index 0dadc63c4d..dffeb47e93 100644 --- a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/UsageTrackingConfigEntity.java +++ b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/UsageTrackingConfigEntity.java @@ -21,6 +21,7 @@ import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; +import java.util.Objects; /** * @author Simon L Johnson @@ -41,4 +42,16 @@ public void setEnabled(final boolean enabled) { this.enabled = enabled; } + @Override + public boolean equals(final Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + final UsageTrackingConfigEntity that = (UsageTrackingConfigEntity) o; + return isEnabled() == that.isEnabled(); + } + + @Override + public int hashCode() { + return Objects.hashCode(isEnabled()); + } } diff --git a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/adapter/MqttUserPropertyEntity.java b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/adapter/MqttUserPropertyEntity.java index 475d960935..b40fb600ed 100644 --- a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/adapter/MqttUserPropertyEntity.java +++ b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/adapter/MqttUserPropertyEntity.java @@ -20,6 +20,7 @@ import org.jetbrains.annotations.NotNull; import javax.xml.bind.annotation.XmlElement; +import java.util.Objects; public class MqttUserPropertyEntity { @@ -56,28 +57,20 @@ public MqttUserPropertyEntity( } @Override - public boolean equals(final @Nullable Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - - final MqttUserPropertyEntity that = (MqttUserPropertyEntity) o; - return name.equals(that.name) && value.equals(that.value); + public @NotNull String toString() { + return "MqttUserProperty{" + "name='" + name + '\'' + ", value='" + value + '\'' + '}'; } @Override - public int hashCode() { - int result = name.hashCode(); - result = 31 * result + value.hashCode(); - return result; + public boolean equals(final Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + final MqttUserPropertyEntity that = (MqttUserPropertyEntity) o; + return Objects.equals(getName(), that.getName()) && Objects.equals(getValue(), that.getValue()); } @Override - public @NotNull String toString() { - return "MqttUserProperty{" + "name='" + name + '\'' + ", value='" + value + '\'' + '}'; + public int hashCode() { + return Objects.hash(getName(), getValue()); } - } diff --git a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/adapter/NorthboundMappingEntity.java b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/adapter/NorthboundMappingEntity.java index ad678705e9..1a79ae355d 100644 --- a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/adapter/NorthboundMappingEntity.java +++ b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/adapter/NorthboundMappingEntity.java @@ -28,6 +28,7 @@ import javax.xml.bind.helpers.ValidationEventImpl; import java.util.ArrayList; import java.util.List; +import java.util.Objects; import java.util.stream.Collectors; public class NorthboundMappingEntity { @@ -205,4 +206,31 @@ public String toString() { mqttUserProperties, ctx.getMessageExpiryInterval()); } + + @Override + public boolean equals(final Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + final NorthboundMappingEntity that = (NorthboundMappingEntity) o; + return getMaxQoS() == that.getMaxQoS() && + isIncludeTagNames() == that.isIncludeTagNames() && + isIncludeTimestamp() == that.isIncludeTimestamp() && + getMessageExpiryInterval() == that.getMessageExpiryInterval() && + Objects.equals(getTopic(), that.getTopic()) && + Objects.equals(getTagName(), that.getTagName()) && + getMessageHandlingOptions() == that.getMessageHandlingOptions() && + Objects.equals(getUserProperties(), that.getUserProperties()); + } + + @Override + public int hashCode() { + return Objects.hash(getTopic(), + getTagName(), + getMaxQoS(), + getMessageHandlingOptions(), + isIncludeTagNames(), + isIncludeTimestamp(), + getUserProperties(), + getMessageExpiryInterval()); + } } diff --git a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/adapter/ProtocolAdapterEntity.java b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/adapter/ProtocolAdapterEntity.java index edd5f5a6b0..4e4e3702d0 100644 --- a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/adapter/ProtocolAdapterEntity.java +++ b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/adapter/ProtocolAdapterEntity.java @@ -159,5 +159,28 @@ public void validate(final @NotNull List validationEvents) { tagEntities); } + @Override + public boolean equals(final Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + final ProtocolAdapterEntity that = (ProtocolAdapterEntity) o; + return Objects.equals(getAdapterId(), that.getAdapterId()) && + Objects.equals(getProtocolId(), that.getProtocolId()) && + Objects.equals(getConfigVersion(), that.getConfigVersion()) && + Objects.equals(getConfig(), that.getConfig()) && + Objects.equals(getTags(), that.getTags()) && + Objects.equals(getSouthboundMappingEntities(), that.getSouthboundMappingEntities()) && + Objects.equals(getNorthboundMappingEntities(), that.getNorthboundMappingEntities()); + } + @Override + public int hashCode() { + return Objects.hash(getAdapterId(), + getProtocolId(), + getConfigVersion(), + getConfig(), + getTags(), + getSouthboundMappingEntities(), + getNorthboundMappingEntities()); + } } diff --git a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/adapter/SouthboundMappingEntity.java b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/adapter/SouthboundMappingEntity.java index 70dd865124..2711d49917 100644 --- a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/adapter/SouthboundMappingEntity.java +++ b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/adapter/SouthboundMappingEntity.java @@ -24,6 +24,7 @@ import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.helpers.ValidationEventImpl; import java.util.List; +import java.util.Objects; @SuppressWarnings("unused") public class SouthboundMappingEntity { @@ -94,4 +95,19 @@ public void validate(final @NotNull List validationEvents) { southboundMapping.getSchema()); } + @Override + public boolean equals(final Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + final SouthboundMappingEntity that = (SouthboundMappingEntity) o; + return Objects.equals(getTopicFilter(), that.getTopicFilter()) && + Objects.equals(getTagName(), that.getTagName()) && + Objects.equals(fieldMapping, that.fieldMapping) && + Objects.equals(fromNorthSchema, that.fromNorthSchema); + } + + @Override + public int hashCode() { + return Objects.hash(getTopicFilter(), getTagName(), fieldMapping, fromNorthSchema); + } } diff --git a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/adapter/TagEntity.java b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/adapter/TagEntity.java index 37025f751d..20d4094ff3 100644 --- a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/adapter/TagEntity.java +++ b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/adapter/TagEntity.java @@ -25,6 +25,7 @@ import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import java.util.HashMap; import java.util.Map; +import java.util.Objects; public class TagEntity { @@ -83,4 +84,19 @@ public static TagEntity fromAdapterTag(final @NotNull Tag tag, final @NotNull Ob map.put("definition", definition); return map; } + + @Override + public boolean equals(final Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + final TagEntity tagEntity = (TagEntity) o; + return Objects.equals(getName(), tagEntity.getName()) && + Objects.equals(getDescription(), tagEntity.getDescription()) && + Objects.equals(getDefinition(), tagEntity.getDefinition()); + } + + @Override + public int hashCode() { + return Objects.hash(getName(), getDescription(), getDefinition()); + } } diff --git a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/adapter/fieldmapping/FieldMappingEntity.java b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/adapter/fieldmapping/FieldMappingEntity.java index 72757a84b0..03a06b6115 100644 --- a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/adapter/fieldmapping/FieldMappingEntity.java +++ b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/adapter/fieldmapping/FieldMappingEntity.java @@ -24,6 +24,7 @@ import javax.xml.bind.annotation.XmlElementWrapper; import java.util.ArrayList; import java.util.List; +import java.util.Objects; import java.util.stream.Collectors; @SuppressWarnings("unused") @@ -61,4 +62,17 @@ public FieldMappingEntity( getInstructions().stream().map(InstructionEntity::to).collect(Collectors.toList()); return new FieldMapping(instructions); } + + @Override + public boolean equals(final Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + final FieldMappingEntity that = (FieldMappingEntity) o; + return Objects.equals(getInstructions(), that.getInstructions()); + } + + @Override + public int hashCode() { + return Objects.hashCode(getInstructions()); + } } diff --git a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/adapter/fieldmapping/InstructionEntity.java b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/adapter/fieldmapping/InstructionEntity.java index a281590370..1ed9d07e83 100644 --- a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/adapter/fieldmapping/InstructionEntity.java +++ b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/adapter/fieldmapping/InstructionEntity.java @@ -19,6 +19,7 @@ import com.hivemq.persistence.mappings.fieldmapping.Instruction; import javax.xml.bind.annotation.XmlElement; +import java.util.Objects; public class InstructionEntity { @@ -54,4 +55,18 @@ public InstructionEntity( public @NotNull Instruction to() { return new Instruction(getSourceFieldName(), getDestinationFieldName()); } + + @Override + public boolean equals(final Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + final InstructionEntity that = (InstructionEntity) o; + return Objects.equals(getSourceFieldName(), that.getSourceFieldName()) && + Objects.equals(getDestinationFieldName(), that.getDestinationFieldName()); + } + + @Override + public int hashCode() { + return Objects.hash(getSourceFieldName(), getDestinationFieldName()); + } } diff --git a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/api/AdminApiEntity.java b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/api/AdminApiEntity.java index bdd379b59e..4b7e57651d 100644 --- a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/api/AdminApiEntity.java +++ b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/api/AdminApiEntity.java @@ -26,6 +26,7 @@ import javax.xml.bind.annotation.XmlRootElement; import java.util.ArrayList; import java.util.List; +import java.util.Objects; /** * @author Simon L Johnson @@ -66,4 +67,21 @@ public List getUsers() { public ApiTlsEntity getTls() { return tls; } + + @Override + public boolean equals(final Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + if (!super.equals(o)) return false; + final AdminApiEntity that = (AdminApiEntity) o; + return Objects.equals(getListeners(), that.getListeners()) && + Objects.equals(getTls(), that.getTls()) && + Objects.equals(getJws(), that.getJws()) && + Objects.equals(getUsers(), that.getUsers()); + } + + @Override + public int hashCode() { + return Objects.hash(super.hashCode(), getListeners(), getTls(), getJws(), getUsers()); + } } diff --git a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/api/ApiJwsEntity.java b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/api/ApiJwsEntity.java index 6f014f2c69..e32c406455 100644 --- a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/api/ApiJwsEntity.java +++ b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/api/ApiJwsEntity.java @@ -18,6 +18,7 @@ import org.jetbrains.annotations.NotNull; import javax.xml.bind.annotation.*; +import java.util.Objects; /** * @author Simon L Johnson @@ -57,4 +58,25 @@ public int getExpiryTimeMinutes() { public int getTokenEarlyEpochThresholdMinutes() { return tokenEarlyEpochThresholdMinutes; } + + @Override + public boolean equals(final Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + final ApiJwsEntity that = (ApiJwsEntity) o; + return getKeySize() == that.getKeySize() && + getExpiryTimeMinutes() == that.getExpiryTimeMinutes() && + getTokenEarlyEpochThresholdMinutes() == that.getTokenEarlyEpochThresholdMinutes() && + Objects.equals(getIssuer(), that.getIssuer()) && + Objects.equals(getAudience(), that.getAudience()); + } + + @Override + public int hashCode() { + return Objects.hash(getKeySize(), + getIssuer(), + getAudience(), + getExpiryTimeMinutes(), + getTokenEarlyEpochThresholdMinutes()); + } } diff --git a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/api/ApiListenerEntity.java b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/api/ApiListenerEntity.java index 4001f2dd81..f921794f1d 100644 --- a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/api/ApiListenerEntity.java +++ b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/api/ApiListenerEntity.java @@ -20,6 +20,7 @@ import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; +import java.util.Objects; @XmlAccessorType(XmlAccessType.NONE) @SuppressWarnings({"FieldMayBeFinal", "FieldCanBeLocal"}) @@ -39,4 +40,16 @@ public int getPort() { return bindAddress; } + @Override + public boolean equals(final Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + final ApiListenerEntity that = (ApiListenerEntity) o; + return getPort() == that.getPort() && Objects.equals(getBindAddress(), that.getBindAddress()); + } + + @Override + public int hashCode() { + return Objects.hash(getPort(), getBindAddress()); + } } diff --git a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/api/ApiTlsEntity.java b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/api/ApiTlsEntity.java index f11b96956b..895d34c756 100644 --- a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/api/ApiTlsEntity.java +++ b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/api/ApiTlsEntity.java @@ -27,6 +27,7 @@ import javax.xml.bind.annotation.XmlRootElement; import java.util.ArrayList; import java.util.List; +import java.util.Objects; /** * @author Simon L Johnson @@ -59,4 +60,18 @@ public class ApiTlsEntity { return cipherSuites; } + @Override + public boolean equals(final Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + final ApiTlsEntity that = (ApiTlsEntity) o; + return Objects.equals(getKeystoreEntity(), that.getKeystoreEntity()) && + Objects.equals(getProtocols(), that.getProtocols()) && + Objects.equals(getCipherSuites(), that.getCipherSuites()); + } + + @Override + public int hashCode() { + return Objects.hash(getKeystoreEntity(), getProtocols(), getCipherSuites()); + } } diff --git a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/api/HttpsListenerEntity.java b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/api/HttpsListenerEntity.java index f13183f32a..e6cc9aeaca 100644 --- a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/api/HttpsListenerEntity.java +++ b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/api/HttpsListenerEntity.java @@ -21,6 +21,7 @@ import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElementRef; import javax.xml.bind.annotation.XmlRootElement; +import java.util.Objects; @XmlRootElement(name = "https-listener") @@ -34,4 +35,18 @@ public class HttpsListenerEntity extends ApiListenerEntity { public @NotNull ApiTlsEntity getTls() { return tls; } + + @Override + public boolean equals(final Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + if (!super.equals(o)) return false; + final HttpsListenerEntity that = (HttpsListenerEntity) o; + return Objects.equals(getTls(), that.getTls()); + } + + @Override + public int hashCode() { + return Objects.hash(super.hashCode(), getTls()); + } } diff --git a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/api/ResourcePath.java b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/api/ResourcePath.java index f9cbd3e9b8..4024333e97 100644 --- a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/api/ResourcePath.java +++ b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/api/ResourcePath.java @@ -19,6 +19,7 @@ import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; +import java.util.Objects; @SuppressWarnings({"FieldMayBeFinal", "FieldCanBeLocal"}) @XmlRootElement(name = "resource-path") @@ -38,4 +39,17 @@ public String getPath() { public String getUri() { return uri; } + + @Override + public boolean equals(final Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + final ResourcePath that = (ResourcePath) o; + return Objects.equals(getPath(), that.getPath()) && Objects.equals(getUri(), that.getUri()); + } + + @Override + public int hashCode() { + return Objects.hash(getPath(), getUri()); + } } diff --git a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/api/UserEntity.java b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/api/UserEntity.java index 92283e6f51..022e37a881 100644 --- a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/api/UserEntity.java +++ b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/api/UserEntity.java @@ -24,6 +24,7 @@ import javax.xml.bind.annotation.XmlRootElement; import java.util.ArrayList; import java.util.List; +import java.util.Objects; @SuppressWarnings({"FieldMayBeFinal", "FieldCanBeLocal"}) @XmlRootElement(name = "user") @@ -48,4 +49,19 @@ public String getPassword() { public List getRoles() { return roles; } + + @Override + public boolean equals(final Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + final UserEntity that = (UserEntity) o; + return Objects.equals(getUserName(), that.getUserName()) && + Objects.equals(getPassword(), that.getPassword()) && + Objects.equals(getRoles(), that.getRoles()); + } + + @Override + public int hashCode() { + return Objects.hash(getUserName(), getPassword(), getRoles()); + } } diff --git a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/bridge/BridgeAuthenticationEntity.java b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/bridge/BridgeAuthenticationEntity.java index 35dff07520..ccf91791fc 100644 --- a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/bridge/BridgeAuthenticationEntity.java +++ b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/bridge/BridgeAuthenticationEntity.java @@ -21,6 +21,7 @@ import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElementRef; import javax.xml.bind.annotation.XmlRootElement; +import java.util.Objects; @SuppressWarnings({"FieldMayBeFinal", "FieldCanBeLocal"}) @XmlRootElement(name = "authentication") @@ -37,4 +38,17 @@ public class BridgeAuthenticationEntity { public void setMqttSimpleAuthenticationEntity(final MqttSimpleAuthenticationEntity mqttSimpleAuthenticationEntity) { this.mqttSimpleAuthenticationEntity = mqttSimpleAuthenticationEntity; } + + @Override + public boolean equals(final Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + final BridgeAuthenticationEntity that = (BridgeAuthenticationEntity) o; + return Objects.equals(getMqttSimpleAuthenticationEntity(), that.getMqttSimpleAuthenticationEntity()); + } + + @Override + public int hashCode() { + return Objects.hashCode(getMqttSimpleAuthenticationEntity()); + } } diff --git a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/bridge/BridgeMqttEntity.java b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/bridge/BridgeMqttEntity.java index 8ed8a793db..c263fb8499 100644 --- a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/bridge/BridgeMqttEntity.java +++ b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/bridge/BridgeMqttEntity.java @@ -21,6 +21,7 @@ import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; +import java.util.Objects; @SuppressWarnings({"FieldMayBeFinal", "FieldCanBeLocal"}) @XmlRootElement(name = "mqtt") @@ -70,4 +71,20 @@ public void setSessionExpiry(final long sessionExpiry) { public void setKeepAlive(final int keepAlive) { this.keepAlive = keepAlive; } + + @Override + public boolean equals(final Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + final BridgeMqttEntity that = (BridgeMqttEntity) o; + return isCleanStart() == that.isCleanStart() && + getSessionExpiry() == that.getSessionExpiry() && + getKeepAlive() == that.getKeepAlive() && + Objects.equals(getClientId(), that.getClientId()); + } + + @Override + public int hashCode() { + return Objects.hash(getClientId(), isCleanStart(), getSessionExpiry(), getKeepAlive()); + } } diff --git a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/bridge/BridgeTlsEntity.java b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/bridge/BridgeTlsEntity.java index 9e9566a616..869fcac9d3 100644 --- a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/bridge/BridgeTlsEntity.java +++ b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/bridge/BridgeTlsEntity.java @@ -23,6 +23,7 @@ import javax.xml.bind.annotation.*; import java.util.ArrayList; import java.util.List; +import java.util.Objects; @SuppressWarnings({"FieldMayBeFinal", "FieldCanBeLocal"}) @XmlRootElement(name = "tls") @@ -107,4 +108,29 @@ public void setHandshakeTimeout(final int handshakeTimeout) { public void setVerifyHostname(final boolean verifyHostname) { this.verifyHostname = verifyHostname; } + + @Override + public boolean equals(final Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + final BridgeTlsEntity that = (BridgeTlsEntity) o; + return isEnabled() == that.isEnabled() && + getHandshakeTimeout() == that.getHandshakeTimeout() && + isVerifyHostname() == that.isVerifyHostname() && + Objects.equals(getKeyStore(), that.getKeyStore()) && + Objects.equals(getTrustStore(), that.getTrustStore()) && + Objects.equals(getProtocols(), that.getProtocols()) && + Objects.equals(getCipherSuites(), that.getCipherSuites()); + } + + @Override + public int hashCode() { + return Objects.hash(isEnabled(), + getKeyStore(), + getTrustStore(), + getProtocols(), + getCipherSuites(), + getHandshakeTimeout(), + isVerifyHostname()); + } } diff --git a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/bridge/BridgeWebsocketConfigurationEntity.java b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/bridge/BridgeWebsocketConfigurationEntity.java index 4fa90ce1a6..10bfda79dc 100644 --- a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/bridge/BridgeWebsocketConfigurationEntity.java +++ b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/bridge/BridgeWebsocketConfigurationEntity.java @@ -28,6 +28,7 @@ import javax.xml.bind.annotation.XmlRootElement; import java.util.ArrayList; import java.util.List; +import java.util.Objects; @SuppressWarnings({"FieldMayBeFinal", "FieldCanBeLocal"}) @XmlRootElement(name = "websocket") @@ -66,4 +67,19 @@ public void setServerPath(final @NotNull String serverPath) { public void setSubProtocol(final @NotNull String subProtocol) { this.subProtocol = subProtocol; } + + @Override + public boolean equals(final Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + final BridgeWebsocketConfigurationEntity that = (BridgeWebsocketConfigurationEntity) o; + return isEnabled() == that.isEnabled() && + Objects.equals(getServerPath(), that.getServerPath()) && + Objects.equals(getSubProtocol(), that.getSubProtocol()); + } + + @Override + public int hashCode() { + return Objects.hash(isEnabled(), getServerPath(), getSubProtocol()); + } } diff --git a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/bridge/CustomUserPropertyEntity.java b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/bridge/CustomUserPropertyEntity.java index d31bd2c4d0..adcb4c767f 100644 --- a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/bridge/CustomUserPropertyEntity.java +++ b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/bridge/CustomUserPropertyEntity.java @@ -21,6 +21,7 @@ import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; +import java.util.Objects; @SuppressWarnings({"FieldMayBeFinal", "FieldCanBeLocal"}) @XmlRootElement(name = "user-property") @@ -48,4 +49,17 @@ public void setKey(final String key) { public void setValue(final String value) { this.value = value; } + + @Override + public boolean equals(final Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + final CustomUserPropertyEntity that = (CustomUserPropertyEntity) o; + return Objects.equals(getKey(), that.getKey()) && Objects.equals(getValue(), that.getValue()); + } + + @Override + public int hashCode() { + return Objects.hash(getKey(), getValue()); + } } diff --git a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/bridge/ForwardedTopicEntity.java b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/bridge/ForwardedTopicEntity.java index 264549474a..2d2a5c0f20 100644 --- a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/bridge/ForwardedTopicEntity.java +++ b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/bridge/ForwardedTopicEntity.java @@ -26,6 +26,7 @@ import javax.xml.bind.annotation.XmlRootElement; import java.util.ArrayList; import java.util.List; +import java.util.Objects; @SuppressWarnings({"FieldMayBeFinal", "FieldCanBeLocal"}) @XmlRootElement(name = "forwarded-topic") @@ -110,4 +111,29 @@ public void setExcludes(final List excludes) { public @Nullable Long getQueueLimit() { return queueLimit; } + + @Override + public boolean equals(final Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + final ForwardedTopicEntity that = (ForwardedTopicEntity) o; + return getMaxQoS() == that.getMaxQoS() && + isPreserveRetain() == that.isPreserveRetain() && + Objects.equals(getFilters(), that.getFilters()) && + Objects.equals(getDestination(), that.getDestination()) && + Objects.equals(getCustomUserProperties(), that.getCustomUserProperties()) && + Objects.equals(getExcludes(), that.getExcludes()) && + Objects.equals(getQueueLimit(), that.getQueueLimit()); + } + + @Override + public int hashCode() { + return Objects.hash(getFilters(), + getMaxQoS(), + isPreserveRetain(), + getDestination(), + getCustomUserProperties(), + getExcludes(), + getQueueLimit()); + } } diff --git a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/bridge/LoopPreventionEntity.java b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/bridge/LoopPreventionEntity.java index ee6148c2ab..31f1d7bcb0 100644 --- a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/bridge/LoopPreventionEntity.java +++ b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/bridge/LoopPreventionEntity.java @@ -19,6 +19,7 @@ import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; +import java.util.Objects; @SuppressWarnings({"FieldMayBeFinal", "FieldCanBeLocal"}) @XmlRootElement(name = "loop-prevention") @@ -46,4 +47,17 @@ public void setEnabled(final boolean enabled) { public void setHopCountLimit(final int hopCountLimit) { this.hopCountLimit = hopCountLimit; } + + @Override + public boolean equals(final Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + final LoopPreventionEntity that = (LoopPreventionEntity) o; + return isEnabled() == that.isEnabled() && getHopCountLimit() == that.getHopCountLimit(); + } + + @Override + public int hashCode() { + return Objects.hash(isEnabled(), getHopCountLimit()); + } } diff --git a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/bridge/MqttBridgeEntity.java b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/bridge/MqttBridgeEntity.java index 571b2ed25b..d9afa9e90f 100644 --- a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/bridge/MqttBridgeEntity.java +++ b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/bridge/MqttBridgeEntity.java @@ -26,6 +26,7 @@ import javax.xml.bind.annotation.XmlRootElement; import java.util.ArrayList; import java.util.List; +import java.util.Objects; @SuppressWarnings({"FieldMayBeFinal", "FieldCanBeLocal"}) @@ -100,4 +101,27 @@ public boolean getPersist() { public void setPersist(final boolean persist) { this.persist = persist; } + + @Override + public boolean equals(final Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + final MqttBridgeEntity that = (MqttBridgeEntity) o; + return getPersist() == that.getPersist() && + Objects.equals(getId(), that.getId()) && + Objects.equals(getRemoteBroker(), that.getRemoteBroker()) && + Objects.equals(getRemoteSubscriptions(), that.getRemoteSubscriptions()) && + Objects.equals(getForwardedTopics(), that.getForwardedTopics()) && + Objects.equals(getLoopPrevention(), that.getLoopPrevention()); + } + + @Override + public int hashCode() { + return Objects.hash(getId(), + getRemoteBroker(), + getRemoteSubscriptions(), + getForwardedTopics(), + getLoopPrevention(), + getPersist()); + } } diff --git a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/bridge/MqttSimpleAuthenticationEntity.java b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/bridge/MqttSimpleAuthenticationEntity.java index ef79ab3e80..703956c2ef 100644 --- a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/bridge/MqttSimpleAuthenticationEntity.java +++ b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/bridge/MqttSimpleAuthenticationEntity.java @@ -21,6 +21,7 @@ import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; +import java.util.Objects; @XmlAccessorType(XmlAccessType.NONE) @XmlRootElement(name = "mqtt-simple-authentication") @@ -47,4 +48,17 @@ public void setUser(final String user) { public void setPassword(final String password) { this.password = password; } + + @Override + public boolean equals(final Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + final MqttSimpleAuthenticationEntity that = (MqttSimpleAuthenticationEntity) o; + return Objects.equals(getUser(), that.getUser()) && Objects.equals(getPassword(), that.getPassword()); + } + + @Override + public int hashCode() { + return Objects.hash(getUser(), getPassword()); + } } diff --git a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/bridge/RemoteBrokerEntity.java b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/bridge/RemoteBrokerEntity.java index 001bbf44fa..40c6e90e85 100644 --- a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/bridge/RemoteBrokerEntity.java +++ b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/bridge/RemoteBrokerEntity.java @@ -19,6 +19,7 @@ import org.jetbrains.annotations.Nullable; import javax.xml.bind.annotation.*; +import java.util.Objects; @SuppressWarnings({"FieldMayBeFinal", "FieldCanBeLocal"}) @XmlRootElement(name = "remote-broker") @@ -90,4 +91,22 @@ public void setAuthentication(final BridgeAuthenticationEntity authentication) { public void setTls(final BridgeTlsEntity tls) { this.tls = tls; } + + @Override + public boolean equals(final Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + final RemoteBrokerEntity that = (RemoteBrokerEntity) o; + return getPort() == that.getPort() && + Objects.equals(getHost(), that.getHost()) && + Objects.equals(getMqtt(), that.getMqtt()) && + Objects.equals(getAuthentication(), that.getAuthentication()) && + Objects.equals(getBridgeWebsocketConfig(), that.getBridgeWebsocketConfig()) && + Objects.equals(getTls(), that.getTls()); + } + + @Override + public int hashCode() { + return Objects.hash(getPort(), getHost(), getMqtt(), getAuthentication(), getBridgeWebsocketConfig(), getTls()); + } } diff --git a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/bridge/RemoteSubscriptionEntity.java b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/bridge/RemoteSubscriptionEntity.java index 46f263df5f..f0250c1779 100644 --- a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/bridge/RemoteSubscriptionEntity.java +++ b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/bridge/RemoteSubscriptionEntity.java @@ -26,6 +26,7 @@ import javax.xml.bind.annotation.XmlRootElement; import java.util.ArrayList; import java.util.List; +import java.util.Objects; @SuppressWarnings({"FieldMayBeFinal", "FieldCanBeLocal"}) @XmlRootElement(name = "remote-subscription") @@ -88,4 +89,21 @@ public void setDestination(final String destination) { public void setCustomUserProperties(final List customUserProperties) { this.customUserProperties = customUserProperties; } + + @Override + public boolean equals(final Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + final RemoteSubscriptionEntity that = (RemoteSubscriptionEntity) o; + return getMaxQoS() == that.getMaxQoS() && + isPreserveRetain() == that.isPreserveRetain() && + Objects.equals(getFilters(), that.getFilters()) && + Objects.equals(getDestination(), that.getDestination()) && + Objects.equals(getCustomUserProperties(), that.getCustomUserProperties()); + } + + @Override + public int hashCode() { + return Objects.hash(getFilters(), getMaxQoS(), isPreserveRetain(), getDestination(), getCustomUserProperties()); + } } diff --git a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/listener/ListenerEntity.java b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/listener/ListenerEntity.java index ae062e37f5..87a7ad6588 100644 --- a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/listener/ListenerEntity.java +++ b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/listener/ListenerEntity.java @@ -21,6 +21,7 @@ import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; +import java.util.Objects; @XmlAccessorType(XmlAccessType.NONE) @SuppressWarnings({"FieldMayBeFinal", "FieldCanBeLocal"}) @@ -53,4 +54,20 @@ public int getPort() { public @Nullable String getExternalHostname() { return externalHostname; } + + @Override + public boolean equals(final Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + final ListenerEntity that = (ListenerEntity) o; + return getPort() == that.getPort() && + Objects.equals(getBindAddress(), that.getBindAddress()) && + Objects.equals(getName(), that.getName()) && + Objects.equals(getExternalHostname(), that.getExternalHostname()); + } + + @Override + public int hashCode() { + return Objects.hash(getPort(), getBindAddress(), getName(), getExternalHostname()); + } } diff --git a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/listener/TLSEntity.java b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/listener/TLSEntity.java index d043c8008d..6490452c0f 100644 --- a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/listener/TLSEntity.java +++ b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/listener/TLSEntity.java @@ -25,6 +25,7 @@ import javax.xml.bind.annotation.*; import java.util.ArrayList; import java.util.List; +import java.util.Objects; /** * @author Dominik Obermaier @@ -86,4 +87,28 @@ public int getHandshakeTimeout() { return preferServerCipherSuites; } + @Override + public boolean equals(final Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + final TLSEntity tlsEntity = (TLSEntity) o; + return Objects.equals(getKeystoreEntity(), tlsEntity.getKeystoreEntity()) && + Objects.equals(getTruststoreEntity(), tlsEntity.getTruststoreEntity()) && + Objects.equals(getHandshakeTimeout(), tlsEntity.getHandshakeTimeout()) && + getClientAuthMode() == tlsEntity.getClientAuthMode() && + Objects.equals(getProtocols(), tlsEntity.getProtocols()) && + Objects.equals(getCipherSuites(), tlsEntity.getCipherSuites()) && + Objects.equals(preferServerCipherSuites, tlsEntity.preferServerCipherSuites); + } + + @Override + public int hashCode() { + return Objects.hash(getKeystoreEntity(), + getTruststoreEntity(), + getHandshakeTimeout(), + getClientAuthMode(), + getProtocols(), + getCipherSuites(), + preferServerCipherSuites); + } } diff --git a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/listener/TlsTCPListenerEntity.java b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/listener/TlsTCPListenerEntity.java index c5a1953a9b..d0ac2f2337 100644 --- a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/listener/TlsTCPListenerEntity.java +++ b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/listener/TlsTCPListenerEntity.java @@ -22,6 +22,7 @@ import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElementRef; import javax.xml.bind.annotation.XmlRootElement; +import java.util.Objects; /** * @author Dominik Obermaier @@ -37,4 +38,18 @@ public class TlsTCPListenerEntity extends ListenerEntity { public @Nullable TLSEntity getTls() { return tls; } + + @Override + public boolean equals(final Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + if (!super.equals(o)) return false; + final TlsTCPListenerEntity that = (TlsTCPListenerEntity) o; + return Objects.equals(getTls(), that.getTls()); + } + + @Override + public int hashCode() { + return Objects.hash(super.hashCode(), getTls()); + } } diff --git a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/listener/TlsWebsocketListenerEntity.java b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/listener/TlsWebsocketListenerEntity.java index b6c6edf818..f6217addf5 100644 --- a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/listener/TlsWebsocketListenerEntity.java +++ b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/listener/TlsWebsocketListenerEntity.java @@ -20,6 +20,7 @@ import javax.xml.bind.annotation.*; import java.util.ArrayList; import java.util.List; +import java.util.Objects; /** * @author Dominik Obermaier @@ -65,4 +66,21 @@ public boolean isAllowExtensions() { protocols.add("mqtt"); return protocols; } + + @Override + public boolean equals(final Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + if (!super.equals(o)) return false; + final TlsWebsocketListenerEntity that = (TlsWebsocketListenerEntity) o; + return isAllowExtensions() == that.isAllowExtensions() && + Objects.equals(getPath(), that.getPath()) && + Objects.equals(getSubprotocols(), that.getSubprotocols()) && + Objects.equals(getTls(), that.getTls()); + } + + @Override + public int hashCode() { + return Objects.hash(super.hashCode(), getPath(), getSubprotocols(), isAllowExtensions(), getTls()); + } } diff --git a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/listener/WebsocketListenerEntity.java b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/listener/WebsocketListenerEntity.java index d708a83619..77feada126 100644 --- a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/listener/WebsocketListenerEntity.java +++ b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/listener/WebsocketListenerEntity.java @@ -20,6 +20,7 @@ import javax.xml.bind.annotation.*; import java.util.ArrayList; import java.util.List; +import java.util.Objects; /** * @author Dominik Obermaier @@ -58,4 +59,20 @@ public boolean isAllowExtensions() { protocols.add("mqtt"); return protocols; } + + @Override + public boolean equals(final Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + if (!super.equals(o)) return false; + final WebsocketListenerEntity that = (WebsocketListenerEntity) o; + return Objects.equals(getPath(), that.getPath()) && + Objects.equals(getSubprotocols(), that.getSubprotocols()) && + Objects.equals(isAllowExtensions(), that.isAllowExtensions()); + } + + @Override + public int hashCode() { + return Objects.hash(super.hashCode(), getPath(), getSubprotocols(), isAllowExtensions()); + } } diff --git a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/listener/tls/KeystoreEntity.java b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/listener/tls/KeystoreEntity.java index f6f439b0d9..ffe85e823d 100644 --- a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/listener/tls/KeystoreEntity.java +++ b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/listener/tls/KeystoreEntity.java @@ -21,6 +21,7 @@ import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; +import java.util.Objects; /** * @author Georg Held @@ -62,4 +63,19 @@ public void setPassword(final String password) { public void setPrivateKeyPassword(final String privateKeyPassword) { this.privateKeyPassword = privateKeyPassword; } + + @Override + public boolean equals(final Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + final KeystoreEntity that = (KeystoreEntity) o; + return Objects.equals(getPath(), that.getPath()) && + Objects.equals(getPassword(), that.getPassword()) && + Objects.equals(getPrivateKeyPassword(), that.getPrivateKeyPassword()); + } + + @Override + public int hashCode() { + return Objects.hash(getPath(), getPassword(), getPrivateKeyPassword()); + } } diff --git a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/listener/tls/TruststoreEntity.java b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/listener/tls/TruststoreEntity.java index 9ca47ac5e4..b4708838f0 100644 --- a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/listener/tls/TruststoreEntity.java +++ b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/listener/tls/TruststoreEntity.java @@ -21,6 +21,7 @@ import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; +import java.util.Objects; /** * @author Georg Held @@ -51,4 +52,17 @@ public void setPath(final String path) { public void setPassword(final String password) { this.password = password; } + + @Override + public boolean equals(final Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + final TruststoreEntity that = (TruststoreEntity) o; + return Objects.equals(getPath(), that.getPath()) && Objects.equals(getPassword(), that.getPassword()); + } + + @Override + public int hashCode() { + return Objects.hash(getPath(), getPassword()); + } } diff --git a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/mqtt/KeepAliveConfigEntity.java b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/mqtt/KeepAliveConfigEntity.java index d345a46fe5..ba34bb8811 100644 --- a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/mqtt/KeepAliveConfigEntity.java +++ b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/mqtt/KeepAliveConfigEntity.java @@ -19,6 +19,7 @@ import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; +import java.util.Objects; /** * @author Florian Limpöck @@ -42,4 +43,17 @@ public int getMaxKeepAlive() { public boolean isAllowUnlimted() { return allowUnlimted; } + + @Override + public boolean equals(final Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + final KeepAliveConfigEntity that = (KeepAliveConfigEntity) o; + return getMaxKeepAlive() == that.getMaxKeepAlive() && isAllowUnlimted() == that.isAllowUnlimted(); + } + + @Override + public int hashCode() { + return Objects.hash(getMaxKeepAlive(), isAllowUnlimted()); + } } diff --git a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/mqtt/MessageExpiryConfigEntity.java b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/mqtt/MessageExpiryConfigEntity.java index 7efd166b5b..36053b0dac 100644 --- a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/mqtt/MessageExpiryConfigEntity.java +++ b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/mqtt/MessageExpiryConfigEntity.java @@ -20,6 +20,8 @@ import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; +import java.util.Objects; + import static com.hivemq.configuration.entity.mqtt.MqttConfigurationDefaults.MAX_EXPIRY_INTERVAL_DEFAULT; /** @@ -38,4 +40,17 @@ public class MessageExpiryConfigEntity { public long getMaxInterval() { return maxInterval; } + + @Override + public boolean equals(final Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + final MessageExpiryConfigEntity that = (MessageExpiryConfigEntity) o; + return getMaxInterval() == that.getMaxInterval(); + } + + @Override + public int hashCode() { + return Objects.hashCode(getMaxInterval()); + } } diff --git a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/mqtt/PacketsConfigEntity.java b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/mqtt/PacketsConfigEntity.java index 106caa8fbe..b83e3eb356 100644 --- a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/mqtt/PacketsConfigEntity.java +++ b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/mqtt/PacketsConfigEntity.java @@ -20,6 +20,8 @@ import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; +import java.util.Objects; + import static com.hivemq.mqtt.message.connack.Mqtt5CONNACK.DEFAULT_MAXIMUM_PACKET_SIZE_NO_LIMIT; /** @@ -37,4 +39,17 @@ public class PacketsConfigEntity { public int getMaxPacketSize() { return maxPacketSize; } + + @Override + public boolean equals(final Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + final PacketsConfigEntity that = (PacketsConfigEntity) o; + return getMaxPacketSize() == that.getMaxPacketSize(); + } + + @Override + public int hashCode() { + return Objects.hashCode(getMaxPacketSize()); + } } diff --git a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/mqtt/QoSConfigEntity.java b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/mqtt/QoSConfigEntity.java index 69efcd4c44..e0b914daec 100644 --- a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/mqtt/QoSConfigEntity.java +++ b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/mqtt/QoSConfigEntity.java @@ -20,6 +20,8 @@ import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; +import java.util.Objects; + import static com.hivemq.configuration.entity.mqtt.MqttConfigurationDefaults.MAXIMUM_QOS_DEFAULT; /** @@ -37,4 +39,17 @@ public class QoSConfigEntity { public int getMaxQos() { return maxQos; } + + @Override + public boolean equals(final Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + final QoSConfigEntity that = (QoSConfigEntity) o; + return getMaxQos() == that.getMaxQos(); + } + + @Override + public int hashCode() { + return Objects.hashCode(getMaxQos()); + } } diff --git a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/mqtt/QueuedMessagesConfigEntity.java b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/mqtt/QueuedMessagesConfigEntity.java index 10d096a2e2..ba294c3d60 100644 --- a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/mqtt/QueuedMessagesConfigEntity.java +++ b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/mqtt/QueuedMessagesConfigEntity.java @@ -18,6 +18,7 @@ import org.jetbrains.annotations.NotNull; import javax.xml.bind.annotation.*; +import java.util.Objects; @XmlRootElement(name = "queued-messages") @XmlAccessorType(XmlAccessType.NONE) @@ -47,4 +48,17 @@ public long getMaxQueueSize() { return queuedMessagesStrategy; } + @Override + public boolean equals(final Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + final QueuedMessagesConfigEntity that = (QueuedMessagesConfigEntity) o; + return getMaxQueueSize() == that.getMaxQueueSize() && + getQueuedMessagesStrategy() == that.getQueuedMessagesStrategy(); + } + + @Override + public int hashCode() { + return Objects.hash(getMaxQueueSize(), getQueuedMessagesStrategy()); + } } diff --git a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/mqtt/ReceiveMaximumConfigEntity.java b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/mqtt/ReceiveMaximumConfigEntity.java index 6ebc2b71ec..0ea971d7b2 100644 --- a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/mqtt/ReceiveMaximumConfigEntity.java +++ b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/mqtt/ReceiveMaximumConfigEntity.java @@ -19,6 +19,7 @@ import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; +import java.util.Objects; /** * @author Florian Limpöck @@ -35,4 +36,17 @@ public class ReceiveMaximumConfigEntity { public int getServerReceiveMaximum() { return serverReceiveMaximum; } + + @Override + public boolean equals(final Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + final ReceiveMaximumConfigEntity that = (ReceiveMaximumConfigEntity) o; + return getServerReceiveMaximum() == that.getServerReceiveMaximum(); + } + + @Override + public int hashCode() { + return Objects.hashCode(getServerReceiveMaximum()); + } } diff --git a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/mqtt/SessionExpiryConfigEntity.java b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/mqtt/SessionExpiryConfigEntity.java index 57a2bd8c14..c4537c0013 100644 --- a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/mqtt/SessionExpiryConfigEntity.java +++ b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/mqtt/SessionExpiryConfigEntity.java @@ -20,6 +20,8 @@ import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; +import java.util.Objects; + import static com.hivemq.mqtt.message.connect.Mqtt5CONNECT.SESSION_EXPIRY_MAX; /** @@ -38,4 +40,17 @@ public class SessionExpiryConfigEntity { public long getMaxInterval() { return maxInterval; } + + @Override + public boolean equals(final Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + final SessionExpiryConfigEntity that = (SessionExpiryConfigEntity) o; + return getMaxInterval() == that.getMaxInterval(); + } + + @Override + public int hashCode() { + return Objects.hashCode(getMaxInterval()); + } } diff --git a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/mqtt/TopicAliasConfigEntity.java b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/mqtt/TopicAliasConfigEntity.java index 0a0538306b..5cd6fd2f5c 100644 --- a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/mqtt/TopicAliasConfigEntity.java +++ b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/mqtt/TopicAliasConfigEntity.java @@ -22,6 +22,8 @@ import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; +import java.util.Objects; + import static com.hivemq.configuration.entity.mqtt.MqttConfigurationDefaults.TOPIC_ALIAS_MAX_PER_CLIENT_DEFAULT; /** @@ -40,4 +42,17 @@ public int getMaxPerClient() { return maxPerClient; } + @Override + public boolean equals(final Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + if (!super.equals(o)) return false; + final TopicAliasConfigEntity that = (TopicAliasConfigEntity) o; + return getMaxPerClient() == that.getMaxPerClient(); + } + + @Override + public int hashCode() { + return Objects.hash(super.hashCode(), getMaxPerClient()); + } } diff --git a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/mqttsn/MqttsnPredefinedTopicAliasEntity.java b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/mqttsn/MqttsnPredefinedTopicAliasEntity.java index 2f339754b8..c024b1870d 100644 --- a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/mqttsn/MqttsnPredefinedTopicAliasEntity.java +++ b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/mqttsn/MqttsnPredefinedTopicAliasEntity.java @@ -21,6 +21,7 @@ import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; +import java.util.Objects; /** * @author Simon L Johnson @@ -44,4 +45,17 @@ public int getAlias() { public String getTopicName() { return topicName; } + + @Override + public boolean equals(final Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + final MqttsnPredefinedTopicAliasEntity that = (MqttsnPredefinedTopicAliasEntity) o; + return getAlias() == that.getAlias() && Objects.equals(getTopicName(), that.getTopicName()); + } + + @Override + public int hashCode() { + return Objects.hash(getTopicName(), getAlias()); + } } diff --git a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/uns/ISA95Entity.java b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/uns/ISA95Entity.java index 93772cf00d..869fc1ca57 100644 --- a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/uns/ISA95Entity.java +++ b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/uns/ISA95Entity.java @@ -22,6 +22,7 @@ import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; +import java.util.Objects; /** * @author Simon L Johnson @@ -91,4 +92,27 @@ public void setProductionLine(final String productionLine) { public void setWorkCell(final String workCell) { this.workCell = workCell; } + + @Override + public boolean equals(final Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + final ISA95Entity that = (ISA95Entity) o; + return isPrefixAllTopics() == that.isPrefixAllTopics() && + Objects.equals(getEnterprise(), that.getEnterprise()) && + Objects.equals(getSite(), that.getSite()) && + Objects.equals(getArea(), that.getArea()) && + Objects.equals(getProductionLine(), that.getProductionLine()) && + Objects.equals(getWorkCell(), that.getWorkCell()); + } + + @Override + public int hashCode() { + return Objects.hash(isPrefixAllTopics(), + getEnterprise(), + getSite(), + getArea(), + getProductionLine(), + getWorkCell()); + } } diff --git a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/uns/UnsConfigEntity.java b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/uns/UnsConfigEntity.java index ff33842966..48059d4f2e 100644 --- a/hivemq-edge/src/main/java/com/hivemq/configuration/entity/uns/UnsConfigEntity.java +++ b/hivemq-edge/src/main/java/com/hivemq/configuration/entity/uns/UnsConfigEntity.java @@ -21,6 +21,7 @@ import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElementRef; import javax.xml.bind.annotation.XmlRootElement; +import java.util.Objects; /** * @author Simon L Johnson @@ -35,4 +36,16 @@ public class UnsConfigEntity { public @NotNull ISA95Entity getIsa95() { return isa95; } + @Override + public boolean equals(final Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + final UnsConfigEntity that = (UnsConfigEntity) o; + return Objects.equals(getIsa95(), that.getIsa95()); + } + + @Override + public int hashCode() { + return Objects.hashCode(getIsa95()); + } } diff --git a/hivemq-edge/src/main/java/com/hivemq/configuration/reader/ConfigFileReaderWriter.java b/hivemq-edge/src/main/java/com/hivemq/configuration/reader/ConfigFileReaderWriter.java index 578e620a79..95a5566006 100644 --- a/hivemq-edge/src/main/java/com/hivemq/configuration/reader/ConfigFileReaderWriter.java +++ b/hivemq-edge/src/main/java/com/hivemq/configuration/reader/ConfigFileReaderWriter.java @@ -131,7 +131,6 @@ public void applyConfigAndWatch(final long checkIntervalInMs) { final HiveMQConfigEntity entity = applyConfig(); fileModificationTimestamps = findFilesToWatch(entity); - final AtomicLong fileModifiedTimestamp = new AtomicLong(); try { fileModifiedTimestamp.set(Files.getLastModifiedTime(configFile.toPath()).toMillis()); @@ -153,27 +152,28 @@ private void checkMonitoredFilesForChanges( final @NotNull AtomicLong fileModified, final @NotNull Map fileModificationTimestamps) { try { + final boolean devmode = "true".equals(System.getProperty(HiveMQEdgeConstants.DEVELOPMENT_MODE)); + + if(!devmode) { + final Map pathsToCheck = new HashMap<>(fragmentToModificationTime); + + pathsToCheck.putAll(fileModificationTimestamps); + pathsToCheck.entrySet().forEach(pathToTs -> { + try { + if (Files.getLastModifiedTime(pathToTs.getKey()).toMillis() > pathToTs.getValue()) { + log.error("Restarting because a required file was updated: {}", pathToTs.getKey()); + System.exit(0); + } + } catch (IOException e) { + throw new RuntimeException("Unable to read last modified time for " + pathToTs.getKey(), e); + } + }); + } final long modified = Files.getLastModifiedTime(configFile.toPath()).toMillis(); if (modified > fileModified.get()) { fileModified.set(modified); final HiveMQConfigEntity hiveMQConfigEntity = readConfigFromXML(configFile); - final boolean devmode = "true".equals(System.getProperty(HiveMQEdgeConstants.DEVELOPMENT_MODE)); this.configEntity = hiveMQConfigEntity; - if(!devmode) { - final Map pathsToCheck = new HashMap<>(fragmentToModificationTime); - - pathsToCheck.putAll(fileModificationTimestamps); - pathsToCheck.entrySet().forEach(pathToTs -> { - try { - if (Files.getLastModifiedTime(pathToTs.getKey()).toMillis() > pathToTs.getValue()) { - log.error("Restarting because a required file was updated: {}", pathToTs.getKey()); - System.exit(0); - } - } catch (IOException e) { - throw new RuntimeException("Unable to read last modified time for " + pathToTs.getKey(), e); - } - }); - } if(!setConfiguration(hiveMQConfigEntity)) { if(!devmode) { log.error("Restarting because new config can't be hot-reloaded"); @@ -376,6 +376,7 @@ public void writeConfigToXML(final @NotNull Writer writer) { configFileContent = fragmentResult.getRenderResult(); //must happen before env rendering so templates can be used with envs configFileContent = EnvVarUtil.replaceEnvironmentVariablePlaceholders(configFileContent); + log.error("Resulting file {}", configFileContent); final ByteArrayInputStream is = new ByteArrayInputStream(configFileContent.getBytes(StandardCharsets.UTF_8)); final StreamSource streamSource = new StreamSource(is); @@ -395,7 +396,7 @@ public void writeConfigToXML(final @NotNull Writer writer) { throw new JAXBException("Parsing failed"); } - HiveMQConfigEntity configEntity = result.getValue(); + final HiveMQConfigEntity configEntity = result.getValue(); if (configEntity == null) { throw new JAXBException("Result is null"); @@ -441,8 +442,11 @@ public void writeConfigToXML(final @NotNull Writer writer) { boolean setConfiguration(final @NotNull HiveMQConfigEntity config) { - List requiresRestart = - configurators.stream().filter(c -> c.needsRestartWithConfig(config)).map(c -> c.getClass().getSimpleName()).collect(Collectors.toList()); + final List requiresRestart = + configurators.stream() + .filter(c -> c.needsRestartWithConfig(config)) + .map(c -> c.getClass().getSimpleName()) + .collect(Collectors.toList()); if (requiresRestart.isEmpty()) { log.debug("Config can be applied"); diff --git a/hivemq-edge/src/main/java/com/hivemq/configuration/reader/Configurator.java b/hivemq-edge/src/main/java/com/hivemq/configuration/reader/Configurator.java index 508f461d66..064206f5ef 100644 --- a/hivemq-edge/src/main/java/com/hivemq/configuration/reader/Configurator.java +++ b/hivemq-edge/src/main/java/com/hivemq/configuration/reader/Configurator.java @@ -16,10 +16,14 @@ package com.hivemq.configuration.reader; import com.hivemq.configuration.entity.HiveMQConfigEntity; -import org.apache.commons.lang3.builder.ReflectionDiffBuilder; -import org.apache.commons.lang3.builder.ToStringStyle; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.Objects; public interface Configurator { + Logger log = LoggerFactory.getLogger(Configurator.class); + enum ConfigResult {SUCCESS, NO_OP, NEEDS_RESTART} ConfigResult setConfig(HiveMQConfigEntity config); @@ -28,9 +32,10 @@ enum ConfigResult {SUCCESS, NO_OP, NEEDS_RESTART} default boolean hasChanged(final T originalConfig, final T newConfig) { if ((originalConfig != null && newConfig == null) || (originalConfig == null && newConfig != null)) { + log.error( "{} has changed {} {}", originalConfig.getClass().getSimpleName(), originalConfig == null, newConfig == null); return true; } - return new ReflectionDiffBuilder<>(originalConfig, newConfig, ToStringStyle.SHORT_PREFIX_STYLE) - .build().getDiffs().isEmpty(); + + return !Objects.equals(originalConfig, newConfig); } } diff --git a/hivemq-edge/src/main/java/com/hivemq/configuration/reader/ListenerConfigurator.java b/hivemq-edge/src/main/java/com/hivemq/configuration/reader/ListenerConfigurator.java index 9d64562c44..cf794cb752 100644 --- a/hivemq-edge/src/main/java/com/hivemq/configuration/reader/ListenerConfigurator.java +++ b/hivemq-edge/src/main/java/com/hivemq/configuration/reader/ListenerConfigurator.java @@ -82,6 +82,9 @@ public boolean needsRestartWithConfig(final HiveMQConfigEntity config) { @Override public ConfigResult setConfig(final @NotNull HiveMQConfigEntity config) { final Listeners listeners = new Listeners(config.getMqttListenerConfig(), config.getMqttsnListenerConfig()); + if(listeners.equals(configEntity)) { + return ConfigResult.NO_OP; + } this.configEntity = listeners; this.initialized = true; @@ -284,5 +287,19 @@ public Listeners(final @NotNull List mqttListeners, final @NotNu this.mqttListeners = mqttListeners; this.mqttsnListeners = mqttsnListeners; } + + @Override + public boolean equals(final Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + final Listeners listeners = (Listeners) o; + return Objects.equals(mqttListeners, listeners.mqttListeners) && + Objects.equals(mqttsnListeners, listeners.mqttsnListeners); + } + + @Override + public int hashCode() { + return Objects.hash(mqttListeners, mqttsnListeners); + } } } diff --git a/hivemq-edge/src/main/java/com/hivemq/configuration/service/impl/listener/ListenerConfigurationService.java b/hivemq-edge/src/main/java/com/hivemq/configuration/service/impl/listener/ListenerConfigurationService.java index 7046662cb0..2f84c7462e 100644 --- a/hivemq-edge/src/main/java/com/hivemq/configuration/service/impl/listener/ListenerConfigurationService.java +++ b/hivemq-edge/src/main/java/com/hivemq/configuration/service/impl/listener/ListenerConfigurationService.java @@ -76,4 +76,7 @@ void addListener(final @NotNull T listener) @ReadOnly @NotNull List getUdpListeners(); + @ReadOnly + void clear(); + }