Class GatewayConnector

java.lang.Object
org.openremote.manager.gateway.GatewayConnector

public class GatewayConnector extends Object
Handles all communication between a gateway and this manager instance
  • Field Details

    • MAX_SYNC_RETRIES

      public static int MAX_SYNC_RETRIES
    • SYNC_ASSET_BATCH_SIZE

      public static int SYNC_ASSET_BATCH_SIZE
    • ASSET_READ_EVENT_NAME_INITIAL

      public static final String ASSET_READ_EVENT_NAME_INITIAL
      See Also:
    • ASSET_READ_EVENT_NAME_BATCH

      public static final String ASSET_READ_EVENT_NAME_BATCH
      See Also:
    • RESPONSE_TIMEOUT_MILLIS

      public static final long RESPONSE_TIMEOUT_MILLIS
      See Also:
    • ASSET_ID_MAPPERS

      protected static final Map<String,org.openremote.model.util.Pair<Function<String,String>,Function<String,String>>> ASSET_ID_MAPPERS
    • realm

      protected final String realm
    • gatewayId

      protected final String gatewayId
    • assetStorageService

      protected final AssetStorageService assetStorageService
    • executorService

      protected final ExecutorService executorService
    • scheduledExecutorService

      protected final ScheduledExecutorService scheduledExecutorService
    • assetProcessingService

      protected final AssetProcessingService assetProcessingService
    • gatewayService

      protected final GatewayService gatewayService
    • cachedAssetEvents

      protected List<org.openremote.model.asset.AssetEvent> cachedAssetEvents
    • cachedAttributeEvents

      protected List<org.openremote.model.attribute.AttributeEvent> cachedAttributeEvents
    • gatewayMessageConsumer

      protected Consumer<Object> gatewayMessageConsumer
    • requestDisconnect

      protected Runnable requestDisconnect
    • sessionId

      protected final AtomicReference<String> sessionId
    • disabled

      protected boolean disabled
    • initialSyncInProgress

      protected boolean initialSyncInProgress
    • syncProcessorFuture

      protected ScheduledFuture<?> syncProcessorFuture
    • capabilitiesFuture

      protected Future<?> capabilitiesFuture
    • gatewayAsset

      protected org.openremote.model.asset.impl.GatewayAsset gatewayAsset
    • tunnellingSupported

      protected boolean tunnellingSupported
    • eventConsumerMap

      protected final Map<Class<? extends org.openremote.model.event.shared.SharedEvent>,Consumer<org.openremote.model.event.shared.SharedEvent>> eventConsumerMap
    • ALPHA_NUMERIC_CHARACTERS

      protected static List<Integer> ALPHA_NUMERIC_CHARACTERS
  • Constructor Details

  • Method Details

    • sendMessageToGateway

      protected void sendMessageToGateway(Object message)
    • connected

      protected void connected(String sessionId, Consumer<Object> gatewayMessageConsumer, Runnable requestDisconnect)
      Connection for this gateway has started so initiate synchronisation of assets
    • disconnected

      protected void disconnected(String sessionId)
      Connection to the edge gateway instance has been disconnected so stop any synchronisation
    • disconnect

      protected void disconnect(org.openremote.model.gateway.GatewayDisconnectEvent.Reason reason)
    • isConnected

      protected boolean isConnected()
    • isInitialSyncInProgress

      protected boolean isInitialSyncInProgress()
    • isTunnellingSupported

      protected boolean isTunnellingSupported()
    • getCapabilities

      protected CompletableFuture<org.openremote.model.gateway.GatewayCapabilitiesResponseEvent> getCapabilities()
      Request for gateway capabilities such as tunneling support
    • startTunnel

      protected CompletableFuture<Void> startTunnel(org.openremote.model.gateway.GatewayTunnelInfo tunnelInfo)
    • stopTunnel

      protected CompletableFuture<Void> stopTunnel(org.openremote.model.gateway.GatewayTunnelInfo tunnelInfo)
    • getRealm

      protected String getRealm()
    • isDisabled

      protected boolean isDisabled()
    • setDisabled

      protected void setDisabled(boolean disabled)
    • getSessionId

      protected String getSessionId()
    • publishAttributeEvent

      protected void publishAttributeEvent(org.openremote.model.attribute.AttributeEvent event)
    • onGatewayEvent

      protected void onGatewayEvent(org.openremote.model.event.shared.SharedEvent e)
    • startSync

      protected void startSync()
      Get list of gateway assets (get basic details and then batch load them to minimise load)
    • onSyncAssetsTimeout

      protected void onSyncAssetsTimeout()
      Called if a response isn't received from the gateway within RESPONSE_TIMEOUT_MILLIS
    • syncAborted

      protected boolean syncAborted()
    • requestAssets

      protected void requestAssets()
      Request assets in batches of SYNC_ASSET_BATCH_SIZE to avoid overloading the gateway
    • onSyncAssetsResponse

      protected void onSyncAssetsResponse(org.openremote.model.asset.AssetsEvent e)
    • deleteObsoleteLocalAssets

      protected void deleteObsoleteLocalAssets()
    • onInitialSyncComplete

      protected void onInitialSyncComplete()
    • onAssetEvent

      protected void onAssetEvent(org.openremote.model.asset.AssetEvent e)
    • onAttributeEvent

      protected void onAttributeEvent(org.openremote.model.attribute.AttributeEvent e)
    • saveAssetLocally

      protected <T extends org.openremote.model.asset.Asset<?>> T saveAssetLocally(T asset)
    • deleteAssetsLocally

      protected boolean deleteAssetsLocally(List<String> assetIds)
    • getGatewayAsset

      public org.openremote.model.asset.impl.GatewayAsset getGatewayAsset()
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • mapAssetId

      public static String mapAssetId(String gatewayId, String assetId, boolean outbound)
      An easily reversible mathematical way of ensuring gateway asset IDs are unique by incrementing the first two characters by adding the first two characters of the gateway ID for inbound IDs and the reverse for outbound.