hosts()

Read(625) Label: hosts, node,

Here’s how to use hosts() functions.

hosts( i;j )

Description:

Set or get the number of memory zone holding a specified task on the current node.

Syntax:

hosts(i;j)

Note:

The function gets the number of memory zone accommodating task j on the current node when parameter i is absent; sets the number of memory zone holding task j on the current node when both parameter i and parameter j are present; and clear the existing memory zone number when i is 0. It is usually used in the initiation file init.dfx.

Parameters:

i

An integer that represents memory zone number

j

Task name; can be absent

Return value:

A Boolean value or an integer

Example:

 

A

 

1

=hosts(2;"task2")

Set the number of memory zone holding task 2 on the current node as 2, and return true

2

=hosts(;"task2")

Get the number of memory zone holding task 2 on the current node as 2, and return true

3

=hosts(0;"task2")

Delete the number of memory zone holding task 2 and return true since parameter i is 0

4

=hosts(;"task2")

Then get the number of memory zone holding task 2 on the current node as 2, and return false

 

hosts( n,h s;j )

Description:

Return a sequence of available nodes.

Syntax

hosts(n,hs;j)

Note:

The function finds the number of memory zone holding task j across a node list hs, and returns a sequence of available nodes in the format of 1,…,n.

If the target memory zone cannot be found on a certain node, execute initiation using init.dfx on it where the function gets null. The function returns null if it cannot find the sufficient number of available nodes.

The function returns a sequence of all nodes, where the unavailable nodes are recorded as nulls.

Parameters:

n

The number of nodes

hs

A node sequence

j

Task name

Return value:

A node sequence

Example:

Parameter configuration for init.dfx on node 192.168.46.1:

 

Parameter configuration for init.dfx on node 192.168.31.39:

 

init.dfx script:

 

A

B

 

1

if i>0

 

 

2

 

=file("emp.ctx":i)

1.emp.ctx and 2.emp.ctx are respectively stored in the main paths of node 192.168.46.1 and node 192.168.31.39

3

 

=B2.open().cursor().fetch()

 

4

 

>env(EMP,B3)

Store B3’s result in global variable EMP

 

Start node 192.168.46.1:8281 and node 192.168.31.39:8281, search for the available nodes, and compute data stored in the specified memory zone:

 

A

B

 

1

[192.168.46.1:8281,192.168.31.39:8281,192.168.46.1:8282]

 

 

2

=hosts(2,A1;"task1")

 

Return a sequence of nodes containing task 1 in memory zones 1 and 2 from A1’s node sequence

3

if A2!=null

 

Judge whether A2 can find an enough number of available nodes after it is executed, and return null if it cannot

4

 

=memory(A2,EMP)

Generate a cluster composite table using the global variables EMP stored in the memory zones of all nodes found in A2

5

 

=B4.cursor().fetch()

Query data in A4’s cluster composite table

6

else

 

 

7

 

>output("ERROR!")

 

8

=hosts(0,A1;"task1")

 

With parameter n being 0, return a sequence of all nodes the unavailable one is recorded as null