Class UdfJob

Job class for waiting for UDF module registration/deregistration to complete across an entire Aerospike cluster.

const Aerospike = require('aerospike')

let path = './udf/my_module.lua'

Aerospike.connect()
.then(client => {
client.udfRegister(path)
.then(job => job.wait())
.then(() => {
console.info('UDF module %s was registered successfully', path)
client.close()
})
.catch(error => {
console.error('Error registering UDF module:', error)
client.close()
})
})
.catch(error => console.error('Error connecting to cluster:', error))

Hierarchy (view full)

Constructors

Properties

client: Client
command: string

UDF Command type. Acceptable values are REGISTER and UNREGISTER

jobID: number

Identification number asssociated with the Job.

module: string

Database command associated with the Job. query and scan are the possible values`

udfModule: string

Path to UDF.

REGISTER: string

UDF Register command code.

UNREGISTER: string

UDF un-register command code.

Methods

  • Check the progress of a background job running on the database.

    Parameters

    Returns Promise<JobInfoResponse>

    A Promise that resolves to the job info.

    const Aerospike = require('aerospike')

    // INSERT HOSTNAME AND PORT NUMBER OF AEROSPIKE SERVER NODE HERE!
    var config = {
    hosts: '192.168.33.10:3000',
    // Timeouts disabled, latency dependent on server location. Configure as needed.
    policies: {
    scan : new Aerospike.ScanPolicy({socketTimeout : 0, totalTimeout : 0}),
    }
    }
    Aerospike.connect(config, (error, client) => {
    if (error) throw error

    var scan = client.scan('test', 'demo')
    scan.background('myUdfModule', 'myUdfFunction', (error, job) => {
    if (error) throw error
    var timer = setInterval(() => {
    job.info((error, info) => {
    if (error) throw error
    console.info('scan status: %d (%d%% complete, %d records scanned)', info.status, info.progressPct, info.recordsRead)
    if (info.status === Aerospike.jobStatus.COMPLETED) {
    console.info('scan completed!')
    clearInterval(timer)
    client.close()
    }
    })
    }, 1000)
    })
    })
  • Parameters

    Returns void

  • Parameters

    Returns void

  • Wait until the task has been completed.

    Parameters

    • OptionalpollInterval: number

      Interval in milliseconds to use when polling the cluster nodes. Default is 1000 (ms)

    Returns Promise<void>

    A Promise that resolves once the job is completed.

  • Parameters

    • callback: TypedCallback<void>

      The function to call when the task has completed.

    Returns void

  • Parameters

    • pollInterval: number

      Interval in milliseconds to use when polling the cluster nodes. Default is 1000 (ms)

    • callback: TypedCallback<void>

      The function to call when the task has completed.

    Returns void

  • Alias for wait. See wait for usage examples and more.

    Parameters

    • OptionalpollInterval: number

      Interval in milliseconds to use when polling the cluster nodes. Default is 1000 (ms)

    Returns Promise<void>

    A Promise that resolves to the job info.

  • Parameters

    • callback: TypedCallback<void>

      The function to call with the job info response.

    Returns void

  • Parameters

    • pollInterval: number

      Interval in milliseconds to use when polling the cluster nodes. Default is 1000 (ms)

    • callback: TypedCallback<void>

      The function to call with the job info response.

    Returns void

MMNEPVFCICPMFPCPTTAAATR