public JobCreator(int nrClusters, String registry) throws RemoteException 
	{
		this.nrClusters = nrClusters;
		JobCreator.registry = registry;
		
		
		/*LocalSocket lSocket = new LocalSocket();
		socket = new SynchronizedSocket(lSocket);
		socket.register("JobCreator");

		socket.addMessageReceivedHandler(this);*/
		
		System.setProperty("java.security.policy", "file:./my.policy");
		if (System.getSecurityManager() == null) {
			System.setSecurityManager(new RMISecurityManager());
		}
		
		// Bind the node to the RMI registry.
		try {
			String registryServer = "localhost";
			//Registry registry2 = java.rmi.registry.LocateRegistry.getRegistry(registryServer);
			//registry2.rebind("JobCreator", this );
			
			String url = "rmi://"+registry+":1099/JobCreator";
			System.out.println("trying to bind to: "+url);
			java.rmi.Naming.bind(url, this);
			System.out.println("binded to: "+url);
		} catch (MalformedURLException e) {
			e.printStackTrace();
		} catch (AlreadyBoundException e) {
			e.printStackTrace();
		}
				
		final String name = "rmi://"+registry+":1099/JobCreator";
		
				
		// Let the node unregister from RMI registry on shut down.
		Runtime.getRuntime().addShutdownHook(new Thread() {
			@Override
			public void run() {
				System.out.println("Shutting down " + name + ".");
				try {
					java.rmi.Naming.unbind(name);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
		
		// start the polling thread
		running = true;
		pollingThread = new Thread(this);
		//pollingThread.start();
	}