Package org.apache.giraph.master
Class MasterCompute
- java.lang.Object
-
- org.apache.giraph.conf.DefaultImmutableClassesGiraphConfigurable
-
- org.apache.giraph.master.MasterCompute
-
- All Implemented Interfaces:
org.apache.giraph.aggregators.AggregatorUsage
,org.apache.giraph.conf.GiraphConfigurationSettable
,org.apache.giraph.conf.ImmutableClassesGiraphConfigurable
,org.apache.giraph.master.MasterAggregatorUsage
,org.apache.giraph.master.MasterGlobalCommUsage
,org.apache.giraph.master.MasterGlobalCommUsageAggregators
,org.apache.hadoop.io.Writable
- Direct Known Subclasses:
org.apache.giraph.master.DefaultMasterCompute
public abstract class MasterCompute extends org.apache.giraph.conf.DefaultImmutableClassesGiraphConfigurable implements org.apache.giraph.master.MasterAggregatorUsage, org.apache.giraph.master.MasterGlobalCommUsage, org.apache.hadoop.io.Writable
Interface for defining a master vertex that can perform centralized computation between supersteps. This class will be instantiated on the master node and will run every superstep before the workers do.Communication with the workers should be performed via aggregators. The values of the aggregators are broadcast to the workers before vertex.compute() is called and collected by the master before master.compute() is called. This means aggregator values used by the workers are consistent with aggregator values from the master from the same superstep and aggregator used by the master are consistent with aggregator values from the workers from the previous superstep.
-
-
Constructor Summary
Constructors Constructor Description MasterCompute()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
broadcast(String name, org.apache.hadoop.io.Writable object)
abstract void
compute()
Must be defined by user to specify what the master has to do.<A extends org.apache.hadoop.io.Writable>
AgetAggregatedValue(String name)
Class<? extends org.apache.giraph.graph.Computation>
getComputation()
Get Computation class to be usedorg.apache.hadoop.mapreduce.Mapper.Context
getContext()
Get the mapper contextClass<? extends org.apache.giraph.combiner.MessageCombiner>
getMessageCombiner()
Get MessageCombiner class to be used<T extends org.apache.hadoop.io.Writable>
TgetReduced(String name)
long
getSuperstep()
Retrieves the current superstep.long
getTotalNumEdges()
Get the total (all workers) number of edges that existed in the previous superstep.long
getTotalNumVertices()
Get the total (all workers) number of vertices that existed in the previous superstep.void
haltComputation()
After this is called, the computation will stop, even if there are still messages in the system or vertices that have not voted to halt.void
incSuperStep()
abstract void
initialize()
Initialize the MasterCompute class, this is the place to register aggregators.boolean
isHalted()
Has the master halted?void
logToCommandLine(String line)
Call this to log a line to command line of the job.<A extends org.apache.hadoop.io.Writable>
booleanregisterAggregator(String name, Class<? extends org.apache.giraph.aggregators.Aggregator<A>> aggregatorClass)
<A extends org.apache.hadoop.io.Writable>
booleanregisterPersistentAggregator(String name, Class<? extends org.apache.giraph.aggregators.Aggregator<A>> aggregatorClass)
<S,R extends org.apache.hadoop.io.Writable>
voidregisterReducer(String name, org.apache.giraph.reducers.ReduceOperation<S,R> reduceOp)
<S,R extends org.apache.hadoop.io.Writable>
voidregisterReducer(String name, org.apache.giraph.reducers.ReduceOperation<S,R> reduceOp, R globalInitialValue)
<A extends org.apache.hadoop.io.Writable>
voidsetAggregatedValue(String name, A value)
void
setAggregatorManager(AggregatorManager aggregatorManager)
void
setComputation(Class<? extends org.apache.giraph.graph.Computation> computationClass)
Set Computation class to be usedvoid
setFragment(IFragment fragment)
void
setIncomingMessage(Class<? extends org.apache.hadoop.io.Writable> incomingMessageClass)
Deprecated.void
setMessageCombiner(Class<? extends org.apache.giraph.combiner.MessageCombiner> combinerClass)
Set MessageCombiner class to be usedvoid
setOutgoingMessage(Class<? extends org.apache.hadoop.io.Writable> outgoingMessageClass)
Set outgoing message class to be usedvoid
setOutgoingMessageClasses(org.apache.giraph.conf.MessageClasses<? extends org.apache.hadoop.io.WritableComparable,? extends org.apache.hadoop.io.Writable> outgoingMessageClasses)
Set outgoing message classes to be usedvoid
setSuperStep(int superStep)
-
Methods inherited from class org.apache.giraph.conf.DefaultImmutableClassesGiraphConfigurable
getConf, setConf
-
-
-
-
Method Detail
-
setFragment
public void setFragment(IFragment fragment)
-
setSuperStep
public void setSuperStep(int superStep)
-
incSuperStep
public void incSuperStep()
-
setAggregatorManager
public void setAggregatorManager(AggregatorManager aggregatorManager)
-
compute
public abstract void compute()
Must be defined by user to specify what the master has to do.
-
initialize
public abstract void initialize() throws InstantiationException, IllegalAccessException
Initialize the MasterCompute class, this is the place to register aggregators.
-
getSuperstep
public final long getSuperstep()
Retrieves the current superstep.- Returns:
- Current superstep
-
getTotalNumVertices
public final long getTotalNumVertices()
Get the total (all workers) number of vertices that existed in the previous superstep.- Returns:
- Total number of vertices (-1 if first superstep)
-
getTotalNumEdges
public final long getTotalNumEdges()
Get the total (all workers) number of edges that existed in the previous superstep.- Returns:
- Total number of edges (-1 if first superstep)
-
haltComputation
public final void haltComputation()
After this is called, the computation will stop, even if there are still messages in the system or vertices that have not voted to halt.
-
isHalted
public final boolean isHalted()
Has the master halted?- Returns:
- True if halted, false otherwise.
-
getContext
public final org.apache.hadoop.mapreduce.Mapper.Context getContext()
Get the mapper context- Returns:
- Mapper context
-
getComputation
public final Class<? extends org.apache.giraph.graph.Computation> getComputation()
Get Computation class to be used- Returns:
- Computation class
-
setComputation
public final void setComputation(Class<? extends org.apache.giraph.graph.Computation> computationClass)
Set Computation class to be used- Parameters:
computationClass
- Computation class
-
getMessageCombiner
public final Class<? extends org.apache.giraph.combiner.MessageCombiner> getMessageCombiner()
Get MessageCombiner class to be used- Returns:
- MessageCombiner class
-
setMessageCombiner
public final void setMessageCombiner(Class<? extends org.apache.giraph.combiner.MessageCombiner> combinerClass)
Set MessageCombiner class to be used- Parameters:
combinerClass
- MessageCombiner class
-
setIncomingMessage
@Deprecated public final void setIncomingMessage(Class<? extends org.apache.hadoop.io.Writable> incomingMessageClass)
Deprecated.Set incoming message class to be used- Parameters:
incomingMessageClass
- incoming message class
-
setOutgoingMessage
public final void setOutgoingMessage(Class<? extends org.apache.hadoop.io.Writable> outgoingMessageClass)
Set outgoing message class to be used- Parameters:
outgoingMessageClass
- outgoing message class
-
setOutgoingMessageClasses
public void setOutgoingMessageClasses(org.apache.giraph.conf.MessageClasses<? extends org.apache.hadoop.io.WritableComparable,? extends org.apache.hadoop.io.Writable> outgoingMessageClasses)
Set outgoing message classes to be used- Parameters:
outgoingMessageClasses
- outgoing message classes
-
registerReducer
public final <S,R extends org.apache.hadoop.io.Writable> void registerReducer(String name, org.apache.giraph.reducers.ReduceOperation<S,R> reduceOp)
- Specified by:
registerReducer
in interfaceorg.apache.giraph.master.MasterGlobalCommUsageAggregators
-
registerReducer
public final <S,R extends org.apache.hadoop.io.Writable> void registerReducer(String name, org.apache.giraph.reducers.ReduceOperation<S,R> reduceOp, R globalInitialValue)
- Specified by:
registerReducer
in interfaceorg.apache.giraph.master.MasterGlobalCommUsageAggregators
-
getReduced
public final <T extends org.apache.hadoop.io.Writable> T getReduced(String name)
- Specified by:
getReduced
in interfaceorg.apache.giraph.master.MasterGlobalCommUsageAggregators
-
broadcast
public final void broadcast(String name, org.apache.hadoop.io.Writable object)
- Specified by:
broadcast
in interfaceorg.apache.giraph.master.MasterGlobalCommUsageAggregators
-
registerAggregator
public final <A extends org.apache.hadoop.io.Writable> boolean registerAggregator(String name, Class<? extends org.apache.giraph.aggregators.Aggregator<A>> aggregatorClass) throws InstantiationException, IllegalAccessException
- Specified by:
registerAggregator
in interfaceorg.apache.giraph.master.MasterAggregatorUsage
- Throws:
InstantiationException
IllegalAccessException
-
registerPersistentAggregator
public final <A extends org.apache.hadoop.io.Writable> boolean registerPersistentAggregator(String name, Class<? extends org.apache.giraph.aggregators.Aggregator<A>> aggregatorClass) throws InstantiationException, IllegalAccessException
- Specified by:
registerPersistentAggregator
in interfaceorg.apache.giraph.master.MasterAggregatorUsage
- Throws:
InstantiationException
IllegalAccessException
-
getAggregatedValue
public final <A extends org.apache.hadoop.io.Writable> A getAggregatedValue(String name)
- Specified by:
getAggregatedValue
in interfaceorg.apache.giraph.aggregators.AggregatorUsage
-
setAggregatedValue
public final <A extends org.apache.hadoop.io.Writable> void setAggregatedValue(String name, A value)
- Specified by:
setAggregatedValue
in interfaceorg.apache.giraph.master.MasterAggregatorUsage
-
logToCommandLine
public void logToCommandLine(String line)
Call this to log a line to command line of the job. Use in moderation - it's a synchronous call to Job client- Parameters:
line
- Line to print
-
-