Note: This FAQ is under construction.
If one of your question is not answered here, just send it at
<[email protected]>
and we'll update the FAQ.
A.1. Frequently Asked Questions |
|
A.1.1. |
How do I build ProActive from the distribution? |
ProActive uses
Ant for its build.
Assuming that the environment variable
If you want only to compile only parts of ProActive,
you should try /home/bob/ProActive/compile/$ build Buildfile: build.xml Main targets: ProActive Documentation.docs Construct the javadoc and the manual ProActive Documentation.javadoc.complete Make complete Javadoc ProActive Documentation.javadoc.published Make published Javadoc ProActive Documentation.manual Build all the different manual version: html, pdf... ProActive Documentation.manualHtml Make only the html files in the manual ProActive Documentation.manualPdf Make only the pdf files in the manual ProActive Documentation.manualSingleHtml Make only the big html file in the manual all build the class files and the documentation clean Remove all generated files compile Deprecated, see compile.all compile.all Build class files (ProActive + Extensions + Extra + Examples + Utils + Tests) compile.benchmarks Compile the benchmarks compile.core Compile ProActive core classes compile.examples Compile all examples classes compile.extensions Compile ProActive Extensions classes compile.extra Compile ProActive Extensions classes compile.stubGenerator Compile Stub Generator Classes compile.tests Compile functional and unit tests classes compile.trywithcatch Compile ProActive Try With Catch classes compile.util Compile ProActive Utils classes copyright_format Update Copyright and Version in every text files and format them core Deprecated, see compile.core deploy Populate dist/ with all needed file deploy.all Populate dist/ (with ProActive_examples.jar) deploy.examples Add examples.jar to the dist/ directory docs Construct the javadoc and the manual examples Deprecated, see compile.examples extensions Deprecated, see compile.extensions extra Deprecated, see compile.extra format hibernate's eclipse-based formatter ibis Everything related to ProActive IBIS ic2d.libClean Clean all needed libraries to IC2D ic2d.libCopy Copy all needed libraries to IC2D ic2dLib Deprecated, see ic2d.libCopy ic2dLibClean Deprecated, see ic2d.libClean javadoc.complete Make complete Javadoc javadoc.published Make published Javadoc jdepend JDepend report junit Run all non regression tests on the current host only junit.clover Same as junit but with code coverage enabled junit.distributed Run all non regression tests junit.emma Same as junit but with code coverage enabled manual Build all the different manual version: html, pdf... manualHtml Make only the html files in the manual manualPdf Make only the pdf files in the manual manualSingleHtml Make only the big html file in the manual microTimer Deprecated, see compile.microTimer proActiveJar Deprecated, see deploy release Source and Binary Releases release.all Source and Binary Releases release.bin Binary Release: dist + docs release.src Source Release: sources + docs runPerformanceTest Run performance test on the current host. stubGenerator Deprecated, see compile.stubGenerator update_copyright_and_version Update Copyright and Version in every text files uploadSchemas upload schemas on web site Default target: compile.all |
|
A.1.2. |
Why don't the examples and compilation work under Windows? |
It happens quite often, that the default installation directory under Windows is under Program Files which contains space. Then setting the JAVA_HOME environment variable to the install directory, might be a problem for bat files(all windows examples, and compilation are ran with bat files). To get rid of those problems, the best thing is to install jdk in a directory whose name does not contain spaces such as C:\java\j2sdk.... or D:\java\j2sdk... and then to set the JAVA_HOME environment variable accordingly: set JAVA_HOME=C:\java\j2sdk... Another solution is to do a copy paste of the command defined in the bat file in the DOS window. |
|
A.1.3. |
Why do I get a Permission denied when trying to launch examples scripts under Linux? |
According to the tool used to unpackage the ProActive distribution, permissions of newly created files can be based on default UMASK permissions. If you get a permission denied, just run the command: chmod 755 *.sh in the ProActive/scripts/unix directory in order to change the permissions. |
|
A.1.4. |
How does the node creation happen? |
An active object is always attached to a node. A node
represents a logical entity deployed onto one JVM. When creating a
new active object you have to provide a URL or a reference to a
node. That node has to exist at the moment you create the active
object. It has to be launched on a local or on a remote JVM. In
order to be accessible from any remote JVM, a node automatically
registers itself in the local RMI Registry on the local machine.
Getting a reference to a remote node ends up doing a lookup into a
RMI registry. The class In order to start a node you can use the script
It is nevertheless possible to create an object on a remote node once it is created. On host X you can use startNode to start a new node startNode.sh ///node1 On host Y you can create an active object on host X org.objectweb.proactive.core.node.Node n = org.objectweb.proactive.core.n\ ode.NodeFactory.getNode('//X/node1'); PAActiveObject.turnActive(myObject, n); You do not need to start any rmiregistry manually as they are started automatically as needed. As we support other ways of registration and discovery (such
as Jini), getting a node can be protocol dependant. For instance,
the url of a node When an active object is created locally without specifying a node, it is automatically attached to a default node. The default node is created automatically by ProActive on the local JVM when a first active object is created without a given node. The name of the default node is generated based on a random number. |
|
A.1.5. |
How does the RMI Registry creation happen? |
ProActive relies on the RMI Registry for registering and discovering nodes. For this reason, the existence of a RMI Registry is necessary for ProActive to be used. In order to simplify the deployment of ProActive applications, we have included the creation of the RMI Registry with the creation of nodes. Therefore, if no RMI Registry exists on the local machine, ProActive will automatically create one. If one exists, ProActive will automatically use it. |
|
A.1.6. |
What is the class server, why do we need it? |
In the RMI model, a class server is a HTTP Server able to
answer simple HTTP requests for getting class files. It is needed in
the case an object being sent to a remote location where the class
the object belongs to is unknown. In such case, if the property
Because ProActive makes use of on-the-fly, in memory, generated classes (the stubs), a class server is necessary for each JVM using active objects. For this reason, ProActive starts automatically one small class server per JVM. The launching and the use of this class server is transparent to you. |
|
A.1.7. |
What is a reifiable object? |
An object is said to be reifiable if it meets certain criterias in order to become an Active Object:
|
|
A.1.8. |
What is the body of an active object? What are its local and remote representations? |
When created, an active object is associated with a Body that is the entity managing all the non functional properties of the active object. The body contains the request queue receiving all reified method calls to the reified object (the object from which the active object has been created). It is responsible for storing pending requests and serving them according to a given synchronization policy, which default behavior is FIFO. The body of the active object should be the only object able to access directly the reified object. All other objects accessing the active object do so through the stub-proxy couple that eventually sends a request to the body. The body owns its own thread that represent the activity of the active object. The body has two representations. One is local and given by
the interface public interface Body extends LocalBodyStrategy, UniversalBody { /** * Returns whether the body is alive or not. The body is alive as long as it is processing * request and reply * * @return whether the body is alive or not. */ public boolean isAlive(); /** * Returns whether the body is active or not. The body is active as long as it has an associated * thread running to serve the requests by calling methods on the active object. * * @return whether the body is active or not. */ public boolean isActive(); /** * To avoid some causal ordering corruptions, the body can be temporarly set as <i>sterile</i>. * Then, it will not be able to send any request, except to himself and to its parent. Such * restriction should be necessary when sending multiple requests in parallel. * * @see org.objectweb.proactive.core.body.proxy.SendingQueue * @param isSteril * @param parentUID */ public void setSterility(boolean isSterile, UniqueID parentUID); /** * Get the sterility status of the body * * @see org.objectweb.proactive.core.body.proxy.SendingQueue * @return the sterility status */ public boolean isSterile(); /** * Get the parent UniqueID of the body * * @see org.objectweb.proactive.core.body.proxy.SendingQueue * @return the parent UniqueID */ public UniqueID getParentUID(); /** * blocks all incoming communications. After this call, the body cannot receive any request or * reply. */ public void blockCommunication(); /** * Signals the body to accept all incoming communications. This call undo a previous call to * blockCommunication. */ public void acceptCommunication(); /** * Allows the calling thread to enter in the ThreadStore of this body. */ public void enterInThreadStore(); /** * Allows the calling thread to exit from the ThreadStore of this body. */ public void exitFromThreadStore(); /** * Tries to find a local version of the body of id uniqueID. If a local version is found it is * returned. If not, tries to find the body of id uniqueID in the known body of this body. If a * body is found it is returned, else null is returned. * * @param uniqueID * the id of the body to lookup * @return the last known version of the body of id uniqueID or null if not known */ public UniversalBody checkNewLocation(UniqueID uniqueID); /** * Returns the MBean associated to this active object. * * @return the MBean associated to this active object. */ public BodyWrapperMBean getMBean(); /** * Returns the body that is the target of this shortcut for this component interface * * @param functionalItfID * the id of the interface on which the shortcut is available * @return the body that is the target of this shortcut for this interface */ public UniversalBody getShortcutTargetBody(ItfID functionalItfID); // /** // * set the policy server of the active object // * @param server the policy server // */ // public void setPolicyServer(PolicyServer server); /** * Set the nodeURL of this body * * @param newNodeURL * the new URL of the node */ public void updateNodeURL(String newNodeURL); /** * For setting an immediate service for this body. An immediate service is a method that will bw * excecuted by the calling thread. */ public void setImmediateService(String methodName); /** * Removes an immediate service for this body An immediate service is a method that will bw * excecuted by the calling thread. * * @param methodName * the name of the method * @param parametersTypes * the types of the parameters of the method */ public void removeImmediateService(String methodName); /** * Adds an immediate service for this body An immediate service is a method that will bw * excecuted by the calling thread. * * @param methodName * the name of the method * @param parametersTypes * the types of the parameters of the method */ public void setImmediateService(String methodName, Class<?>[] parametersTypes); /** * Removes an immediate service for this body An immediate service is a method that will bw * excecuted by the calling thread. * * @param methodName * the name of the method * @param parametersTypes * the types of the parameters of the method */ public void removeImmediateService(String methodName, Class<?>[] parametersTypes); /** * Sets the ForgetOnSend strategy when sending a request <i>methodName</i> to <i>activeObject</i>. * @param activeObject * the destination * @param methodName * the name of the method */ public void setForgetOnSendRequest(Object activeObject, String methodName); /** * Remove the ForgetOnSend setting attached to the given <i>methodName</i> for the given <i>activeObject</i> * @param activeObject * the destination * @param methodName * the name of the method */ public void removeForgetOnSendRequest(Object activeObject, String methodName); /** * Terminate the body. After this call the body is no more alive and no more active. The body is * unuseable after this call. If some automatic continuations are registred in the futurepool of * this body, the ACThread will be killed when the last registred AC is sent. */ public void terminate(); /** * @see terminate(). If completeACs is true, this call has the same behavior than terminate(). * Otherwise, the ACThread is killed even if some ACs remain in the futurepool. * @param completeACs * if true, this call has the same behavior than terminate(). Otherwise, the ACThread * is killed even if some ACs remain in the futurepool. */ public void terminate(boolean completeACs); /** * Checks if a method methodName is declared by the reified object AND the method has the same * parameters as parametersTypes Note that the called method should be <i>public</i>, since * only the public methods can be called on an active object. Note also that a call to * checkMethod(methodName, null) is different to a call to checkMethod(methodName, new Class[0]) * The former means that no checking is done on the parameters, whereas the latter means that we * look for a method with no parameters. * * @param methodName * the name of the method * @param parametersTypes * an array of parameter types * @return true if the method exists, false otherwise */ public boolean checkMethod(String methodName, Class<?>[] parametersTypes); /** * Checks if a method methodName is declared by the reified object Note that the called method * should be <i>public</i>, since only the public methods can be called on an active object. * Note that this call is strictly equivalent to checkMethod(methodName, null); * * @param methodName * the name of the method * @return true if the method exists, false otherwise */ public boolean checkMethod(String methodName); public void registerIncomingFutures(); } This is the
local view of the body an object can have when being in the same JVM
as the body. For instance, the implementation of the activity of an
object done through the method public interface UniversalBody extends Job, Serializable, SecurityEntity { public static Logger bodyLogger = ProActiveLogger.getLogger(Loggers.BODY); public static Logger sendReplyExceptionsLogger = ProActiveLogger.getLogger(Loggers.EXCEPTIONS_SEND_REPLY); /** * Receives a request for later processing. The call to this method is non blocking * unless the body cannot temporary receive the request. * @param request the request to process * @exception java.io.IOException if the request cannot be accepted * @return value for fault-tolerance protocol */ public int receiveRequest(Request request) throws java.io.IOException, RenegotiateSessionException; /** * Receives a reply in response to a former request. * @param r the reply received * @exception java.io.IOException if the reply cannot be accepted * @return value for fault-tolerance procotol */ public int receiveReply(Reply r) throws java.io.IOException; /** * Returns the url of the node this body is associated to * The url of the node can change if the active object migrates * @return the url of the node this body is associated to */ public String getNodeURL(); /** * Returns the UniqueID of this body * This identifier is unique accross all JVMs * @return the UniqueID of this body */ public UniqueID getID(); /** * Signals to this body that the body identified by id is now to a new * remote location. The body given in parameter is a new stub pointing * to this new location. This call is a way for a body to signal to his * peer that it has migrated to a new location * @param id the id of the body * @param body the stub to the new location * @exception java.io.IOException if a pb occurs during this method call */ public void updateLocation(UniqueID id, UniversalBody body) throws java.io.IOException; /** * similar to the {@link UniversalBody#updateLocation(org.objectweb.proactive.core.UniqueID, UniversalBody)} method, * it allows direct communication to the target of a functional call, accross membranes of composite components. * @param shortcut the shortcut to create * @exception java.io.IOException if a pb occurs during this method call */ public void createShortcut(Shortcut shortcut) throws java.io.IOException; /** * Returns the remote friendly version of this body * @return the remote friendly version of this body */ public UniversalBody getRemoteAdapter(); /** * Returns the name of the class of the reified object * @return the name of the class of the reified object */ public String getReifiedClassName(); /** * Enables automatic continuation mechanism for this body * @exception java.io.IOException if a pb occurs during this method call */ public void enableAC() throws java.io.IOException; /** * Disables automatic continuation mechanism for this body * @exception java.io.IOException if a pb occurs during this method call */ public void disableAC() throws java.io.IOException; // FAULT TOLERANCE /** * For sending a non fonctional message to the FTManager linked to this object. * @param ev the message to send * @return depends on the message meaning * @exception java.io.IOException if a pb occurs during this method call */ public Object receiveFTMessage(FTMessage ev) throws IOException; /** * The DGC broadcasting method, called every GarbageCollector.TTB between * referenced active objects. The GC{Message,Response} may actually be * composed of many GCSimple{Message,Response}. * * @param toSend the message * @return its associated response * @throws IOException if a pb occurs during this method call */ public GCResponse receiveGCMessage(GCMessage toSend) throws IOException; /** * Inform the DGC that an active object is pinned somewhere so cannot * be garbage collected until being unregistered. * @param registered true for a registration, false for an unregistration * @throws IOException if a pb occurs during this method call */ public void setRegistered(boolean registered) throws IOException; /** * Allow to specify an url where to register the active object. * @param url the url where to bind the active object * @throws IOException * @throws UnknownProtocolException thrown if the protocol is not supported by * the current active object */ public void register(String url) throws IOException, UnknownProtocolException; } |
|
A.1.9. |
What is a ProActive stub? |
When you create an active object from a regular object, you
get in return a reference on an automatically generated
ProActive stub.
ProActive uses
ASM to generate the stub on
the fly. Suppose you have a class A a = new A(); A activeA = (A) PAActiveObject.turnActive(a); In the code above, the variable The reified object can be indifferently in the same virtual machine as the active reference or in another one. |
|
A.1.10. |
Are the call to an Active Object always asynchronous? |
No. Calls to an Active Object methods are asynchronous under some conditions. This is explained in Section 9.7, “Asynchronous calls and futures”. If for instance the return type of a method call is not reifiable, you can use wrappers to keep asynchronism capabilities: suppose that one of your object has a method int getNumber() calling this method with ProActive is sychronous since the 'int'
type is not reifiable. To keep the asynchronism it is advised to
use the classes given in the
IntWrapper getNumber() Then calling this new |
|
A.1.11. |
Why do I get an exception java.lang.NoClassDefFoundError about asm? |
ProActive uses ASM for the on the fly
generation of stub classes. The library Exception in thread 'main' java.lang.NoClassDefFoundError: org/objectweb/asm/Constants at java.lang.ClassLoader.defineClass0(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:509) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123) at java.net.URLClassLoader.defineClass(URLClassLoader.java:246) at java.net.URLClassLoader.access$100(URLClassLoader.java:54) at java.net.URLClassLoader$1.run(URLClassLoader.java:193) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:186) at java.lang.ClassLoader.loadClass(ClassLoader.java:306) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:265) at java.lang.ClassLoader.loadClass(ClassLoader.java:262) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:322) at org.objectweb.proactive.core.mop.MOP.<clinit>(MOP.java:88) at org.objectweb.proactive.MOP.createStubObject(MOP.java:836) at org.objectweb.proactive.MOP.createStubObject(MOP.java:830) at org.objectweb.proactive.PAActiveObject.newActive(PAActiveObject.java:255) at org.objectweb.proactive.PAActiveObject.newActive(PAActiveObject.java:180) at org.objectweb.proactive.examples.binarytree.TreeApplet.main(TreeApplet.java:103) The problem can simply be fixed by adding asm |
|
A.1.12. |
Why do I get an exception java.lang.NoClassDefFoundError about bcel? |
ProActive uses BCEL for the on the
fly generation of stub classes. The library
Exception in thread 'main' java.lang.NoClassDefFoundError: org/apache/bcel/generic/Type at org.objectweb.proactive.core.mop.MOPClassLoader.loadClass(MOPClassLoader.java:129) at org.objectweb.proactive.core.mop.MOPClassLoader.loadClass(MOPClassLoader.java:109) at org.objectweb.proactive.core.mop.MOP.createStubClass(MOP.java:341) at org.objectweb.proactive.core.mop.MOP.findStubConstructor(MOP.java:376) at org.objectweb.proactive.core.mop.MOP.createStubObject(MOP.java:443) at org.objectweb.proactive.core.mop.MOP.newInstance(MOP.java:165) at org.objectweb.proactive.core.mop.MOP.newInstance(MOP.java:137) at org.objectweb.proactive.MOP.createStubObject(MOP.java:590) at org.objectweb.proactive.MOP.createStubObject(MOP.java:585) at org.objectweb.proactive.PAActiveObject.newActive(PAActiveObject.java:170) at org.objectweb.proactive.PAActiveObject.newActive(PAActiveObject.java:137) at DiscoveryManager.main(DiscoveryManager.java:226) The problem can simply be fixed by adding
|
|
A.1.13. |
Why do I get an exception java.security.AccessControlException access denied? |
If you don't properly set permissions when launching code using ProActive you may get the following exception or a similar one. java.security.AccessControlException: access denied (java.net.SocketPermission 127.0.0.1:1099 connect,resolve) at java.security.AccessControlContext.checkPermission(AccessControlContext.java:270) at java.security.AccessController.checkPermission(AccessController.java:401) at java.lang.SecurityManager.checkPermission(SecurityManager.java:542) at java.lang.SecurityManager.checkConnect(SecurityManager.java:1044) at java.net.Socket.connect(Socket.java:419) at java.net.Socket.connect(Socket.java:375) at java.net.Socket.<init>(Socket.java:290) at java.net.Socket.<init>(Socket.java:118) at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSocketFactory.java:22) at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMasterSocketFactory.java:122) at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:562) at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:185) at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:171) at sun.rmi.server.UnicastRef.newCall(UnicastRef.java:313) at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source) at org.objectweb.proactive.core.rmi.RegistryHelper.detectRegistry(RegistryHelper.java:101) at org.objectweb.proactive.core.rmi.RegistryHelper.getOrCreateRegistry(RegistryHelper.java:114) at org.objectweb.proactive.core.rmi.RegistryHelper.initializeRegistry(RegistryHelper.java:77) at org.objectweb.proactive.core.node.rmi.RemoteNodeFactory(RemoteNodeFactory.java:56) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:274) at java.lang.Class.newInstance0(Class.java:296) at java.lang.Class.newInstance(Class.java:249) at org.objectweb.proactive.core.node.NodeFactory.createNodeFactory(NodeFactory.java:281) at org.objectweb.proactive.core.node.NodeFactory.createNodeFactory(NodeFactory.java:298) at org.objectweb.proactive.core.node.NodeFactory.getFactory(NodeFactory.java:308) at org.objectweb.proactive.core.node.NodeFactory.createNode(NodeFactory.java:179) at org.objectweb.proactive.core.node.NodeFactory.createNode(NodeFactory.java:158) ... ProActive uses
RMI as its
underlying transport technology. Moreover it uses code downloading
features to automatically move generated stub classes from one JVM
to another one. For those reasons, ProActive needs to install a
See Permissions in the JavaTM 2 SDK to learn more about Java permissions. As a first approximation, in order to run your code, you can create a simple policy file granting all permissions for all code: grant { permission java.security.AllPermission; }; Then you need to start your Java program using the property
java -Djava.security.policy=my.policy.file MyMainClass |
|
A.1.14. |
Why do I get an exception when using Jini? |
In order to get Jini working properly in ProActive, you have to put in your HOME directory a copy of proactive.java.policy located in ProActive/scripts/unix or windows. Indeed the rmid deamon needs this file to start. If you try to use Jini without this policy file, it will not work. Moreover, if you did it once, make sure that there is no file called machine_namejiniLockFile in your working directory. This file is usefull to avoid many Service Lookup to be created by concurrent threads. This file is removed automatically when a Lookup Service is created. If the application failed(for instance because of the policy file) it is possible that this file remains in the directory, in that case if you restart the application it will not work. So checkout if this file is present in your working directory, if so remove it and restart the application |
|
A.1.15. |
Why do I get a java.rmi.ConnectException: Connection refused to host: 127.0.0.1 ? |
Sometimes, the hosts files ( -Dsun.net.spi.nameservice.provider.1=dns,sun" This tells java not to look at the hosts file, but rather to ask the DNS for network information. |
|
A.1.16. |
Why aren't my object's properties updated? |
Suppose you have a class public class A { public int a1; public static void main(String[] args) { A a = new A(); A activeA = (A) PAActiveObject.turnActive(a); a.a1 = 2; // set the attribute a1 of the instance pointed by a to 2 activeA.a1 = 2; // !!! set the attribute a1 of the stub instance to 2 } } When you reference an active object, you always reference it through its associated stub (see Section 9.6, “ Elements of an active object and futures ” for the definition of Stub). The stub class inheriting from the reified class, it has also all its attributes. But those attributes are totally useless as the only role of the generated stub is to reify every public methods call into a request passed to the associated proxy. Therefore accessing directly the attributes of an active object through its active reference would result in accessing the attributes of the generated stub. This is certainly not the behavior one would expect. The solution to this problem is very simple: active object properties should only be accessed through a public method. Otherwise, you're accessing the local Stub's properties. |
|
A.1.17. |
How can I pass a reference on an active object or the difference between this and PAActiveObject.getStubOnThis()? |
Suppose you have a class public class A { public A getRef() { return this; // !!!! THIS IS WRONG FOR AN ACTIVE OBJECT } } There is indeed a problem in the code above. If an instance of
The solution, if you want to pass a link to the active object
from the code of the reified object, is to use the method
public class A { public A getRef() { return PAActiveObject.getStubOnThis(); // returns a reference on the stub } } |
|
A.1.18. |
How can I create an active object? |
To create an active object you invoke one of the methods
Here is a simple example creating an active object of class
public class A { private int i; private String s; public A() {} public A(int i, String s) { this.i = i; this.s = s; } } // instance based creation A a; Object[] params = new Object[] { new Integer (26), 'astring' }; try { a = (A) PAActiveObject.newActive(A.class.getName(), params); } catch (ActiveObjectCreationException e) { // creation of ActiveObject failed e.printStackTrace(); } // object based creation A a = new A(26, 'astring'); try { a = (A) PAActiveObject.turnActive(a); } catch (ActiveObjectCreationException e) { // creation of ActiveObject failed e.printStackTrace(); } |
|
A.1.19. |
What are the differences between instantiation based and object based active objects creation? |
In ProActive there are two
ways to create active objects. One way is to use
When using instantiation based creation, any argument passed
to the constructor of the reified object through
When using object based creation, you create the object that
is going to be reified as an active object before hand. Therefore
there is no serialization involved when you create the object. When
you invoke |
|
A.1.20. |
Why do I have to write a no-args constructor? |
ProActive automatically creates a stub/skeleton pair for your active objects. When the stub is instancied on the remote node, its constructor ascends the ancestors chain, thus calling its parent constructor [the active object]. So if you place initialization stuff in your no args constructor, it will be executed on the stub, which can lead to disastrous results! |
|
A.1.21. |
|
As explained in Section 9.5.4, “Using A Custom Activity”, there are two ways to define the activity of your active object
Implementing the interfaces directly in the class used to create the active object This is the easiest solution when you do control the class
that you make active. Depending on which phase in the life of the
active object you want to customize, you implement the corresponding
interface (one or more) amongst import org.objectweb.proactive.*; public class A implements InitActive, RunActive { private String myName; public String getName() { return myName; } // -- implements InitActive public void initActivity(Body body) { myName = body.getName(); } // -- implements RunActive for serving request in a LIFO fashion public void runActivity(Body body) { Service service = new Service(Body); while (body.isActive()) { service.blockingServeYoungest(); } } public static void main(String[] args) throws Exception { A a = (A) PAActiveObject.newActive(A.class.getName,null); System.out.println('Name = '+a.getName()); } } Passing an object implementing the interfaces when creating the active object This is the solution to use when you do not control the class
that you make active or when you want to write generic activities
policy and reused them with several active objects. Depending on
which phase in the life of the active object you want to customize,
you implement the corresponding interface (one or more) amongst
Compared to the solution above where interfaces are directly implemented in the reified class, there is one restriction here: you cannot access the internal state of the reified object. Using an external object should therefore be used when the implementation of the activity is generic enough not to have to access the member variables of the reified object. import org.objectweb.proactive.*; public class LIFOActivity implements RunActive { // -- implements RunActive for serving request in a LIFO fashion public void runActivity(Body body) { Service service = new Service(Body); while (body.isActive()) { service.blockingServeYoungest(); } } } import org.objectweb.proactive.*; public class A implements InitActive { private String myName; public String getName() { return myName; } // -- implements InitActive public void initActivity(Body body) { myName = body.getName(); } public static void main(String[] args) throws Exception { // newActive(classname, constructor parameter (null = none), // node (null = local), active, MetaObjectFactory (null = d\ efault) A a = (A) PAActiveObject.newActive(A.class.getName(), null, null, new LIFO\ Activity(), null); System.out.println('Name = '+a.getName()); } } |
|
A.1.22. |
What happened to the former live() method and Active interface? |
The former public interface MetaObjectFactory { /** * Creates or reuses a RequestFactory * @return a new or existing RequestFactory * @see RequestFactory */ public RequestFactory newRequestFactory(); /** * Creates or reuses a ReplyReceiverFactory * @return a new or existing ReplyReceiverFactory * @see ReplyReceiverFactory */ public ReplyReceiverFactory newReplyReceiverFactory(); /** * Creates or reuses a RequestReceiverFactory * @return a new or existing RequestReceiverFactory * @see RequestReceiverFactory */ public RequestReceiverFactory newRequestReceiverFactory(); /** * Creates or reuses a RequestQueueFactory * @return a new or existing RequestQueueFactory * @see RequestQueueFactory */ public RequestQueueFactory newRequestQueueFactory(); /** * Creates or reuses a MigrationManagerFactory * @return a new or existing MigrationManagerFactory * @see MigrationManagerFactory */ public MigrationManagerFactory newMigrationManagerFactory(); // /** // * Creates or reuses a RemoteBodyFactory // * @return a new or existing RemoteBodyFactory // * @see RemoteBodyFactory // */ // public RemoteBodyFactory newRemoteBodyFactory(); /** * Creates or reuses a ThreadStoreFactory * @return a new or existing ThreadStoreFactory * @see ThreadStoreFactory */ public ThreadStoreFactory newThreadStoreFactory(); // GROUP /** * Creates or reuses a ProActiveGroupManagerFactory * @return a new ProActiveGroupManagerFactory */ public ProActiveSPMDGroupManagerFactory newProActiveSPMDGroupManagerFactory(); /** * creates a ProActiveComponentFactory * @return a new ProActiveComponentFactory */ // COMPONENTS public ProActiveComponentFactory newComponentFactory(); /** Creates a DebuggerFactory * @return a new DebuggerFactory */ public DebuggerFactory newDebuggerFactory(); /** * accessor to the parameters of the factory (object-based configurations) * @return the parameters of the factory */ // COMPONENTS public Map<String, Object> getParameters(); //SECURITY /** * Creates the ProActiveSecurityManager * @return a new ProActiveSecurityManager * @see ProActiveSecurityManager */ public ProActiveSecurityManager getProActiveSecurityManager(); public void setProActiveSecurityManager(ProActiveSecurityManager psm); public Object clone() throws CloneNotSupportedException; // FAULT-TOLERANCE /** * Creates the fault-tolerance manager. * @return the fault-tolerance manager. */ public FTManagerFactory newFTManagerFactory(); // TIMING /** * A setter for the reductor. * @param timitReductor */ public void setTimItReductor(Object timItReductor); /** * A getter for the reductor stub. * @return The stub on the reductor */ public Object getTimItReductor(); } Up to ProActive 0.9.3 the
activity of an active object was given by a method
In order to convert the code of an active object containing a
method
|
|
A.1.23. |
Why should I avoid to return null in methods body? |
On the caller side the test if(result_from_method == null) has no sense. Indeed result_from_method is a couple Stub-FutureProxy as explained above, so even if the method returns null, result_from_method cannot be null: public class MyObject{ public MyObject(){ //empty constructor with no-args } public Object getObject{ if(.....) { return new Object(); } else { return null; --> to avoid in ProActive } } } On the caller side: MyObject o = new MyObject(); Object result_from_method = o.getObject(); if(result_from_method == null){ ...... } This test is never true, indeed, result_from_method is Stub-->Proxy-->null if the future is not yet available or the method returns null or Stub-->Proxy-->Object if the future is available, but result_from_method is never null. See Documentation on Futures in Section 9.7.4, “Good ProActive programming practices” for more documentation about common errors to avoid. |
|
A.1.24. |
How can I use Jini in ProActive? |
In order to use Jini in ProActive you have to configure properly the deployment descriptor. All informations on how to configure XML deployment descriptor are provided in Chapter 19, XML Deployment Descriptors. |
|
A.1.25. |
How do I make a Component version out of an Active Object version? |
There is such an example, in the examples/components/c3d directory. The code for c3d is adapted to use components. There are several steps to cover:
|
|
A.1.26. |
How can I use Jini in ProActive? |
In order to use Jini in ProActive you have to configure properly the deployment descriptor. All informations on how to configure XML deployment descriptor are provided in Chapter 19, XML Deployment Descriptors. |
|
A.1.27. |
Why is my call not asynchronous? |
ProActive allows to have asynchronous code, in the following cases:
More explanations can be found in Section 9.7, “Asynchronous calls and futures”. |
|
A.1.28. |
What is the difference between passing parameters in Deployment Descriptor and setting properties in ProActive Configuration file? |
Parameters defined in Deployment Descriptor should be only jvm related, whereas properties set in the Configuration file are ProActive properties or user-defined properties. They are used with a different approach: parameters given in descriptors are part of the java command that will create other jvms, whereas properties will be loaded once jvms are created |
|
A.1.29. |
Why do I get the following message when parsing my xml deployment file: ERROR: file:~/ProActive/descriptor.xml Line:2 Message:cvc-elt.1: Cannot find the declaration of element 'ProActiveDescriptor' |
This message turns up because the Schema cannot be found. Indeed at the beginning of our XML deployment files we put the line <ProActiveDescriptor xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:noNamespaceSchemaLocation='DescriptorSchema.xsd'> which means, the schema named DescriptorSchema.xsd is expected to be found in the current directory to validate the xml. Be sure you have this file in the same dir than your file, or just change the path to point to the correct schema. |
© 1997-2008 INRIA Sophia Antipolis All Rights Reserved