X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;ds=sidebyside;f=opendaylight%2Fmd-sal%2Fsal-distributed-datastore%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2FShardDataTree.java;h=72ca1aebd8e1723a2a0c86de0ed2a9e7d250d544;hb=4bbbd57c8f96e864d4353c1bdbce0dc068a6a57b;hp=d43602aceafa8eb1d98e3fc54a19483089b4e0ce;hpb=bfb38b42aa055a2478a5972f15ca4246dee796e9;p=controller.git diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardDataTree.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardDataTree.java index d43602acea..72ca1aebd8 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardDataTree.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardDataTree.java @@ -18,6 +18,7 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap.Builder; import com.google.common.primitives.UnsignedLong; +import java.io.File; import java.io.IOException; import java.util.AbstractMap.SimpleEntry; import java.util.ArrayDeque; @@ -42,6 +43,7 @@ import org.opendaylight.controller.cluster.datastore.persisted.CommitTransaction import org.opendaylight.controller.cluster.datastore.persisted.MetadataShardDataTreeSnapshot; import org.opendaylight.controller.cluster.datastore.persisted.ShardDataTreeSnapshot; import org.opendaylight.controller.cluster.datastore.persisted.ShardDataTreeSnapshotMetadata; +import org.opendaylight.controller.cluster.datastore.utils.DataTreeModificationOutput; import org.opendaylight.controller.cluster.datastore.utils.PruningDataTreeModification; import org.opendaylight.controller.cluster.raft.protobuff.client.messages.Payload; import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope; @@ -160,7 +162,7 @@ public class ShardDataTree extends ShardDataTreeTransactionParent { ImmutableMap.builder(); for (ShardDataTreeMetadata m : metadata) { - final ShardDataTreeSnapshotMetadata meta = m.toStapshot(); + final ShardDataTreeSnapshotMetadata meta = m.toSnapshot(); if (meta != null) { metaBuilder.put(meta.getType(), meta); } @@ -252,8 +254,17 @@ public class ShardDataTree extends ShardDataTreeTransactionParent { final DataTreeModification unwrapped = mod.delegate(); LOG.trace("{}: Applying recovery modification {}", logContext, unwrapped); - dataTree.validate(unwrapped); - dataTree.commit(dataTree.prepare(unwrapped)); + try { + dataTree.validate(unwrapped); + dataTree.commit(dataTree.prepare(unwrapped)); + } catch (Exception e) { + File file = new File(System.getProperty("karaf.data", "."), + "failed-recovery-payload-" + logContext + ".out"); + DataTreeModificationOutput.toFile(file, unwrapped); + throw new IllegalStateException(String.format( + "%s: Failed to apply recovery payload. Modification data was written to file %s", + logContext, file), e); + } } /**