</dependency>
</dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ <configuration>
+ <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
<scm>
<connection>scm:git:http://git.opendaylight.org/gerrit/controller.git</connection>
<developerConnection>scm:git:ssh://git.opendaylight.org:29418/controller.git</developerConnection>
*/
@Beta
public enum ABIVersion implements WritableObject {
- // NOTE: enumeration values need to be sorted in asceding order of their version to keep Comparable working
+ // NOTE: enumeration values need to be sorted in ascending order of their version to keep Comparable working
/**
* Version which is older than any other version. This version exists purely for testing purposes.
*
* @return Current {@link ABIVersion}
*/
- public static @Nonnull ABIVersion current() {
+ @Nonnull
+ public static ABIVersion current() {
return BORON;
}
* Return the {@link ABIVersion} corresponding to an unsigned short integer. This method is provided for callers
* which provide their own recovery strategy in case of version incompatibility.
*
- * @param s Short integer as returned from {@link #shortValue()}
+ * @param value Short integer as returned from {@link #shortValue()}
* @return {@link ABIVersion}
* @throws FutureVersionException if the specified integer identifies a future version
* @throws PastVersionException if the specified integer identifies a past version which is no longer supported
*/
- public static @Nonnull ABIVersion valueOf(final short s) throws FutureVersionException, PastVersionException {
- switch (Short.toUnsignedInt(s)) {
+ @Nonnull
+ public static ABIVersion valueOf(final short value) throws FutureVersionException, PastVersionException {
+ switch (Short.toUnsignedInt(value)) {
case 0:
case 1:
case 2:
case 3:
case 4:
- throw new PastVersionException(s, BORON);
+ throw new PastVersionException(value, BORON);
case 5:
return BORON;
default:
- throw new FutureVersionException(s, BORON);
+ throw new FutureVersionException(value, BORON);
}
}
* @return An {@link ABIVersion}
* @throws IOException If read fails or an unsupported version is encountered
*/
- public static @Nonnull ABIVersion readFrom(final @Nonnull DataInput in) throws IOException {
+ @Nonnull
+ public static ABIVersion readFrom(@Nonnull final DataInput in) throws IOException {
final short s = in.readShort();
try {
return valueOf(s);
}
}
- public static ABIVersion inexactReadFrom(final @Nonnull DataInput in) throws IOException {
+ public static ABIVersion inexactReadFrom(@Nonnull final DataInput in) throws IOException {
final short onWire = in.readShort();
try {
return ABIVersion.valueOf(onWire);
*
* @return Closest supported {@link ABIVersion}
*/
- public final @Nonnull ABIVersion getClosestVersion() {
+ @Nonnull
+ public final ABIVersion getClosestVersion() {
return closestVersion;
}
public final class AbortLocalTransactionRequest extends AbstractLocalTransactionRequest<AbortLocalTransactionRequest> {
private static final long serialVersionUID = 1L;
- public AbortLocalTransactionRequest(final @Nonnull TransactionIdentifier identifier,
- final @Nonnull ActorRef replyTo) {
+ public AbortLocalTransactionRequest(@Nonnull final TransactionIdentifier identifier,
+ @Nonnull final ActorRef replyTo) {
super(identifier, 0, replyTo);
}
-}
\ No newline at end of file
+}
*
* @param <T> Message type
*/
-abstract class AbstractLocalHistoryRequestProxy<T extends LocalHistoryRequest<T>> extends AbstractRequestProxy<LocalHistoryIdentifier, T> {
+abstract class AbstractLocalHistoryRequestProxy<T extends LocalHistoryRequest<T>>
+ extends AbstractRequestProxy<LocalHistoryIdentifier, T> {
private static final long serialVersionUID = 1L;
- AbstractLocalHistoryRequestProxy() {
+ protected AbstractLocalHistoryRequestProxy() {
// For Externalizable
}
*
* @param <T> Message type
*/
-abstract class AbstractLocalTransactionRequest<T extends AbstractLocalTransactionRequest<T>> extends TransactionRequest<T> {
+abstract class AbstractLocalTransactionRequest<T extends AbstractLocalTransactionRequest<T>>
+ extends TransactionRequest<T> {
private static final long serialVersionUID = 1L;
- AbstractLocalTransactionRequest(final TransactionIdentifier identifier, final long sequence, final ActorRef replyTo) {
+ AbstractLocalTransactionRequest(final TransactionIdentifier identifier, final long sequence,
+ final ActorRef replyTo) {
super(identifier, sequence, replyTo);
}
* Abstract base class for {@link TransactionRequest}s accessing data as visible in the isolated context of a particular
* transaction. The path of the data being accessed is returned via {@link #getPath()}.
*
+ * <p>
* This class is visible outside of this package for the purpose of allowing common instanceof checks
* and simplified codepaths.
*
* @param <T> Message type
*/
@Beta
-public abstract class AbstractReadTransactionRequest<T extends AbstractReadTransactionRequest<T>> extends TransactionRequest<T> {
+public abstract class AbstractReadTransactionRequest<T extends AbstractReadTransactionRequest<T>>
+ extends TransactionRequest<T> {
private static final long serialVersionUID = 1L;
private final YangInstanceIdentifier path;
this.path = request.getPath();
}
- public final @Nonnull YangInstanceIdentifier getPath() {
+ @Nonnull
+ public final YangInstanceIdentifier getPath() {
return path;
}
*
* @param <T> Message type
*/
-abstract class AbstractReadTransactionRequestProxyV1<T extends AbstractReadTransactionRequest<T>> extends AbstractTransactionRequestProxy<T> {
+abstract class AbstractReadTransactionRequestProxyV1<T extends AbstractReadTransactionRequest<T>>
+ extends AbstractTransactionRequestProxy<T> {
private static final long serialVersionUID = 1L;
private YangInstanceIdentifier path;
- AbstractReadTransactionRequestProxyV1() {
+ protected AbstractReadTransactionRequestProxyV1() {
// For Externalizable
}
}
abstract T createReadRequest(TransactionIdentifier target, long sequence, ActorRef replyTo,
- YangInstanceIdentifier path);
+ YangInstanceIdentifier requestPath);
}
*
* @param <T> Message type
*/
-abstract class AbstractTransactionRequestProxy<T extends TransactionRequest<T>> extends AbstractRequestProxy<TransactionIdentifier, T> {
+abstract class AbstractTransactionRequestProxy<T extends TransactionRequest<T>>
+ extends AbstractRequestProxy<TransactionIdentifier, T> {
private static final long serialVersionUID = 1L;
- AbstractTransactionRequestProxy() {
+ protected AbstractTransactionRequestProxy() {
// For Externalizable
}
*
* @param <T> Message type
*/
-abstract class AbstractTransactionSuccessProxy<T extends TransactionSuccess<T>> extends AbstractSuccessProxy<TransactionIdentifier, T> {
+abstract class AbstractTransactionSuccessProxy<T extends TransactionSuccess<T>>
+ extends AbstractSuccessProxy<TransactionIdentifier, T> {
private static final long serialVersionUID = 1L;
- AbstractTransactionSuccessProxy() {
+ protected AbstractTransactionSuccessProxy() {
// For Externalizable
}
* @author Robert Varga
*/
@Beta
-public final class CommitLocalTransactionRequest extends AbstractLocalTransactionRequest<CommitLocalTransactionRequest> {
+public final class CommitLocalTransactionRequest
+ extends AbstractLocalTransactionRequest<CommitLocalTransactionRequest> {
private static final long serialVersionUID = 1L;
private final DataTreeModification mod;
private final boolean coordinated;
- public CommitLocalTransactionRequest(final @Nonnull TransactionIdentifier identifier,
- final @Nonnull ActorRef replyTo, final @Nonnull DataTreeModification mod, final boolean coordinated) {
+ public CommitLocalTransactionRequest(@Nonnull final TransactionIdentifier identifier,
+ @Nonnull final ActorRef replyTo, @Nonnull final DataTreeModification mod, final boolean coordinated) {
super(identifier, 0, replyTo);
this.mod = Preconditions.checkNotNull(mod);
this.coordinated = coordinated;
protected ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) {
return super.addToStringAttributes(toStringHelper).add("coordinated", coordinated);
}
-}
\ No newline at end of file
+}
* @author Robert Varga
*/
final class ConnectClientFailureProxyV1 extends AbstractRequestFailureProxy<ClientIdentifier, ConnectClientFailure> {
+ // checkstyle flags the public modifier as redundant however it is explicitly needed for Java serialization to
+ // be able to create instances via reflection.
+ @SuppressWarnings("checkstyle:RedundantModifier")
public ConnectClientFailureProxyV1() {
// For Externalizable
}
* - its minimum supported ABI version
* - its maximum supported ABI version
*
+ * <p>
* It also includes request stream sequencing information.
*
* @author Robert Varga
}
@Override
- public final ConnectClientFailure toRequestFailure(final RequestException cause) {
+ public ConnectClientFailure toRequestFailure(final RequestException cause) {
return new ConnectClientFailure(getTarget(), getSequence(), cause);
}
@Override
- protected AbstractRequestProxy<ClientIdentifier, ConnectClientRequest> externalizableProxy(final ABIVersion version) {
+ protected AbstractRequestProxy<ClientIdentifier, ConnectClientRequest> externalizableProxy(
+ final ABIVersion version) {
return new ConnectClientRequestProxyV1(this);
}
}
@Override
- protected @Nonnull ToStringHelper addToStringAttributes(final @Nonnull ToStringHelper toStringHelper) {
+ @Nonnull
+ protected ToStringHelper addToStringAttributes(@Nonnull final ToStringHelper toStringHelper) {
return super.addToStringAttributes(toStringHelper).add("minVersion", minVersion).add("maxVersion", maxVersion);
}
}
private ABIVersion minVersion;
private ABIVersion maxVersion;
+ // checkstyle flags the public modifier as redundant however it is explicitly needed for Java serialization to
+ // be able to create instances via reflection.
+ @SuppressWarnings("checkstyle:RedundantModifier")
public ConnectClientRequestProxyV1() {
// for Externalizable
}
this.maxMessages = maxMessages;
}
- public ConnectClientSuccess(final @Nonnull ClientIdentifier target, final long sequence,
- final @Nonnull ActorRef backend, final @Nonnull List<ActorSelection> alternates,
- final @Nonnull DataTree dataTree, final int maxMessages) {
+ public ConnectClientSuccess(@Nonnull final ClientIdentifier target, final long sequence,
+ @Nonnull final ActorRef backend, @Nonnull final List<ActorSelection> alternates,
+ @Nonnull final DataTree dataTree, final int maxMessages) {
this(target, sequence, backend, alternates, Optional.of(dataTree), maxMessages);
}
*
* @return a list of known backend alternates
*/
- public @Nonnull List<ActorSelection> getAlternates() {
+ @Nonnull
+ public List<ActorSelection> getAlternates() {
return alternates;
}
- public @Nonnull ActorRef getBackend() {
+ @Nonnull
+ public ActorRef getBackend() {
return backend;
}
private ActorRef backend;
private int maxMessages;
+ // checkstyle flags the public modifier as redundant however it is explicitly needed for Java serialization to
+ // be able to create instances via reflection.
+ @SuppressWarnings("checkstyle:RedundantModifier")
public ConnectClientSuccessProxyV1() {
// For Externalizable
}
}
@Override
- protected AbstractLocalHistoryRequestProxy<CreateLocalHistoryRequest> externalizableProxy(final ABIVersion version) {
+ protected AbstractLocalHistoryRequestProxy<CreateLocalHistoryRequest> externalizableProxy(
+ final ABIVersion version) {
return new CreateLocalHistoryRequestProxyV1(this);
}
final class CreateLocalHistoryRequestProxyV1 extends AbstractLocalHistoryRequestProxy<CreateLocalHistoryRequest> {
private static final long serialVersionUID = 1L;
+ // checkstyle flags the public modifier as redundant however it is explicitly needed for Java serialization to
+ // be able to create instances via reflection.
+ @SuppressWarnings("checkstyle:RedundantModifier")
public CreateLocalHistoryRequestProxyV1() {
// For Externalizable
}
public final class DestroyLocalHistoryRequest extends LocalHistoryRequest<DestroyLocalHistoryRequest> {
private static final long serialVersionUID = 1L;
- public DestroyLocalHistoryRequest(final LocalHistoryIdentifier target, final long sequence, final ActorRef replyTo) {
+ public DestroyLocalHistoryRequest(final LocalHistoryIdentifier target, final long sequence,
+ final ActorRef replyTo) {
super(target, sequence, replyTo);
}
}
@Override
- protected AbstractLocalHistoryRequestProxy<DestroyLocalHistoryRequest> externalizableProxy(final ABIVersion version) {
+ protected AbstractLocalHistoryRequestProxy<DestroyLocalHistoryRequest> externalizableProxy(
+ final ABIVersion version) {
return new DestroyLocalHistoryRequestProxyV1(this);
}
final class DestroyLocalHistoryRequestProxyV1 extends AbstractLocalHistoryRequestProxy<DestroyLocalHistoryRequest> {
private static final long serialVersionUID = 1L;
+ // checkstyle flags the public modifier as redundant however it is explicitly needed for Java serialization to
+ // be able to create instances via reflection.
+ @SuppressWarnings("checkstyle:RedundantModifier")
public DestroyLocalHistoryRequestProxyV1() {
// For Externalizable
}
public final class ExistsTransactionRequest extends AbstractReadTransactionRequest<ExistsTransactionRequest> {
private static final long serialVersionUID = 1L;
- public ExistsTransactionRequest(final @Nonnull TransactionIdentifier identifier, final long sequence,
- final @Nonnull ActorRef replyTo, final @Nonnull YangInstanceIdentifier path) {
+ public ExistsTransactionRequest(@Nonnull final TransactionIdentifier identifier, final long sequence,
+ @Nonnull final ActorRef replyTo, @Nonnull final YangInstanceIdentifier path) {
super(identifier, sequence, replyTo, path);
}
final class ExistsTransactionRequestProxyV1 extends AbstractReadTransactionRequestProxyV1<ExistsTransactionRequest> {
private static final long serialVersionUID = 1L;
+ // checkstyle flags the public modifier as redundant however it is explicitly needed for Java serialization to
+ // be able to create instances via reflection.
+ @SuppressWarnings("checkstyle:RedundantModifier")
public ExistsTransactionRequestProxyV1() {
// For Externalizable
}
final ActorRef replyTo, final YangInstanceIdentifier path) {
return new ExistsTransactionRequest(target, sequence, replyTo, path);
}
-}
\ No newline at end of file
+}
private static final long serialVersionUID = 1L;
private boolean exists;
+ // checkstyle flags the public modifier as redundant however it is explicitly needed for Java serialization to
+ // be able to create instances via reflection.
+ @SuppressWarnings("checkstyle:RedundantModifier")
public ExistsTransactionSuccessProxyV1() {
// For Externalizable
}
*
* @author Robert Varga
*/
-final class LocalHistoryFailureProxyV1 extends AbstractRequestFailureProxy<LocalHistoryIdentifier, LocalHistoryFailure> {
+final class LocalHistoryFailureProxyV1 extends
+ AbstractRequestFailureProxy<LocalHistoryIdentifier, LocalHistoryFailure> {
private static final long serialVersionUID = 1L;
+ // checkstyle flags the public modifier as redundant however it is explicitly needed for Java serialization to
+ // be able to create instances via reflection.
+ @SuppressWarnings("checkstyle:RedundantModifier")
public LocalHistoryFailureProxyV1() {
// For Externalizable
}
final class LocalHistorySuccessProxyV1 extends AbstractSuccessProxy<LocalHistoryIdentifier, LocalHistorySuccess> {
private static final long serialVersionUID = 1L;
- LocalHistorySuccessProxyV1() {
+ // checkstyle flags the public modifier as redundant however it is explicitly needed for Java serialization to
+ // be able to create instances via reflection.
+ @SuppressWarnings("checkstyle:RedundantModifier")
+ public LocalHistorySuccessProxyV1() {
// For Externalizable
}
}
@Override
- protected final LocalHistoryIdentifier readTarget(final DataInput in) throws IOException {
+ protected LocalHistoryIdentifier readTarget(final DataInput in) throws IOException {
return LocalHistoryIdentifier.readFrom(in);
}
private List<TransactionModification> modifications;
private Optional<PersistenceProtocol> protocol;
+ // checkstyle flags the public modifier as redundant however it is explicitly needed for Java serialization to
+ // be able to create instances via reflection.
+ @SuppressWarnings("checkstyle:RedundantModifier")
public ModifyTransactionRequestProxyV1() {
// For Externalizable
}
out.writeByte(byteValue());
}
- abstract byte byteValue();
-
public static PersistenceProtocol readFrom(final DataInput in) throws IOException {
return valueOf(in.readByte());
}
+ abstract byte byteValue();
+
static int byteValue(final PersistenceProtocol finish) {
return finish == null ? 0 : finish.byteValue();
}
- static PersistenceProtocol valueOf(final byte b) {
- switch (b) {
+ static PersistenceProtocol valueOf(final byte value) {
+ switch (value) {
case 0:
return null;
case 1:
case 3:
return THREE_PHASE;
default:
- throw new IllegalArgumentException("Unhandled byte value " + b);
+ throw new IllegalArgumentException("Unhandled byte value " + value);
}
}
}
final class PurgeLocalHistoryRequestProxyV1 extends AbstractLocalHistoryRequestProxy<PurgeLocalHistoryRequest> {
private static final long serialVersionUID = 1L;
+ // checkstyle flags the public modifier as redundant however it is explicitly needed for Java serialization to
+ // be able to create instances via reflection.
+ @SuppressWarnings("checkstyle:RedundantModifier")
public PurgeLocalHistoryRequestProxyV1() {
// For Externalizable
}
public final class ReadTransactionRequest extends AbstractReadTransactionRequest<ReadTransactionRequest> {
private static final long serialVersionUID = 1L;
- public ReadTransactionRequest(final @Nonnull TransactionIdentifier identifier, final long sequence,
- final @Nonnull ActorRef replyTo, final @Nonnull YangInstanceIdentifier path) {
+ public ReadTransactionRequest(@Nonnull final TransactionIdentifier identifier, final long sequence,
+ @Nonnull final ActorRef replyTo, @Nonnull final YangInstanceIdentifier path) {
super(identifier, sequence, replyTo, path);
}
final class ReadTransactionRequestProxyV1 extends AbstractReadTransactionRequestProxyV1<ReadTransactionRequest> {
private static final long serialVersionUID = 1L;
+ // checkstyle flags the public modifier as redundant however it is explicitly needed for Java serialization to
+ // be able to create instances via reflection.
+ @SuppressWarnings("checkstyle:RedundantModifier")
public ReadTransactionRequestProxyV1() {
// For Externalizable
}
final ActorRef replyTo, final YangInstanceIdentifier path) {
return new ReadTransactionRequest(target, sequence, replyTo, path);
}
-}
\ No newline at end of file
+}
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
/**
- * Successful reply to an {@link ReadTransactionRequest}. It indicates presence of requested data via {@link #getData()}.
+ * Successful reply to an {@link ReadTransactionRequest}. It indicates presence of requested data via
+ * {@link #getData()}.
*
* @author Robert Varga
*/
private static final long serialVersionUID = 1L;
private Optional<NormalizedNode<?, ?>> data;
+ // checkstyle flags the public modifier as redundant however it is explicitly needed for Java serialization to
+ // be able to create instances via reflection.
+ @SuppressWarnings("checkstyle:RedundantModifier")
public ReadTransactionSuccessProxyV1() {
// For Externalizable
}
final class TransactionAbortRequestProxyV1 extends AbstractTransactionRequestProxy<TransactionAbortRequest> {
private static final long serialVersionUID = 1L;
+ // checkstyle flags the public modifier as redundant however it is explicitly needed for Java serialization to
+ // be able to create instances via reflection.
+ @SuppressWarnings("checkstyle:RedundantModifier")
public TransactionAbortRequestProxyV1() {
// For Externalizable
}
final class TransactionAbortSuccessProxyV1 extends AbstractTransactionSuccessProxy<TransactionAbortSuccess> {
private static final long serialVersionUID = 1L;
+ // checkstyle flags the public modifier as redundant however it is explicitly needed for Java serialization to
+ // be able to create instances via reflection.
+ @SuppressWarnings("checkstyle:RedundantModifier")
public TransactionAbortSuccessProxyV1() {
// For Externalizable
}
}
@Override
- protected AbstractTransactionSuccessProxy<TransactionCanCommitSuccess> externalizableProxy(final ABIVersion version) {
+ protected AbstractTransactionSuccessProxy<TransactionCanCommitSuccess> externalizableProxy(
+ final ABIVersion version) {
return new TransactionCanCommitSuccessProxyV1(this);
}
final class TransactionCanCommitSuccessProxyV1 extends AbstractTransactionSuccessProxy<TransactionCanCommitSuccess> {
private static final long serialVersionUID = 1L;
+ // checkstyle flags the public modifier as redundant however it is explicitly needed for Java serialization to
+ // be able to create instances via reflection.
+ @SuppressWarnings("checkstyle:RedundantModifier")
public TransactionCanCommitSuccessProxyV1() {
// For Externalizable
}
final class TransactionCommitSuccessProxyV1 extends AbstractTransactionSuccessProxy<TransactionCommitSuccess> {
private static final long serialVersionUID = 1L;
+ // checkstyle flags the public modifier as redundant however it is explicitly needed for Java serialization to
+ // be able to create instances via reflection.
+ @SuppressWarnings("checkstyle:RedundantModifier")
public TransactionCommitSuccessProxyV1() {
// For Externalizable
}
final class TransactionDoCommitRequestProxyV1 extends AbstractTransactionRequestProxy<TransactionDoCommitRequest> {
private static final long serialVersionUID = 1L;
+ // checkstyle flags the public modifier as redundant however it is explicitly needed for Java serialization to
+ // be able to create instances via reflection.
+ @SuppressWarnings("checkstyle:RedundantModifier")
public TransactionDoCommitRequestProxyV1() {
// For Externalizable
}
final class TransactionFailureProxyV1 extends AbstractRequestFailureProxy<TransactionIdentifier, TransactionFailure> {
private static final long serialVersionUID = 1L;
+ // checkstyle flags the public modifier as redundant however it is explicitly needed for Java serialization to
+ // be able to create instances via reflection.
+ @SuppressWarnings("checkstyle:RedundantModifier")
public TransactionFailureProxyV1() {
// For Externalizable
}
public final class TransactionPreCommitRequest extends TransactionRequest<TransactionPreCommitRequest> {
private static final long serialVersionUID = 1L;
- public TransactionPreCommitRequest(final TransactionIdentifier target, final long sequence, final ActorRef replyTo) {
+ public TransactionPreCommitRequest(final TransactionIdentifier target, final long sequence,
+ final ActorRef replyTo) {
super(target, sequence, replyTo);
}
import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
/**
- * Externalizable proxy for use with {@link TransactionPreCommitRequest}. It implements the initial (Boron) serialization
- * format.
+ * Externalizable proxy for use with {@link TransactionPreCommitRequest}. It implements the initial (Boron)
+ * serialization format.
*
* @author Robert Varga
*/
final class TransactionPreCommitRequestProxyV1 extends AbstractTransactionRequestProxy<TransactionPreCommitRequest> {
private static final long serialVersionUID = 1L;
+ // checkstyle flags the public modifier as redundant however it is explicitly needed for Java serialization to
+ // be able to create instances via reflection.
+ @SuppressWarnings("checkstyle:RedundantModifier")
public TransactionPreCommitRequestProxyV1() {
// For Externalizable
}
}
@Override
- protected AbstractTransactionSuccessProxy<TransactionPreCommitSuccess> externalizableProxy(final ABIVersion version) {
+ protected AbstractTransactionSuccessProxy<TransactionPreCommitSuccess> externalizableProxy(
+ final ABIVersion version) {
return new TransactionPreCommitSuccessProxyV1(this);
}
final class TransactionPreCommitSuccessProxyV1 extends AbstractTransactionSuccessProxy<TransactionPreCommitSuccess> {
private static final long serialVersionUID = 1L;
+ // checkstyle flags the public modifier as redundant however it is explicitly needed for Java serialization to
+ // be able to create instances via reflection.
+ @SuppressWarnings("checkstyle:RedundantModifier")
public TransactionPreCommitSuccessProxyV1() {
// For Externalizable
}
* @param <T> Message type
*/
@Beta
-public abstract class TransactionSuccess<T extends TransactionSuccess<T>> extends RequestSuccess<TransactionIdentifier, T> {
+public abstract class TransactionSuccess<T extends TransactionSuccess<T>>
+ extends RequestSuccess<TransactionIdentifier, T> {
private static final long serialVersionUID = 1L;
TransactionSuccess(final TransactionIdentifier identifier, final long sequence) {
private long sessionId;
private long txSequence;
- public AbstractEnvelopeProxy() {
+ protected AbstractEnvelopeProxy() {
// for Externalizable
}
message = (T) in.readObject();
}
- abstract Envelope<T> createEnvelope(T message, long sessionId, long txSequence);
+ abstract Envelope<T> createEnvelope(T wrappedNessage, long envSessionId, long envTxSequence);
final Object readResolve() {
return createEnvelope(message, sessionId, txSequence);
}
-}
\ No newline at end of file
+}
// For Externalizable
}
- AbstractMessageProxy(final @Nonnull C message) {
+ AbstractMessageProxy(@Nonnull final C message) {
this.target = message.getTarget();
this.sequence = message.getSequence();
}
return Verify.verifyNotNull(createMessage(target, sequence));
}
- protected abstract @Nonnull T readTarget(@Nonnull DataInput in) throws IOException;
- abstract @Nonnull C createMessage(@Nonnull T target, long sequence);
-}
\ No newline at end of file
+ @Nonnull
+ protected abstract T readTarget(@Nonnull DataInput in) throws IOException;
+
+ @Nonnull
+ abstract C createMessage(@Nonnull T msgTarget, long msgSequence);
+}
// For Externalizable
}
- protected AbstractRequestFailureProxy(final @Nonnull C failure) {
+ protected AbstractRequestFailureProxy(@Nonnull final C failure) {
super(failure);
this.cause = failure.getCause();
}
return createFailure(target, sequence, cause);
}
- protected abstract @Nonnull C createFailure(@Nonnull T target, long sequence, @Nonnull RequestException cause);
-}
\ No newline at end of file
+ @Nonnull
+ protected abstract C createFailure(@Nonnull T target, long sequence, @Nonnull RequestException failureCause);
+}
// For Externalizable
}
- protected AbstractRequestProxy(final @Nonnull C request) {
+ protected AbstractRequestProxy(@Nonnull final C request) {
super(request);
this.replyTo = request.getReplyTo();
}
}
@Override
- final @Nonnull C createMessage(@Nonnull final T target, final long sequence) {
+ @Nonnull
+ final C createMessage(@Nonnull final T target, final long sequence) {
return createRequest(target, sequence, replyTo);
}
- protected abstract @Nonnull C createRequest(@Nonnull T target, long sequence, @Nonnull ActorRef replyTo);
-}
\ No newline at end of file
+ @Nonnull
+ protected abstract C createRequest(@Nonnull T target, long sequence, @Nonnull ActorRef replyToActor);
+}
abstract class AbstractResponseEnvelopeProxy<T extends Response<?, ?>> extends AbstractEnvelopeProxy<T> {
private static final long serialVersionUID = 1L;
- public AbstractResponseEnvelopeProxy() {
+ protected AbstractResponseEnvelopeProxy() {
// for Externalizable
}
@Override
abstract ResponseEnvelope<T> createEnvelope(T message, long sequence, long retry);
-}
\ No newline at end of file
+}
extends AbstractMessageProxy<T, C> {
private static final long serialVersionUID = 1L;
- AbstractResponseProxy() {
+ protected AbstractResponseProxy() {
// for Externalizable
}
- AbstractResponseProxy(final @Nonnull C response) {
+ AbstractResponseProxy(@Nonnull final C response) {
super(response);
}
return createResponse(target, sequence);
}
- abstract @Nonnull C createResponse(@Nonnull T target, long sequence);
+ @Nonnull
+ abstract C createResponse(@Nonnull T target, long sequence);
}
// For Externalizable
}
- protected AbstractSuccessProxy(final @Nonnull C success) {
+ protected AbstractSuccessProxy(@Nonnull final C success) {
super(success);
}
return createSuccess(target, sequence);
}
- protected abstract @Nonnull C createSuccess(@Nonnull T target, long sequence);
-}
\ No newline at end of file
+ @Nonnull
+ protected abstract C createSuccess(@Nonnull T target, long sequence);
+}
private FrontendIdentifier frontendId;
private long generation;
+ // checkstyle flags the public modifier as redundant however it is explicitly needed for Java serialization to
+ // be able to create instances via reflection.
+ @SuppressWarnings("checkstyle:RedundantModifier")
public Proxy() {
// Needed for Externalizable
}
}
@Override
- public boolean equals(final Object o) {
- if (this == o) {
+ public boolean equals(final Object obj) {
+ if (this == obj) {
return true;
}
- if (!(o instanceof ClientIdentifier)) {
+ if (!(obj instanceof ClientIdentifier)) {
return false;
}
- final ClientIdentifier other = (ClientIdentifier) o;
+ final ClientIdentifier other = (ClientIdentifier) obj;
return generation == other.generation && frontendId.equals(other.frontendId);
}
}
/**
- * Get the enclosed message
+ * Get the enclosed message.
*
* @return enclose message
*/
final class FailureEnvelopeProxy extends AbstractResponseEnvelopeProxy<RequestFailure<?, ?>> {
private static final long serialVersionUID = 1L;
+ // checkstyle flags the public modifier as redundant however it is explicitly needed for Java serialization to be
+ // able to create instances via reflection.
+ @SuppressWarnings("checkstyle:RedundantModifier")
public FailureEnvelopeProxy() {
// for Externalizable
}
private MemberName memberName;
private FrontendType clientType;
+ // checkstyle flags the public modifier as redundant however it is explicitly needed for Java serialization to
+ // be able to create instances via reflection.
+ @SuppressWarnings("checkstyle:RedundantModifier")
public Proxy() {
// Needed for Externalizable
}
}
@Override
- public boolean equals(final Object o) {
- if (this == o) {
+ public boolean equals(final Object obj) {
+ if (this == obj) {
return true;
}
- if (!(o instanceof FrontendIdentifier)) {
+ if (!(obj instanceof FrontendIdentifier)) {
return false;
}
- final FrontendIdentifier other = (FrontendIdentifier) o;
+ final FrontendIdentifier other = (FrontendIdentifier) obj;
return memberName.equals(other.memberName) && clientType.equals(other.clientType);
}
private static final long serialVersionUID = 1L;
private byte[] serialized;
+ // checkstyle flags the public modifier as redundant however it is explicitly needed for Java serialization to
+ // be able to create instances via reflection.
+ @SuppressWarnings("checkstyle:RedundantModifier")
public Proxy() {
// For Externalizable
}
* - US-ASCII letters and numbers
* - special characters: -_.*+:=,!~';
*
+ * @param name the input name
* @return A {@link FrontendType} instance
* @throws IllegalArgumentException if the string is null, empty or contains invalid characters
*/
@Override
public void writeTo(final DataOutput out) throws IOException {
- final byte[] serialized = getSerialized();
- out.writeInt(serialized.length);
- out.write(serialized);
+ final byte[] local = getSerialized();
+ out.writeInt(local.length);
+ out.write(local);
}
public String getName() {
}
@Override
- public boolean equals(final Object o) {
- return this == o || (o instanceof FrontendType && name.equals(((FrontendType)o).name));
+ public boolean equals(final Object obj) {
+ return this == obj || obj instanceof FrontendType && name.equals(((FrontendType)obj).name);
}
@Override
- public int compareTo(final FrontendType o) {
- return this == o ? 0 : name.compareTo(o.name);
+ public int compareTo(final FrontendType obj) {
+ return this == obj ? 0 : name.compareTo(obj.name);
}
@Override
private long historyId;
private long cookie;
+ // checkstyle flags the public modifier as redundant however it is explicitly needed for Java serialization to
+ // be able to create instances via reflection.
+ @SuppressWarnings("checkstyle:RedundantModifier")
public Proxy() {
// For Externalizable
}
}
@Override
- public boolean equals(final Object o) {
- if (this == o) {
+ public boolean equals(final Object obj) {
+ if (this == obj) {
return true;
}
- if (!(o instanceof LocalHistoryIdentifier)) {
+ if (!(obj instanceof LocalHistoryIdentifier)) {
return false;
}
- final LocalHistoryIdentifier other = (LocalHistoryIdentifier) o;
+ final LocalHistoryIdentifier other = (LocalHistoryIdentifier) obj;
return historyId == other.historyId && cookie == other.cookie && clientId.equals(other.clientId);
}
private static final long serialVersionUID = 1L;
private byte[] serialized;
+ // checkstyle flags the public modifier as redundant however it is explicitly needed for Java serialization to
+ // be able to create instances via reflection.
+ @SuppressWarnings("checkstyle:RedundantModifier")
public Proxy() {
// For Externalizable
}
@Override
public void writeTo(final DataOutput out) throws IOException {
- final byte[] serialized = getSerialized();
- out.writeInt(serialized.length);
- out.write(serialized);
+ final byte[] local = getSerialized();
+ out.writeInt(local.length);
+ out.write(local);
}
public String getName() {
}
@Override
- public boolean equals(final Object o) {
- return this == o || (o instanceof MemberName && name.equals(((MemberName)o).name));
+ public boolean equals(final Object obj) {
+ return this == obj || obj instanceof MemberName && name.equals(((MemberName)obj).name);
}
@Override
- public int compareTo(final MemberName o) {
- return this == o ? 0 : name.compareTo(o.name);
+ public int compareTo(final MemberName obj) {
+ return this == obj ? 0 : name.compareTo(obj.name);
}
@Override
* An abstract concept of a Message. This class cannot be instantiated directly, use its specializations {@link Request}
* and {@link Response}.
*
+ * <p>
* Messages have a target and a sequence number. Sequence numbers are expected to be assigned monotonically on a
* per-target basis, hence two targets can observe the same sequence number.
*
+ * <p>
* This class includes explicit versioning for forward- and backward- compatibility of serialization format. This is
* achieved by using the serialization proxy pattern. Subclasses are in complete control of what proxy is used to
* serialize a particular object on the wire. This class can serve as an explicit version marker, hence no further
* action is necessary in the deserialization path.
*
+ * <p>
* For the serialization path an explicit call from the user is required to select the appropriate serialization
* version. This is done via {@link #toVersion(ABIVersion)} method, which should return a copy of this object with
* the requested ABI version recorded and should return the appropriate serialization proxy.
*
+ * <p>
* This workflow allows least disturbance across ABI versions, as all messages not affected by a ABI version bump
* will remain working with the same serialization format for the new ABI version.
*
+ * <p>
* Note that this class specifies the {@link Immutable} contract, which means that all subclasses must follow this API
* contract.
*
*
* @return Target identifier
*/
- public final @Nonnull T getTarget() {
+ @Nonnull
+ public final T getTarget() {
return target;
}
}
@VisibleForTesting
- public final @Nonnull ABIVersion getVersion() {
+ @Nonnull
+ public final ABIVersion getVersion() {
return version;
}
/**
* Return a message which will end up being serialized in the specified {@link ABIVersion}.
*
- * @param version Request {@link ABIVersion}
+ * @param toVersion Request {@link ABIVersion}
* @return A new message which will use ABIVersion as its serialization.
*/
@SuppressWarnings("unchecked")
- public final @Nonnull C toVersion(final @Nonnull ABIVersion version) {
- if (this.version == version) {
+ @Nonnull
+ public final C toVersion(@Nonnull final ABIVersion toVersion) {
+ if (this.version == toVersion) {
return (C)this;
}
- switch (version) {
+ switch (toVersion) {
case BORON:
- return Verify.verifyNotNull(cloneAsVersion(version));
+ return Verify.verifyNotNull(cloneAsVersion(toVersion));
case TEST_PAST_VERSION:
case TEST_FUTURE_VERSION:
+ default:
// Fall-through to throw
break;
}
- throw new IllegalArgumentException("Unhandled ABI version " + version);
+ throw new IllegalArgumentException("Unhandled ABI version " + toVersion);
}
/**
* method should be implemented by the concrete final message class and should invoke the equivalent of
* {@link #Message(Message, ABIVersion)}.
*
- * @param version target ABI version
+ * @param targetVersion target ABI version
* @return A message with the specified serialization stream
* @throws IllegalArgumentException if this message does not support the target ABI
*/
- protected abstract @Nonnull C cloneAsVersion(@Nonnull ABIVersion version);
+ @Nonnull
+ protected abstract C cloneAsVersion(@Nonnull ABIVersion targetVersion);
@Override
public final String toString() {
* @return The {@link ToStringHelper} passed in as argument
* @throws NullPointerException if toStringHelper is null
*/
- protected @Nonnull ToStringHelper addToStringAttributes(final @Nonnull ToStringHelper toStringHelper) {
+ @Nonnull
+ protected ToStringHelper addToStringAttributes(@Nonnull final ToStringHelper toStringHelper) {
return toStringHelper.add("target", target).add("sequence", Long.toUnsignedString(sequence));
}
* different objects for incompatible {@link ABIVersion}s. This method should never fail, as any compatibility
* checks should have been done by {@link #cloneAsVersion(ABIVersion)}.
*
- * @param version Requested ABI version
+ * @param reqVersion Requested ABI version
* @return Proxy for this object
*/
- abstract @Nonnull AbstractMessageProxy<T, C> externalizableProxy(@Nonnull ABIVersion version);
+ @Nonnull
+ abstract AbstractMessageProxy<T, C> externalizableProxy(@Nonnull ABIVersion reqVersion);
protected final Object writeReplace() {
return externalizableProxy(version);
private static final long serialVersionUID = 1L;
private final ActorRef replyTo;
- protected Request(final @Nonnull T target, final long sequence, final @Nonnull ActorRef replyTo) {
+ protected Request(@Nonnull final T target, final long sequence, @Nonnull final ActorRef replyTo) {
super(target, sequence);
this.replyTo = Preconditions.checkNotNull(replyTo);
}
- protected Request(final @Nonnull C request, final @Nonnull ABIVersion version) {
+ protected Request(@Nonnull final C request, @Nonnull final ABIVersion version) {
super(request, version);
this.replyTo = Preconditions.checkNotNull(request.getReplyTo());
}
*
* @return Original requestor
*/
- public final @Nonnull ActorRef getReplyTo() {
+ @Nonnull
+ public final ActorRef getReplyTo() {
return replyTo;
}
* @param cause Failure cause
* @return {@link RequestFailure} corresponding to this request
*/
- public abstract @Nonnull RequestFailure<T, ?> toRequestFailure(final @Nonnull RequestException cause);
+ @Nonnull
+ public abstract RequestFailure<T, ?> toRequestFailure(@Nonnull final RequestException cause);
@Override
protected ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) {
final class RequestEnvelopeProxy extends AbstractEnvelopeProxy<Request<?, ?>> {
private static final long serialVersionUID = 1L;
+ // checkstyle flags the public modifier as redundant however it is explicitly needed for Java serialization to
+ // be able to create instances via reflection.
+ @SuppressWarnings("checkstyle:RedundantModifier")
public RequestEnvelopeProxy() {
// for Externalizable
}
public abstract class RequestException extends Exception {
private static final long serialVersionUID = 1L;
- protected RequestException(final @Nonnull String message) {
+ protected RequestException(@Nonnull final String message) {
super(Preconditions.checkNotNull(message));
}
- protected RequestException(final @Nonnull String message, final @Nonnull Exception cause) {
+ protected RequestException(@Nonnull final String message, @Nonnull final Exception cause) {
super(Preconditions.checkNotNull(message), Preconditions.checkNotNull(cause));
}
* @param <C> Message class
*/
@Beta
-public abstract class RequestFailure<T extends WritableIdentifier, C extends RequestFailure<T, C>> extends Response<T, C> {
+public abstract class RequestFailure<T extends WritableIdentifier, C extends RequestFailure<T, C>>
+ extends Response<T, C> {
private static final long serialVersionUID = 1L;
private final RequestException cause;
- protected RequestFailure(final @Nonnull C failure, final @Nonnull ABIVersion version) {
+ protected RequestFailure(@Nonnull final C failure, @Nonnull final ABIVersion version) {
super(failure, version);
this.cause = Preconditions.checkNotNull(failure.getCause());
}
- protected RequestFailure(final @Nonnull T target, final long sequence, final @Nonnull RequestException cause) {
+ protected RequestFailure(@Nonnull final T target, final long sequence, @Nonnull final RequestException cause) {
super(target, sequence);
this.cause = Preconditions.checkNotNull(cause);
}
*
* @return Failure cause.
*/
- public final @Nonnull RequestException getCause() {
+ @Nonnull
+ public final RequestException getCause() {
return cause;
}
Response<T, C> {
private static final long serialVersionUID = 1L;
- protected RequestSuccess(final @Nonnull C success, final @Nonnull ABIVersion version) {
+ protected RequestSuccess(@Nonnull final C success, @Nonnull final ABIVersion version) {
super(success, version);
}
- protected RequestSuccess(final @Nonnull T target, final long sequence) {
+ protected RequestSuccess(@Nonnull final T target, final long sequence) {
super(target, sequence);
}
public abstract class Response<T extends WritableIdentifier, C extends Response<T, C>> extends Message<T, C> {
private static final long serialVersionUID = 1L;
- Response(final @Nonnull T target, final long sequence) {
+ Response(@Nonnull final T target, final long sequence) {
super(target, sequence);
}
- Response(final @Nonnull C response, final @Nonnull ABIVersion version) {
+ Response(@Nonnull final C response, @Nonnull final ABIVersion version) {
super(response, version);
}
final class SuccessEnvelopeProxy extends AbstractResponseEnvelopeProxy<RequestSuccess<?, ?>> {
private static final long serialVersionUID = 1L;
+ // checkstyle flags the public modifier as redundant however it is explicitly needed for Java serialization to
+ // be able to create instances via reflection.
+ @SuppressWarnings("checkstyle:RedundantModifier")
public SuccessEnvelopeProxy() {
// for Externalizable
}
private LocalHistoryIdentifier historyId;
private long transactionId;
+ // checkstyle flags the public modifier as redundant however it is explicitly needed for Java serialization to
+ // be able to create instances via reflection.
+ @SuppressWarnings("checkstyle:RedundantModifier")
public Proxy() {
// For Externalizable
}
private final long transactionId;
private transient String shortString;
- public TransactionIdentifier(final @Nonnull LocalHistoryIdentifier historyId, final long transactionId) {
+ public TransactionIdentifier(@Nonnull final LocalHistoryIdentifier historyId, final long transactionId) {
this.historyId = Preconditions.checkNotNull(historyId);
this.transactionId = transactionId;
}
}
@Override
- public boolean equals(final Object o) {
- if (this == o) {
+ public boolean equals(final Object obj) {
+ if (this == obj) {
return true;
}
- if (!(o instanceof TransactionIdentifier)) {
+ if (!(obj instanceof TransactionIdentifier)) {
return false;
}
- final TransactionIdentifier other = (TransactionIdentifier) o;
+ final TransactionIdentifier other = (TransactionIdentifier) obj;
return transactionId == other.transactionId && historyId.equals(other.historyId);
}
public String toShortString() {
- if(shortString == null) {
+ if (shortString == null) {
String histStr = historyId.getHistoryId() == 0 ? "" : "-chn-" + historyId.getHistoryId();
- shortString = historyId.getClientId().getFrontendId().getMemberName().getName() + "-" +
- historyId.getClientId().getFrontendId().getClientType().getName() + "-fe-" +
- historyId.getClientId().getGeneration() + histStr + "-txn-" + transactionId;
+ shortString = historyId.getClientId().getFrontendId().getMemberName().getName() + "-"
+ + historyId.getClientId().getFrontendId().getClientType().getName() + "-fe-"
+ + historyId.getClientId().getGeneration() + histStr + "-txn-" + transactionId;
}
return shortString;
import static org.opendaylight.controller.cluster.access.ABIVersion.BORON;
import static org.opendaylight.controller.cluster.access.ABIVersion.TEST_FUTURE_VERSION;
import static org.opendaylight.controller.cluster.access.ABIVersion.TEST_PAST_VERSION;
+
import com.google.common.io.ByteArrayDataOutput;
import com.google.common.io.ByteStreams;
import java.io.IOException;
assertEquals(BORON, ABIVersion.readFrom(ByteStreams.newDataInput(writeVersion(BORON))));
}
- @Test(expected=PastVersionException.class)
+ @Test(expected = PastVersionException.class)
public void testInvalidPastVersion() throws Exception {
ABIVersion.valueOf(TEST_PAST_VERSION.shortValue());
}
- @Test(expected=FutureVersionException.class)
+ @Test(expected = FutureVersionException.class)
public void testInvalidFutureVersion() throws Exception {
ABIVersion.valueOf(TEST_FUTURE_VERSION.shortValue());
}
return bado.toByteArray();
}
- @Test(expected=IOException.class)
+ @Test(expected = IOException.class)
public void testBadRead() throws IOException {
ABIVersion.readFrom(ByteStreams.newDataInput(writeVersion(TEST_PAST_VERSION)));
}
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
+
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
public abstract class AbstractIdentifierTest<T extends Identifier> {
abstract T object();
+
abstract T differentObject();
+
abstract T equalObject();
@Test
}
@SuppressWarnings("unchecked")
- private static <T> T copy(T o) throws IOException, ClassNotFoundException {
+ private static <T> T copy(T obj) throws IOException, ClassNotFoundException {
final ByteArrayOutputStream bos = new ByteArrayOutputStream();
try (ObjectOutputStream oos = new ObjectOutputStream(bos)) {
- oos.writeObject(o);
+ oos.writeObject(obj);
}
try (ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(bos.toByteArray()))) {
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
+
import org.junit.Test;
public class MemberNameTest extends AbstractIdentifierTest<MemberName> {