diff options
author | Jan Srnicek <jsrnicek@cisco.com> | 2016-09-23 16:39:09 +0200 |
---|---|---|
committer | Jan Srnicek <jsrnicek@cisco.com> | 2016-09-23 16:41:57 +0200 |
commit | a7147d16c31d9028c6b5dc557264433de0f11c91 (patch) | |
tree | 15816600ab3dfa5eea706ef1b1910b2e13ae66d7 /v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vppclassifier/ClassifySessionWriter.java | |
parent | e7a0775b21c2ea6b7bb8efb63b5384df26e27fbb (diff) |
HONEYCOMB-145 - Utility Class Refactoring
problematic mockito-all changed to mockito-core( https://github.com/mockito/mockito/issues/324)
Translate Utils Splitted to multiple Trait Interfaces
Ipv4Translator - Logic for translation of ipv4-based data
Ipv6Translator - Logic for translation of ipv6-based data
MacTranslator - Logic for translation of mac-based data
AddressTranslator - Aggregation trait for Ipv4/Ipv6/Mac
JvppReplyConsumer - Logic for extracting replies from jvpp calls
ByteDataTranslator - any byte-based conversions
Plus some existing utility classes changed to traits
Change-Id: I342b625954223966802e65dca0fabf8456c89345
Signed-off-by: Jan Srnicek <jsrnicek@cisco.com>
Diffstat (limited to 'v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vppclassifier/ClassifySessionWriter.java')
-rw-r--r-- | v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vppclassifier/ClassifySessionWriter.java | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vppclassifier/ClassifySessionWriter.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vppclassifier/ClassifySessionWriter.java index d2029a368..e4870aecf 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vppclassifier/ClassifySessionWriter.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vppclassifier/ClassifySessionWriter.java @@ -19,12 +19,12 @@ package io.fd.honeycomb.translate.v3po.vppclassifier; import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkState; -import static io.fd.honeycomb.translate.v3po.util.TranslateUtils.booleanToByte; import com.google.common.base.Optional; import io.fd.honeycomb.translate.MappingContext; import io.fd.honeycomb.translate.spi.write.ListWriterCustomizer; -import io.fd.honeycomb.translate.v3po.util.TranslateUtils; +import io.fd.honeycomb.translate.v3po.util.ByteDataTranslator; +import io.fd.honeycomb.translate.v3po.util.JvppReplyConsumer; import io.fd.honeycomb.translate.write.WriteContext; import io.fd.honeycomb.translate.write.WriteFailedException; import java.util.concurrent.CompletionStage; @@ -49,7 +49,7 @@ import org.slf4j.LoggerFactory; * to VPP.<br> Equivalent to invoking {@code vppctl classify table} command. */ public class ClassifySessionWriter extends VppNodeWriter - implements ListWriterCustomizer<ClassifySession, ClassifySessionKey> { + implements ListWriterCustomizer<ClassifySession, ClassifySessionKey>, ByteDataTranslator, JvppReplyConsumer { private static final Logger LOG = LoggerFactory.getLogger(ClassifySessionWriter.class); private final VppClassifierContextManager classifyTableContext; @@ -97,32 +97,32 @@ public class ClassifySessionWriter extends VppNodeWriter private void classifyAddDelSession(final boolean isAdd, @Nonnull final InstanceIdentifier<ClassifySession> id, @Nonnull final ClassifySession classifySession, @Nonnull final WriteContext writeContext) - throws VppBaseCallException, WriteFailedException { + throws VppBaseCallException, WriteFailedException { final ClassifyTableKey tableKey = id.firstKeyOf(ClassifyTable.class); checkArgument(tableKey != null, "could not find classify table key in {}", id); final String tableName = tableKey.getName(); checkState(classifyTableContext.containsTable(tableName, writeContext.getMappingContext()), - "Could not find classify table index for {} in the classify table context", tableName); + "Could not find classify table index for {} in the classify table context", tableName); final int tableIndex = classifyTableContext.getTableIndex(tableName, writeContext.getMappingContext()); final ClassifyTable classifyTable = - getClassifyTable(writeContext, id.firstIdentifierOf(ClassifyTable.class), isAdd); + getClassifyTable(writeContext, id.firstIdentifierOf(ClassifyTable.class), isAdd); final int hitNextIndex = getNodeIndex(classifySession.getHitNext(), classifyTable, classifyTableContext, - writeContext.getMappingContext(), id); + writeContext.getMappingContext(), id); final int opaqueIndex = - getOpaqueIndex(classifySession.getOpaqueIndex(), classifyTable, writeContext.getMappingContext(), id); + getOpaqueIndex(classifySession.getOpaqueIndex(), classifyTable, writeContext.getMappingContext(), id); final CompletionStage<ClassifyAddDelSessionReply> createClassifyTableReplyCompletionStage = getFutureJVpp() - .classifyAddDelSession( - getClassifyAddDelSessionRequest(isAdd, classifySession, tableIndex, hitNextIndex, opaqueIndex)); + .classifyAddDelSession( + getClassifyAddDelSessionRequest(isAdd, classifySession, tableIndex, hitNextIndex, opaqueIndex)); - TranslateUtils.getReplyForWrite(createClassifyTableReplyCompletionStage.toCompletableFuture(), id); + getReplyForWrite(createClassifyTableReplyCompletionStage.toCompletableFuture(), id); } private ClassifyTable getClassifyTable(final WriteContext writeContext, - @Nonnull final InstanceIdentifier<ClassifyTable> id, - final boolean isAdd) { + @Nonnull final InstanceIdentifier<ClassifyTable> id, + final boolean isAdd) { final Optional<ClassifyTable> classifyTable; if (isAdd) { classifyTable = writeContext.readAfter(id); @@ -132,11 +132,11 @@ public class ClassifySessionWriter extends VppNodeWriter return classifyTable.get(); } - private static ClassifyAddDelSession getClassifyAddDelSessionRequest(final boolean isAdd, - @Nonnull final ClassifySession classifySession, - final int tableIndex, - final int hitNextIndex, - final int opaqueIndex) { + private ClassifyAddDelSession getClassifyAddDelSessionRequest(final boolean isAdd, + @Nonnull final ClassifySession classifySession, + final int tableIndex, + final int hitNextIndex, + final int opaqueIndex) { ClassifyAddDelSession request = new ClassifyAddDelSession(); request.isAdd = booleanToByte(isAdd); request.tableIndex = tableIndex; @@ -152,7 +152,7 @@ public class ClassifySessionWriter extends VppNodeWriter private int getOpaqueIndex(@Nullable final OpaqueIndex opaqueIndex, final ClassifyTable classifyTable, final MappingContext ctx, final InstanceIdentifier<ClassifySession> id) - throws VppBaseCallException, WriteFailedException { + throws VppBaseCallException, WriteFailedException { if (opaqueIndex == null) { return ~0; // value not specified } |