org/objectweb/proactive/core/component/controller/MigrationControllerImpl.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.core.component.controller;
00032 
00033 import java.net.URL;
00034 
00035 import org.objectweb.fractal.api.Component;
00036 import org.objectweb.fractal.api.factory.InstantiationException;
00037 import org.objectweb.fractal.api.type.TypeFactory;
00038 import org.objectweb.proactive.ProActive;
00039 import org.objectweb.proactive.core.ProActiveRuntimeException;
00040 import org.objectweb.proactive.core.body.migration.MigrationException;
00041 import org.objectweb.proactive.core.component.Constants;
00042 import org.objectweb.proactive.core.component.identity.ProActiveComponentImpl;
00043 import org.objectweb.proactive.core.component.type.ProActiveTypeFactoryImpl;
00044 import org.objectweb.proactive.core.node.Node;
00045 import org.objectweb.proactive.core.node.NodeException;
00046 import org.objectweb.proactive.core.node.NodeFactory;
00047 
00048 
00049 public class MigrationControllerImpl extends AbstractProActiveController
00050     implements MigrationController {
00051     public MigrationControllerImpl(Component owner) {
00052         super(owner);
00053     }
00054 
00055     @Override
00056     protected void setControllerItfType() {
00057         try {
00058             setItfType(ProActiveTypeFactoryImpl.instance()
00059                                                .createFcItfType(Constants.MIGRATION_CONTROLLER,
00060                     MigrationController.class.getName(), TypeFactory.SERVER,
00061                     TypeFactory.MANDATORY, TypeFactory.SINGLE));
00062         } catch (InstantiationException e) {
00063             throw new ProActiveRuntimeException(
00064                 "cannot create controller type for controller " +
00065                 this.getClass().getName());
00066         }
00067     }
00068 
00069     public void migrateTo(Node node) throws MigrationException {
00070         // need to migrate gathercast futures handlers active objects first
00071         ((ProActiveComponentImpl)owner).migrateControllersDependentActiveObjectsTo(node);
00072         ProActive.migrateTo(node);
00073     }
00074 
00075     public void migrateTo(URL url) throws MigrationException {
00076         try {
00077             migrateTo(NodeFactory.getNode(url.toString()));
00078         } catch (NodeException e) {
00079             throw new MigrationException("Cannot find node with URL " + url);
00080         }
00081     }
00082 
00083     public void migrateTo(String stringUrl) throws MigrationException {
00084         try {
00085             migrateTo(NodeFactory.getNode(stringUrl));
00086         } catch (NodeException e) {
00087             throw new MigrationException("Cannot find node with URL " +
00088                 stringUrl);
00089         }
00090     }
00091 }

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