From 130c716105017c7b20b4779973b915968b3dc322 Mon Sep 17 00:00:00 2001 From: Jan Srnicek Date: Wed, 16 Aug 2017 09:21:24 +0200 Subject: HONEYCOMB-386 - Make update optional If customizer does not support update directly, updates for its handled nodes are broken up to delete + create pairs. Change-Id: I2929109e8c9a1db0bef108367cf7d839135ce173 Signed-off-by: Jan Srnicek --- .../java/io/fd/honeycomb/translate/write/Writer.java | 16 +++++++++++----- .../translate/write/registry/WriterRegistry.java | 15 +++++++++++---- 2 files changed, 22 insertions(+), 9 deletions(-) (limited to 'infra/translate-api') diff --git a/infra/translate-api/src/main/java/io/fd/honeycomb/translate/write/Writer.java b/infra/translate-api/src/main/java/io/fd/honeycomb/translate/write/Writer.java index e6538012b..1a16b72e6 100644 --- a/infra/translate-api/src/main/java/io/fd/honeycomb/translate/write/Writer.java +++ b/infra/translate-api/src/main/java/io/fd/honeycomb/translate/write/Writer.java @@ -33,7 +33,7 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; public interface Writer extends SubtreeManager { /** - * Handle update operation. U from CRUD. + * Process modifications and translate them as create/update/delete operations to lower level * * @param id Identifier of data being written * @param dataBefore Old data @@ -41,8 +41,14 @@ public interface Writer extends SubtreeManager { * @param ctx Write context enabling writer to get information about candidate data as well as current data * @throws WriteFailedException if update failed */ - void update(@Nonnull final InstanceIdentifier id, - @Nullable final DataObject dataBefore, - @Nullable final DataObject dataAfter, - @Nonnull final WriteContext ctx) throws WriteFailedException; + void processModification(@Nonnull final InstanceIdentifier id, + @Nullable final DataObject dataBefore, + @Nullable final DataObject dataAfter, + @Nonnull final WriteContext ctx) throws WriteFailedException; + + /** + * Indicates whether there is direct support for updating nodes handled by this writer, + * or they must be broken up to individual deletes and creates. + */ + boolean supportsDirectUpdate(); } diff --git a/infra/translate-api/src/main/java/io/fd/honeycomb/translate/write/registry/WriterRegistry.java b/infra/translate-api/src/main/java/io/fd/honeycomb/translate/write/registry/WriterRegistry.java index 5520c00ec..a297b6de8 100644 --- a/infra/translate-api/src/main/java/io/fd/honeycomb/translate/write/registry/WriterRegistry.java +++ b/infra/translate-api/src/main/java/io/fd/honeycomb/translate/write/registry/WriterRegistry.java @@ -41,12 +41,19 @@ public interface WriterRegistry { * @throws BulkUpdateException in case bulk update fails * @throws TranslationException in case some other error occurs while processing update request */ - void update(@Nonnull DataObjectUpdates updates, - @Nonnull WriteContext ctx) throws TranslationException; + void processModifications(@Nonnull DataObjectUpdates updates, + @Nonnull WriteContext ctx) throws TranslationException; /** - * Simple DTO containing updates for {@link WriterRegistry}. Currently only deletes and updates (create + update) - * are distinguished. + * Indicates direct support for update operation on provided type + * + * @param type data object type + */ + boolean writerSupportsUpdate(@Nonnull InstanceIdentifier type); + + /** + * Simple DTO containing updates for {@link WriterRegistry}. Currently only deletes and updates (create + + * update) are distinguished. */ @Beta final class DataObjectUpdates { -- cgit 1.2.3-korg