summaryrefslogtreecommitdiffstats
path: root/infra/data-impl
diff options
context:
space:
mode:
authorMaros Marsalek <mmarsale@cisco.com>2016-11-09 09:44:26 +0100
committerMarek Gradzki <mgradzki@cisco.com>2016-11-23 13:03:57 +0000
commit567247ad5a1ba1c8aff3cb2b47211f7c68f0545d (patch)
treeeca23e838a6b1c7e69838b617e25762de1e2170e /infra/data-impl
parent8e0c7007906730fe4547b0265a895ad8a322a7dc (diff)
HONEYCOMB-170 Add more information to RevertFailedEx
Change-Id: I6b24a1d061c94d57730b20cde4c5b3c39444b119 Signed-off-by: Maros Marsalek <mmarsale@cisco.com>
Diffstat (limited to 'infra/data-impl')
-rw-r--r--infra/data-impl/src/main/java/io/fd/honeycomb/data/impl/ModifiableDataTreeDelegator.java5
-rw-r--r--infra/data-impl/src/main/java/io/fd/honeycomb/data/impl/ModificationDiff.java2
-rw-r--r--infra/data-impl/src/test/java/io/fd/honeycomb/data/impl/ModifiableDataTreeDelegatorTest.java14
3 files changed, 12 insertions, 9 deletions
diff --git a/infra/data-impl/src/main/java/io/fd/honeycomb/data/impl/ModifiableDataTreeDelegator.java b/infra/data-impl/src/main/java/io/fd/honeycomb/data/impl/ModifiableDataTreeDelegator.java
index 3de9131..f4989aa 100644
--- a/infra/data-impl/src/main/java/io/fd/honeycomb/data/impl/ModifiableDataTreeDelegator.java
+++ b/infra/data-impl/src/main/java/io/fd/honeycomb/data/impl/ModifiableDataTreeDelegator.java
@@ -146,13 +146,14 @@ public final class ModifiableDataTreeDelegator extends ModifiableDataTreeManager
LOG.info("Changes successfully reverted");
} catch (WriterRegistry.Reverter.RevertFailedException revertFailedException) {
// fail with failed revert
- LOG.error("Failed to revert successful changes", revertFailedException);
+ LOG.error("Failed to revert successful(comitted) changes, failure occurred for: {}. State might be corrupted.",
+ revertFailedException.getFailedUpdate(), revertFailedException);
throw revertFailedException;
}
// fail with success revert
// not passing the cause,its logged above and it would be logged after transaction
// ended again(prevent double logging of same error
- throw new WriterRegistry.Reverter.RevertSuccessException(e.getFailedIds());
+ throw new WriterRegistry.Reverter.RevertSuccessException(e.getUnrevertedSubtrees());
} catch (TransactionCommitFailedException e) {
// TODO HONEYCOMB-162 revert should probably occur when context is not written successfully
final String msg = "Error while updating mapping context data";
diff --git a/infra/data-impl/src/main/java/io/fd/honeycomb/data/impl/ModificationDiff.java b/infra/data-impl/src/main/java/io/fd/honeycomb/data/impl/ModificationDiff.java
index 723bb88..f999ba1 100644
--- a/infra/data-impl/src/main/java/io/fd/honeycomb/data/impl/ModificationDiff.java
+++ b/infra/data-impl/src/main/java/io/fd/honeycomb/data/impl/ModificationDiff.java
@@ -246,7 +246,7 @@ final class ModificationDiff {
final com.google.common.base.Optional<NormalizedNode<?, ?>> afterData =
modification.getDataAfter();
checkArgument(beforeData.isPresent() || afterData.isPresent(),
- "Both before and after data are null for $s", modification.getId());
+ "Both before and after data are null for %s", modification.getId());
return NormalizedNodeUpdate.create(modification.getId(), beforeData.orNull(), afterData.orNull());
}
diff --git a/infra/data-impl/src/test/java/io/fd/honeycomb/data/impl/ModifiableDataTreeDelegatorTest.java b/infra/data-impl/src/test/java/io/fd/honeycomb/data/impl/ModifiableDataTreeDelegatorTest.java
index 3223285..26a936f 100644
--- a/infra/data-impl/src/test/java/io/fd/honeycomb/data/impl/ModifiableDataTreeDelegatorTest.java
+++ b/infra/data-impl/src/test/java/io/fd/honeycomb/data/impl/ModifiableDataTreeDelegatorTest.java
@@ -82,6 +82,7 @@ public class ModifiableDataTreeDelegatorTest {
private ArgumentCaptor<WriteContext> writeContextCaptor;
private ModifiableDataTreeManager configDataTree;
+ private final DataObjectUpdate update = DataObjectUpdate.create(DEFAULT_ID, null, DEFAULT_DATA_OBJECT);
static final InstanceIdentifier<?> DEFAULT_ID = InstanceIdentifier.create(DataObject.class);
static DataObject DEFAULT_DATA_OBJECT = mockDataObject("serialized", DataObject.class);
@@ -145,7 +146,7 @@ public class ModifiableDataTreeDelegatorTest {
// Fail on update:
final WriterRegistry.Reverter reverter = mock(WriterRegistry.Reverter.class);
final TranslationException failedOnUpdateException = new TranslationException("update failed");
- doThrow(new WriterRegistry.BulkUpdateException(Collections.singleton(DEFAULT_ID), reverter, failedOnUpdateException))
+ doThrow(new WriterRegistry.BulkUpdateException(DEFAULT_ID, update, Collections.singleton(DEFAULT_ID), reverter, failedOnUpdateException))
.when(writer).update(any(WriterRegistry.DataObjectUpdates.class), any(WriteContext.class));
try {
@@ -169,12 +170,13 @@ public class ModifiableDataTreeDelegatorTest {
// Fail on update:
final WriterRegistry.Reverter reverter = mock(WriterRegistry.Reverter.class);
final TranslationException failedOnUpdateException = new TranslationException("update failed");
- doThrow(new WriterRegistry.BulkUpdateException(Collections.singleton(DEFAULT_ID), reverter, failedOnUpdateException))
- .when(writer).update(any(WriterRegistry.DataObjectUpdates.class), any(WriteContext.class));
+ final WriterRegistry.BulkUpdateException bulkFailEx =
+ new WriterRegistry.BulkUpdateException(DEFAULT_ID, update, Collections.singleton(DEFAULT_ID), reverter,
+ failedOnUpdateException);
+ doThrow(bulkFailEx).when(writer).update(any(WriterRegistry.DataObjectUpdates.class), any(WriteContext.class));
// Fail on revert:
- final TranslationException failedOnRevertException = new TranslationException("revert failed");
- doThrow(new WriterRegistry.Reverter.RevertFailedException(Collections.emptySet(), failedOnRevertException))
+ doThrow(new WriterRegistry.Reverter.RevertFailedException(bulkFailEx))
.when(reverter).revert(any(WriteContext.class));
try {
@@ -187,7 +189,7 @@ public class ModifiableDataTreeDelegatorTest {
} catch (WriterRegistry.Reverter.RevertFailedException e) {
verify(writer).update(any(WriterRegistry.DataObjectUpdates.class), any(WriteContext.class));
verify(reverter).revert(any(WriteContext.class));
- assertEquals(failedOnRevertException, e.getCause());
+ assertEquals(bulkFailEx, e.getCause());
}
}