Search in sources :

Example 1 with PruningDataTreeModification

use of org.opendaylight.controller.cluster.datastore.utils.PruningDataTreeModification in project controller by opendaylight.

the class ShardDataTree method applyRecoveryCandidate.

@SuppressWarnings("checkstyle:IllegalCatch")
private void applyRecoveryCandidate(final DataTreeCandidate candidate) throws DataValidationFailedException {
    final PruningDataTreeModification mod = wrapWithPruning(dataTree.takeSnapshot().newModification());
    DataTreeCandidates.applyToModification(mod, candidate);
    mod.ready();
    final DataTreeModification unwrapped = mod.delegate();
    LOG.trace("{}: Applying recovery modification {}", logContext, 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);
    }
}
Also used : DataTreeModification(org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification) PruningDataTreeModification(org.opendaylight.controller.cluster.datastore.utils.PruningDataTreeModification) PruningDataTreeModification(org.opendaylight.controller.cluster.datastore.utils.PruningDataTreeModification) File(java.io.File) TimeoutException(java.util.concurrent.TimeoutException) ConflictingModificationAppliedException(org.opendaylight.yangtools.yang.data.api.schema.tree.ConflictingModificationAppliedException) IOException(java.io.IOException) DataValidationFailedException(org.opendaylight.yangtools.yang.data.api.schema.tree.DataValidationFailedException) TransactionCommitFailedException(org.opendaylight.mdsal.common.api.TransactionCommitFailedException) OptimisticLockFailedException(org.opendaylight.mdsal.common.api.OptimisticLockFailedException)

Aggregations

File (java.io.File)1 IOException (java.io.IOException)1 TimeoutException (java.util.concurrent.TimeoutException)1 PruningDataTreeModification (org.opendaylight.controller.cluster.datastore.utils.PruningDataTreeModification)1 OptimisticLockFailedException (org.opendaylight.mdsal.common.api.OptimisticLockFailedException)1 TransactionCommitFailedException (org.opendaylight.mdsal.common.api.TransactionCommitFailedException)1 ConflictingModificationAppliedException (org.opendaylight.yangtools.yang.data.api.schema.tree.ConflictingModificationAppliedException)1 DataTreeModification (org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification)1 DataValidationFailedException (org.opendaylight.yangtools.yang.data.api.schema.tree.DataValidationFailedException)1