org/objectweb/proactive/branchnbound/ProActiveBranchNBound.java

00001 /* 
00002  * ################################################################
00003  * 
00004  * ProActive: The Java(TM) library for Parallel, Distributed, 
00005  *            Concurrent computing with Security and Mobility
00006  * 
00007  * Copyright (C) 1997-2007 INRIA/University of Nice-Sophia Antipolis
00008  * Contact: proactive@objectweb.org
00009  * 
00010  * This library is free software; you can redistribute it and/or
00011  * modify it under the terms of the GNU Lesser General Public
00012  * License as published by the Free Software Foundation; either
00013  * version 2.1 of the License, or any later version.
00014  *  
00015  * This library is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018  * Lesser General Public License for more details.
00019  * 
00020  * You should have received a copy of the GNU Lesser General Public
00021  * License along with this library; if not, write to the Free Software
00022  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
00023  * USA
00024  *  
00025  *  Initial developer(s):               The ProActive Team
00026  *                        http://www.inria.fr/oasis/ProActive/contacts.html
00027  *  Contributor(s): 
00028  * 
00029  * ################################################################
00030  */ 
00031 package org.objectweb.proactive.branchnbound;
00032 
00033 import org.apache.log4j.Logger;
00034 import org.objectweb.proactive.ActiveObjectCreationException;
00035 import org.objectweb.proactive.ProActive;
00036 import org.objectweb.proactive.branchnbound.core.Manager;
00037 import org.objectweb.proactive.branchnbound.core.Task;
00038 import org.objectweb.proactive.branchnbound.core.queue.TaskQueue;
00039 import org.objectweb.proactive.core.config.ProActiveConfiguration;
00040 import org.objectweb.proactive.core.descriptor.data.VirtualNode;
00041 import org.objectweb.proactive.core.node.Node;
00042 import org.objectweb.proactive.core.node.NodeException;
00043 import org.objectweb.proactive.core.node.NodeFactory;
00044 import org.objectweb.proactive.core.util.log.Loggers;
00045 import org.objectweb.proactive.core.util.log.ProActiveLogger;
00046 
00047 
00060 public class ProActiveBranchNBound {
00061     private static Logger logger = ProActiveLogger.getLogger(Loggers.P2P_SKELETONS);
00062 
00063     static {
00064         // Loading the ProActive's configuration
00065         ProActiveConfiguration.load();
00066     }
00067 
00068     // -------------------------------------------------------------------------
00069     // Manager static constructor
00070     // -------------------------------------------------------------------------
00071 
00091     public static Manager newBnB(Task root, Node managerNode, Node[] nodes,
00092         String queueType) throws ActiveObjectCreationException, NodeException {
00093         Object[] args = new Object[4];
00094         args[0] = root;
00095         args[1] = managerNode;
00096         args[2] = nodes;
00097         args[3] = queueType;
00098         return ProActiveBranchNBound.activingTheManager(args);
00099     }
00100 
00121     public static Manager newBnB(Task root, VirtualNode virtualNode,
00122         String queueType) throws ActiveObjectCreationException, NodeException {
00123         virtualNode.activate();
00124         Object[] args = new Object[4];
00125         args[0] = root;
00126         args[1] = null;
00127         args[2] = virtualNode.getNodes();
00128         args[3] = queueType;
00129         return ProActiveBranchNBound.activingTheManager(args);
00130     }
00131 
00154     public static Manager newBnB(Task root, Node managerNode, Node[][] nodes,
00155         String queueType) throws ActiveObjectCreationException, NodeException {
00156         Object[] args = new Object[4];
00157         args[0] = root;
00158         args[1] = managerNode;
00159         args[2] = nodes;
00160         args[3] = queueType;
00161         return ProActiveBranchNBound.activingTheManager(args);
00162     }
00163 
00190     public static Manager newBnB(Task root, VirtualNode[] virtualNodes,
00191         String queueType) throws ActiveObjectCreationException, NodeException {
00192         Object[] args = new Object[4];
00193         args[0] = root;
00194         args[1] = null;
00195         args[2] = virtualNodes;
00196         args[3] = queueType;
00197         return ProActiveBranchNBound.activingTheManager(args);
00198     }
00199 
00200     // -------------------------------------------------------------------------
00201     // Private methods
00202     // -------------------------------------------------------------------------
00203 
00226     private static Manager activingTheManager(Object[] args)
00227         throws ActiveObjectCreationException, NodeException {
00228         assert args.length == 4 : args;
00229         if (logger.isDebugEnabled()) {
00230             logger.debug("New Active Manager with these arguments:\n" + "\t" +
00231                 args[0].getClass().getName() + "\n" + "\t" +
00232                 args[1].getClass().getName() + "\n" + "\t" +
00233                 args[2].getClass().getName() + "\n" + "\t" +
00234                 args[3].getClass().getName() + "\n");
00235         }
00236         assert args[0] instanceof Task : args[0];
00237         args[1] = (args[1] == null) ? NodeFactory.getDefaultNode()
00238                                     : (Node) args[1];
00239         assert args[1] instanceof Node : args[1];
00240         assert args[2] instanceof Node[] || args[2] instanceof Node[][] ||
00241         args[2] instanceof VirtualNode[] : args[2];
00242         assert args[3] instanceof String : args[3];
00243 
00244         return (Manager) ProActive.newActive(Manager.class.getName(), args,
00245             (Node) args[1]);
00246     }
00247 }

Generated on Mon Jan 22 15:16:05 2007 for ProActive by  doxygen 1.5.1