On this page

# State

### new State(type, manager, options, logger)

The `State` constructor. Will attach any needed listeners.

Parameters:

Name | Type | Description
--- | --- | ---
`type` | string |
`manager` | InternalStateManager | RedisStateManager |
`options` | Object |
`logger` | Logger |

Source
  - models/state.js, line 31

## Extends

- InternalStateManager

## Classes

State

## Members

### (private) fleet :Array.<string>

The fleet to follow.

Type:

- Array.<string>

Source
  - models/state.js, line 54

### logger

{Logger} logger

Overrides
  - InternalStateManager#logger
Source
  - models/state.js, line 71

### (private) manager :RedisStateManager|InternalStateManager

The state manager to use for storing and applying state operations.

Type:

- RedisStateManager | InternalStateManager

Source
  - models/state.js, line 46

### (private) networkRequestsHandler :NetworkRequestsHandler

The open network transactions handler.

Type:

- NetworkRequestsHandler

Source
  - models/state.js, line 62

### (private) state :Object

The internal state to be stored and updated by this instance. The `state` property will hold:

- heartbeat information to be passed to worker threads for context
- other observed nodes (not registered in the working fleet)
- pending transactions (updates communicated to the node without any responses)
- network status as provided by the network supervisor

Type:

- Object

Overrides
  - InternalStateManager#state
Source
  - models/internal.state.manager.js, line 28

### (private) threads :Object

Handlers for the message processing threads.

Type:

- Object

Overrides
  - InternalStateManager#threads
Source
  - models/internal.state.manager.js, line 41

### (private) type :string

The type of manager to use. It can be either INTERNAL_STATE_MANAGER or REDIS_STATE_MANAGER.

Type:

- string

Source
  - models/state.js, line 38

## Methods

### (private) _getAddressForNode(node) → {string|null}

Returns the address for a given node name. Returns null if node has not been observed.

Parameters:

Name | Type | Description
--- | --- | ---
`node` | string |

Source
  - models/state.js, line 477

Returns:

Type:
  string | null

### (private) _onRemoteFleetUpdateReceived(eventData)

Parameters:

Name | Type | Description
--- | --- | ---
`eventData` |  |

Source
  - models/state.js, line 147

### (private) _refreshAddresses(message)

Parameters:

Name | Type | Description
--- | --- | ---
`message` |  |

Source
  - models/state.js, line 458

### broadcastIgnoreRequestId(requestId, watches)

Signals the registered threads to remove the watch for a specific session id.

Parameters:

Name | Type | Description
--- | --- | ---
`requestId` | string |
`watches` | Array.<string> |

Overrides
  - InternalStateManager#broadcastIgnoreRequestId
Source
  - models/internal.state.manager.js, line 117

### broadcastPayloadStickySession(stickySessionId)

Broadcast a sticky id that is to be found in the payloads. Any payload containing this session-id should be routed to this specific process.

Parameters:

Name | Type | Description
--- | --- | ---
`stickySessionId` | string |

Source
  - models/state.js, line 254

### broadcastRequestId(requestId, watches)

Broadcasts interest for a specific session id to all the registered threads. The session id will be used for correct routing of the received notifications from the network.

Parameters:

Name | Type | Description
--- | --- | ---
`requestId` | string |
`watches` | Array.<string> |

Overrides
  - InternalStateManager#broadcastRequestId
Source
  - models/internal.state.manager.js, line 100

### broadcastUpdateFleet(stateChange)

Update fleet and notify other interested parties (managed threads or other observing processes) about the update.

Parameters:

Name | Type | Description
--- | --- | ---
`stateChange` | * |

Overrides
  - InternalStateManager#broadcastUpdateFleet
Source
  - models/state.js, line 238

### getAddress(value) → {string|null}

Returns the address for a given value if the value is a node name, returns the value if the value is already and address.

Parameters:

Name | Type | Description
--- | --- | ---
`value` | string |

Source
  - models/state.js, line 435

Returns:

Type:
  string | null

### (async) getFleet() → {Promise.<Array.<NodeStatus>>}

Return the status of the controlled fleet.

Source
  - models/state.js, line 269

Returns:

Type:
  Promise.<Array.<NodeStatus>>

### (async) getNetworkSnapshot(supervisor) → {Promise.<Object>}

Returns the network information as received from the supervisors.

Parameters:

Name | Type | Description
--- | --- | ---
`supervisor` | string |

Overrides
  - InternalStateManager#getNetworkSnapshot
Source
  - models/internal.state.manager.js, line 227

Returns:

Type:
  Promise.<Object>

### (async) getNetworkStatus(supervisor) → {Promise.<Object>}

Returns the network as seen by the `supervisor` node.

Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`supervisor` | string | null |

Source
  - models/state.js, line 340

