com.cliftonsnyder.clutch.mr
Class Mapper

java.lang.Object
  extended by com.cliftonsnyder.clutch.Agent
      extended by com.cliftonsnyder.clutch.mr.Mapper
All Implemented Interfaces:
java.io.Serializable, java.lang.Runnable

public class Mapper
extends Agent

a mobile agent representing a mapper

Author:
Clifton L. Snyder
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class com.cliftonsnyder.clutch.Agent
Agent.State
 
Field Summary
protected  boolean newAgent
           
 
Fields inherited from class com.cliftonsnyder.clutch.Agent
agentState, ancestorList, children, id, level, maxPeers, parent, state
 
Constructor Summary
Mapper()
          an empty, parameterless constructor; this is necessary if the Mapper object is to "play nice" with ProActive
Mapper(ClutchState state)
          constructs a new Mapper object, with maxPeers maximum peers
 
Method Summary
 void addNewReducer(Reducer r)
           
 Mapper createAgent(Node newAgentNode, Node newDataNode)
          method to be implemented by subclasses of Agent; this is where the interesting organization of a Clutch network will take place
 MapTask createMapTask(long offset, long length)
           
 MapTask getMapTask(long offset, long length)
           
 MapTask getMapTask(java.lang.String id)
           
 ReduceTask getReduceTask(long offset, long length)
           
 boolean hasReducer()
           
 boolean isNew()
          determines whether or not the Agent is newly created or is a current member of a Clutch network
static void main(java.lang.String[] args)
           
 void run()
           
 void setInputFactory(MapTaskFactory input)
           
 void setNew(boolean newAgent)
           
 void setReducer(Reducer reducer)
           
 void setState(ClutchState state)
          sets the state information for the Agent
 void shutdown()
          shut down the Agent
 java.lang.String status()
          gives a String representation of the current status of the Agent
 int test(int test)
           
 
Methods inherited from class com.cliftonsnyder.clutch.Agent
addChild, getAgentState, getAncestorList, getChildren, getHostName, getID, getLevel, getParent, getRef, isRoot, removeChild, removeChild, setAgentState, setAncestorList, setID, setLevel, setMaxPeers, setParent, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

newAgent

protected boolean newAgent
Constructor Detail

Mapper

public Mapper()
an empty, parameterless constructor; this is necessary if the Mapper object is to "play nice" with ProActive


Mapper

public Mapper(ClutchState state)
constructs a new Mapper object, with maxPeers maximum peers

Parameters:
maxPeers - the maximum number of peers that the Mapper will be allowed
Method Detail

main

public static void main(java.lang.String[] args)
Parameters:
args - This main method optionally takes the location of the Mapper's configuration file as a parameter. If the parameter is not supplied, the default location of '$PWD/etc/clutch.properties' is used. If no configuration file exists at that location, the Mapper will fail since it won't have any way of knowing what class to use for it's tasks.

addNewReducer

public void addNewReducer(Reducer r)

createAgent

public Mapper createAgent(Node newAgentNode,
                          Node newDataNode)
Description copied from class: Agent
method to be implemented by subclasses of Agent; this is where the interesting organization of a Clutch network will take place

Specified by:
createAgent in class Agent
Returns:
a newly constructed Agent object that is attached to the Clutch network (i.e., has a parent and possibly some children)

createMapTask

public MapTask createMapTask(long offset,
                             long length)
                      throws java.io.IOException
Throws:
java.io.IOException

getMapTask

public MapTask getMapTask(long offset,
                          long length)
                   throws java.io.IOException
Throws:
java.io.IOException

getMapTask

public MapTask getMapTask(java.lang.String id)
                   throws java.io.IOException
Throws:
java.io.IOException

getReduceTask

public ReduceTask getReduceTask(long offset,
                                long length)
                         throws java.io.IOException
Throws:
java.io.IOException

hasReducer

public boolean hasReducer()

isNew

public boolean isNew()
Description copied from class: Agent
determines whether or not the Agent is newly created or is a current member of a Clutch network

Specified by:
isNew in class Agent
Returns:
true iff the Agent is newly created, false otherwise

run

public void run()

setInputFactory

public void setInputFactory(MapTaskFactory input)

setNew

public void setNew(boolean newAgent)

setReducer

public void setReducer(Reducer reducer)

setState

public void setState(ClutchState state)
Description copied from class: Agent
sets the state information for the Agent

Overrides:
setState in class Agent
Parameters:
state - a ClutchState object with local state information about the Agent

shutdown

public void shutdown()
Description copied from class: Agent
shut down the Agent

Specified by:
shutdown in class Agent

status

public java.lang.String status()
Description copied from class: Agent
gives a String representation of the current status of the Agent

Specified by:
status in class Agent
Returns:
a String representation of the current status of the Agent

test

public int test(int test)