@Test public void testGetNextAvailableNodeId() throws IOException { assertNull(createFor( "n1:localhost:11211", null, null, _mcc ).getNextAvailableNodeId("n1")); assertEquals(createFor( "n1:localhost:11211,n2:localhost:11212", null, null, _mcc ).getNextAvailableNodeId("n1"), "n2"); final StorageClientCallback mcc = mock(StorageClientCallback.class); when(mcc.get(anyString())).thenReturn(null); when(mcc.get(endsWith("n2"))).thenThrow(new OperationTimeoutException("SimulatedException")); assertNull(createFor( "n1:localhost:11211,n2:localhost:11212", null, null, mcc).getNextAvailableNodeId("n1")); assertEquals(createFor( "n1:localhost:11211,n2:localhost:11212,n3:localhost:11213", null, null, mcc).getNextAvailableNodeId("n1"), "n3"); }
@Override public boolean isNodeAvailable( final String key ) { try { storageClientCallback.get(_sessionIdFormat.createSessionId( "ping", key ) ); return true; } catch ( final Exception e ) { return false; } }
@Override public boolean isNodeAvailable( final String key ) { try { storageClientCallback.get(_sessionIdFormat.createSessionId( "ping", key ) ); return true; } catch ( final Exception e ) { return false; } }