Class PiDistributed.Node

    • Constructor Detail

      • Node

        public Node​(String host,
                    int port,
                    int weight)
        Construct a Node with the specified parameters and one processor.
        Parameters:
        host - The remote host.
        port - The remote port.
        weight - The weight.
      • Node

        public Node​(String host,
                    int port,
                    int weight,
                    int numberOfProcessors)
        Construct a Node with the specified parameters.
        Parameters:
        host - The remote host.
        port - The remote port.
        weight - The weight.
        numberOfProcessors - The number of processors.
    • Method Detail

      • execute

        public <T> T execute​(Operation<T> operation)
        Description copied from class: RemoteOperationExecutor
        Execute an operation remotely. This method will block until the return value has been received.
        Specified by:
        execute in interface OperationExecutor
        Overrides:
        execute in class RemoteOperationExecutor
        Type Parameters:
        T - Return value type of the operation.
        Parameters:
        operation - The operation to execute remotely.
        Returns:
        The result of the operation.
      • setWeight

        public void setWeight​(int weight)
        Set the weight.
        Parameters:
        weight - The weight.
      • getWeight

        public int getWeight()
        Description copied from interface: OperationExecutor
        Returns the relative weight of this executor. The weights of different operation executors can be used to distribute work more equally.
        Specified by:
        getWeight in interface OperationExecutor
        Overrides:
        getWeight in class RemoteOperationExecutor
        Returns:
        The relative weight of this operation executor.
      • setNumberOfProcessors

        public void setNumberOfProcessors​(int numberOfProcessors)
        Set the number of processors.
        Parameters:
        numberOfProcessors - The number of processors.
      • getNumberOfProcessors

        public int getNumberOfProcessors()
        Get the number of processors.
        Returns:
        The number of processors.
      • compareTo

        public int compareTo​(PiDistributed.Node that)
        Compare this Node to another Node.
        Specified by:
        compareTo in interface Comparable<PiDistributed.Node>
        Parameters:
        that - The other node to compare to.
        Returns:
        A number less than zero if this Node should be ordered before the other node, or gerater than zero for the reverse order. Should not return zero.
      • toString

        public String toString()
        Convert to String.
        Overrides:
        toString in class Object
        Returns:
        The string representation.