Returns:

Type:
  Promise.<Object>

### (async) getNetworkSupervisors() → {Promise.<Array.<string>>}

Get the list of observed supervisor nodes.

Overrides
  - InternalStateManager#getNetworkSupervisors
Source
  - models/state.js, line 330

Returns:

Type:
  Promise.<Array.<string>>

### getNodeForAddress(address) → {string|null}

Returns the node name for a given address. Returns null if address has not been observed.

Parameters:

Name | Type | Description
--- | --- | ---
`address` | string |

Source
  - models/state.js, line 449

Returns:

Type:
  string | null

### (async) getNodeInfo(node) → {Promise.<Object>}

Retrieves the cached heartbeat info.

Parameters:

Name | Type | Description
--- | --- | ---
`node` |  |

Overrides
  - InternalStateManager#getNodeInfo
Source
  - models/state.js, line 178

Returns:

Type:
  Promise.<Object>

### (async) getRunningInstanceConfig(node, pipelineId, instanceId) → {Promise.<Object>}

Returns the configuration of a specific instance deployed on a pipeline running on the provided node.

Parameters:

Name | Type | Description
--- | --- | ---
`node` | string |
`pipelineId` | string |
`instanceId` | string |

Source
  - models/state.js, line 206

Returns:

Type:
  Promise.<Object>

### (async) getRunningPipelineConfig(node, pipelineId) → {Promise.<Object>}

Returns the configuration of a specific pipeline running on the requested node.

Parameters:

Name | Type | Description
--- | --- | ---
`node` | string |
`pipelineId` | string |

Source
  - models/state.js, line 189

Returns:

Type:
  Promise.<Object>

### getUniverse() → {Promise.<ObservedNodes>}

A method that returns all the nodes observed from the heartbeat stream with the observation timestamps.

Overrides
  - InternalStateManager#getUniverse
Source
  - models/state.js, line 168

Returns:

Type:
  Promise.<ObservedNodes>

### (async) markAsSeen(address, timestamp) → {Promise.<boolean>}

Will mark a specific node as seen in the dictionary of nodes.

Parameters:

Name | Type | Description
--- | --- | ---
`address` | string |
`timestamp` | number |

Source
  - models/state.js, line 227

Returns:

Type:
  Promise.<boolean>

### (async) markNodeAsSeen(node, timestamp) → {Promise.<boolean>}

Will mark a specific node as seen in the dictionary of nodes.

Parameters:

Name | Type | Description
--- | --- | ---
`node` |  |
`timestamp` |  |

Overrides
  - InternalStateManager#markNodeAsSeen
Source
  - models/internal.state.manager.js, line 242

Returns:

Type:
  Promise.<boolean>

### nodeInfoUpdate(info) → {InternalStateManager}

Method for storing the processed heartbeat into the state.

Parameters:

Name | Type | Description
--- | --- | ---
`info` | Object |

Overrides
  - InternalStateManager#nodeInfoUpdate
Source
  - models/state.js, line 118

Returns:

Type:
  InternalStateManager

### onRequestResponseNotification(self, message)

Pushes the received message to the transaction handler watching the message target.

Parameters:

Name | Type | Description
--- | --- | ---
`self` | State |
`message` | Object |

Source
  - models/state.js, line 128

### registerMessage(message, watches, onSuccess, onFail) → {NetworkRequest}

Creates and configures a new transaction that will follow the completion of the request published to the network.

Parameters:

Name | Type | Description
--- | --- | ---
`message` | Object |
`watches` | Array.<Array.<string>> |
`onSuccess` | function |
`onFail` | function |

Source
  - models/state.js, line 409

Returns:

Type:
  NetworkRequest

### registerThread(threadType, thread) → {State}

Registers a thread into the InternalStateManager if that is the state manager loaded.

Parameters:

Name | Type | Description
--- | --- | ---
`threadType` | string |
`thread` | Object |

Overrides
  - InternalStateManager#registerThread
Source
  - models/state.js, line 391

Returns:

Type:
  State

### (async) storeNetworkInfo(data) → {Promise.<boolean>}

Store the network snapshot as provided by the network supervisor.

Parameters:

Name | Type | Description
--- | --- | ---
`data` | Object |

Source
  - models/state.js, line 311

Returns:

Type:
  Promise.<boolean>

### (async) updateNetworkSnapshot(supervisor, update) → {Promise.<boolean>}

Will store the network snapshot as seen from a specific supervisor node.

Parameters:

Name | Type | Description
--- | --- | ---
`supervisor` | string |
`update` | Object |

Overrides
  - InternalStateManager#updateNetworkSnapshot
Source
  - models/internal.state.manager.js, line 200

Returns:

Type:
  Promise.<boolean>

Type anything to view search result