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.WritableInterface 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 voidbroadcast(String name, org.apache.hadoop.io.Writable object)abstract voidcompute()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.ContextgetContext()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)longgetSuperstep()Retrieves the current superstep.longgetTotalNumEdges()Get the total (all workers) number of edges that existed in the previous superstep.longgetTotalNumVertices()Get the total (all workers) number of vertices that existed in the previous superstep.voidhaltComputation()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.voidincSuperStep()abstract voidinitialize()Initialize the MasterCompute class, this is the place to register aggregators.booleanisHalted()Has the master halted?voidlogToCommandLine(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)voidsetAggregatorManager(AggregatorManager aggregatorManager)voidsetComputation(Class<? extends org.apache.giraph.graph.Computation> computationClass)Set Computation class to be usedvoidsetFragment(IFragment fragment)voidsetIncomingMessage(Class<? extends org.apache.hadoop.io.Writable> incomingMessageClass)Deprecated.voidsetMessageCombiner(Class<? extends org.apache.giraph.combiner.MessageCombiner> combinerClass)Set MessageCombiner class to be usedvoidsetOutgoingMessage(Class<? extends org.apache.hadoop.io.Writable> outgoingMessageClass)Set outgoing message class to be usedvoidsetOutgoingMessageClasses(org.apache.giraph.conf.MessageClasses<? extends org.apache.hadoop.io.WritableComparable,? extends org.apache.hadoop.io.Writable> outgoingMessageClasses)Set outgoing message classes to be usedvoidsetSuperStep(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, IllegalAccessExceptionInitialize 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:
registerReducerin 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:
registerReducerin interfaceorg.apache.giraph.master.MasterGlobalCommUsageAggregators
-
getReduced
public final <T extends org.apache.hadoop.io.Writable> T getReduced(String name)
- Specified by:
getReducedin interfaceorg.apache.giraph.master.MasterGlobalCommUsageAggregators
-
broadcast
public final void broadcast(String name, org.apache.hadoop.io.Writable object)
- Specified by:
broadcastin 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:
registerAggregatorin interfaceorg.apache.giraph.master.MasterAggregatorUsage- Throws:
InstantiationExceptionIllegalAccessException
-
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:
registerPersistentAggregatorin interfaceorg.apache.giraph.master.MasterAggregatorUsage- Throws:
InstantiationExceptionIllegalAccessException
-
getAggregatedValue
public final <A extends org.apache.hadoop.io.Writable> A getAggregatedValue(String name)
- Specified by:
getAggregatedValuein interfaceorg.apache.giraph.aggregators.AggregatorUsage
-
setAggregatedValue
public final <A extends org.apache.hadoop.io.Writable> void setAggregatedValue(String name, A value)
- Specified by:
setAggregatedValuein 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
-
-