// Path: src/org/gearman/GearmanLostConnectionPolicy.java
// public final static class Action {
// 		
// 	static final Action RECONNECT = new Action(0);
// 	static final Action DROP = new Action(0);
// 		
// 	private final long nanoTime;
// 		
// 	private Action(final long nanoTime) {
// 		this.nanoTime = nanoTime;
// 	}
// 		
// 	/**
// 	 * Tells the calling service to reconnect at it's own discretion
// 	 */
// 	public static Action reconnectServer() {
// 		return RECONNECT;
// 	}
// 		
// 	/**
// 	 * Tells the calling service to reconnect no earlier then the the specified delay
// 	 * 
// 	 * @param time
// 	 * 		The amount of time that must pass before any attempts to reconnect can occur
// 	 * @param unit
// 	 * 		The unit time
// 	 */
// 	public static Action reconnectServer(long time, final TimeUnit unit) {
// 		if(time<0) time=0;
// 		return new Action(unit.toNanos(time));
// 	}
// 		
// 	/**
// 	 * Tells the calling service to drop the server from its control
// 	 */
// 	public static Action dropServer() {
// 		return DROP;
// 	}
// 		
// 	/**
// 	 * Returns the amount of time the gearman service must wait before attempting
// 	 * to reconnect
// 	 * 
// 	 * @return
// 	 * 		The amount of time the gearman service must wait before attempting
// 	 * 		to reconnect
// 	 */
// 	long getNanoTime() {
// 		return nanoTime;
// 	}
// }
// 
// Path: src/org/gearman/GearmanLostConnectionPolicy.java
// public static enum Grounds {
// 		
// 	/**
// 	 * The server in question unexpectedly disconnected.
// 	 */
// 	UNEXPECTED_DISCONNECT,
// 		
// 	/**
// 	 * The gearman service failed to connect to a server registed with the service  
// 	 */
// 	FAILED_CONNECTION,
// 		
// 	/** 
// 	 * The connection was closed due to a server failing to respond
// 	 */
// 	RESPONCE_TIMEOUT,
// };


import java.net.InetSocketAddress;
import java.util.Collections;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import org.gearman.GearmanLostConnectionPolicy.Action;
import org.gearman.GearmanLostConnectionPolicy.Grounds;
		RemoteConnectionController(InetSocketAddress key) {
			super(WorkerImpl.this, key);
		}

		@Override
		public void onOpen(ControllerState oldState) {
			if(WorkerImpl.this.funcMap.isEmpty()) {
				super.closeServer();
			} else {
				super.onOpen(oldState);
			}
		}
		
		@Override
		protected WorkerDispatcher getDispatcher() {
			return WorkerImpl.this.dispatcher;
		}

		@Override
		protected WorkerImpl getWorker() {
			return WorkerImpl.this;
		}

		@Override
		protected void onConnect(ControllerState oldState) {
			gearman.getGearmanConnectionManager().createGearmanConnection(super.getKey(), this, this);
		}

		@Override
		protected void onLostConnection(GearmanLostConnectionPolicy policy, Grounds grounds) {
// Path: src/org/gearman/GearmanLostConnectionPolicy.java
// public final static class Action {
// 		
// 	static final Action RECONNECT = new Action(0);
// 	static final Action DROP = new Action(0);
// 		
// 	private final long nanoTime;
// 		
// 	private Action(final long nanoTime) {
// 		this.nanoTime = nanoTime;
// 	}
// 		
// 	/**
// 	 * Tells the calling service to reconnect at it's own discretion
// 	 */
// 	public static Action reconnectServer() {
// 		return RECONNECT;
// 	}
// 		
// 	/**
// 	 * Tells the calling service to reconnect no earlier then the the specified delay
// 	 * 
// 	 * @param time
// 	 * 		The amount of time that must pass before any attempts to reconnect can occur
// 	 * @param unit
// 	 * 		The unit time
// 	 */
// 	public static Action reconnectServer(long time, final TimeUnit unit) {
// 		if(time<0) time=0;
// 		return new Action(unit.toNanos(time));
// 	}
// 		
// 	/**
// 	 * Tells the calling service to drop the server from its control
// 	 */
// 	public static Action dropServer() {
// 		return DROP;
// 	}
// 		
// 	/**
// 	 * Returns the amount of time the gearman service must wait before attempting
// 	 * to reconnect
// 	 * 
// 	 * @return
// 	 * 		The amount of time the gearman service must wait before attempting
// 	 * 		to reconnect
// 	 */
// 	long getNanoTime() {
// 		return nanoTime;
// 	}
// }
// 
// Path: src/org/gearman/GearmanLostConnectionPolicy.java
// public static enum Grounds {
// 		
// 	/**
// 	 * The server in question unexpectedly disconnected.
// 	 */
// 	UNEXPECTED_DISCONNECT,
// 		
// 	/**
// 	 * The gearman service failed to connect to a server registed with the service  
// 	 */
// 	FAILED_CONNECTION,
// 		
// 	/** 
// 	 * The connection was closed due to a server failing to respond
// 	 */
// 	RESPONCE_TIMEOUT,
// };


// Path: src/org/gearman/WorkerImpl.java
import java.net.InetSocketAddress;
import java.util.Collections;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import org.gearman.GearmanLostConnectionPolicy.Action;
import org.gearman.GearmanLostConnectionPolicy.Grounds;

		RemoteConnectionController(InetSocketAddress key) {
			super(WorkerImpl.this, key);
		}

		@Override
		public void onOpen(ControllerState oldState) {
			if(WorkerImpl.this.funcMap.isEmpty()) {
				super.closeServer();
			} else {
				super.onOpen(oldState);
			}
		}
		
		@Override
		protected WorkerDispatcher getDispatcher() {
			return WorkerImpl.this.dispatcher;
		}

		@Override
		protected WorkerImpl getWorker() {
			return WorkerImpl.this;
		}

		@Override
		protected void onConnect(ControllerState oldState) {
			gearman.getGearmanConnectionManager().createGearmanConnection(super.getKey(), this, this);
		}

		@Override
		protected void onLostConnection(GearmanLostConnectionPolicy policy, Grounds grounds) {
			Action action = null;