Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## drm.core
Class Node

    java.lang.Object
      |
      +--drm.agentbase.Base
            |
            +--drm.core.Node

All Implemented Interfaces:
  Contributor, Controller, IAgent, IBase, IDRM, Observer, java.lang.Runnable, java.io.Serializable

public final class Node
extends Base
implements Observer, Contributor, Controller, IDRM

This class extends `Base` to become a DRM node. A node is a member of the DRM (distributed resource machine) collective, a collective which has the goal of serving distributed applications. The agents living in a Node are given the chance to observe the DRM. The agents can cast the IBase object set through setBase into the type IDRM, and they can access information about the DRM through it.

All communication is implemented via the standard Base messaging interface, the low level protocol is not extended.

See Also:
  `IDRM`, `IAgent.setBase(IBase)`, Serialized Form

Inner classes inherited from class drm.agentbase.Base
`Base.Firewall`

Fields inherited from class drm.agentbase.Base
`AGENT, boxes, cfg, GET_JAR, group, GROUP_MISMATCH, ISALIVE, MESSAGE, name, NOT_OK, OK, PROTOCOL_VERSION, RELEASE_VERSION, SENDING_DIR`

Constructor Summary
`Node(java.util.Properties cfg)` Calls super constructor.

Method Summary
`void` | `addNodes(java.util.Properties cfg)` Adds the peers defined in `cfg` to the default peer list of the collective.
`void` | `close()` Calls super implementation and after that closes the collective.
`void` | `collectiveUpdated(ContributionBox peer)` Stores the peer, and performs new commands.
`IRequest` | `fireMessage(Address recipient, java.lang.String type, java.lang.Object content)` The observer must provide this method to allow requesting information.
`java.util.Set` | `getCommands()` The controller has to return the new commands it intends to execute in the collective.
`java.lang.Object` | `getContribution()` The contributor has to return its contribution to the common repository when asked through this method.
`ContributionBox` | `getContribution(java.lang.String nodeName)` Returns the contribution that belongs to the given node name.
`java.util.List` | `getContributions()` Returns all known contributions in the DRM collective.
`Base.Firewall` | `getFirewall()` This method should return the firewall that is given to the agents.
`ContributionBox` | `getNewestContribution()` Returns the most up-to-date contribution.
`Address[]` | `getPeerAddresses()` Returns always null.
`java.lang.String` | `getType()` Returns "Node".
`boolean` | `handleMessage(Message m, java.lang.Object object)` Handles message type `"collectiveUpdate-"+getJob()`.
`void` | `invokeCommand(NodeCommand command)` Invokes the command on the DRM.
`void` | `invokeCommandLocally(NodeCommand command)` Invokes the command only on this local node.
`IRequest` | `launch(java.lang.String method, IAgent agent, java.lang.Object par)` Adds implementation of launch method "RANDOM".
`void` | `onArrival(Address from, Address to)` Connects to the DRM collective.
`java.lang.String` | `toString()`

Methods inherited from class drm.agentbase.Base
`addListener, destroyAgent, dispatchAgent, fireMessage, getBaseName, getJob, getName, getNames, getProperty, getUniqueName, goOffline, goOnline, isOnline, onDestruction, removeListener, run, setBase, version, wipeClean`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Methods inherited from interface drm.core.Contributor
`getName`

Constructor Detail

### Node

    public Node(java.util.Properties cfg)

  Calls super constructor. The additional configuration parameters understood by the class are the following:
  - Every property that starts with `"node"` gives the address of another living node in the form host:port.
  - If the property `spy` is "true" (case sensitive) then when exchanging information with other nodes this will not publis its own descriptor. Thus this will be an observer of the collective but not a contributor. The default is false.

Method Detail

### launch

    public IRequest launch(java.lang.String method,
                           IAgent agent,
                           java.lang.Object par)

  Adds implementation of launch method "RANDOM". Launches an agent to an indirectly specified location. If no peers of the agent are present (a peer of a thread is a thread from the same job) at the local host then launches the agent locally ("local" type) otherwise launches to a random base ("random" type or "random local" type if the random base was the local base).
  Overrides:
    `launch` in class `Base`
  Parameters:
    `method` - If "RANDOM", runs the above algorithm otherwise propagates call to superclass.
    `par` - ignored
  Returns:
    The request. The `getInfo` method there knows two kinds of queries: "type" which returns the type as desribed above in String format and "address" which returns the address of the launched agent (type `Address`) if status is DONE, otherwise null.

### getContribution

    public ContributionBox getContribution(java.lang.String nodeName)

  Description copied from interface: `IDRM`
  Returns the contribution that belongs to the given node name. If the contribution of the given node is not known, returns null.
  Specified by:
    `getContribution` in interface `IDRM`

