@Test public void testChangeSessionIdForTomcatFailover() { assertEquals(createFor("localhost:11211", null, null, _mcc) .changeSessionIdForTomcatFailover(sessionId("123", null, null), null), sessionId("123", null, null)); assertEquals(createFor("localhost:11211", null, null, _mcc) .changeSessionIdForTomcatFailover(sessionId("123", null, "tc1"), "tc2"), sessionId("123", null, "tc2")); assertEquals(createFor("n1:localhost:11211,n2:localhost:11212", null, null, _mcc) .changeSessionIdForTomcatFailover(sessionId("123", "n1", null), null), sessionId("123", "n1", null)); assertEquals(createFor("n1:localhost:11211,n2:localhost:11212", null, null, _mcc) .changeSessionIdForTomcatFailover(sessionId("123", "n1", null), "tc2"), sessionId("123", "n1", "tc2")); assertEquals(createFor("n1:localhost:11211,n2:localhost:11212", null, null, _mcc) .changeSessionIdForTomcatFailover(sessionId("123", "n1", "tc1"), "tc2"), sessionId("123", "n1", "tc2")); assertEquals(createFor("n1:localhost:11211,n2:localhost:11212", "n2", null, _mcc) .changeSessionIdForTomcatFailover(sessionId("123", "n1", null), null), sessionId("123", "n1", null)); assertEquals(createFor("n1:localhost:11211,n2:localhost:11212", "n2", null, _mcc) .changeSessionIdForTomcatFailover(sessionId("123", "n1", null), "tc2"), sessionId("123", "n1", "tc2")); assertEquals(createFor("n1:localhost:11211,n2:localhost:11212", "n2", null, _mcc) .changeSessionIdForTomcatFailover(sessionId("123", "n1", "tc1"), "tc2"), sessionId("123", "n1", "tc2")); assertEquals(createFor("n1:localhost:11211,n2:localhost:11212", "n1", null, _mcc) .changeSessionIdForTomcatFailover(sessionId("123", "n1", null), null), sessionId("123", "n2", null)); assertEquals(createFor("n1:localhost:11211,n2:localhost:11212", "n1", null, _mcc) .changeSessionIdForTomcatFailover(sessionId("123", "n1", null), "tc2"), sessionId("123", "n2", "tc2")); assertEquals(createFor("n1:localhost:11211,n2:localhost:11212", "n1", null, _mcc) .changeSessionIdForTomcatFailover(sessionId("123", "n1", "tc1"), "tc2"), sessionId("123", "n2", "tc2")); }
public String changeSessionIdForTomcatFailover( @Nonnull final String sessionId, final String jvmRoute ) { final String newSessionId = jvmRoute != null && !jvmRoute.trim().isEmpty() ? _sessionIdFormat.changeJvmRoute( sessionId, jvmRoute ) : _sessionIdFormat.stripJvmRoute(sessionId); if ( isEncodeNodeIdInSessionId() ) { final String nodeId = _sessionIdFormat.extractMemcachedId( newSessionId ); if(_failoverNodeIds != null && _failoverNodeIds.contains(nodeId)) { final String newNodeId = _nodeIdService.getAvailableNodeId( nodeId ); if ( newNodeId != null ) { return _sessionIdFormat.createNewSessionId( newSessionId, newNodeId); } } } return newSessionId; }
MemcachedNodesManager { public String changeSessionIdForTomcatFailover( @Nonnull final String sessionId, final String jvmRoute ) { final String newSessionId = jvmRoute != null && !jvmRoute.trim().isEmpty() ? _sessionIdFormat.changeJvmRoute( sessionId, jvmRoute ) : _sessionIdFormat.stripJvmRoute(sessionId); if ( isEncodeNodeIdInSessionId() ) { final String nodeId = _sessionIdFormat.extractMemcachedId( newSessionId ); if(_failoverNodeIds != null && _failoverNodeIds.contains(nodeId)) { final String newNodeId = _nodeIdService.getAvailableNodeId( nodeId ); if ( newNodeId != null ) { return _sessionIdFormat.createNewSessionId( newSessionId, newNodeId); } } } return newSessionId; } }
MemcachedNodesManager { public String changeSessionIdForTomcatFailover( @Nonnull final String sessionId, final String jvmRoute ) { final String newSessionId = jvmRoute != null && !jvmRoute.trim().isEmpty() ? _sessionIdFormat.changeJvmRoute( sessionId, jvmRoute ) : _sessionIdFormat.stripJvmRoute(sessionId); if ( isEncodeNodeIdInSessionId() ) { final String nodeId = _sessionIdFormat.extractMemcachedId( newSessionId ); if(_failoverNodeIds != null && _failoverNodeIds.contains(nodeId)) { final String newNodeId = _nodeIdService.getAvailableNodeId( nodeId ); if ( newNodeId != null ) { return _sessionIdFormat.createNewSessionId( newSessionId, newNodeId); } } } return newSessionId; } MemcachedNodesManager(final String memcachedNodes, @Nonnull final NodeIdList primaryNodeIds, @Nonnull final List<String> failoverNodeIds,
			@Nonnull final LinkedHashMap<InetSocketAddress, String> address2Ids,
			@Nullable final StorageKeyFormat storageKeyFormat, @Nullable final StorageClientCallback storageClientCallback); }
