X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-distributed-datastore%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2Fmessages%2FDataExists.java;h=1bd687cbb7576c65513cafd8e4823c502914bcb5;hb=583f30d1c7a8199b401c9393745c62fe27b5ced8;hp=7d1bcdb8f65c3273e50685eaa58c76cdc6d67d9b;hpb=e448e4e5f1f071aa61152b2f49b239d878c0a580;p=controller.git diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/DataExists.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/DataExists.java index 7d1bcdb8f6..1bd687cbb7 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/DataExists.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/DataExists.java @@ -8,12 +8,10 @@ package org.opendaylight.controller.cluster.datastore.messages; +import com.google.common.base.Preconditions; import com.google.common.util.concurrent.CheckedFuture; import com.google.common.util.concurrent.SettableFuture; -import org.opendaylight.controller.cluster.datastore.DataStoreVersions; -import org.opendaylight.controller.cluster.datastore.util.InstanceIdentifierUtils; import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException; -import org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages; import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; @@ -27,16 +25,6 @@ public class DataExists extends AbstractRead { super(path, version); } - @Override - public Object toSerializable() { - if(getVersion() >= DataStoreVersions.BORON_VERSION) { - return this; - } else { - return ShardTransactionMessages.DataExists.newBuilder().setInstanceIdentifierPathArguments( - InstanceIdentifierUtils.toSerializable(getPath())).build(); - } - } - @Override public CheckedFuture apply(DOMStoreReadTransaction readDelegate) { return readDelegate.exists(getPath()); @@ -44,10 +32,11 @@ public class DataExists extends AbstractRead { @Override public void processResponse(Object response, SettableFuture returnFuture) { - if(DataExistsReply.isSerializedType(response)) { + if (DataExistsReply.isSerializedType(response)) { returnFuture.set(Boolean.valueOf(DataExistsReply.fromSerializable(response).exists())); } else { - returnFuture.setException(new ReadFailedException("Invalid response checking exists for path " + getPath())); + returnFuture.setException(new ReadFailedException("Invalid response checking exists for path " + + getPath())); } } @@ -56,17 +45,12 @@ public class DataExists extends AbstractRead { return new DataExists(getPath(), withVersion); } - public static DataExists fromSerializable(final Object serializable){ - if(serializable instanceof DataExists) { - return (DataExists)serializable; - } else { - ShardTransactionMessages.DataExists o = (ShardTransactionMessages.DataExists) serializable; - return new DataExists(InstanceIdentifierUtils.fromSerializable(o.getInstanceIdentifierPathArguments()), - DataStoreVersions.LITHIUM_VERSION); - } + public static DataExists fromSerializable(final Object serializable) { + Preconditions.checkArgument(serializable instanceof DataExists); + return (DataExists)serializable; } public static boolean isSerializedType(Object message) { - return message instanceof DataExists || message instanceof ShardTransactionMessages.DataExists; + return message instanceof DataExists; } }