// Path: src/main/java/ch/ethz/globis/tinspin/util/rmi/TestRunnerLocal.java
// static class NoSecurityManager extends SecurityManager {
//     @Override
// 	public void checkConnect (String host, int port) {}
//     @Override
// 	public void checkConnect (String host, int port, Object context) {}
//     @Override
// 	public void checkPropertyAccess(String key) {};
//     @Override
// 	public void checkPermission(Permission perm) {};
//     @Override
// 	public void checkPermission(Permission perm, Object context) {};
//     @Override
// 	public void checkAccept(String host, int port) {};   
// }


import java.rmi.ConnectException;
import java.rmi.NotBoundException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import ch.ethz.globis.tinspin.TestStats;
import ch.ethz.globis.tinspin.util.rmi.TestRunnerLocal.NoSecurityManager;
/*
 * Copyright 2011-2016 ETH Zurich. All Rights Reserved.
 *
 * This software is the proprietary information of ETH Zurich.
 * Use is subject to license terms.
 */
package ch.ethz.globis.tinspin.util.rmi;




public class TestManagerRMI {

	public static String PROCESS_OPTIONS = "-Xmx24G -XX:+UseConcMarkSweepGC"; 
    
    private static final boolean USE_RMI = true;
	
	static final String RMI_NAME = "TestRunnerRMI";
	
	
	private static TestStats runRmiTest(TestStats stats0) {
		TestProcessLauncher.launchRmiRegistry();

		//Check whether there are already tests running
		try {
			Registry registry = LocateRegistry.getRegistry();
			TestRunnerAPI comp = (TestRunnerAPI) registry.lookup(RMI_NAME);
			if (comp.isAlive()) {
				throw new IllegalStateException("Test process already running!");
			}
		} catch (NotBoundException e) {
			//good!
		} catch (ConnectException e) {
			//good!
		} catch (Exception e) {
			throw new RuntimeException(e);
		}
		
		
		// start test process
		System.out.println("Manager: starting task.");
		//TestProcessLauncher.launchProcess("rmigegistry", new String[]{});
// Path: src/main/java/ch/ethz/globis/tinspin/util/rmi/TestRunnerLocal.java
// static class NoSecurityManager extends SecurityManager {
//     @Override
// 	public void checkConnect (String host, int port) {}
//     @Override
// 	public void checkConnect (String host, int port, Object context) {}
//     @Override
// 	public void checkPropertyAccess(String key) {};
//     @Override
// 	public void checkPermission(Permission perm) {};
//     @Override
// 	public void checkPermission(Permission perm, Object context) {};
//     @Override
// 	public void checkAccept(String host, int port) {};   
// }


// Path: src/main/java/ch/ethz/globis/tinspin/util/rmi/TestManagerRMI.java
import java.rmi.ConnectException;
import java.rmi.NotBoundException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import ch.ethz.globis.tinspin.TestStats;
import ch.ethz.globis.tinspin.util.rmi.TestRunnerLocal.NoSecurityManager;

/*
 * Copyright 2011-2016 ETH Zurich. All Rights Reserved.
 *
 * This software is the proprietary information of ETH Zurich.
 * Use is subject to license terms.
 */
package ch.ethz.globis.tinspin.util.rmi;




public class TestManagerRMI {

	public static String PROCESS_OPTIONS = "-Xmx24G -XX:+UseConcMarkSweepGC"; 
    
    private static final boolean USE_RMI = true;
	
	static final String RMI_NAME = "TestRunnerRMI";
	
	
	private static TestStats runRmiTest(TestStats stats0) {
		TestProcessLauncher.launchRmiRegistry();

		//Check whether there are already tests running
		try {
			Registry registry = LocateRegistry.getRegistry();
			TestRunnerAPI comp = (TestRunnerAPI) registry.lookup(RMI_NAME);
			if (comp.isAlive()) {
				throw new IllegalStateException("Test process already running!");
			}
		} catch (NotBoundException e) {
			//good!
		} catch (ConnectException e) {
			//good!
		} catch (Exception e) {
			throw new RuntimeException(e);
		}
		
		
		// start test process
		System.out.println("Manager: starting task.");
		//TestProcessLauncher.launchProcess("rmigegistry", new String[]{});
		System.setSecurityManager (new NoSecurityManager());