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, 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()  
    • 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.
        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 interface org.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 interface org.apache.giraph.master.MasterGlobalCommUsageAggregators
      • getReduced

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

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

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

        public final <A extends org.apache.hadoop.io.Writable> 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
        Parameters:
        line - Line to print