Skip to content

Automatic - Onteon

Overview

If you want to use automatic scheduling, you can use distributions. Distribution automatically creates the specified number of instances and distribute them trough nodes. To decide which node should run new application instance during the up-scaling or which application instance should be removed during the down-scaling, distribution uses the scripts written in JavaScript. You can create your scripts or use the default ones.

Create distribution

If you want to create a distribution, you need to get the id (or name and version in name:version pattern) of application, number of instances and names of scripts (can be the default scripts). You can create distribution by:

  • Executing the onteoncli distribution create command
  • Creating the distribution file and executing the onteoncli distribution create-from-file command

  • example distribution file with default scripts

             application: onteon-demo-app-cookbook-native:1.2.0
             numberOfInstances: 2
             type: total
             scripts:
                 checkIfNodeCanAcceptNewApplicationInstance: defaultAvailableNodeOnlyCINCANAIV1
                 selectNodeForNewApplicationInstance: defaultApplicationInstancesCountOnlySNFNAIV1
                 selectApplicationInstanceToRemove: defaultApplicationInstancesCountOnlySAITRV1
    
  • Using the POST /api/distributions endpoint.

Upscale and Downscale

To upscale or downscale application, get the id of distribution and execute onteoncli distribution set-number-of-instances or use the PUT /api/distributions endpoint.

How it works

Adding more instances

When Onteon finds out that there is not enough instances of application, it will start process of adding more of them. This process can be controlled by the user with proper scripts definition. The algorithm looks like below:

for <number of instances to add> times do:
    nodeCandidates = (run script with type 'check-if-node-can-accept-new-application-instance-v1')

    selectedNode = (run script with type 'select-node-for-new-application-instance-v1')

    schedule new instance on selectedNode

Onteon includes default definitions of the scripts, so you don't need to write them by yourself. In cases where you need better control, you can always provide your custom implementation of the scripts.

Removing instances

When Onteon finds out that there is too many instances of application, it will start process of removing some of them. This process can be controlled by the user with proper scripts definition. The algorithm looks like below:

for <number of instances to remove> times do:
    selectedApplicationInstance = (run script with type 'select-application-instance-to-remove-v1')

    schedule removal of selectedApplicationInstance

Onteon includes default definitions of the scripts, so you don't need to write them by yourself. In cases where you need better control you can always provide your custom implementation of the scripts.

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

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

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.