flux.agent
Class Agent

java.lang.Object
  extended by flux.agent.Agent

public class Agent
extends java.lang.Object

Represents an active Flux agent. Flux agents run processes that are distributed from Flux engines. The results from running processes on Flux agents are reported back to a Flux engine.

Flux agents register with a Flux engine, which shares information about the agent among all engines in the cluster. Subsequently, Flux engines distribute processes to Flux agents, in effect delegating a Process Action to an agent. Finally, after the agent finishes executing that process, it submits its results back to a Flux engine.

Author:
Copyright 2014 Flux Corporation. All rights reserved.

Constructor Summary
Agent(AgentConfiguration configuration)
          Creates a new Flux agent.
Agent(java.lang.String configurationFile)
          Creates a new Flux agent using the supplied configuration file; if the agent is later restarted with a new configuration, the configuration file specified here will be overwritten with the new configuration.
 
Method Summary
 void dispose()
          Stops this agent, waits for any running processes to finish, and then shuts down the agent.
 AgentInfo getInfo()
          Returns information about the status of this agent.
 void interrupt()
          Interrupts the currently executing processes.
 void restart(AgentConfiguration configuration)
          Provides a way to reconfigure an agent without creating a new agent object.
 void start()
          Starts this agent.
 void stop()
          Stops this agent.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Agent

public Agent(AgentConfiguration configuration)
      throws AgentException
Creates a new Flux agent. The freshly created agent attempts to register with its configured master Flux engine. When a connection to a Flux engine cannot be established or is lost, the agent automatically attempts to reestablish the connection. These reconnection attempts are performed automatically and do not cause remote exceptions to be thrown.

During the creation process, the new Flux agent attempts to bind itself to the configured port. If a process is listening on the configured port but binding fails, a remote exception is thrown.

If no process is listening on the configured port, an attempt is made to bind to it. If this procedure fails, a remote exception is thrown.

Parameters:
configuration - Properties that control how this agent communicates with an engine and how it otherwise behaves.
Throws:
AgentException - If the agent configuration is invalid.

Agent

public Agent(java.lang.String configurationFile)
      throws AgentException
Creates a new Flux agent using the supplied configuration file; if the agent is later restarted with a new configuration, the configuration file specified here will be overwritten with the new configuration.

The freshly created agent attempts to register with its configured master Flux engine. When a connection to a Flux engine cannot be established or is lost, the agent automatically attempts to reestablish the connection. These reconnection attempts are performed automatically and do not cause remote exceptions to be thrown.

During the creation process, the new Flux agent attempts to bind itself to the configured port. If a process is listening on the configured but binding fails, a remote exception is thrown.

If no process is listening on the configured port, an attempt is made to bind to it. If this procedure fails, a remote exception is thrown.

Parameters:
configurationFile - Filename to an agent configuration file, which contains properties that control how this agent communicates with an engine and how it otherwise behaves.
Throws:
AgentException - If the agent configuration is invalid.
Method Detail

dispose

public void dispose()
Stops this agent, waits for any running processes to finish, and then shuts down the agent. After dispose() is called, calling any method on this agent will cause an exception to be thrown.


getInfo

public AgentInfo getInfo()
Returns information about the status of this agent.

Returns:
Information about the status of this agent.

interrupt

public void interrupt()
Interrupts the currently executing processes. Any running process will be destroyed only if it is running synchronously and its destroy on interrupt flag is enabled.


restart

public void restart(AgentConfiguration configuration)
             throws AgentException
Provides a way to reconfigure an agent without creating a new agent object. Disposes this agent and reinstantiates it using the supplied agent configuration.

If this agent was created originally with Agent(String configurationFile), after a successful restart, the configuration file specified there will be overwritten with the new configuration supplied here. The purpose is that when the agent is restarted from a command line script, it will use the agent configuration data from the new configuration supplied here.

If an exception is thrown, this agent will become inactive until reset() is called successfully on it.

Parameters:
configuration - Properties that control how this agent communicates with an engine and how it otherwise behaves.
Throws:
AgentException - If the agent configuration is invalid.

start

public void start()
           throws AgentException
Starts this agent. A started agent can accept requests from Flux engines to run processes.

Throws:
AgentException - If the agent could not contact an engine to inform it that the agent is being started.

stop

public void stop()
          throws AgentException
Stops this agent. A stopped agent does not accept any new requests to run processes. If any processes are currently executing, this method blocks until those processes finish.

Throws:
AgentException - If the agent could not contact an engine to inform it that the agent is being stopped.


© 2014 Flux Corporation. All rights reserved.