View Javadoc

1   /*
2    * Created on Mar 7, 2005
3    *
4    * TODO To change the template for this generated file go to
5    * Window - Preferences - Java - Code Style - Code Templates
6    */
7   package jgroup.experiment.runnables;
8   
9   import jgroup.core.ConfigurationException;
10  import jgroup.core.registry.DependableRegistry;
11  import jgroup.core.registry.RegistryFactory;
12  import jgroup.experiment.PropertyDefinition;
13  import jgroup.experiment.Runnable;
14  import jgroup.relacs.config.AppConfig;
15  import jgroup.relacs.config.ExperimentConfig;
16  import jgroup.upgrade.UpgradeManager;
17  import jgroup.util.Abort;
18  
19  /**
20   * @author joandre
21   *
22   * TODO To change the template for this generated type comment go to
23   * Window - Preferences - Java - Code Style - Code Templates
24   */
25  public class UpgradeReplicas
26    implements Runnable
27  {
28  
29    /* (non-Javadoc)
30     * @see jgroup.experiment.Runnable#run(jgroup.relacs.config.ExperimentConfig)
31     */
32    public void run(ExperimentConfig ec) throws ConfigurationException
33    {
34      try {deployApp(ec);}
35      catch (Exception exception){}
36    }
37  
38    /* (non-Javadoc)
39     * @see jgroup.experiment.Runnable#getProperties()
40     */
41    public PropertyDefinition[] getProperties()
42    {
43      // TODO Auto-generated method stub
44      return null;
45    }
46    
47    private void deployApp(ExperimentConfig ec)
48    	throws Exception
49    {
50      DependableRegistry dregistry = RegistryFactory.getRegistry();
51      UpgradeManager upgrManager = (UpgradeManager) dregistry.lookup("Jgroup/UpgradeManager");
52      String clazz = ec.getProperty(this, "class");
53      AppConfig app = AppConfig.getApplication(clazz);
54  	long start = 0; 
55  	long utp = 0;
56  	try {
57  		System.out.println("Upgrading group: " + app);
58  		start = System.currentTimeMillis();
59  		upgrManager.upgradeGroup(app);
60  		utp = System.currentTimeMillis() - start;
61  		System.out.println("Server upgraded, UTP = " + utp);
62  	} catch (Exception exception) {
63  		utp = System.currentTimeMillis() - start;
64  		System.out.println("Server upgrade FAILED, exception thrown after time = " + utp);
65  		throw new Abort("Failed to create upgrserver", exception);
66  	}
67      
68    }
69    	
70  
71  }