Add netcfg for INT

Use network config subsystem to handle such configs

Change-Id: I8ec14d31c30e3d1d8cd2c703d8db5535bb8b5cd4
diff --git a/apps/inbandtelemetry/app/src/main/java/org/onosproject/inbandtelemetry/app/ui/IntAppUiMessageHandler.java b/apps/inbandtelemetry/app/src/main/java/org/onosproject/inbandtelemetry/app/ui/IntAppUiMessageHandler.java
index 34e8fb4..9d1fb90 100644
--- a/apps/inbandtelemetry/app/src/main/java/org/onosproject/inbandtelemetry/app/ui/IntAppUiMessageHandler.java
+++ b/apps/inbandtelemetry/app/src/main/java/org/onosproject/inbandtelemetry/app/ui/IntAppUiMessageHandler.java
@@ -20,14 +20,11 @@
 import com.fasterxml.jackson.databind.node.ObjectNode;
 import org.onlab.packet.Ip4Address;
 import org.onlab.packet.Ip4Prefix;
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.MacAddress;
 import org.onlab.packet.TpPort;
 import org.onosproject.inbandtelemetry.api.IntIntent;
 import org.onosproject.inbandtelemetry.api.IntIntentId;
 import org.onosproject.net.behaviour.inbandtelemetry.IntMetadataType;
 import org.onosproject.inbandtelemetry.api.IntService;
-import org.onosproject.net.behaviour.inbandtelemetry.IntDeviceConfig;
 import org.onosproject.net.flow.DefaultTrafficSelector;
 import org.onosproject.net.flow.TrafficSelector;
 import org.onosproject.ui.RequestHandler;
@@ -43,8 +40,6 @@
 
     private static final String INT_INTENT_ADD_REQUEST = "intIntentAddRequest";
     private static final String INT_INTENT_DEL_REQUEST = "intIntentDelRequest";
-    private static final String INT_CONFIG_ADD_REQUEST = "intConfigAddRequest";
-//    private static final String INT_CONFIG_DEL_REQUEST = "intConfigDelRequest";
 
     private final Logger log = LoggerFactory.getLogger(getClass());
 
@@ -54,46 +49,10 @@
     protected Collection<RequestHandler> createRequestHandlers() {
         return ImmutableSet.of(
                 new IntIntentAddRequestHandler(),
-                new IntIntentDelRequestHandler(),
-                new IntConfigAddRequestHandler()
-                //new intConfigDelRequestHandler()
+                new IntIntentDelRequestHandler()
         );
     }
 