### getNewestContribution

    public ContributionBox getNewestContribution()

  Description copied from interface: `IDRM`
  Returns the most up-to-date contribution. Returns null if the node has never communicated with anyone.
  Specified by:
    `getNewestContribution` in interface `IDRM`

### getContributions

    public java.util.List getContributions()

  Description copied from interface: `IDRM`
  Returns all known contributions in the DRM collective. Dynamic type of objects is `ContributionBox`, and the type of the contribution field is `NodeContribution`. Returned list might be empty, but it's never null.
  Specified by:
    `getContributions` in interface `IDRM`
  Following copied from interface: `drm.core.IDRM`
  See Also:
    `Collective.getContributions()`

### close

    public void close()

  Calls super implementation and after that closes the collective.
  Overrides:
    `close` in class `Base`

### getFirewall

    public Base.Firewall getFirewall()

  Description copied from class: `Base`
  This method should return the firewall that is given to the agents. It is useful to put it here because extending classes can extend the firewall with new functionality that agents can check for.
  Overrides:
    `getFirewall` in class `Base`

### handleMessage

    public boolean handleMessage(Message m,
                                 java.lang.Object object)

  Handles message type `"collectiveUpdate-"+getJob()`. In fact only forwards it to the collective.
  Overrides:
    `handleMessage` in class `Base`
  Following copied from interface: `drm.agentbase.IAgent`
  Parameters:
    `m` - The message to handle.
    `object` - The object that is wrapped in the message. If null then there is no binary content or it is not a serialized object (in which case it can be read using `Message.getBinary()`).
  Returns:
    If the message could be handled succesfully (i.e. it was known to the implementation and no errors occured) returns true, otherwise false.
  See Also:
    `Message.setReply(Object)`, `IBase.fireMessage(Message)`

### getType

    public java.lang.String getType()

  Returns "Node".
  Overrides:
    `getType` in class `Base`

### onArrival

    public void onArrival(Address from,
                          Address to)

  Connects to the DRM collective. It is called by the Base when going online. It is not supposed to be called by users, it has to be public because it is an interface function.
  Overrides:
    `onArrival` in class `Base`
  Following copied from interface: `drm.agentbase.IAgent`
  Parameters:
    `from` - The address of the base from which the agent was sent. If the agent has never been on any base it is null.
    `to` - The address of the local base at the time of the arrival. It is not guaranteed to remain valid trough the lifetime of the agent. If the agent has never been on a base it is null.
  See Also:
    `IAgent.setBase(IBase)`

### collectiveUpdated

    public void collectiveUpdated(ContributionBox peer)

  Stores the peer, and performs new commands.
  Specified by:
    `collectiveUpdated` in interface `Observer`

### getPeerAddresses

    public Address[] getPeerAddresses()

  Returns always null. Implements required functionality via calling `addPeerAddress`instead, thus through a side effect.``
  Specified by:
    `getPeerAddresses` in interface `Observer`
  See Also:
    `Collective.addPeerAddress(Address)`

### fireMessage

    public IRequest fireMessage(Address recipient,
                                java.lang.String type,
                                java.lang.Object content)

  Description copied from interface: `Observer`
  The observer must provide this method to allow requesting information.
  Specified by:
    `fireMessage` in interface `Observer`

### getContribution

    public java.lang.Object getContribution()

  Description copied from interface: `Contributor`
  The contributor has to return its contribution to the common repository when asked through this method.
  Specified by:
    `getContribution` in interface `Contributor`

### getCommands

    public java.util.Set getCommands()

  Description copied from interface: `Controller`
  The controller has to return the new commands it intends to execute in the collective. The type of the commands is collective-specific, but command objects have to implement equals and also hashCode to allow storage of commands in hashtables. It is also necessary that every command is unique, ie it does not equal any other command invoked at some other time (maybe by the same user).
  Specified by:
    `getCommands` in interface `Controller`

### addNodes

    public void addNodes(java.util.Properties cfg)

  Adds the peers defined in `cfg` to the default peer list of the collective. Initializes peers from the properties starting with "base" or "node". The format of the property value should be host[:port]. If no port is given then the one defined in cfg is used, or 10101 as default.

### invokeCommand

    public void invokeCommand(NodeCommand command)

  Invokes the command on the DRM.

### invokeCommandLocally

    public void invokeCommandLocally(NodeCommand command)

  Invokes the command only on this local node.

### toString

    public java.lang.String toString()

  Overrides:
    `toString` in class `java.lang.Object`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD