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%2Fmodification%2FDeleteModification.java;h=833f86fb981f1179ce326c4d3703f17c3449aa73;hb=0fe0f14ff574f1f17d25b3129ea6073d1c1c8ef9;hp=056fe756371589c7d055d054b8884f50db5bd60f;hpb=4f81f4ed61cf74c4dcac48e4f7714adcda501a5f;p=controller.git diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/DeleteModification.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/DeleteModification.java index 056fe75637..833f86fb98 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/DeleteModification.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/DeleteModification.java @@ -8,7 +8,12 @@ package org.opendaylight.controller.cluster.datastore.modification; +import java.io.IOException; +import java.io.ObjectInput; +import java.io.ObjectOutput; +import org.opendaylight.controller.cluster.datastore.DataStoreVersions; import org.opendaylight.controller.cluster.datastore.util.InstanceIdentifierUtils; +import org.opendaylight.controller.cluster.datastore.utils.SerializationUtils; import org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages; import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; @@ -19,23 +24,51 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; public class DeleteModification extends AbstractModification { private static final long serialVersionUID = 1L; + public DeleteModification() { + } + public DeleteModification(YangInstanceIdentifier path) { super(path); } @Override public void apply(DOMStoreWriteTransaction transaction) { - transaction.delete(path); + transaction.delete(getPath()); } @Override + public byte getType() { + return DELETE; + } + + @Override + public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { + in.readShort(); + setPath(SerializationUtils.deserializePath(in)); + } + + @Override + public void writeExternal(ObjectOutput out) throws IOException { + out.writeShort(DataStoreVersions.CURRENT_VERSION); + SerializationUtils.serializePath(getPath(), out); + } + + @Override + @Deprecated public Object toSerializable() { return PersistentMessages.Modification.newBuilder().setType(this.getClass().toString()) - .setPath(InstanceIdentifierUtils.toSerializable(this.path)).build(); + .setPath(InstanceIdentifierUtils.toSerializable(getPath())).build(); } + @Deprecated public static DeleteModification fromSerializable(Object serializable) { PersistentMessages.Modification o = (PersistentMessages.Modification) serializable; return new DeleteModification(InstanceIdentifierUtils.fromSerializable(o.getPath())); } + + public static DeleteModification fromStream(ObjectInput in) throws ClassNotFoundException, IOException { + DeleteModification mod = new DeleteModification(); + mod.readExternal(in); + return mod; + } }