-    private final class IntConfigAddRequestHandler extends RequestHandler {
-        private IntConfigAddRequestHandler() {
-            super(INT_CONFIG_ADD_REQUEST);
-        }
-
-        @Override
-        public void process(ObjectNode payload) {
-            log.info("intConfigAddRequest: {}", payload);
-
-            intService = get(IntService.class);
-            IntDeviceConfig.Builder builder = IntDeviceConfig.builder();
-
-            if (payload.get("collectorIp") != null) {
-                builder.withCollectorIp(IpAddress.valueOf(payload.get("collectorIp").asText()));
-            } else {
-                builder.withCollectorIp(IpAddress.valueOf("127.0.0.1"));
-            }
-
-            if (payload.get("collectorPort") != null) {
-                builder.withCollectorPort(TpPort.tpPort(
-                        payload.get("collectorPort").asInt()));
-            } else {
-                builder.withCollectorPort(TpPort.tpPort(1234));
-            }
-
-            builder.enabled(true)
-                    .withSinkIp(IpAddress.valueOf("10.192.19.180"))
-                    .withSinkMac(MacAddress.NONE)
-                    .withCollectorNextHopMac(MacAddress.BROADCAST);
-
-            intService.setConfig(builder.build());
-        }
-    }
-
     private final class IntIntentDelRequestHandler extends RequestHandler {
         private IntIntentDelRequestHandler() {
             super(INT_INTENT_DEL_REQUEST);
diff --git a/apps/inbandtelemetry/app/src/main/resources/app/view/intApp/intApp.html b/apps/inbandtelemetry/app/src/main/resources/app/view/intApp/intApp.html
index 7b69168..44698dd 100644
--- a/apps/inbandtelemetry/app/src/main/resources/app/view/intApp/intApp.html
+++ b/apps/inbandtelemetry/app/src/main/resources/app/view/intApp/intApp.html
@@ -9,32 +9,6 @@
 
     <div class="tabular-header">
         <h2>
-            INT Collector Configuration
-        </h2>
-        <div class="config-panel">
-            <h3>
-                Collector IPv4 address and UDP port
-            </h3>
-            <div>
-                <input type="text" required
-                       pattern="^([0-9]{1,3}\.){3}[0-9]{1,3}$"
-                       ng-model="collectorIp" placeholder="IPv4 address">
-                :
-                <input type="text" required pattern="^[0-9]{0,5}$"
-                       ng-model="collectorPort" placeholder="port">
-            </div>
-        </div>
-        <div class="config-button-panel">
-            <div class="int-app-config-button" ng-click="sendIntConfigString()">
-                Apply Configuration
-            </div>
-        </div>
-    </div>
-
-    <hr>
-
-    <div class="tabular-header">
-        <h2>
             INT Watchlist Rules
         </h2>
 
diff --git a/apps/inbandtelemetry/app/src/main/resources/app/view/intApp/intApp.js b/apps/inbandtelemetry/app/src/main/resources/app/view/intApp/intApp.js
index 3d4f652..efcb3b4 100644
--- a/apps/inbandtelemetry/app/src/main/resources/app/view/intApp/intApp.js
+++ b/apps/inbandtelemetry/app/src/main/resources/app/view/intApp/intApp.js
@@ -7,21 +7,12 @@
     // constants
     var intIntentAddReq = 'intIntentAddRequest';
     var intIntentDelReq = 'intIntentDelRequest';
-    var intConfigAddReq = 'intConfigAddRequest';
 
     var refreshInterval = 1000;
 
     var propOrder = ['id', 'srcAddr', 'dstAddr', 'srcPort', 'dstPort', 'insMask'];
     var friendlyProps = ['IntIntent ID', 'Src Address', 'Dst Address', 'Src Port', 'Dst Port', 'Ins Mask'];
 
-    function sendIntConfigString() {
-        var configObjectNode = {
-            "collectorIp": $scope.collectorIp,
-            "collectorPort": $scope.collectorPort
-        };
-        wss.sendEvent(intConfigAddReq, configObjectNode);
-    }
-
     function sendIntIntentString() {
         var inst = [];
         if ($scope.metaSwId) inst.push("SWITCH_ID");
diff --git a/apps/inbandtelemetry/impl/BUILD b/apps/inbandtelemetry/impl/BUILD
index b3a1d46..c3c3fba 100644
--- a/apps/inbandtelemetry/impl/BUILD
+++ b/apps/inbandtelemetry/impl/BUILD
@@ -4,7 +4,7 @@
     "//apps/inbandtelemetry/api:onos-apps-inbandtelemetry-api",
 ]
 
-TEST_DEPS = TEST_ADAPTERS
+TEST_DEPS = TEST_ADAPTERS + JACKSON
 
 osgi_jar_with_tests(
     test_deps = TEST_DEPS,
diff --git a/apps/inbandtelemetry/impl/src/main/java/org/onosproject/inbandtelemetry/impl/SimpleIntManager.java b/apps/inbandtelemetry/impl/src/main/java/org/onosproject/inbandtelemetry/impl/SimpleIntManager.java
index 906efd8..48a7a24 100644
--- a/apps/inbandtelemetry/impl/src/main/java/org/onosproject/inbandtelemetry/impl/SimpleIntManager.java
+++ b/apps/inbandtelemetry/impl/src/main/java/org/onosproject/inbandtelemetry/impl/SimpleIntManager.java
@@ -21,6 +21,7 @@
 import org.onlab.util.SharedScheduledExecutors;
 import org.onosproject.core.ApplicationId;
 import org.onosproject.core.CoreService;
+import org.onosproject.net.behaviour.inbandtelemetry.IntReportConfig;
 import org.onosproject.net.behaviour.inbandtelemetry.IntMetadataType;
 import org.onosproject.net.behaviour.inbandtelemetry.IntDeviceConfig;
 import org.onosproject.inbandtelemetry.api.IntIntent;
@@ -34,6 +35,12 @@
 import org.onosproject.net.DeviceId;
 import org.onosproject.net.MastershipRole;
 import org.onosproject.net.PortNumber;
+import org.onosproject.net.config.ConfigFactory;
+import org.onosproject.net.config.NetworkConfigEvent;
+import org.onosproject.net.config.NetworkConfigListener;
+import org.onosproject.net.config.NetworkConfigRegistry;
+import org.onosproject.net.config.NetworkConfigService;
+import org.onosproject.net.config.basics.SubjectFactories;
 import org.onosproject.net.device.DeviceEvent;
 import org.onosproject.net.device.DeviceListener;
 import org.onosproject.net.device.DeviceService;
@@ -108,6 +115,12 @@
     @Reference(cardinality = ReferenceCardinality.MANDATORY)
     private HostService hostService;
 
+    @Reference(cardinality = ReferenceCardinality.MANDATORY)
+    private NetworkConfigService netcfgService;
+
+    @Reference(cardinality = ReferenceCardinality.MANDATORY)
+    private NetworkConfigRegistry netcfgRegistry;
+
     private final Striped<Lock> deviceLocks = Striped.lock(10);
 
     private final ConcurrentMap<DeviceId, ScheduledFuture<?>> scheduledDeviceTasks = Maps.newConcurrentMap();
@@ -127,6 +140,16 @@
     private final InternalIntStartedListener intStartedListener = new InternalIntStartedListener();
     private final InternalDeviceToConfigureListener devicesToConfigureListener =
             new InternalDeviceToConfigureListener();
+    private final NetworkConfigListener appConfigListener = new IntAppConfigListener();
+
+    private final ConfigFactory<ApplicationId, IntReportConfig> intAppConfigFactory =
+            new ConfigFactory<>(SubjectFactories.APP_SUBJECT_FACTORY,
+                    IntReportConfig.class, "report") {
+                @Override
+                public IntReportConfig createConfig() {
+                    return new IntReportConfig();
+                }
+            };
 
     @Activate
     public void activate() {
@@ -185,6 +208,9 @@
         hostService.addListener(hostListener);
         deviceService.addListener(deviceListener);
 
+        netcfgRegistry.registerConfigFactory(intAppConfigFactory);
+        netcfgService.addListener(appConfigListener);
+
         startInt();
         log.info("Started", appId.id());
     }
@@ -524,4 +550,35 @@
             }
         }
     }
