Interface RedundancyManager
-
public interface RedundancyManager
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
CONFIG_UPDATES_GAUGE
static java.lang.String
CONFIG_UPDATES_GAUGE_MAX
static java.lang.String
RUNTIME_UPDATES_GAUGE
static java.lang.String
RUNTIME_UPDATES_GAUGE_MAX
static java.lang.String
SYSTEM_ID
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description void
addMessageReceiver(java.lang.String protocol, MessageReceiver recv)
Adds a message receiver for the clustered task system.void
addRedundancyStateListener(RedundancyStateListener l)
The redundancy state listener will be notified each time there is a change to any part of the redundancy state.void
applySettings(RedundancySettings settings)
java.io.Serializable
executeTask(RedundantTask task)
Takes a RedundantTask and executes it locally before replicating it to the clustered backup node.java.io.Serializable
executeTask(java.lang.String protocol, java.io.Serializable message)
This executes a task locally, and then replicates the task to the backup node IF the execution didn't produce an exception.java.io.Serializable
executeTask(java.lang.String protocol, java.io.Serializable message, boolean async)
void
forceConfigurationSync()
Requests that the system execute a full config sync.GatewayAddressGroup
getAllHttpAddresses()
Lists the HTTP urls for the gateways in the redundant cluster.java.lang.Object
getConfigLock()
The following were part of the cluster manager, and may or may not be appropriate for this interface.RedundancyState
getCurrentState()
java.lang.String
getLocalAddress()
Returns the network address of the local machine.java.lang.Long
getMasterStartTime()
Returns the time, coordinated for this node, that the master last started.java.util.List<MetricValue>
getMetrics()
com.inductiveautomation.metro.api.ServerId
getPeerAddress()
Returns the gateway network server id of the peer Warning: may return null if redundant servers are not connectedPeerStatus
getPeerConnectionStatus()
default SystemMap
getPeerSystemMap()
Deprecated.RuntimeStateManager
getRuntimeStateManager()
Provides the RuntimeStateManager.RedundancySettings
getSettings()
boolean
isActive()
Returns whether the system is currently "active", i.e., the node should be running fully.boolean
isAutoDetectHttp()
boolean
isMaster()
Returns whether this node's responsibility is MASTER.boolean
isRedundancyEnabled()
void
registerSynchronizedStateProvider(SynchronizedStateProvider<?,?> provider)
void
removeMessageReceiver(java.lang.String protocol, MessageReceiver recv)
void
removeRedundancyStateListener(RedundancyStateListener l)
void
requestPeerActivityLevel(ActivityLevel level)
Request that the peer assume either Active or Inactive activity.void
shutdown()
void
unregisterSynchronizedStateProvider(java.lang.String id)
void
updateAddressesInClients()
Update all designers and clients' list of available gateways.
-
-
-
Field Detail
-
SYSTEM_ID
static final java.lang.String SYSTEM_ID
- See Also:
- Constant Field Values
-
RUNTIME_UPDATES_GAUGE
static final java.lang.String RUNTIME_UPDATES_GAUGE
- See Also:
- Constant Field Values
-
RUNTIME_UPDATES_GAUGE_MAX
static final java.lang.String RUNTIME_UPDATES_GAUGE_MAX
- See Also:
- Constant Field Values
-
CONFIG_UPDATES_GAUGE
static final java.lang.String CONFIG_UPDATES_GAUGE
- See Also:
- Constant Field Values
-
CONFIG_UPDATES_GAUGE_MAX
static final java.lang.String CONFIG_UPDATES_GAUGE_MAX
- See Also:
- Constant Field Values
-
-
Method Detail
-
getCurrentState
RedundancyState getCurrentState()
-
getPeerConnectionStatus
PeerStatus getPeerConnectionStatus()
-
isRedundancyEnabled
boolean isRedundancyEnabled()
-
isActive
boolean isActive()
Returns whether the system is currently "active", i.e., the node should be running fully.This should be checked by any part of the system that should base its state on whether or not this node is "responsible" or active. When the node is not active, the system should likely not do things like write to the PLC, query the database, etc. However, that is ultimately up to the module, and will likely involve looking at the full cluster state for the real state - ie, cold, hot, active.
Note: it is safe to check this even when redundancy isn't enabled- in that case, it will always return true.
- Returns:
- whether the redundant node is active, or TRUE if redundancy is not enabled.
-
isMaster
boolean isMaster()
Returns whether this node's responsibility is MASTER. Also returns true if the node is INDEPENDENT, or not part of a cluster. Only the master is allowed to make changes to the system configuration. It is important to note that being MASTER and being ACTIVE are independent. All modules and systems should check isActive in order to determine whether they should run.To reiterate: this should only be used in relation to configuration related changes.
-
requestPeerActivityLevel
void requestPeerActivityLevel(ActivityLevel level)
Request that the peer assume either Active or Inactive activity. The peer won't necessarily assume the exact level requested, but instead will use it's fallback activity level (such as warm).
-
forceConfigurationSync
void forceConfigurationSync()
Requests that the system execute a full config sync.
-
getMasterStartTime
java.lang.Long getMasterStartTime()
Returns the time, coordinated for this node, that the master last started. Used to negotiate history storage for "partial history" mode.
-
addRedundancyStateListener
void addRedundancyStateListener(RedundancyStateListener l)
The redundancy state listener will be notified each time there is a change to any part of the redundancy state. There are really only 2 driving changes: the project state, and the responsibility state. The other parts of the RedundantState are either statically defined or based off those.
-
removeRedundancyStateListener
void removeRedundancyStateListener(RedundancyStateListener l)
-
addMessageReceiver
void addMessageReceiver(java.lang.String protocol, MessageReceiver recv)
Adds a message receiver for the clustered task system. This is one manner of handling clustered tasks, and is better for tasks who rely heavily on the state of the system where they're generated, as they'll be delivered directly into that system.- Parameters:
protocol
- a unique string identifier for messages that will be delivered to the given receiver.recv
- a listener who will receive clustered tasks sent on the specified protocol.
-
removeMessageReceiver
void removeMessageReceiver(java.lang.String protocol, MessageReceiver recv)
-
executeTask
java.io.Serializable executeTask(java.lang.String protocol, java.io.Serializable message) throws java.lang.Exception
This executes a task locally, and then replicates the task to the backup node IF the execution didn't produce an exception. The return value has different meanings based on whether the node is master or not. On the master, the return can be used like the normal return value of a function. On the backup it is not currently used, however, it in the future, it may be sent along so that the backup can confirm that its results line up with what was expected.This overload takes a protocol ID and serializable message. The message will be delivered to any MessageReceivers registered for that protocol, both locally and remotely.
- Throws:
java.lang.Exception
-
executeTask
java.io.Serializable executeTask(java.lang.String protocol, java.io.Serializable message, boolean async) throws java.lang.Exception
- Throws:
java.lang.Exception
-
executeTask
java.io.Serializable executeTask(RedundantTask task) throws java.lang.Exception
Takes a RedundantTask and executes it locally before replicating it to the clustered backup node.- Throws:
java.lang.Exception
- See Also:
executeTask(String, Serializable)
-
getRuntimeStateManager
RuntimeStateManager getRuntimeStateManager()
Provides the RuntimeStateManager. RuntimeState is state information that is synchronized between the active and non-active node. This is different from Config state, which only goes from Master to Backup.
-
shutdown
void shutdown()
-
getSettings
RedundancySettings getSettings()
-
applySettings
void applySettings(RedundancySettings settings)
-
getConfigLock
java.lang.Object getConfigLock()
The following were part of the cluster manager, and may or may not be appropriate for this interface.
-
isAutoDetectHttp
boolean isAutoDetectHttp()
-
updateAddressesInClients
void updateAddressesInClients()
Update all designers and clients' list of available gateways.
-
getAllHttpAddresses
GatewayAddressGroup getAllHttpAddresses()
Lists the HTTP urls for the gateways in the redundant cluster. May include backup addresses if a backup node is present.
-
getPeerSystemMap
@Deprecated default SystemMap getPeerSystemMap()
Deprecated.
-
getMetrics
java.util.List<MetricValue> getMetrics()
-
getLocalAddress
java.lang.String getLocalAddress()
Returns the network address of the local machine.- Since:
- 7.8.1
-
getPeerAddress
com.inductiveautomation.metro.api.ServerId getPeerAddress()
Returns the gateway network server id of the peer Warning: may return null if redundant servers are not connected
-
registerSynchronizedStateProvider
void registerSynchronizedStateProvider(SynchronizedStateProvider<?,?> provider)
-
unregisterSynchronizedStateProvider
void unregisterSynchronizedStateProvider(java.lang.String id)
-
-