Post on 13-Jan-2016
transcript
Emil Salageanu
ProActive Parallel Suite
ActiveEon
March 2008
ActiveEon
Hands On Programming
Emil Salageanu
Hands On Programming
Implementation of a Monitor and Compute Agent
1. create an Active Object (the Monitoring Agent)
2. manage the lifecycle of an Active Object (record info on requests, service time, …)
3. deploy the Agent on a remote host
4. use inter-Active Object communications. Deal with synchronizations
5. migrate your Agent from one host to another to gather information
6. create, manage and use a group of Agents
7. publish the web Agent as web service
8. use your agent to perform some computation (check prime numbers)
9. use the Master Worker framework to solve the Prime Number problem
2 ActiveEon
Exercises
Emil Salageanu
Hands On Programming
The Project Exercises contains the skeleton sources for the exercises a different package for each exercise each exercise consists in extending classes implemented in a
previous exercise and adding new functionalities each package contains a Main class corresponding to the exercise
Don’t worry, the solutions are in project Solutions… Just copy and past the package if needed
3 ActiveEon
Eclipse Workspace
Emil Salageanu
ACTIVE OBJECTSHands-on programming
ActiveEon4
Emil Salageanu
Active Object Structure
5 ActiveEon
Active objects : coarse-grained structuring entities (subsystems)
Each active object: - possibly owns many passive objects
- has exactly one thread.
Remote Method Invocation (Object RPC)
No shared passive objects -- Parameters are passed by deep-copy
Asynchronous Communication between active objects
Full control to serve incoming requests (reification)
Emil Salageanu
Active objects
6 ActiveEon 6
A
Proxy
Java Object
A ag = newActive (“A”, […], Node)V v1 = ag.foo (param);V v2 = ag.bar (param);...v1.bar(); //Wait-By-Necessity
V
Wait-By-Necessity
provides
Dataflow
Synchronization
JVM
A
JVM
Active Object
Future Object Request
Req. Queue
Thread
v1v2 ag
WBN!
Emil Salageanu
Creating active objects
7 ActiveEon 7
Instantiation-based:
A a = (A)ProActive.newActive(«A», params, node);
Class-based:
class pA extends A implements RunActive { … }
Object-based:A a = new A (obj, 7);
... ...
a = (A)ProActive.turnActive (a, node);
Emil Salageanu
Creating active objects
no direct access to field variables (use getter/setter methods)
provide a no-argument and preferably an empty constructor
provide remote functionalities as public methods with non-final and serializable type
ActiveEon8
Emil Salageanu
Polymorphism
9 ActiveEon 9
"A"
“A"
ara
Public class O { ...public void foo (A a)
{ a.g (...); v = a.f (...); ... v.bar (...);}
...}
1) o.foo(a) :
a.g() and a.f() are « local »
2) o.foo(ra)a.g() and a.f() are «remote + Async.»
O
Emil Salageanu
Terminating Active Objects
10 ActiveEon 10
PAActiveObject.terminateActiveObject(ao, immediately)
‘immediately’ specifies if the termination request should be put in the request queue of ao or executed preemptively (called an immediate service).
Emil Salageanu
Exercise1
TODO create an ActiveObject (CMAgent) call a method on the object (getCurrentstate()) terminate your active object
Exercise source package org.objectweb.proactive.examples.userguide.cmagent.simple
ProActive API org.objectweb.proactive.api.PAActiveObject org.objectweb.proactive.core.node.NodeException org.objectweb.proactive.ActiveObjectCreationException
11 ActiveEon
Getting Started with The Simple Computation And Monitoring Agent
Emil Salageanu
ACTIVE OBJECTS LIFECYCLEHands-on programming
ActiveEon12
Emil Salageanu
Active Object Lifecycle
13 ActiveEon 13
class BoundedBuffer extends FixedBuffer implements InitActive,
RunActive, EndActive {
public void initActivity(Body body) { // executed only once when object is created};
public void runActivity(Body body){ // define object behaviour // request serving policies // additional treatment between request services}
public void endActivity(Body body) { // executed before the termination of the Object}
}
Emil Salageanu
Active Objects
14 ActiveEon
Intra-object synchronization
14
class BoundedBuffer extends FixedBuffer implements
InitActive, RunActive, EndActive { runActivity (Body myBody) { Service service = new Service(body); while (...) { if (this.isFull()) service.serveOldest("get"); else if (this.isEmpty()) service.serveOldest ("put"); else
service.serveOldest (); //FIFO
service.waitForRequest (); }}}
Explicit control
Library of service routines:
Non-blocking services,...serveOldest ();serveOldest (f);
Blocking services, timed, etc.serveOldestBl ();serveOldestTm (ms);
Waiting primitiveswaitARequest(); etc.
Emil Salageanu
Exercise 2
TODO implement initActivity(), runActivity() and endActivity() methods
in order to keep track of last request duration, number of requests served and total running time of your Monitoring Agent
Exercise source package org.objectweb.proactive.examples.userguide.cmagent.initialized
ProActive API org.objectweb.proactive.Body org.objectweb.proactive.api.PALifeCycle org.objectweb.proactive.InitActive, ...EndActive, ...RunActive org.objectweb.proactive.Service org.objectweb.proactive.core.util.wrapper.LongWrapper
15 ActiveEon
Active Objects Lifecycle: Using InitActive and EndActive
Emil Salageanu
PROACTIVE DEPLOYMENTHands on programming
ActiveEon16
Emil Salageanu
Virtualization of resources
17 ActiveEon
VN1
VN2
GCM XMLDeployment Descriptor
node
node
HostJVM
node
JVM
Host
node
JVM
Emil Salageanu
Virtualization of resources
18 ActiveEon
VN1
VN2
node
node
HostJVM
node
JVM
Host
node
JVM
Emil Salageanu
XML Deployment files Virtual Node (VN):
• Identified as a string name• Used in program source• Configured (mapped) in the XML descriptor file --> Nodes
Operations specified in descriptors:• Mapping of VN to JVMs (leads to Node in a JVM on Host)• Register or Lookup VNs • Create or Acquire JVMs• Security
ActiveEon19
Runtime structured entities :1 VN → n nodes in m JVMs on k hosts
Program Source Descriptor (RunTime)
Activities(AO) →VN→Nodes VN→JVMs→Hosts
Emil Salageanu
ProActive Deployment
Virtual Nodes Definition Define the Virtual Nodes provided by the deployment descriptors and the
services that applies to these virtual nodes
Deployment Mapping [VN→JVM] or Lookup VN
Map the Virtual Nodes to the JVMS:
[1 VN – 1 JVM] or [1 VN – n JVMs] or [n VNs – m JVMs] Lookup an already deployed Virtual Node
Register Virtual Node JVMs
Define a number of nodes for a JVM ([1 JVM – 1 Node] or [1 JVM – n Nodes]) Define the process for creation or lookup for each JVM
Infrastructure JVM Creation/Lookup processes Services (P2P, FT, Timit)
20 ActiveEon
Structure of Deployment Descriptor Files
Emil Salageanu
ProActive Deployment
In the Virtual Node definition are defined: The Virtual Node name The services that applies to this VN The file transfer needed for this VN Node attributes: property (unique/multiple), timeout, waitForTimeout,
minNodeNumber
21 ActiveEon
Virtual Nodes Definition
<componentDefinition>
<virtualNodesDefinition>
<virtualNode name="Workers" property="multiple"
ftServiceId="appli" />
</virtualNodesDefinition>
</componentDefinition>
Emil Salageanu
ProActive Deployment
Mapping of VNs on JVMs → Nodes
Mapping [1 VN – 1JVM]
22 ActiveEon
Deployment: Mapping
<deployment>
<mapping>
<map virtualNode=‘Workers'>
<jvmSet>
<vmName value='Jvm0'/>
</jvmSet> </map>
</mapping>
…
</deployment>
Emil Salageanu
ProActive Deployment
Mapping [1 VN – n JVM]
23 ActiveEon
Deployment: Mapping
<deployment>
<mapping>
<map virtualNode=‘Workers'>
<jvmSet>
<currentJvm/>
<vmName value='Jvm1'/>
<vmName value='Jvm2'/>
</jvmSet>
</map>
</mapping>
…
</deployment>
Emil Salageanu
ProActive Deployment
Mapping [n VN – m JVM]
24 ActiveEon
Deployment: Mapping
<mapping>
<map virtualNode='Dispatcher'>
<jvmSet>
<vmName value='Jvm1'/>
</jvmSet>
</map>
<map virtualNode='Renderer'>
<jvmSet>
<vmName value='Jvm1'/>
<vmName value='Jvm1'/>
<vmName value='Jvm2'/>
</jvmSet>
</map>
</mapping>
Emil Salageanu
ProActive Deployment
Register a Virtual Node to make it accessible by another applications
25 ActiveEon
Deployment: Virtual Node Registration
<deployment>
<register virtualNode='Dispatcher' protocol='rmi'/> or
<register virtualNode='Dispatcher’/>
<mapping>
<map virtualNode='Dispatcher'>
…
</map>
</mapping>
<deployment>
Emil Salageanu
ProActive Deployment
Acquire a VirtualNode already deployed by another application
26 ActiveEon
Deployment: Virtual Node Acquisition
<virtualNodesAcquisition>
<virtualNode name='Dispatcher'/>
</virtualNodesAcquisition>
..........
<deployment>
..........
<lookup virtualNode='Dispatcher' host='machine_name' protocol='rmi' port='2020'/>
<lookup virtualNode=‘Workers' host='*' protocol='rmi'/>
</deployment>
Emil Salageanu
ProActive Deployment
Specify a process for the creation of the JVM
27 ActiveEon
Deployment: JVMs creation
<deployment>
<mapping>
............
</mapping>
<jvms>
<jvm name='jvm1'>
<creation>
<processReference refid='jvmProcess'/>
</creation>
</jvm>
</jvms>
</deployment>
</deployment>
Emil Salageanu
ProActive Deployment
Acquire already created JVMs Use of the RMIRegistryLookup service or the P2PService
28 ActiveEon
Deployment: JVMs acquisition
<deployment>
<mapping>
............
</mapping>
<jvms>
<jvm name='jvm1’>
<acquisition>
<serviceReference refid='lookup'/> </acquisition>
</jvm>
</jvms>
</deployment>
</deployment>
Emil Salageanu
ProActive Deployment
Define the processes used in the ‘deployment’ section Create and acquire JVMs Define
classpath environment variable the java path the policy file path the log4j properties file path the ProActive properties file path parameters to the JVM to be created
29 ActiveEon
Infrastructure
Emil Salageanu
ProActive Deployment
The class attribute defines the class to instantiate in order to create the process
30 ActiveEon
Infrastructure: Local JVMs
<infrastructure>
<processes>
<processDefinition id='jvmProcess'>
<jvmProcess class='org.objectweb.proactive.core.process.JVMNodeProcesss'>
<classpath> .... </classpath>
<javaPath> ... </javapath>
<policyFile> ... </policyfile>
<log4jpropertiesFile> ... </log4jpropertiesFile>
<jvmParameters> ... </jvmParameters>
<ProActiveUserPropertiesFile> ... </...>
</jvmProcess>
</processDefinition>
</processes>
</infrastructure>
Emil Salageanu
ProActive Deployment
Several Protocols implemented: rsh, ssh, rlogin, lsf, pbs, oar, prun, globus, unicore, arc (nordugrid), glite
Hierarchy of processes: each remote process must have a pointer either on another remote process or on
a jvmProcess to create a jvm
31 ActiveEon
Infrastructure: Remote JVMs
<processDefinition id='rshProcess'>
<rshProcess class='org.objectweb.proactive.core.process.rsh.RSHProcess'
hostname='sea.inria.fr'>
<processReference refid='jvmProcess'/>
</rshProcess>
</processDefinition>
Emil Salageanu
ProActive Deployment
Use ssh public/private keys
32 ActiveEon
Infrastructure: Remote JVMs (SSH Process)
<processes>
<processDefinition id='jvmProcess'>
<jvmProcess class='org.objectweb.proactive.core.process.JVMNodeProcess'/> </processDefinition>
<processDefinition id='sshProcess'>
<sshProcess class='org.objectweb.proactive.core.process.ssh.SSHProcess' hostname='sea.inria.fr'>
<processReference refid='jvmProcess'/>
</sshProcess>
</processDefinition>
</processes>
Emil Salageanu
ProActive Deployment
Build a list of JVMs processes using protocols like RSH, SSH, RLOGIN
33 ActiveEon
Infrastructure: Remote JVMs (Process List)
...
<jvm name='jvm1'>
<creation>
<processReference refid='processlist'/>
</creation>
</jvm>
...
<processDefinition id='processlist'>
<processListByHost class='org.objectweb.proactive.core.process.ssh.SSHProcessList' hostlist='crusoe waha nahuel' domain='inria.fr'>
<processReference refid='jvmProcess'/>
</processListByHost>
</processDefinition>
Emil Salageanu
ProActive Deployment
LSF Process Create Nodes(JVMs) on a cluster
PBS Process Create jobs on cluster managed by PBS, PBSPro or Torque
Sun Grid Engine Process This protocol is used to create jobs on cluster managed by Sun Grid Engine
GLOBUS Process
Etc ...
34 ActiveEon
Infrastructure: Job Scheduler Support
Emil Salageanu
ProActive Deployment
Use a service to acquire an already running JVM RMIRegistryLookup P2PService
35 ActiveEon
Infrastructure: Acquire JVMs
<infrastructure>
<services>
<serviceDefinition id='lookupRMI'>
<RMIRegistryLookup url='//localhost:2020/PA_JVM1'/> </serviceDefinition>
<serviceDefinition id='lookupP2P'>
<P2PService nodesAsked='2‘ acq='rmi' port='2410' NOA='10' TTU='60000' TTL='10'>
<peerSet>
<peer>rmi://localhost:3000</peer>
</peerSet>
</P2PService>
</serviceDefinition>
</services> </infrastructure>
Emil Salageanu
Using Virtual Nodes in the Application
36 ActiveEon
1. create object representation of the deployment file:ProActiveDescriptor pad=PADeployment.getProactiveDescriptor(“file:…”)
2. activate all virtual nodes:pad.activateMappings();
3. obtain the virtual nodesVirtualNode[] vns= pad.getVirtualNodes();
VirtualNode virtualNode=vns[0];
4. obtain the nodes:Node[] nodes=virtualNode.getNodes();
Or:Node node = virtualNode.get(index);
5. create an active object on the node:A a = PAActiveObject.newActive(A.class.getName(),[…],node)
log("created at: ”+node.name()+node.JVM()+node.host());
Emil Salageanu
Exercise 3
TODO Write code for obtaining a virtual node from your deployment descriptor and
deploy your agent on a Node of the Virtual Node Modify the deployment descriptor in order to deploy your agent on some other
machine without modifying the source code
Exercise source package org.objectweb.proactive.examples.userguide.cmagent.deployed
ProActive API org.objectweb.proactive.api.PADeployment org.objectweb.proactive.core.descriptor.data.ProActiveDescriptor org.objectweb.proactive.core.descriptor.data.VirtualNode org.objectweb.proactive.core.node.Node org.objectweb.proactive.core.node.NodeException
37 ActiveEon
Application Deployment
Emil Salageanu
SYNCHRONIZATION ANDPOLYMORPHISM
Hands on programming
ActiveEon38
Emil Salageanu
Call on an Active Object
39 ActiveEon
Internally, a method call on an active object consists in 2 stepsA query : name of the method, parameters…A Reply : the result of the method call
A query returns a Future object which is a placeholder for the result
The callee will update the Future when the result is available
The caller can continue its execution event if the Future has not been updated
39
foo (){ Result r = a.process(); //do other things ... r.toString();}
Result process(){ //perform long //calculation
return result;}
will block if not available
Emil Salageanu
Call between Objects
40 ActiveEon
Parameter Passing: Active Objects
40
ba
x
Copyat
serialization
Object passed by Deep Copy - Active Object by Reference
b.foo(x, c)
c
c
Reference Passing
Emil Salageanu
Wait-By-Necessity: Automatic Continuation
41 ActiveEon 41
ba
Futures are Global Single-Assignment Variables
V= b.bar ()
c
c
c.gee (V)
v
v
b
Emil Salageanu
Synchronizations
42 ActiveEon
Explicit Synchronization:- ProActive.isAwaited (v); // Test if available- .waitFor (v); // Wait until availab.Vectors of Futures:
- .waitForAll (Vector); // Wait All- .waitForAny (Vector); // Get First
42
A ag = newActive (“A”, […], VirtualNode)V v = ag.foo(param);... v.bar(); //Wait-by-necessity
Implicit Synchronization: Wait-by-necessity
Emil Salageanu
Polymorphism
43 ActiveEon 43
"A"
“A"
ara
Public class O { ...public void foo (A a)
{ a.g (...); v = a.f (...); ... v.bar (...);}
...}
1) o.foo(a) :
a.g() and a.f() are « local »
2) o.foo(ra)a.g() and a.f() are «remote + Async.»
O
Emil Salageanu
Active Objects
44 ActiveEon
The meaning of “this”
44
public class A { B b = … public void foo() {
b.gee(this);
OR: b.gee(PAActiveObject.getStubOnThis()) }}
With
public class B { public void gee(A a) { //do something with a }}
?
Emil Salageanu
Standard system at Runtime
45 ActiveEon
Dynamic Topology, Asynchrony, WbN, ... but no sharing
Denis Caromel 45
Emil Salageanu
Exercise 4
TODO Implement inter-Agent communications in order to gather the states on several
machines Deal with implicit and explicit synchronization
Exercise source package org.objectweb.proactive.examples.userguide.cmagent.sync
ProActive API Use the ProActive API you have encountered in the previous exercises
46 ActiveEon
Synchronization and Polymorphism: inter-Agent communications
Emil Salageanu
MIGRATION OF ACTIVE OBJECTS
Hands on programming
ActiveEon47
Emil SalageanuActiveEon48 48
Migration of active objects
ProxyBody
Object
Migration is initiated by the active object through a request The active object migrates with
its passive objects the queue of pending requests its future objects
2 Techniques : Forwarders or Centralized server
CallingObject F
orwarder
Emil Salageanu
Migration API
49 ActiveEon
Migrate to a given node:
PAMobileAgent.migrateTo(Node nodeToMigrateTo);
Migrate to the node with the URL given as parameter:
PAMobileAgent.migrateTo(String NodeUrl);
Migrate to the location of the ActiveObject given as parameter:
PAMobileAgent.migrateTo(Object activeObject);
Emil Salageanu
Migration API
50 ActiveEon
On departure / On arrival
public class A implements InitActive{
public void initActivity(Body body) { MigrationStrategyManagerImpl myStrategyManager = new
MigrationStrategyManagerImpl((Migratable) body);
myStrategyManager.onArrival(“afterMigration"); myStrategyManager.onDeparture(“beforeMigration");
}
public void beforeMigration(){
//actions to be executed before the migration
}
public void afterMigration() {
//actions to be executed after migration (on the new location)
}
Emil Salageanu
Exercise 5
TODO Migrate the Agent from one machine to another and report the state of each JMV
on the machines.
Exercise source package org.objectweb.proactive.examples.userguide.cmagent.migration
ProActive API org.objectweb.proactive.api.PAMobileAgent
51 ActiveEon
Monitoring Several Computers Using Migration
Emil Salageanu
TYPED GROUPSHands on programming
ActiveEon52
Emil Salageanu
ProActive Groups
53 ActiveEon 53
Typed and polymorphic Groups of local and remote objectsDynamic generation of group of resultsLanguage centric, Dot notation
Manipulate groups of Active Objects, in a simple and typed manner:
A ag=(A)ProActiveGroup.newGroup(«A»,{{p1},...},{Nodes,..});V v = ag.foo(param); v.bar();
Emil Salageanu
Collective Operations : Example
54 ActiveEon 54
// Build a Group of OBJECTS « A » (Standard and/or Active)
A agS = (A)ProActiveGroup.newGroup(“A”,....)
V v = ag.foo(param); // foo(param) invoked // on each member
// A group v of result of type V is created
// Build an Active Group of OBJECTS « A »
//(Standard and/or Active)
A ag = (A) newActiveGroup(“A”,{…}, Nodes)
V v=ag.foo(param);//invoked on each member
Emil Salageanu
Two Representations Scheme
55 ActiveEon 55
Group of objects‘Group’
Typed group‘A’
getGroupByTypestatic method of class
ProActive
getGroupmethod of class
Group
Management
of the group
Functional use
of the group
Emil Salageanu
Two Representation Scheme
56 ActiveEon
groupAFunctional – has type ‘A’ : functional representation
A groupAFunctional = (A)ProActiveGroup.newGroup(“A”,{…})
groupAManagement – has type ‘Group’: management representation
Group groupAManagement = ProActiveGroup.getGroup(groupAFunctional);
groupAManagement.add(new A());
groupAManagement.add(new B()); //B inherits from A
A groupAFunctional_copy = (A)groupAManagement.getGroupeByType();
Variables groupAFunctional, groupAManagement, groupAFunctionalCopy reference the same group object
56
Emil Salageanu
Example
57 ActiveEon
pubic Class A {
public V foo(…) {…}
}
// Build a group of ACTIVE OBJECTS « A »
A ag = (A)ProActiveGroup.newGroup(“A”,{…}, Nodes)
V v=ag.foo(param);//invoked on each member
// Get the management representation of group vGroup vGroup = ProActiveGroup.getGroup(v );vGropup.addMember(……) ….
Emil Salageanu
Implementation
58 ActiveEon
Stub Class automatic generated
Stub inherits from the class of object
Stub connects a proxy
special proxy for group
result is stub+proxy
58
groupA.foo();
Stub A
Proxy for
group
groupA
Stub B
Proxy for
group
groupB
B groupB =
Emil Salageanu
Broadcast and Scatter
59 ActiveEon 59
JVM
JVM
JVM
JVM
agcg
ag.bar(cg); // broadcast cgProActive.setScatterGroup(cg);ag.bar(cg); // scatter cg
c1 c2c3c1 c2c3
c1 c2c3c1 c2c3
c1 c2c3
c1 c2c3
s
c1 c2c3
s
Broadcast is the default behavior Use a group as parameter, Scattered depends on rankings
Emil Salageanu
Handling Group Failures
60 ActiveEon 60
JVM
JVM
JVM
JVM
agvg
V vg = ag.foo (param);Group groupV = PAG.getGroup(vg);el = groupV.getExceptionList();...vg.gee();
failure
Except.
Except.List
Emil Salageanu
Active and Hierarchical Groups
Active Group: a group being a (Remote) Active Object
A group becomes remotely accessible Multiple coherent view of a single Group from several JVMs
Hierarchical group
A group that contains either standard objects, active objects or groups Dynamically built Achieves scalability
ActiveEon61 61
Emil Salageanu
Hierarchical Groups
62 ActiveEon
Add a typed group into a typed group vs. Adding an element in a group
Scalability of groups Can match the network topology
62
A
A
G1
G2
Emil Salageanu
Grid deployment
63 ActiveEon 63
grid frontal
cluster
clusterclustercluster
Emil Salageanu
Exercise 6
TODO Create a group object containing Monitoring Agents Use the functional representation of the group to perform monitoring actions Use the management representation of your group to add and remove agents
Exercise source package org.objectweb.proactive.examples.userguide.cmagent.groups
ProActive API org.objectweb.proactive.api.PAGroup org.objectweb.proactive.core.group.Group
64 ActiveEon
Use of ProActive Groups
Emil Salageanu
WEB SERVICESHands on programming
ActiveEon65
Emil Salageanu
Exercise 7
TODO Expose the Monitoring Agent as a Web Service Use a Web Service Client to perform a call on the Agent through the Web Service
Exercise source package org.objectweb.proactive.examples.userguide.cmagent.webservice
ProActive API org.objectweb.proactive.extensions.webservices.WebServices
66 ActiveEon
Expose the Monitoring agent as a Web Service
Emil Salageanu
DISTRIBUTED PRIMESHands on programming
ActiveEon67
Emil Salageanu
Exercise 8
TODO Use your Agent to perform computation: check if a candidate number has a divisor
in a given range You will have to transform your sequential application in a parallel/distributed one
Exercise source packages org.objectweb.proactive.examples.userguide.primes.sequential org.objectweb.proactive.examples.userguide.primes.distributed
ProActive API org.objectweb.proactive.api.PAFuture org.objectweb.proactive.core.util.wrapper.BooleanWrapper
68 ActiveEon
Distributed Prime Numbers
Emil Salageanu
MASTER-WORKERHands on programming
ActiveEon69
Emil SalageanuActiveEon70
C re a teS la ve 1
C re a teS la ve 2
C re a teS la ve 3
C re a teS la ve n
How it works ?
U s e r
D e p lo y m e nt D e s c rip to rM a s te r
S o lv eT a s k 1 ... T a s k M
p u b lic c la s s M yT a s k im p le m e n ts T a s k <S trin g >{
p ub l ic S trin g run () {re tu rn "H e llo W o rld !" ;
}}
T a s k D e fin itio n
S c he d uleT a s k 1
S c he d uleT a s k 2
S c he d uleT a s k 3
S c he d uleT a s k n
S e ndR e s ult1
S e ndR e s ult2
S e ndR e s ult3
S e ndR e s ultn
R e su lts
1 Res ult1
2 Res ult2
3 Res ult3
4 Res ult4
...
n Res ultn
...
MS c he d uleT a s k n+1
S la ve 1 S la ve 2 S la ve 3 S la ve n
R e s ult1 ... R e s ultM
Emil SalageanuActiveEon71
Creating/Terminating the Master
Local creation :
public ProActiveMaster();
Remote creation :
public ProActiveMaster(Node remoteNodeToUse);
public ProActiveMaster(URL descriptorURL, String masterVNName);
Termination :
public void terminate(boolean freeResources);
Emil SalageanuActiveEon72
Adding Resources
public void addResources(URL descriptorURL, String virtualNodeName);
public void addResources(VirtualNode virtualNode);
public void addResources(Collection<Node> nodes);
public void addResources(URL descriptorURL);
Emil SalageanuActiveEon73
Task Definition / Submission
Task definition :public interface Task<R extends Serializable> extends Serializable {
public R run(WorkerMemory memory) throws Exception;
}
Task submission : public void solve(List<T> tasks)
throws TaskAlreadySubmittedException;
Emil SalageanuActiveEon74
Retrieving the Results
Result reception order : public void setResultReceptionOrder(OrderingMode mode);
Blocking calls :public List<R> waitAllResults() throws TaskException;
public List<R> waitKResults(int k) throws TaskException;
public R waitOneResult() throws TaskException;
Non-Blocking calls :public boolean isEmpty();
public int countAvailableResults();
Emil SalageanuActiveEon75
Results reception order
CompletionOrder Mode
SubmissionOrder Mode
Emil Salageanu
Exercise 9
TODO Use the same algorithm as the one used at the previous exercise and the Master
Worker API to solve the Prime Number problem
Exercise source packages org.objectweb.proactive.examples.userguide.primes.distributedmw
ProActive API org.objectweb.proactive.extensions.masterworker.ProActiveMaster org.objectweb.proactive.extensions.masterworker.interfaces.Task
76 ActiveEon
Check Prime Numbers using the Master Worker Framework