MemcachedNodesManager { public String changeSessionIdForTomcatFailover( @Nonnull final String sessionId, final String jvmRoute ) { final String newSessionId = jvmRoute != null && !jvmRoute.trim().isEmpty() ? _sessionIdFormat.changeJvmRoute( sessionId, jvmRoute ) : _sessionIdFormat.stripJvmRoute(sessionId); if ( isEncodeNodeIdInSessionId() ) { final String nodeId = _sessionIdFormat.extractMemcachedId( newSessionId ); if(_failoverNodeIds != null && _failoverNodeIds.contains(nodeId)) { final String newNodeId = _nodeIdService.getAvailableNodeId( nodeId ); if ( newNodeId != null ) { return _sessionIdFormat.createNewSessionId( newSessionId, newNodeId); } } } return newSessionId; } MemcachedNodesManager(final String memcachedNodes, @Nonnull final NodeIdList primaryNodeIds, @Nonnull final List<String> failoverNodeIds,
			@Nonnull final LinkedHashMap<InetSocketAddress, String> address2Ids,
			@Nullable final StorageKeyFormat storageKeyFormat, @Nullable final StorageClientCallback storageClientCallback); @Nonnull static MemcachedNodesManager createFor(final String memcachedNodes, final String failoverNodes, final StorageKeyFormat storageKeyFormat,
            final StorageClientCallback storageClientCallback); String getMemcachedNodes(); int getCountNodes(); @Nonnull NodeIdList getPrimaryNodeIds(); @Nonnull List<String> getFailoverNodeIds(); boolean isEncodeNodeIdInSessionId(); @Nonnull String getNodeId(final InetSocketAddress socketAddress); @CheckForNull String getNextPrimaryNodeId(final String nodeId); String getNextAvailableNodeId(final String nodeId); @Nonnull SessionIdFormat getSessionIdFormat(); @Nonnull StorageKeyFormat getStorageKeyFormat(); @Nonnull List<InetSocketAddress> getAllMemcachedAddresses(); @Nonnull String createSessionId( @Nonnull final String sessionId ); void setNodeAvailable(@Nullable final String nodeId, final boolean available); boolean isNodeAvailable(final String nodeId); boolean isValidForMemcached(final String sessionId); boolean canHitMemcached(final String sessionId); void onLoadFromMemcachedSuccess(final String sessionId); void onLoadFromMemcachedFailure(final String sessionId); String setNodeAvailableForSessionId(final String sessionId, final boolean available); String getNewSessionIdIfNodeFromSessionIdUnavailable( @Nonnull final String sessionId ); String changeSessionIdForTomcatFailover( @Nonnull final String sessionId, final String jvmRoute ); boolean isCouchbaseBucketConfig(); boolean isRedisConfig(); List<URI> getCouchbaseBucketURIs(); }
MemcachedNodesManager { public String changeSessionIdForTomcatFailover( @Nonnull final String sessionId, final String jvmRoute ) { final String newSessionId = jvmRoute != null && !jvmRoute.trim().isEmpty() ? _sessionIdFormat.changeJvmRoute( sessionId, jvmRoute ) : _sessionIdFormat.stripJvmRoute(sessionId); if ( isEncodeNodeIdInSessionId() ) { final String nodeId = _sessionIdFormat.extractMemcachedId( newSessionId ); if(_failoverNodeIds != null && _failoverNodeIds.contains(nodeId)) { final String newNodeId = _nodeIdService.getAvailableNodeId( nodeId ); if ( newNodeId != null ) { return _sessionIdFormat.createNewSessionId( newSessionId, newNodeId); } } } return newSessionId; } MemcachedNodesManager(final String memcachedNodes, @Nonnull final NodeIdList primaryNodeIds, @Nonnull final List<String> failoverNodeIds,
			@Nonnull final LinkedHashMap<InetSocketAddress, String> address2Ids,
			@Nullable final StorageKeyFormat storageKeyFormat, @Nullable final StorageClientCallback storageClientCallback); @Nonnull static MemcachedNodesManager createFor(final String memcachedNodes, final String failoverNodes, final StorageKeyFormat storageKeyFormat,
            final StorageClientCallback storageClientCallback); String getMemcachedNodes(); int getCountNodes(); @Nonnull NodeIdList getPrimaryNodeIds(); @Nonnull List<String> getFailoverNodeIds(); boolean isEncodeNodeIdInSessionId(); @Nonnull String getNodeId(final InetSocketAddress socketAddress); @CheckForNull String getNextPrimaryNodeId(final String nodeId); String getNextAvailableNodeId(final String nodeId); @Nonnull SessionIdFormat getSessionIdFormat(); @Nonnull StorageKeyFormat getStorageKeyFormat(); @Nonnull List<InetSocketAddress> getAllMemcachedAddresses(); @Nonnull String createSessionId( @Nonnull final String sessionId ); void setNodeAvailable(@Nullable final String nodeId, final boolean available); boolean isNodeAvailable(final String nodeId); boolean isValidForMemcached(final String sessionId); boolean canHitMemcached(final String sessionId); void onLoadFromMemcachedSuccess(final String sessionId); void onLoadFromMemcachedFailure(final String sessionId); String setNodeAvailableForSessionId(final String sessionId, final boolean available); String getNewSessionIdIfNodeFromSessionIdUnavailable( @Nonnull final String sessionId ); String changeSessionIdForTomcatFailover( @Nonnull final String sessionId, final String jvmRoute ); boolean isCouchbaseBucketConfig(); boolean isRedisConfig(); List<URI> getCouchbaseBucketURIs();  }