summaryrefslogtreecommitdiffstats
path: root/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/notification/InterfaceChangeNotificationProducer.java
diff options
context:
space:
mode:
authorJan Srnicek <jsrnicek@cisco.com>2016-09-23 16:39:09 +0200
committerJan Srnicek <jsrnicek@cisco.com>2016-09-23 16:41:57 +0200
commita7147d16c31d9028c6b5dc557264433de0f11c91 (patch)
tree15816600ab3dfa5eea706ef1b1910b2e13ae66d7 /v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/notification/InterfaceChangeNotificationProducer.java
parente7a0775b21c2ea6b7bb8efb63b5384df26e27fbb (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/notification/InterfaceChangeNotificationProducer.java')
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/notification/InterfaceChangeNotificationProducer.java37
1 files changed, 22 insertions, 15 deletions
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/notification/InterfaceChangeNotificationProducer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/notification/InterfaceChangeNotificationProducer.java
index 481a2eac9..974c4f876 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/notification/InterfaceChangeNotificationProducer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/notification/InterfaceChangeNotificationProducer.java
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package io.fd.honeycomb.translate.v3po.notification;
import com.google.common.base.Optional;
@@ -22,8 +23,8 @@ import com.google.inject.name.Named;
import io.fd.honeycomb.notification.ManagedNotificationProducer;
import io.fd.honeycomb.notification.NotificationCollector;
import io.fd.honeycomb.translate.MappingContext;
+import io.fd.honeycomb.translate.v3po.util.JvppReplyConsumer;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
-import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
import java.util.ArrayList;
import java.util.Collection;
import java.util.concurrent.CompletionStage;
@@ -51,7 +52,7 @@ import org.slf4j.LoggerFactory;
* received notification, it transforms it into its BA equivalent and pushes into HC's notification collector.
*/
@NotThreadSafe
-public final class InterfaceChangeNotificationProducer implements ManagedNotificationProducer {
+public final class InterfaceChangeNotificationProducer implements ManagedNotificationProducer, JvppReplyConsumer {
private static final Logger LOG = LoggerFactory.getLogger(InterfaceChangeNotificationProducer.class);
@@ -76,11 +77,11 @@ public final class InterfaceChangeNotificationProducer implements ManagedNotific
enableDisableIfcNotifications(1);
LOG.debug("Interface notifications started successfully");
notificationListenerReg = jvpp.getNotificationRegistry().registerSwInterfaceSetFlagsNotificationCallback(
- swInterfaceSetFlagsNotification -> {
- LOG.trace("Interface notification received: {}", swInterfaceSetFlagsNotification);
- // TODO HONEYCOMB-166 this should be lazy
- collector.onNotification(transformNotification(swInterfaceSetFlagsNotification));
- }
+ swInterfaceSetFlagsNotification -> {
+ LOG.trace("Interface notification received: {}", swInterfaceSetFlagsNotification);
+ // TODO HONEYCOMB-166 this should be lazy
+ collector.onNotification(transformNotification(swInterfaceSetFlagsNotification));
+ }
);
}
@@ -89,10 +90,14 @@ public final class InterfaceChangeNotificationProducer implements ManagedNotific
return new InterfaceDeletedBuilder().setName(getIfcName(swInterfaceSetFlagsNotification)).build();
} else {
return new InterfaceStateChangeBuilder()
- .setName(getIfcName(swInterfaceSetFlagsNotification))
- .setAdminStatus(swInterfaceSetFlagsNotification.adminUpDown == 1 ? InterfaceStatus.Up : InterfaceStatus.Down)
- .setOperStatus(swInterfaceSetFlagsNotification.linkUpDown == 1 ? InterfaceStatus.Up : InterfaceStatus.Down)
- .build();
+ .setName(getIfcName(swInterfaceSetFlagsNotification))
+ .setAdminStatus(swInterfaceSetFlagsNotification.adminUpDown == 1
+ ? InterfaceStatus.Up
+ : InterfaceStatus.Down)
+ .setOperStatus(swInterfaceSetFlagsNotification.linkUpDown == 1
+ ? InterfaceStatus.Up
+ : InterfaceStatus.Down)
+ .build();
}
}
@@ -107,8 +112,8 @@ public final class InterfaceChangeNotificationProducer implements ManagedNotific
final Optional<String> optionalName =
interfaceContext.getNameIfPresent(swInterfaceSetFlagsNotification.swIfIndex, mappingContext);
return optionalName.isPresent()
- ? new InterfaceNameOrIndex(optionalName.get())
- : new InterfaceNameOrIndex((long) swInterfaceSetFlagsNotification.swIfIndex);
+ ? new InterfaceNameOrIndex(optionalName.get())
+ : new InterfaceNameOrIndex((long) swInterfaceSetFlagsNotification.swIfIndex);
}
@Override
@@ -132,9 +137,11 @@ public final class InterfaceChangeNotificationProducer implements ManagedNotific
final CompletionStage<WantInterfaceEventsReply> wantInterfaceEventsReplyCompletionStage;
try {
wantInterfaceEventsReplyCompletionStage = jvpp.wantInterfaceEvents(wantInterfaceEvents);
- TranslateUtils.getReply(wantInterfaceEventsReplyCompletionStage.toCompletableFuture());
+ getReply(wantInterfaceEventsReplyCompletionStage.toCompletableFuture());
} catch (VppBaseCallException | TimeoutException e) {
- LOG.warn("Unable to {} interface notifications", enableDisable == 1 ? "enable" : "disable", e);
+ LOG.warn("Unable to {} interface notifications", enableDisable == 1
+ ? "enable"
+ : "disable", e);
throw new IllegalStateException("Unable to control interface notifications", e);
}
}