*/
public static ClusterInfoSession stealShard(final ClusterInfoSession originalSession, final ClusterInfoSessionFactory factory,
final String shardPath, final long timeoutmillis) throws InterruptedException, ClusterInfoException
{
// get the current slot data to use as a template
final DefaultRouterSlotInfo newSlot = (DefaultRouterSlotInfo)originalSession.getData(shardPath, null);
final AtomicBoolean stillRunning = new AtomicBoolean(true);
final AtomicBoolean failed = new AtomicBoolean(false);
final ClusterInfoSession session = factory.createSession();
Runnable slotGrabber = new Runnable()
{
@Override
public void run()
{
try
{
Thread.currentThread().setPriority(Thread.MAX_PRIORITY);
boolean haveSlot = false;
while (!haveSlot && stillRunning.get())
{
newSlot.setDestination(new JunkDestination());
if (session.mkdir(shardPath,newSlot,DirMode.EPHEMERAL) != null)
haveSlot = true;
Thread.yield();
}
}