Class 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,
    Direct Known Subclasses:

    public abstract class MasterCompute
    extends org.apache.giraph.conf.DefaultImmutableClassesGiraphConfigurable
    implements org.apache.giraph.master.MasterAggregatorUsage, org.apache.giraph.master.MasterGlobalCommUsage,
    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

      Constructor Description
    • Constructor Detail

      • MasterCompute

        public MasterCompute()
    • 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.
      • getSuperstep

        public final long getSuperstep()
        Retrieves the current superstep.
        Current superstep
      • getTotalNumVertices

        public final long getTotalNumVertices()
        Get the total (all workers) number of vertices that existed in the previous superstep.
        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.
        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?
        True if halted, false otherwise.
      • getContext

        public final org.apache.hadoop.mapreduce.Mapper.Context getContext()
        Get the mapper context
        Mapper context
      • getComputation

        public final Class<? extends org.apache.giraph.graph.Computation> getComputation()
        Get Computation class to be used
        Computation class
      • setComputation

        public final void setComputation​(Class<? extends org.apache.giraph.graph.Computation> computationClass)
        Set Computation class to be used
        computationClass - Computation class
      • getMessageCombiner

        public final Class<? extends org.apache.giraph.combiner.MessageCombiner> getMessageCombiner()
        Get MessageCombiner class to be used
        MessageCombiner class
      • setMessageCombiner

        public final void setMessageCombiner​(Class<? extends org.apache.giraph.combiner.MessageCombiner> combinerClass)
        Set MessageCombiner class to be used
        combinerClass - MessageCombiner class
      • setIncomingMessage

        public final void setIncomingMessage​(Class<? extends> incomingMessageClass)
        Set incoming message class to be used
        incomingMessageClass - incoming message class
      • setOutgoingMessage

        public final void setOutgoingMessage​(Class<? extends> outgoingMessageClass)
        Set outgoing message class to be used
        outgoingMessageClass - outgoing message class
      • setOutgoingMessageClasses

        public void setOutgoingMessageClasses​(org.apache.giraph.conf.MessageClasses<? extends,​? extends> outgoingMessageClasses)
        Set outgoing message classes to be used
        outgoingMessageClasses - outgoing message classes
      • registerReducer

        public final <S,​R extends> void registerReducer​(String name,
                                                                                            org.apache.giraph.reducers.ReduceOperation<S,​R> reduceOp)
        Specified by:
        registerReducer in interface org.apache.giraph.master.MasterGlobalCommUsageAggregators
      • registerReducer

        public final <S,​R extends> void registerReducer​(String name,
                                                                                            org.apache.giraph.reducers.ReduceOperation<S,​R> reduceOp,
                                                                                            R globalInitialValue)
        Specified by:
        registerReducer in interface org.apache.giraph.master.MasterGlobalCommUsageAggregators
      • getReduced

        public final <T extends> T getReduced​(String name)
        Specified by:
        getReduced in interface org.apache.giraph.master.MasterGlobalCommUsageAggregators
      • broadcast

        public final void broadcast​(String name,
        Specified by:
        broadcast in interface org.apache.giraph.master.MasterGlobalCommUsageAggregators
      • getAggregatedValue

        public final <A extends> A getAggregatedValue​(String name)
        Specified by:
        getAggregatedValue in interface org.apache.giraph.aggregators.AggregatorUsage
      • setAggregatedValue

        public final <A extends> void setAggregatedValue​(String name,
                                                                                       A value)
        Specified by:
        setAggregatedValue in interface org.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
        line - Line to print