+
+    private class IntAppConfigListener implements NetworkConfigListener {
+
+        @Override
+        public void event(NetworkConfigEvent event) {
+            switch (event.type()) {
+                case CONFIG_ADDED:
+                case CONFIG_UPDATED:
+                    event.config()
+                            .map(config -> (IntReportConfig) config)
+                            .ifPresent(config -> {
+                                IntDeviceConfig intDeviceConfig = IntDeviceConfig.builder()
+                                        .withMinFlowHopLatencyChangeNs(config.minFlowHopLatencyChangeNs())
+                                        .withCollectorPort(config.collectorPort())
+                                        .withCollectorIp(config.collectorIp())
+                                        .enabled(true)
+                                        .build();
+                                setConfig(intDeviceConfig);
+                            });
+                    break;
+                // TODO: Support removing INT config.
+                default:
+                    break;
+            }
+        }
+
+        @Override
+        public boolean isRelevant(NetworkConfigEvent event) {
+            return event.configClass() == IntReportConfig.class;
+        }
+    }
 }
diff --git a/apps/inbandtelemetry/impl/src/test/java/org/onosproject/inbandtelemetry/impl/SimpleIntManagerTest.java b/apps/inbandtelemetry/impl/src/test/java/org/onosproject/inbandtelemetry/impl/SimpleIntManagerTest.java
new file mode 100644
index 0000000..6f7ed96
--- /dev/null
+++ b/apps/inbandtelemetry/impl/src/test/java/org/onosproject/inbandtelemetry/impl/SimpleIntManagerTest.java
@@ -0,0 +1,132 @@
+/*
+ * Copyright 2020-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.inbandtelemetry.impl;
+
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.JsonNodeFactory;
+import com.google.common.collect.ImmutableList;
+import org.easymock.Capture;
+import org.easymock.EasyMock;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onlab.packet.IpAddress;
+import org.onlab.packet.TpPort;
+import org.onosproject.TestApplicationId;
+import org.onosproject.core.ApplicationId;
+import org.onosproject.core.CoreService;
+import org.onosproject.mastership.MastershipService;
+import org.onosproject.net.behaviour.inbandtelemetry.IntReportConfig;
+import org.onosproject.net.behaviour.inbandtelemetry.IntDeviceConfig;
+import org.onosproject.net.config.ConfigApplyDelegate;
+import org.onosproject.net.config.NetworkConfigEvent;
+import org.onosproject.net.config.NetworkConfigListener;
+import org.onosproject.net.config.NetworkConfigRegistry;
+import org.onosproject.net.config.NetworkConfigService;
+import org.onosproject.net.device.DeviceService;
+import org.onosproject.net.host.HostService;
+import org.onosproject.store.service.StorageService;
+import org.onosproject.store.service.TestStorageService;
+
+import static org.easymock.EasyMock.anyObject;
+import static org.easymock.EasyMock.createNiceMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.expectLastCall;
+import static org.easymock.EasyMock.newCapture;
+import static org.easymock.EasyMock.replay;
+import static org.junit.Assert.assertEquals;
+import static org.onlab.junit.TestUtils.setField;
+
+public class SimpleIntManagerTest {
+    private static final String APP_NAME = "org.onosproject.inbandtelemetry";
+    private static final ApplicationId APP_ID = new TestApplicationId(APP_NAME);
+    private static final IpAddress COLLECTOR_IP = IpAddress.valueOf("10.0.0.1");
+    private static final TpPort COLLECTOR_PORT = TpPort.tpPort(5500);
+    private static final int MIN_FLOW_HOP_LATENCY_CHANGE_NS = 16;
+
+    private SimpleIntManager manager;
+    private StorageService storageService;
+    private MastershipService mastershipService;
+    private CoreService coreService;
+    private HostService hostService;
+    private DeviceService deviceService;
+    private NetworkConfigRegistry networkConfigRegistry;
+    private NetworkConfigService networkConfigService;
+    private NetworkConfigListener networkConfigListener;
+
+
+    @Before
+    public void setup() {
+        storageService = new TestStorageService();
+        mastershipService = createNiceMock(MastershipService.class);
+        coreService = createNiceMock(CoreService.class);
+        hostService = createNiceMock(HostService.class);
+        deviceService = createNiceMock(DeviceService.class);
+        expect(deviceService.getDevices()).andReturn(ImmutableList.of()).anyTimes();
+        networkConfigRegistry = createNiceMock(NetworkConfigRegistry.class);
+        networkConfigService = createNiceMock(NetworkConfigService.class);
+
+        manager = new SimpleIntManager();
+        setField(manager, "coreService", coreService);
+        setField(manager, "deviceService", deviceService);
+        setField(manager, "storageService", storageService);
+        setField(manager, "mastershipService", mastershipService);
+        setField(manager, "hostService", hostService);
+        setField(manager, "netcfgService", networkConfigService);
+        setField(manager, "netcfgRegistry", networkConfigRegistry);
+
+        expect(coreService.registerApplication(APP_NAME)).andReturn(APP_ID).once();
+        networkConfigRegistry.registerConfigFactory(anyObject());
+        expectLastCall().once();
+
+        Capture<NetworkConfigListener> capture = newCapture();
+        networkConfigService.addListener(EasyMock.capture(capture));
+        expectLastCall().once();
+        replay(mastershipService, deviceService, coreService,
+                hostService, networkConfigRegistry, networkConfigService);
+        manager.activate();
+        networkConfigListener = capture.getValue();
+    }
+
+    @After
+    public void teardown() {
+        manager.deactivate();
+    }
+
+    @Test
+    public void testPushIntAppConfig() {
+        IntReportConfig config = new IntReportConfig();
+        ObjectMapper mapper = new ObjectMapper();
+        ConfigApplyDelegate delegate = configApply -> { };
+        config.init(APP_ID, "report", JsonNodeFactory.instance.objectNode(), mapper, delegate);
+        config.setCollectorIp(COLLECTOR_IP)
+                .setCollectorPort(COLLECTOR_PORT)
+                .setMinFlowHopLatencyChangeNs(MIN_FLOW_HOP_LATENCY_CHANGE_NS);
+
+        NetworkConfigEvent event =
+                new NetworkConfigEvent(NetworkConfigEvent.Type.CONFIG_ADDED, APP_ID,
+                        config, null, IntReportConfig.class);
+        networkConfigListener.event(event);
+
+        // We expected that the manager will store the device config which
+        // converted from the app config.
+        IntDeviceConfig deviceConfig = manager.getConfig();
+        assertEquals(COLLECTOR_IP, deviceConfig.collectorIp());
+        assertEquals(COLLECTOR_PORT, deviceConfig.collectorPort());
+        assertEquals(MIN_FLOW_HOP_LATENCY_CHANGE_NS, deviceConfig.minFlowHopLatencyChangeNs());
+    }
+}
diff --git a/apps/inbandtelemetry/impl/src/test/java/org/onosproject/inbandtelemetry/impl/package-info.java b/apps/inbandtelemetry/impl/src/test/java/org/onosproject/inbandtelemetry/impl/package-info.java
new file mode 100644
index 0000000..c918fea
--- /dev/null
+++ b/apps/inbandtelemetry/impl/src/test/java/org/onosproject/inbandtelemetry/impl/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2020-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Unit tests for SimpleIntManager class.
+ */
+package org.onosproject.inbandtelemetry.impl;
diff --git a/core/api/src/main/java/org/onosproject/net/behaviour/inbandtelemetry/IntDeviceConfig.java b/core/api/src/main/java/org/onosproject/net/behaviour/inbandtelemetry/IntDeviceConfig.java
index c77b7bd..e1790bc 100644
--- a/core/api/src/main/java/org/onosproject/net/behaviour/inbandtelemetry/IntDeviceConfig.java
+++ b/core/api/src/main/java/org/onosproject/net/behaviour/inbandtelemetry/IntDeviceConfig.java
@@ -20,6 +20,7 @@
 import org.onlab.packet.MacAddress;
 import org.onlab.packet.TpPort;
 
