summaryrefslogtreecommitdiffstats
path: root/infra/translate-api/src
diff options
context:
space:
mode:
authorJan Srnicek <jsrnicek@cisco.com>2017-08-16 09:21:24 +0200
committerMarek Gradzki <mgradzki@cisco.com>2017-08-16 07:56:39 +0000
commit130c716105017c7b20b4779973b915968b3dc322 (patch)
tree50b28ac5691928dcff03fcf8cb57bec651a270c1 /infra/translate-api/src
parentc643983450d5fd56db40ad2718877ec2289e6e6f (diff)
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 <jsrnicek@cisco.com>
Diffstat (limited to 'infra/translate-api/src')
-rw-r--r--infra/translate-api/src/main/java/io/fd/honeycomb/translate/write/Writer.java16
-rw-r--r--infra/translate-api/src/main/java/io/fd/honeycomb/translate/write/registry/WriterRegistry.java15
2 files changed, 22 insertions, 9 deletions
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<D extends DataObject> extends SubtreeManager<D> {
/**
- * 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<D extends DataObject> extends SubtreeManager<D> {
* @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<? extends DataObject> id,
- @Nullable final DataObject dataBefore,
- @Nullable final DataObject dataAfter,
- @Nonnull final WriteContext ctx) throws WriteFailedException;
+ void processModification(@Nonnull final InstanceIdentifier<? extends DataObject> 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 {