Package org.openremote.manager.gateway
Class GatewayConnector
java.lang.Object
org.openremote.manager.gateway.GatewayConnector
Handles all communication between a gateway and this manager instance
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final Map<String, org.openremote.model.util.Pair<Function<String, String>, Function<String, String>>> static final Stringstatic final Stringprotected final AssetProcessingServiceprotected final AssetStorageServiceprotected List<org.openremote.model.asset.AssetEvent> protected List<org.openremote.model.attribute.AttributeEvent> protected Future<?> protected booleanprotected final Map<Class<? extends org.openremote.model.event.shared.SharedEvent>, Consumer<org.openremote.model.event.shared.SharedEvent>> protected final ExecutorServiceprotected org.openremote.model.asset.impl.GatewayAssetprotected final Stringprotected final GatewayServiceprotected booleanstatic intprotected final Stringprotected Runnablestatic final longprotected final ScheduledExecutorServiceprotected final AtomicReference<String> static intprotected ScheduledFuture<?> protected boolean -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedGatewayConnector(AssetStorageService assetStorageService, AssetProcessingService assetProcessingService, ExecutorService executorService, ScheduledExecutorService scheduledExecutorService, GatewayService gatewayService, org.openremote.model.asset.impl.GatewayAsset gateway) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidConnection for this gateway has started so initiate synchronisation of assetsprotected booleandeleteAssetsLocally(List<String> assetIds) protected voidprotected voiddisconnect(org.openremote.model.gateway.GatewayDisconnectEvent.Reason reason) protected voiddisconnected(String sessionId) Connection to the edge gateway instance has been disconnected so stop any synchronisationprotected CompletableFuture<org.openremote.model.gateway.GatewayCapabilitiesResponseEvent> Request for gateway capabilities such as tunneling supportorg.openremote.model.asset.impl.GatewayAssetprotected StringgetRealm()protected Stringprotected booleanprotected booleanprotected booleanprotected booleanstatic StringmapAssetId(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.protected voidonAssetEvent(org.openremote.model.asset.AssetEvent e) protected voidonAttributeEvent(org.openremote.model.attribute.AttributeEvent e) protected voidonGatewayEvent(org.openremote.model.event.shared.SharedEvent e) protected voidprotected voidonSyncAssetsResponse(org.openremote.model.asset.AssetsEvent e) protected voidCalled if a response isn't received from the gateway withinRESPONSE_TIMEOUT_MILLISprotected voidpublishAttributeEvent(org.openremote.model.attribute.AttributeEvent event) protected voidRequest assets in batches ofSYNC_ASSET_BATCH_SIZEto avoid overloading the gatewayprotected <T extends org.openremote.model.asset.Asset<?>>
TsaveAssetLocally(T asset) protected voidsendMessageToGateway(Object message) protected voidsetDisabled(boolean disabled) protected voidGet list of gateway assets (get basic details and then batch load them to minimise load)protected CompletableFuture<Void> startTunnel(org.openremote.model.gateway.GatewayTunnelInfo tunnelInfo) protected CompletableFuture<Void> stopTunnel(org.openremote.model.gateway.GatewayTunnelInfo tunnelInfo) protected booleantoString()
-
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
- See Also:
-
ASSET_READ_EVENT_NAME_BATCH
- See Also:
-
RESPONSE_TIMEOUT_MILLIS
public static final long RESPONSE_TIMEOUT_MILLIS- See Also:
-
ASSET_ID_MAPPERS
-
realm
-
gatewayId
-
assetStorageService
-
executorService
-
scheduledExecutorService
-
assetProcessingService
-
gatewayService
-
cachedAssetEvents
-
cachedAttributeEvents
-
gatewayMessageConsumer
-
requestDisconnect
-
sessionId
-
disabled
protected boolean disabled -
initialSyncInProgress
protected boolean initialSyncInProgress -
syncProcessorFuture
-
capabilitiesFuture
-
gatewayAsset
protected org.openremote.model.asset.impl.GatewayAsset gatewayAsset -
tunnellingSupported
protected boolean tunnellingSupported -
eventConsumerMap
-
ALPHA_NUMERIC_CHARACTERS
-
-
Constructor Details
-
GatewayConnector
protected GatewayConnector(AssetStorageService assetStorageService, AssetProcessingService assetProcessingService, ExecutorService executorService, ScheduledExecutorService scheduledExecutorService, GatewayService gatewayService, org.openremote.model.asset.impl.GatewayAsset gateway)
-
-
Method Details
-
sendMessageToGateway
-
connected
protected void connected(String sessionId, Consumer<Object> gatewayMessageConsumer, Runnable requestDisconnect) Connection for this gateway has started so initiate synchronisation of assets -
disconnected
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
-
isDisabled
protected boolean isDisabled() -
setDisabled
protected void setDisabled(boolean disabled) -
getSessionId
-
publishAttributeEvent
protected void publishAttributeEvent(org.openremote.model.attribute.AttributeEvent event) -
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 withinRESPONSE_TIMEOUT_MILLIS -
syncAborted
protected boolean syncAborted() -
requestAssets
protected void requestAssets()Request assets in batches ofSYNC_ASSET_BATCH_SIZEto 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
-
getGatewayAsset
public org.openremote.model.asset.impl.GatewayAsset getGatewayAsset() -
toString
-
mapAssetId
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.
-