+import static com.google.common.base.Preconditions.checkArgument;
 import static com.google.common.base.Preconditions.checkNotNull;
 
 /**
@@ -54,9 +55,11 @@
     private final MacAddress sinkMac;
     private final TelemetrySpec spec;
     private boolean enabled;
+    private int hopLatencySensitivity;
 
     private IntDeviceConfig(IpAddress collectorIp, TpPort collectorPort, MacAddress collectorNextHopMac,
-                            IpAddress sinkIp, MacAddress sinkMac, TelemetrySpec spec, boolean enabled) {
+                            IpAddress sinkIp, MacAddress sinkMac, TelemetrySpec spec, boolean enabled,
+                            int hopLatencySensitivity) {
         this.collectorIp = collectorIp;
         this.collectorPort = collectorPort;
         this.collectorNextHopMac = collectorNextHopMac;
@@ -64,6 +67,7 @@
         this.sinkMac = sinkMac;
         this.spec = spec;
         this.enabled = enabled;
+        this.hopLatencySensitivity = hopLatencySensitivity;
     }
 
     /**
@@ -145,6 +149,15 @@
     }
 
     /**
+     * Returns the minimal interval of hop latency change for a flow.
+     *
+     * @return the minimal interval of hop latency change for a flow.
+     */
+    public int minFlowHopLatencyChangeNs() {
+        return hopLatencySensitivity;
+    }
+
+    /**
      * Returns a new builder.
      *
      * @return new builder
@@ -165,6 +178,7 @@
         private MacAddress sinkMac;
         private TelemetrySpec spec = TelemetrySpec.INT;
         private boolean enabled = false;
+        int minFlowHopLatencyChangeNs = 0;
 
         /**
          * Assigns a collector IP address to the IntConfig object.
@@ -246,6 +260,17 @@
         }
 
         /**
+         * Sets the minimal interval of hop latency change for a flow.
+         *
+         * @param value the minimal interval of hop latency change for a flow
+         * @return an IntConfig builder
+         */
+        public IntDeviceConfig.Builder withMinFlowHopLatencyChangeNs(int value) {
+            this.minFlowHopLatencyChangeNs = value;
+            return this;
+        }
+
+        /**
          * Builds the IntConfig object.
          *
          * @return an IntConfig object
@@ -253,11 +278,10 @@
         public IntDeviceConfig build() {
             checkNotNull(collectorIp, "Collector IP should be specified.");
             checkNotNull(collectorPort, "Collector port number should be specified.");
-            checkNotNull(collectorNextHopMac, "Next hop MAC address for report packets should be provided.");
-            checkNotNull(sinkIp, "Sink IP address for report packets should be specified.");
-            checkNotNull(sinkMac, "Sink MAC address for report packets should be specified.");
+            checkArgument(minFlowHopLatencyChangeNs >= 0, "Hop latency sensitivity must be positive or zero");
+
             return new IntDeviceConfig(collectorIp, collectorPort, collectorNextHopMac,
-                                 sinkIp, sinkMac, spec, enabled);
+                                 sinkIp, sinkMac, spec, enabled, minFlowHopLatencyChangeNs);
         }
     }
 }
diff --git a/core/api/src/main/java/org/onosproject/net/behaviour/inbandtelemetry/IntReportConfig.java b/core/api/src/main/java/org/onosproject/net/behaviour/inbandtelemetry/IntReportConfig.java
new file mode 100644
index 0000000..95a8fe5
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/net/behaviour/inbandtelemetry/IntReportConfig.java
@@ -0,0 +1,208 @@
+/*
+ * Copyright 2020-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.net.behaviour.inbandtelemetry;
+
+import com.google.common.annotations.Beta;
+import org.onlab.packet.IpAddress;
+import org.onlab.packet.MacAddress;
+import org.onlab.packet.TpPort;
+import org.onosproject.core.ApplicationId;
+import org.onosproject.net.config.Config;
+import org.onosproject.ui.JsonUtils;
+
+/**
+ * Application level configuration of the INT process.
+ * Config example:
+ * {
+ *   "apps": {
+ *     "org.onosproject.inbandtelemetry": {
+ *       "report": {
+ *         "collectorIp": "192.168.0.1",
+ *         "collectorPort": 5500,
+ *         "minFlowHopLatencyChangeNs": 300
+ *       }
+ *     }
+ *   }
+ * }
+ */
+@Beta
+public final class IntReportConfig extends Config<ApplicationId> {
+    private static final String COLLECTOR_IP = "collectorIp";
+    private static final String COLLECTOR_PORT = "collectorPort";
+    private static final String MIN_FLOW_HOP_LATENCY_CHANGE_NS = "minFlowHopLatencyChangeNs";
+    private static final String COLLECTOR_NEXT_HOP_MAC = "collectorNextHopMac";
+    private static final String SINK_IP = "sinkIp";
+    private static final String SINK_MAC = "sinkMac";
+
+    /**
+     * IP address of the collector.
+     * This is the destination IP address that will be used for all INT reports
+     * generated by all INT devices.
+     *
+     * @return collector IP address, null if not present
+     */
+    public IpAddress collectorIp() {
+        if (object.hasNonNull(COLLECTOR_IP)) {
+            return IpAddress.valueOf(JsonUtils.string(object, COLLECTOR_IP));
+        } else {
+            return null;
+        }
+    }
+
+    /**
+     * UDP port number of the collector.
+     * This is the destination UDP port number that will be used for all INT reports
+     * generated by all INT devices.
+     *
+     * @return collector UDP port number, null if not present
+     */
+    public TpPort collectorPort() {
+        if (object.hasNonNull(COLLECTOR_PORT)) {
+            return TpPort.tpPort((int) JsonUtils.number(object, COLLECTOR_PORT));
+        } else {
+            return null;
+        }
+    }
+
+    /**
+     * Gets the minimal interval of hop latency change for a flow.
+     * This value is used to instruct an INT-capable device to produce reports
+     * only for packets which hop latency changed by at least minFlowHopLatencyChangeNs
+     * from the previously reported value for the same flow (5-tuple), i.e., produce a
+     * report only if `(currentHopLatency - previousHopLatency) > minFlowHopLatencyChangeNs`.
+     * Some device implementations might support only specific intervals, e.g., powers of 2.
+     *
+     * @return Interval in nanoseconds
+     */
+    public int minFlowHopLatencyChangeNs() {
+        if (object.hasNonNull(MIN_FLOW_HOP_LATENCY_CHANGE_NS)) {
+            return (int) JsonUtils.number(object, MIN_FLOW_HOP_LATENCY_CHANGE_NS);
+        } else {
+            return 0;
+        }
+    }
+
+    /**
+     * Returns MAC address of next hop of INT report packets.
+     * This can be either MAC address of the collector or a router.
+     * This is an optional parameter, which means that the usage of this
+     * parameter depends on IntProgrammable implementation.
+     * (e.g., If a report packet needs to be routed to reach the collector,
+     * IntProgrammable will ignore this value and choose next hop router's MAC address.
+     * If a collector itself is the next hop of INT report packets, then
+     * this value will be used as a destination MAC address for all INT report packets.)
+     *
+     * @return MAC address of next hop of INT report packets, null if not present
+     */
+    public MacAddress collectorNextHopMac() {
+        if (object.hasNonNull(COLLECTOR_NEXT_HOP_MAC)) {
+            return MacAddress.valueOf(JsonUtils.string(object, COLLECTOR_NEXT_HOP_MAC));
+        } else {
+            return null;
+        }
+    }
+
+    /**
+     * Returns IP address of the sink device.
+     * All sink devices share this address as the source IP address
+     * for all INT reports.
+     *
+     * @return sink device's IP address, null if not present
+     */
+    public IpAddress sinkIp() {
+        if (object.hasNonNull(SINK_IP)) {
+            return IpAddress.valueOf(JsonUtils.string(object, SINK_IP));
+        } else {
+            return null;
+        }
+    }
+
+    /**
+     * Returns MAC address of the sink device.
+     * All sink devices share this address as the source MAC address
+     * for all INT reports.
+     *
+     * @return sink device's MAC address, null if not present
+     */
+    public MacAddress sinkMac() {
+        if (object.hasNonNull(SINK_MAC)) {
+            return MacAddress.valueOf(JsonUtils.string(object, SINK_MAC));
+        } else {
+            return null;
+        }
+    }
+
+    /**
+     * Sets the collector IP to the config.
+     *
+     * @param collectorIp the collector IP
+     * @return the config
+     */
+    public IntReportConfig setCollectorIp(IpAddress collectorIp) {
+        return (IntReportConfig) setOrClear(COLLECTOR_IP, collectorIp.toString());
+    }
+
+    /**
+     * Sets the collector port to the config.
+     *
+     * @param port the collector port
+     * @return the config
+     */
+    public IntReportConfig setCollectorPort(TpPort port) {
+        return (IntReportConfig) setOrClear(COLLECTOR_PORT, port.toInt());
+    }
+
+    /**
+     * Sets the minimal interval of hop latency change
+     * for a flow to the config.
+     *
+     * @param ns the value of hop latency change
+     * @return the config
+     */
+    public IntReportConfig setMinFlowHopLatencyChangeNs(int ns) {
+        return (IntReportConfig) setOrClear(MIN_FLOW_HOP_LATENCY_CHANGE_NS, ns);
+    }
+
+    /**
+     * Sets collector next hop mac address to the config.
+     *
+     * @param collectorNextHopMac the collector next hop mac address
+     * @return the config
+     */
+    public IntReportConfig setCollectorNextHopMac(MacAddress collectorNextHopMac) {
+        return (IntReportConfig) setOrClear(COLLECTOR_NEXT_HOP_MAC, collectorNextHopMac.toString());
+    }
+
+    /**
+     * Sets the sink IP address to the config.
+     *
+     * @param sinkIp the sink IP address
+     * @return the config
+     */
+    public IntReportConfig setSinkIp(IpAddress sinkIp) {
+        return (IntReportConfig) setOrClear(SINK_IP, sinkIp.toString());
+    }
+
+    /**
+     * Sets the sink mac address to the config.
+     *
+     * @param sinkMac the sink mac address
+     * @return the config
+     */
+    public IntReportConfig setSinkMac(MacAddress sinkMac) {
+        return (IntReportConfig) setOrClear(SINK_MAC, sinkMac.toString());
+    }
+}
diff --git a/core/api/src/test/java/org/onosproject/store/service/TestAtomicValue.java b/core/api/src/test/java/org/onosproject/store/service/TestAtomicValue.java
new file mode 100644
index 0000000..2ab645e
--- /dev/null
+++ b/core/api/src/test/java/org/onosproject/store/service/TestAtomicValue.java
@@ -0,0 +1,80 @@
+/*
+ * Copyright 2020-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.store.service;
+
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.atomic.AtomicReference;
+
+public class TestAtomicValue<V> implements AsyncAtomicValue<V> {
+
+    private AtomicReference<V> ref;
+    private String name;
+
+    TestAtomicValue(String name) {
+        ref = new AtomicReference<>();
+        this.name = name;
+    }
+
+    @Override
+    public CompletableFuture<Boolean> compareAndSet(V expect, V update) {
+        return CompletableFuture.completedFuture(ref.compareAndSet(expect, update));
+    }
+
+    @Override
+    public CompletableFuture<V> get() {
+        return CompletableFuture.completedFuture(ref.get());
+    }
+
+    @Override
+    public CompletableFuture<V> getAndSet(V value) {
+        return CompletableFuture.completedFuture(ref.getAndSet(value));
+    }
+
+    @Override
+    public CompletableFuture<Void> set(V value) {
+        ref.set(value);
+        return CompletableFuture.completedFuture(null);
+    }
+
+    @Override
+    public CompletableFuture<Void> addListener(AtomicValueEventListener<V> listener) {
+        // Unimplemented
+        return CompletableFuture.completedFuture(null);
+    }
+
+    @Override
+    public CompletableFuture<Void> removeListener(AtomicValueEventListener<V> listener) {
+        // Unimplemented
+        return CompletableFuture.completedFuture(null);
+    }
+
+    @Override
+    public String name() {
+        return name;
+    }
+
+    public static Builder builder() {
+        return new Builder();
+    }
+
+    public static class Builder extends AtomicValueBuilder {
+
+        @Override
+        public AsyncAtomicValue build() {
+            return new TestAtomicValue<>("");
+        }
+    }
+}
diff --git a/core/api/src/test/java/org/onosproject/store/service/TestStorageService.java b/core/api/src/test/java/org/onosproject/store/service/TestStorageService.java
index 48ffeac..df7acf1 100644
--- a/core/api/src/test/java/org/onosproject/store/service/TestStorageService.java
+++ b/core/api/src/test/java/org/onosproject/store/service/TestStorageService.java
@@ -47,7 +47,7 @@
 
     @Override
     public <V> AtomicValueBuilder<V> atomicValueBuilder() {
-        throw new UnsupportedOperationException("atomicValueBuilder");
+        return TestAtomicValue.builder();
     }
 
     @Override