Skip to content

Writing scripts

Script types

There are multiple types of scripts which can be provided:

check-if-node-can-accept-new-application-instance-v1

Description

Determines if the node can accept new application instance. Returns true, if node can accept new application instance.

Example

function checkIfNodeCanAcceptNewApplicationInstance(environmentState, environmentProjection, node, application) {
    return true;
}

Syntax

checkIfNodeCanAcceptNewApplicationInstance(environmentState, environmentProjection, node, application)

Arguments

environmentState
Type: EnvironmentStateJS

environmentProjection
Type: EnvironmentProjectionJS

node
Type: NodeProjectionJS

application
Type: ApplicationInfoJS

Return Type

boolean

select-node-for-new-application-instance-v1

Description

Selects node for new application instance. Node is selected from group of nodes determined by check-if-node-can-accept-new-application-instance-v1 script. Returns id of node that will accept new application instance.

Example

function selectNodeForNewApplicationInstance(environmentState, environmentProjection, nodes, application) {
    return nodes[0].id;
}

Syntax

selectNodeForNewApplicationInstance(environmentState, environmentProjection, nodes, application)

Arguments

environmentState
Type: EnvironmentStateJS

environmentProjection
Type: EnvironmentProjectionJS

nodes
Type: array of NodeProjectionJS

application
Type: ApplicationInfoJS

Return type

string

select-application-instance-to-remove-v1

Description

Selects application instance that will be removed. It is used during downscaling. Returns id of application instance that will be removed.

Example

function selectApplicationInstanceToRemove(environmentState, environmentProjection, applicationInstances, application) {
    return applicationInstances[0].id;
}

Syntax

selectApplicationInstanceToRemove(environmentState, environmentProjection, applicationInstances, application)

Arguments

environmentState
Type: EnvironmentStateJS

environmentProjection
Type: EnvironmentProjectionJS

applicationInstances
Type: array of ApplicationInstanceProjectionJS

application
Type: ApplicationInfoJS

Return type

string

Script objects

ApplicationInfoJS

Fields

Type Name Description
string id Application's id.
string name Application's name.
string version Application's version.

Methods

No methods.

EnvironmentProjectionJS

Fields

No fields.

Methods

Syntax Arguments Return type
getZones() Array of ZoneProjectionJS
getZone(id) id
Type: string
ZoneProjectionJS's id.
Array of ZoneProjectionJS
getNodes() Array of NodeProjectionJS
getNode(id) id
Type: string
NodeProjectionJS's id.
Array of NodeProjectionJS
getApplicationInstances() Array of ApplicationInstanceProjectionJS
getApplicationInstanceByNodeId(nodeId) nodeId
Type: string
NodeProjectionJS's id.
Array of ApplicationInstanceProjectionJS
getApplicationInstanceByApplicationId(applicationId) applicationId
Type: string
ApplicationInfoJS's id.
Array of ApplicationInstanceProjectionJS
getApplicationInstance(id) id
Type: string
ApplicationInstanceProjectionJS's id.
Array of ApplicationInstanceProjectionJS

ZoneProjectionJS

Fields

Type Name Description
string id Zone's id.
string name Zone's name.
string parentZoneId Zone's parent zone id.

Methods

No methods.

NodeProjectionJS

Fields

Type Name Description
string id Node's id.
string zoneId Node's zone id.
string ipAddress Node's IP address.
number nodeApiPort Node's API port.
string status Node's status.
map<string, string> customAttributes Node's custom attributes.

Methods

No methods.

ApplicationInstanceProjectionJS

Fields

Type Name Description
string id Random id generated for projected application instance.
string applicationId Projected application instance's application id.
string nodeId Projected application instance's node id.

Methods

No methods.

EnvironmentStateJS

Fields

No fields.

Methods

