@Test public final void testGetNextNodeId_TwoNodes_NoNodeLeft() { final String nodeId1 = "n1"; final String nodeId2 = "n2"; final CacheLoader<String> cacheLoader = new DummyCacheLoader( Arrays.asList( nodeId1 ) ); final NodeIdService cut = new NodeIdService( new NodeAvailabilityCache<String>( 10, 100, cacheLoader ), NodeIdList.create( nodeId1, nodeId2 ), null ); final String actual = cut.getAvailableNodeId( nodeId2 ); assertNull( actual ); }
public String getAvailableNodeId( final String nodeId ) { String result = null; result = getRandomNextNodeId( nodeId, _nodeIds ); if ( result == null && _failoverNodeIds != null && !_failoverNodeIds.isEmpty() ) { result = getRandomNextNodeId( nodeId, _failoverNodeIds ); } return result; }
NodeIdService { public String getAvailableNodeId( final String nodeId ) { String result = null; result = getRandomNextNodeId( nodeId, _nodeIds ); if ( result == null && _failoverNodeIds != null && !_failoverNodeIds.isEmpty() ) { result = getRandomNextNodeId( nodeId, _failoverNodeIds ); } return result; } }
NodeIdService { public String getAvailableNodeId( final String nodeId ) { String result = null; result = getRandomNextNodeId( nodeId, _nodeIds ); if ( result == null && _failoverNodeIds != null && !_failoverNodeIds.isEmpty() ) { result = getRandomNextNodeId( nodeId, _failoverNodeIds ); } return result; } NodeIdService( final NodeAvailabilityCache<String> nodeAvailabilityCache, final NodeIdList nodeIds, final List<String> failoverNodeIds );   NodeIdService( final List<String> nodeIds,
            final List<String> failoverNodeIds ); }
NodeIdService { public String getAvailableNodeId( final String nodeId ) { String result = null; result = getRandomNextNodeId( nodeId, _nodeIds ); if ( result == null && _failoverNodeIds != null && !_failoverNodeIds.isEmpty() ) { result = getRandomNextNodeId( nodeId, _failoverNodeIds ); } return result; } NodeIdService( final NodeAvailabilityCache<String> nodeAvailabilityCache, final NodeIdList nodeIds, final List<String> failoverNodeIds );   NodeIdService( final List<String> nodeIds,
            final List<String> failoverNodeIds ); boolean isNodeAvailable( @Nonnull final String nodeId ); void setNodeAvailable( final String nodeId, final boolean available ); String getAvailableNodeId( final String nodeId ); @CheckForNull String getNextNodeId( @Nonnull final String nodeId ); String getMemcachedNodeId(); String getNewNodeIdIfUnavailable( final String nodeId ); }
NodeIdService { public String getAvailableNodeId( final String nodeId ) { String result = null; result = getRandomNextNodeId( nodeId, _nodeIds ); if ( result == null && _failoverNodeIds != null && !_failoverNodeIds.isEmpty() ) { result = getRandomNextNodeId( nodeId, _failoverNodeIds ); } return result; } NodeIdService( final NodeAvailabilityCache<String> nodeAvailabilityCache, final NodeIdList nodeIds, final List<String> failoverNodeIds );   NodeIdService( final List<String> nodeIds,
            final List<String> failoverNodeIds ); boolean isNodeAvailable( @Nonnull final String nodeId ); void setNodeAvailable( final String nodeId, final boolean available ); String getAvailableNodeId( final String nodeId ); @CheckForNull String getNextNodeId( @Nonnull final String nodeId ); String getMemcachedNodeId(); String getNewNodeIdIfUnavailable( final String nodeId );  }