org.apfloat.samples
Class PiDistributed

java.lang.Object
  |
  +--org.apfloat.samples.Pi
        |
        +--org.apfloat.samples.PiParallel
              |
              +--org.apfloat.samples.PiDistributed

public class PiDistributed
extends PiParallel

Calculates pi using a cluster of servers. The servers should be running OperationServer. The names and ports of the cluster nodes are read from the file cluster.properties, or a ResourceBundle by the name "cluster". The format of the property file is as follows:

 server1=hostname.company.com:1234
 server2=hostname2.company.com:2345
 server3=hostname3.company.com:3456
 weight1=100
 weight2=110
 weight3=50
 
The server addresses are specified as hostname:port. Weights can (but don't have to) be assigned to nodes to indicate the relative performance of each node, to allow distributing a suitable amount of work for each node. For example, weight2 is the relative performance of server2 etc. The weights must be integers in the range 1...1000.

Guidelines for configuring the servers:

Similarly as with PiParallel, if some nodes have multiple CPUs, to get any performance gain from running many threads in parallel, the JVM must be executing native threads. If the JVM is running in green threads mode, there is no advantage of having multiple threads, as the JVM will in fact execute just one thread and divide its time to multiple simulated threads.


Nested Class Summary
protected static class PiDistributed.DistributedPiCalculator
          Distributed version of the Chudnovskys' binary splitting algorithm.
 
Nested classes inherited from class org.apfloat.samples.PiParallel
PiParallel.ThreadLimitedOperation
 
Nested classes inherited from class org.apfloat.samples.Pi
Pi.BorweinPiCalculator, Pi.ChudnovskyProgressIndicator, Pi.GaussLegendrePiCalculator
 
Field Summary
 
Fields inherited from class org.apfloat.samples.Pi
err, out
 
Method Summary
static void main(java.lang.String[] args)
          Command-line entry point.
 
Methods inherited from class org.apfloat.samples.Pi
checkAlive, getErr, getInt, getLong, getOut, getPrecision, getRadix, run, setAlive, setErr, setOut
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

main

public static void main(java.lang.String[] args)
                 throws java.io.IOException,
                        ApfloatRuntimeException
Command-line entry point.

Parameters:
args - Command-line parameters.
Throws:
java.io.IOException - In case writing the output fails.
ApfloatRuntimeException