Added contextual info similar to ask-based, including the
yang path of the requested read and the backend shard name.
Also wrapped RequestTimeoutException with
DataStoreUnavailableException.
Change-Id: I5487e5531034cc1abbda27a4953897da7212eba8
Signed-off-by: Tom Pantelis <tompantelis@gmail.com>
15 files changed:
@GuardedBy("lock")
private final TransmitQueue queue;
private final Long cookie;
@GuardedBy("lock")
private final TransmitQueue queue;
private final Long cookie;
+ private final String backendName;
@GuardedBy("lock")
private boolean haveTimer;
@GuardedBy("lock")
private boolean haveTimer;
private volatile RequestException poisoned;
// Private constructor to avoid code duplication.
private volatile RequestException poisoned;
// Private constructor to avoid code duplication.
- private AbstractClientConnection(final AbstractClientConnection<T> oldConn, final TransmitQueue newQueue) {
+ private AbstractClientConnection(final AbstractClientConnection<T> oldConn, final TransmitQueue newQueue,
+ final String backendName) {
this.context = Preconditions.checkNotNull(oldConn.context);
this.cookie = Preconditions.checkNotNull(oldConn.cookie);
this.context = Preconditions.checkNotNull(oldConn.context);
this.cookie = Preconditions.checkNotNull(oldConn.cookie);
+ this.backendName = Preconditions.checkNotNull(backendName);
this.queue = Preconditions.checkNotNull(newQueue);
// Will be updated in finishReplay if needed.
this.lastReceivedTicks = oldConn.lastReceivedTicks;
this.queue = Preconditions.checkNotNull(newQueue);
// Will be updated in finishReplay if needed.
this.lastReceivedTicks = oldConn.lastReceivedTicks;
// This constructor is only to be called by ConnectingClientConnection constructor.
// Do not allow subclassing outside of this package
// This constructor is only to be called by ConnectingClientConnection constructor.
// Do not allow subclassing outside of this package
- AbstractClientConnection(final ClientActorContext context, final Long cookie, final int queueDepth) {
+ AbstractClientConnection(final ClientActorContext context, final Long cookie, final String backendName,
+ final int queueDepth) {
this.context = Preconditions.checkNotNull(context);
this.cookie = Preconditions.checkNotNull(cookie);
this.context = Preconditions.checkNotNull(context);
this.cookie = Preconditions.checkNotNull(cookie);
+ this.backendName = Preconditions.checkNotNull(backendName);
this.queue = new TransmitQueue.Halted(queueDepth);
this.lastReceivedTicks = currentTime();
}
this.queue = new TransmitQueue.Halted(queueDepth);
this.lastReceivedTicks = currentTime();
}
// This constructor is only to be called (indirectly) by ReconnectingClientConnection constructor.
// Do not allow subclassing outside of this package
AbstractClientConnection(final AbstractClientConnection<T> oldConn) {
// This constructor is only to be called (indirectly) by ReconnectingClientConnection constructor.
// Do not allow subclassing outside of this package
AbstractClientConnection(final AbstractClientConnection<T> oldConn) {
- this(oldConn, new TransmitQueue.Halted(oldConn.queue, oldConn.currentTime()));
+ this(oldConn, new TransmitQueue.Halted(oldConn.queue, oldConn.currentTime()), oldConn.backendName);
}
// This constructor is only to be called (indirectly) by ConnectedClientConnection constructor.
// Do not allow subclassing outside of this package
}
// This constructor is only to be called (indirectly) by ConnectedClientConnection constructor.
// Do not allow subclassing outside of this package
- AbstractClientConnection(final AbstractClientConnection<T> oldConn, final T newBackend, final int queueDepth) {
+ AbstractClientConnection(final AbstractClientConnection<T> oldConn, final T newBackend,
+ final int queueDepth) {
this(oldConn, new TransmitQueue.Transmitting(oldConn.queue, queueDepth, newBackend, oldConn.currentTime(),
this(oldConn, new TransmitQueue.Transmitting(oldConn.queue, queueDepth, newBackend, oldConn.currentTime(),
- Preconditions.checkNotNull(oldConn.context).messageSlicer()));
+ Preconditions.checkNotNull(oldConn.context).messageSlicer()), newBackend.getName());
}
public final ClientActorContext context() {
}
public final ClientActorContext context() {
context.executeInActor(current -> {
final double time = beenOpen * 1.0 / 1_000_000_000;
entry.complete(entry.getRequest().toRequestFailure(
context.executeInActor(current -> {
final double time = beenOpen * 1.0 / 1_000_000_000;
entry.complete(entry.getRequest().toRequestFailure(
- new RequestTimeoutException(entry.getRequest() + " timed out after " + time + " seconds")));
+ new RequestTimeoutException(entry.getRequest() + " timed out after " + time
+ + " seconds. The backend for " + backendName + " is not available.")));
private final ActorRef actor;
private final int maxMessages;
private final long sessionId;
private final ActorRef actor;
private final int maxMessages;
private final long sessionId;
+ private final String name;
- protected BackendInfo(final ActorRef actor, final long sessionId, final ABIVersion version, final int maxMessages) {
+ protected BackendInfo(final ActorRef actor, final String name, final long sessionId, final ABIVersion version,
+ final int maxMessages) {
this.version = Preconditions.checkNotNull(version);
this.actor = Preconditions.checkNotNull(actor);
this.version = Preconditions.checkNotNull(version);
this.actor = Preconditions.checkNotNull(actor);
+ this.name = Preconditions.checkNotNull(name);
Preconditions.checkArgument(maxMessages > 0, "Maximum messages has to be positive, not %s", maxMessages);
this.maxMessages = maxMessages;
this.sessionId = sessionId;
Preconditions.checkArgument(maxMessages > 0, "Maximum messages has to be positive, not %s", maxMessages);
this.maxMessages = maxMessages;
this.sessionId = sessionId;
+ public final String getName() {
+ return name;
+ }
+
public final ABIVersion getVersion() {
return version;
}
public final ABIVersion getVersion() {
return version;
}
@Nonnull
public abstract Registration notifyWhenBackendInfoIsStale(Consumer<Long> callback);
@Nonnull
public abstract Registration notifyWhenBackendInfoIsStale(Consumer<Long> callback);
+ @Nonnull
+ public abstract String resolveCookieName(Long cookie);
+
@Override
public void close() {
}
@Override
public void close() {
}
}
private ConnectingClientConnection<T> createConnection(final Long shard) {
}
private ConnectingClientConnection<T> createConnection(final Long shard) {
- final ConnectingClientConnection<T> conn = new ConnectingClientConnection<>(context(), shard);
+ final ConnectingClientConnection<T> conn = new ConnectingClientConnection<>(context(), shard,
+ resolver().resolveCookieName(shard));
resolveConnection(shard, conn);
return conn;
}
resolveConnection(shard, conn);
return conn;
}
private static final int TARGET_QUEUE_DEPTH = 4000;
// Initial state, never instantiated externally
private static final int TARGET_QUEUE_DEPTH = 4000;
// Initial state, never instantiated externally
- ConnectingClientConnection(final ClientActorContext context, final Long cookie) {
- super(context, cookie, TARGET_QUEUE_DEPTH);
+ ConnectingClientConnection(final ClientActorContext context, final Long cookie, final String backendName) {
+ super(context, cookie, backendName, TARGET_QUEUE_DEPTH);
public static <T extends BackendInfo> ConnectedClientConnection<T> createConnectedConnection(
final ClientActorContext context, final Long cookie, final T backend) {
public static <T extends BackendInfo> ConnectedClientConnection<T> createConnectedConnection(
final ClientActorContext context, final Long cookie, final T backend) {
- return new ConnectedClientConnection<>(new ConnectingClientConnection<>(context, cookie), backend);
+ return new ConnectedClientConnection<>(new ConnectingClientConnection<>(context, cookie, backend.getName()),
+ backend);
}
public static void completeRequest(final AbstractClientConnection<? extends BackendInfo> connection,
}
public static void completeRequest(final AbstractClientConnection<? extends BackendInfo> connection,
*/
package org.opendaylight.controller.cluster.access.client;
*/
package org.opendaylight.controller.cluster.access.client;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.same;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.same;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
@Override
protected ConnectedClientConnection<BackendInfo> createConnection() {
@Override
protected ConnectedClientConnection<BackendInfo> createConnection() {
- final BackendInfo backend = new BackendInfo(backendProbe.ref(), 0L, ABIVersion.BORON, 10);
- final ConnectingClientConnection<BackendInfo> connectingConn = new ConnectingClientConnection<>(context, 0L);
+ final BackendInfo backend = new BackendInfo(backendProbe.ref(), "test", 0L, ABIVersion.BORON, 10);
+ final ConnectingClientConnection<BackendInfo> connectingConn = new ConnectingClientConnection<>(context, 0L,
+ backend.getName());
return new ConnectedClientConnection<>(connectingConn, backend);
}
return new ConnectedClientConnection<>(connectingConn, backend);
}
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
-import static org.mockito.Matchers.any;
+import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
doReturn(mock(MessageSlicer.class)).when(mockContext).messageSlicer();
mockActor = TestProbe.apply(actorSystem);
doReturn(mock(MessageSlicer.class)).when(mockContext).messageSlicer();
mockActor = TestProbe.apply(actorSystem);
- mockBackendInfo = new BackendInfo(mockActor.ref(), 0, ABIVersion.current(), 5);
+ mockBackendInfo = new BackendInfo(mockActor.ref(), "test", 0, ABIVersion.current(), 5);
mockRequest = new MockRequest(mockIdentifier, mockReplyTo);
mockRequest2 = new MockRequest(mockIdentifier, mockReplyTo);
mockResponse = mockRequest.toRequestFailure(mockCause);
mockResponseEnvelope = new FailureEnvelope(mockResponse, 0, 0, 0);
mockCookie = ThreadLocalRandom.current().nextLong();
mockRequest = new MockRequest(mockIdentifier, mockReplyTo);
mockRequest2 = new MockRequest(mockIdentifier, mockReplyTo);
mockResponse = mockRequest.toRequestFailure(mockCause);
mockResponseEnvelope = new FailureEnvelope(mockResponse, 0, 0, 0);
mockCookie = ThreadLocalRandom.current().nextLong();
- queue = new ConnectingClientConnection<>(mockContext, mockCookie);
+ queue = new ConnectingClientConnection<>(mockContext, mockCookie, mockBackendInfo.getName());
private void setupBackend() {
final ConnectingClientConnection<BackendInfo> connectingConn =
private void setupBackend() {
final ConnectingClientConnection<BackendInfo> connectingConn =
- new ConnectingClientConnection<>(mockContext, mockCookie);
+ new ConnectingClientConnection<>(mockContext, mockCookie, "test");
final ConnectedClientConnection<BackendInfo> connectedConn =
new ConnectedClientConnection<>(connectingConn, mockBackendInfo);
queue.setForwarder(new SimpleReconnectForwarder(connectedConn));
final ConnectedClientConnection<BackendInfo> connectedConn =
new ConnectedClientConnection<>(connectingConn, mockBackendInfo);
queue.setForwarder(new SimpleReconnectForwarder(connectedConn));
*/
package org.opendaylight.controller.cluster.access.client;
*/
package org.opendaylight.controller.cluster.access.client;
-import static org.mockito.Matchers.any;
+import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.after;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.after;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
@Override
protected ReconnectingClientConnection<BackendInfo> createConnection() {
@Override
protected ReconnectingClientConnection<BackendInfo> createConnection() {
- final BackendInfo backend = new BackendInfo(backendProbe.ref(), 0L, ABIVersion.BORON, 10);
- final ConnectingClientConnection<BackendInfo> connectingConn = new ConnectingClientConnection<>(context, 0L);
+ final BackendInfo backend = new BackendInfo(backendProbe.ref(), "test", 0L, ABIVersion.BORON, 10);
+ final ConnectingClientConnection<BackendInfo> connectingConn = new ConnectingClientConnection<>(context, 0L,
+ backend.getName());
final ConnectedClientConnection<BackendInfo> connectedConn =
new ConnectedClientConnection<>(connectingConn, backend);
return new ReconnectingClientConnection<>(connectedConn, mock(RequestException.class));
final ConnectedClientConnection<BackendInfo> connectedConn =
new ConnectedClientConnection<>(connectingConn, backend);
return new ReconnectingClientConnection<>(connectedConn, mock(RequestException.class));
connection.receiveResponse(envelope);
verify(callback, after(1000).never()).accept(any());
}
connection.receiveResponse(envelope);
verify(callback, after(1000).never()).accept(any());
}
-}
\ No newline at end of file
@Override
protected TransmitQueue.Transmitting createQueue() {
doReturn(false).when(mockMessageSlicer).slice(any());
@Override
protected TransmitQueue.Transmitting createQueue() {
doReturn(false).when(mockMessageSlicer).slice(any());
- backendInfo = new BackendInfo(probe.ref(), 0L, ABIVersion.BORON, 3);
+ backendInfo = new BackendInfo(probe.ref(), "test", 0L, ABIVersion.BORON, 3);
return new TransmitQueue.Transmitting(new TransmitQueue.Halted(0), 0, backendInfo, now(), mockMessageSlicer);
}
return new TransmitQueue.Transmitting(new TransmitQueue.Halted(0), 0, backendInfo, now(), mockMessageSlicer);
}
package org.opendaylight.controller.cluster.databroker.actors.dds;
import static akka.pattern.Patterns.ask;
package org.opendaylight.controller.cluster.databroker.actors.dds;
import static akka.pattern.Patterns.ask;
+import static com.google.common.base.Verify.verifyNotNull;
import akka.dispatch.ExecutionContexts;
import akka.dispatch.OnComplete;
import akka.dispatch.ExecutionContexts;
import akka.dispatch.OnComplete;
}
LOG.debug("Invalidating backend information {}", staleInfo);
}
LOG.debug("Invalidating backend information {}", staleInfo);
- flushCache(staleInfo.getShardName());
+ flushCache(staleInfo.getName());
LOG.trace("Invalidated cache {}", staleInfo);
backends.remove(cookie, existing);
LOG.trace("Invalidated cache {}", staleInfo);
backends.remove(cookie, existing);
}
}, ExecutionContexts.global());
}
}
}, ExecutionContexts.global());
}
+
+ @Override
+ public String resolveCookieName(Long cookie) {
+ return verifyNotNull(shards.inverse().get(cookie), "Unexpected null cookie: %s", cookie);
+ }
*/
package org.opendaylight.controller.cluster.databroker.actors.dds;
*/
package org.opendaylight.controller.cluster.databroker.actors.dds;
-import com.google.common.base.Function;
import com.google.common.util.concurrent.FluentFuture;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.SettableFuture;
import java.util.Optional;
import java.util.function.Consumer;
import javax.annotation.Nullable;
import com.google.common.util.concurrent.FluentFuture;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.SettableFuture;
import java.util.Optional;
import java.util.function.Consumer;
import javax.annotation.Nullable;
+import org.opendaylight.controller.cluster.access.client.RequestTimeoutException;
import org.opendaylight.controller.cluster.access.commands.AbortLocalTransactionRequest;
import org.opendaylight.controller.cluster.access.commands.AbstractLocalTransactionRequest;
import org.opendaylight.controller.cluster.access.commands.AbstractReadTransactionRequest;
import org.opendaylight.controller.cluster.access.commands.AbortLocalTransactionRequest;
import org.opendaylight.controller.cluster.access.commands.AbstractLocalTransactionRequest;
import org.opendaylight.controller.cluster.access.commands.AbstractReadTransactionRequest;
import org.opendaylight.controller.cluster.access.commands.TransactionRequest;
import org.opendaylight.controller.cluster.access.commands.TransactionSuccess;
import org.opendaylight.controller.cluster.access.commands.TransactionWrite;
import org.opendaylight.controller.cluster.access.commands.TransactionRequest;
import org.opendaylight.controller.cluster.access.commands.TransactionSuccess;
import org.opendaylight.controller.cluster.access.commands.TransactionWrite;
+import org.opendaylight.controller.cluster.access.concepts.RequestException;
import org.opendaylight.controller.cluster.access.concepts.RequestFailure;
import org.opendaylight.controller.cluster.access.concepts.Response;
import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
import org.opendaylight.controller.cluster.datastore.util.AbstractDataTreeModificationCursor;
import org.opendaylight.controller.cluster.access.concepts.RequestFailure;
import org.opendaylight.controller.cluster.access.concepts.Response;
import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
import org.opendaylight.controller.cluster.datastore.util.AbstractDataTreeModificationCursor;
+import org.opendaylight.mdsal.common.api.DataStoreUnavailableException;
import org.opendaylight.mdsal.common.api.ReadFailedException;
import org.opendaylight.yangtools.util.concurrent.FluentFutures;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.mdsal.common.api.ReadFailedException;
import org.opendaylight.yangtools.util.concurrent.FluentFutures;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
final class RemoteProxyTransaction extends AbstractProxyTransaction {
private static final Logger LOG = LoggerFactory.getLogger(RemoteProxyTransaction.class);
final class RemoteProxyTransaction extends AbstractProxyTransaction {
private static final Logger LOG = LoggerFactory.getLogger(RemoteProxyTransaction.class);
- private static final Function<Exception, Exception> NOOP_EXCEPTION_MAPPER = ex -> ex;
-
// FIXME: make this tuneable
private static final int REQUEST_MAX_MODIFICATIONS = 1000;
// FIXME: make this tuneable
private static final int REQUEST_MAX_MODIFICATIONS = 1000;
FluentFuture<Boolean> doExists(final YangInstanceIdentifier path) {
final SettableFuture<Boolean> future = SettableFuture.create();
return sendReadRequest(new ExistsTransactionRequest(getIdentifier(), nextSequence(), localActor(), path,
FluentFuture<Boolean> doExists(final YangInstanceIdentifier path) {
final SettableFuture<Boolean> future = SettableFuture.create();
return sendReadRequest(new ExistsTransactionRequest(getIdentifier(), nextSequence(), localActor(), path,
- isSnapshotOnly()), t -> completeExists(future, t), future);
+ isSnapshotOnly()), t -> completeExists(path, future, t), future);
}
@Override
FluentFuture<Optional<NormalizedNode<?, ?>>> doRead(final YangInstanceIdentifier path) {
final SettableFuture<Optional<NormalizedNode<?, ?>>> future = SettableFuture.create();
return sendReadRequest(new ReadTransactionRequest(getIdentifier(), nextSequence(), localActor(), path,
}
@Override
FluentFuture<Optional<NormalizedNode<?, ?>>> doRead(final YangInstanceIdentifier path) {
final SettableFuture<Optional<NormalizedNode<?, ?>>> future = SettableFuture.create();
return sendReadRequest(new ReadTransactionRequest(getIdentifier(), nextSequence(), localActor(), path,
- isSnapshotOnly()), t -> completeRead(future, t), future);
+ isSnapshotOnly()), t -> completeRead(path, future, t), future);
}
private void ensureInitializedBuilder() {
}
private void ensureInitializedBuilder() {
// Happy path
recordSuccessfulRequest(request);
} else {
// Happy path
recordSuccessfulRequest(request);
} else {
- recordFailedResponse(response, NOOP_EXCEPTION_MAPPER);
+ recordFailedResponse(response);
- private <X extends Exception> X recordFailedResponse(final Response<?, ?> response,
- final Function<Exception, X> exMapper) {
+ private Exception recordFailedResponse(final Response<?, ?> response) {
final Exception failure;
if (response instanceof RequestFailure) {
final Exception failure;
if (response instanceof RequestFailure) {
- failure = ((RequestFailure<?, ?>) response).getCause();
+ final RequestException cause = ((RequestFailure<?, ?>) response).getCause();
+ failure = cause instanceof RequestTimeoutException
+ ? new DataStoreUnavailableException(cause.getMessage(), cause) : cause;
} else {
LOG.warn("Unhandled response {}", response);
failure = new IllegalArgumentException("Unhandled response " + response.getClass());
} else {
LOG.warn("Unhandled response {}", response);
failure = new IllegalArgumentException("Unhandled response " + response.getClass());
LOG.debug("Transaction {} failed", getIdentifier(), failure);
operationFailure = failure;
}
LOG.debug("Transaction {} failed", getIdentifier(), failure);
operationFailure = failure;
}
- return exMapper.apply(failure);
- private void failReadFuture(final SettableFuture<?> future, final Response<?, ?> response) {
- future.setException(recordFailedResponse(response, ReadFailedException.MAPPER));
+ private void failReadFuture(final SettableFuture<?> future, final String message,
+ final Response<?, ?> response) {
+ future.setException(new ReadFailedException(message, recordFailedResponse(response)));
- private void completeExists(final SettableFuture<Boolean> future, final Response<?, ?> response) {
- LOG.debug("Exists request completed with {}", response);
+ private void completeExists(final YangInstanceIdentifier path, final SettableFuture<Boolean> future,
+ final Response<?, ?> response) {
+ LOG.debug("Exists request for {} completed with {}", path, response);
if (response instanceof ExistsTransactionSuccess) {
future.set(((ExistsTransactionSuccess) response).getExists());
} else {
if (response instanceof ExistsTransactionSuccess) {
future.set(((ExistsTransactionSuccess) response).getExists());
} else {
- failReadFuture(future, response);
+ failReadFuture(future, "Error executing exists request for path " + path, response);
}
recordFinishedRequest(response);
}
}
recordFinishedRequest(response);
}
- private void completeRead(final SettableFuture<Optional<NormalizedNode<?, ?>>> future,
- final Response<?, ?> response) {
- LOG.debug("Read request completed with {}", response);
+ private void completeRead(final YangInstanceIdentifier path,
+ final SettableFuture<Optional<NormalizedNode<?, ?>>> future, final Response<?, ?> response) {
+ LOG.debug("Read request for {} completed with {}", path, response);
if (response instanceof ReadTransactionSuccess) {
future.set(((ReadTransactionSuccess) response).getData());
} else {
if (response instanceof ReadTransactionSuccess) {
future.set(((ReadTransactionSuccess) response).getData());
} else {
- failReadFuture(future, response);
+ failReadFuture(future, "Error reading data for path " + path, response);
}
recordFinishedRequest(response);
}
recordFinishedRequest(response);
final class ShardBackendInfo extends BackendInfo {
private final Optional<DataTree> dataTree;
private final UnsignedLong cookie;
final class ShardBackendInfo extends BackendInfo {
private final Optional<DataTree> dataTree;
private final UnsignedLong cookie;
- private final String shardName;
ShardBackendInfo(final ActorRef actor, final long sessionId, final ABIVersion version, final String shardName,
final UnsignedLong cookie, final Optional<DataTree> dataTree, final int maxMessages) {
ShardBackendInfo(final ActorRef actor, final long sessionId, final ABIVersion version, final String shardName,
final UnsignedLong cookie, final Optional<DataTree> dataTree, final int maxMessages) {
- super(actor, sessionId, version, maxMessages);
- this.shardName = Preconditions.checkNotNull(shardName);
+ super(actor, shardName, sessionId, version, maxMessages);
this.cookie = Preconditions.checkNotNull(cookie);
this.dataTree = Preconditions.checkNotNull(dataTree);
}
this.cookie = Preconditions.checkNotNull(cookie);
this.dataTree = Preconditions.checkNotNull(dataTree);
}
- String getShardName() {
- return shardName;
- }
-
LocalHistoryIdentifier brandHistory(final LocalHistoryIdentifier id) {
Preconditions.checkArgument(id.getCookie() == 0, "History %s is already branded", id);
return new LocalHistoryIdentifier(id.getClientId(), id.getHistoryId(), cookie.longValue());
LocalHistoryIdentifier brandHistory(final LocalHistoryIdentifier id) {
Preconditions.checkArgument(id.getCookie() == 0, "History %s is already branded", id);
return new LocalHistoryIdentifier(id.getClientId(), id.getHistoryId(), cookie.longValue());
@Override
protected ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) {
@Override
protected ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) {
- return super.addToStringAttributes(toStringHelper).add("cookie", cookie).add("shard", shardName)
+ return super.addToStringAttributes(toStringHelper).add("cookie", cookie).add("shard", getName())
.add("dataTree", getDataTree().isPresent() ? "present" : "absent");
}
}
.add("dataTree", getDataTree().isPresent() ? "present" : "absent");
}
}
return getBackendInfo(cookie);
}
return getBackendInfo(cookie);
}
+
+ @Override
+ public String resolveCookieName(Long cookie) {
+ return shardName;
+ }
final ShardBackendInfo shardBackendInfo = TestUtils.getWithTimeout(stage.toCompletableFuture());
Assert.assertEquals(0L, shardBackendInfo.getCookie().longValue());
Assert.assertEquals(dataTree, shardBackendInfo.getDataTree().get());
final ShardBackendInfo shardBackendInfo = TestUtils.getWithTimeout(stage.toCompletableFuture());
Assert.assertEquals(0L, shardBackendInfo.getCookie().longValue());
Assert.assertEquals(dataTree, shardBackendInfo.getDataTree().get());
- Assert.assertEquals(DefaultShardStrategy.DEFAULT_SHARD, shardBackendInfo.getShardName());
+ Assert.assertEquals(DefaultShardStrategy.DEFAULT_SHARD, shardBackendInfo.getName());