Syntax Arguments Return type
getZones() Array of ZoneStateJS
getZone(id) id
Type: string
ZoneStateJS's id.
Array of ZoneStateJS
getNodes() Array of NodeStateJS
getNode(id) id
Type: string
NodeStateJS's id.
Array of NodeStateJS
getApplicationInstances() Array of ApplicationInstanceStateJS
getApplicationInstanceByNodeId(nodeId) nodeId
Type: string
NodeStateJS's id.
Array of ApplicationInstanceStateJS
getApplicationInstanceByApplicationId(applicationId) applicationId
Type: string
ApplicationInfoJS's id.
Array of ApplicationInstanceStateJS
getApplicationInstance(id) id
Type: string
ApplicationInstanceStateJS's id.
Array of ApplicationInstanceStateJS

ZoneStateJS

Fields

Type Name Description
string id Zone's id.
string name Zone's name.
string parentZoneId Zone's parent zone id.

Methods

No methods.

NodeStateJS

Fields

Type Name Description
string id Node's id.
string zoneId Node's zone id.
string ipAddress Node's IP address.
number nodeApiPort Node's API port.
string status Node's status.
number lastAvailableAt Timestamp when node was checked and available.
map<string, string> customAttributes Node's custom attributes.
NodeInfoStateJS info Information about the node on which Node Manager is running.
NodeRuntimeStateJS runtime Runtime information about the node on which Node Manager is running.
NodeOSProcessRuntimeStateJS osProcessRuntime OS process runtime information about the Node Manager's process.
Properties properties Node Manager's Java properties.
Properties envs Node's environment variables.

Methods

No methods.

NodeInfoStateJS

Fields

Type Name Description
number processors Number of processors.
number cores Number of cores.
number totalMemoryInBytes Total memory in bytes.

Methods

No methods.

NodeRuntimeStateJS

Fields

Type Name Description
number cpuLoad CPU load.
Array of numbers cpuInterrupts Number of interrupts with core's id as index of array.
Array of numbers cpuAverageUsage CPU avarage usage with core's id as index of array.
number availableMemoryInBytes Available memory in bytes.

Methods

No methods.

NodeOSProcessRuntimeStateJS

Fields

Type Name Description
number processorPercentageUsage Processor's percentage usage.
number processorCumulativeUsage Processor's cumulative usage.
number memoryPercentageUsage Memory's percentage usage.
number memoryUsageInBytes Memory's usage in bytes.
string state Process's state.
number upTimeInMillis Process's up time in millis.
number virtualMemorySize Process's virual memory size.
number residentSetSize Process's resident set size.
number threadCount Process's thread count.
number contextSwitches Process's context switches.
number bytesWritten Process's bytes written.
number bytesRead Process's bytes read.
number minorFaults Process's minor faults.
number majorFaults Process's major faults.
number openFiles Process's open files.
number kernelTimeInMillis Process's kernel time in millis.
number userTimeInMillis Process's user time in millis.

Methods

No methods.

ApplicationInstanceStateJS

Fields

Type Name Description
string id Application Instance's id.
string applicationId Application Instance's id.
string nodeId Application Instance's node id.
string status Application Instance's status.
number createdAt Application Instance's created at.
ApplicationInstanceOSProcessRuntimeStateJS osProcessRuntime Application Instance's OS process runtime information.

Methods

No methods.

ApplicationInstanceOSProcessRuntimeStateJS

Fields

Type Name Description
number processorPercentageUsage Processor's percentage usage.
number processorCumulativeUsage Processor's cumulative usage.
number memoryPercentageUsage Memory's percentage usage.
number memoryUsageInBytes Memory's usage in bytes.
string state Process's state.
number upTimeInMillis Process's up time in millis.
number virtualMemorySize Process's virual memory size.
number residentSetSize Process's resident set size.
number threadCount Process's thread count.
number contextSwitches Process's context switches.
number bytesWritten Process's bytes written.
number bytesRead Process's bytes read.
number minorFaults Process's minor faults.
number majorFaults Process's major faults.
number openFiles Process's open files.
number kernelTimeInMillis Process's kernel time in millis.
number userTimeInMillis Process's user time in millis.

Methods

No methods.