Remove deprecated code left over from removing ConfigProvider

Change-Id: Ib47e345d764abfe8254a0ff0d24d3f6b6f4a4b68
diff --git a/core/store/dist/src/main/java/org/onosproject/store/device/impl/DeviceInjectedEvent.java b/core/store/dist/src/main/java/org/onosproject/store/device/impl/DeviceInjectedEvent.java
deleted file mode 100644
index e5dd857..0000000
--- a/core/store/dist/src/main/java/org/onosproject/store/device/impl/DeviceInjectedEvent.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Laboratory
- *
- * 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.device.impl;
-
-import com.google.common.base.MoreObjects;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.device.DeviceDescription;
-import org.onosproject.net.provider.ProviderId;
-
-/**
- * Remnant of ConfigProvider.
- * @deprecated in Hummingbird(1.7.0)
- */
-@Deprecated
-public class DeviceInjectedEvent {
-    private final ProviderId providerId;
-    private final DeviceId deviceId;
-    private final DeviceDescription deviceDescription;
-
-    protected DeviceInjectedEvent(
-            ProviderId providerId,
-            DeviceId deviceId,
-            DeviceDescription deviceDescription) {
-        this.providerId = providerId;
-        this.deviceId = deviceId;
-        this.deviceDescription = deviceDescription;
-    }
-
-    public DeviceId deviceId() {
-        return deviceId;
-    }
-
-    public ProviderId providerId() {
-        return providerId;
-    }
-
-    public DeviceDescription deviceDescription() {
-        return deviceDescription;
-    }
-
-    @Override
-    public String toString() {
-        return MoreObjects.toStringHelper(getClass())
-                .add("providerId", providerId)
-                .add("deviceId", deviceId)
-                .add("deviceDescription", deviceDescription)
-                .toString();
-    }
-
-    // for serializer
-    protected DeviceInjectedEvent() {
-        this.providerId = null;
-        this.deviceId = null;
-        this.deviceDescription = null;
-    }
-}
diff --git a/core/store/dist/src/main/java/org/onosproject/store/device/impl/ECDeviceStore.java b/core/store/dist/src/main/java/org/onosproject/store/device/impl/ECDeviceStore.java
index 30fae0b..062fd46 100644
--- a/core/store/dist/src/main/java/org/onosproject/store/device/impl/ECDeviceStore.java
+++ b/core/store/dist/src/main/java/org/onosproject/store/device/impl/ECDeviceStore.java
@@ -15,12 +15,19 @@
  */
 package org.onosproject.store.device.impl;
 
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-import com.google.common.collect.Sets;
-import com.google.common.util.concurrent.Futures;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.Set;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicReference;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
 import org.apache.felix.scr.annotations.Activate;
 import org.apache.felix.scr.annotations.Deactivate;
 import org.apache.felix.scr.annotations.Reference;
@@ -28,7 +35,6 @@
 import org.apache.felix.scr.annotations.Service;
 import org.onlab.packet.ChassisId;
 import org.onlab.util.KryoNamespace;
-import org.onlab.util.SharedExecutors;
 import org.onosproject.cluster.ClusterService;
 import org.onosproject.cluster.NodeId;
 import org.onosproject.mastership.MastershipService;
@@ -70,18 +76,12 @@
 import org.onosproject.store.service.WallClockTimestamp;
 import org.slf4j.Logger;
 
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Objects;
-import java.util.Optional;
-import java.util.Set;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicReference;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import com.google.common.collect.Sets;
+import com.google.common.util.concurrent.Futures;
 
 import static com.google.common.base.Preconditions.checkArgument;
 import static com.google.common.base.Verify.verify;
@@ -93,9 +93,7 @@
 import static org.onosproject.net.device.DeviceEvent.Type.PORT_ADDED;
 import static org.onosproject.net.device.DeviceEvent.Type.PORT_STATS_UPDATED;
 import static org.onosproject.net.device.DeviceEvent.Type.PORT_UPDATED;
-import static org.onosproject.store.device.impl.GossipDeviceStoreMessageSubjects.DEVICE_INJECTED;
 import static org.onosproject.store.device.impl.GossipDeviceStoreMessageSubjects.DEVICE_REMOVE_REQ;
-import static org.onosproject.store.device.impl.GossipDeviceStoreMessageSubjects.PORT_INJECTED;
 import static org.onosproject.store.service.EventuallyConsistentMapEvent.Type.PUT;
 import static org.onosproject.store.service.EventuallyConsistentMapEvent.Type.REMOVE;
 import static org.slf4j.LoggerFactory.getLogger;
@@ -156,8 +154,6 @@
                   KryoNamespace.newBuilder()
                     .register(DistributedStoreSerializers.STORE_COMMON)
                     .nextId(DistributedStoreSerializers.STORE_CUSTOM_BEGIN)
-                    .register(DeviceInjectedEvent.class)
-                    .register(PortInjectedEvent.class)
                     .build("ECDevice"));
 
     protected static final KryoNamespace.Builder SERIALIZER_BUILDER = KryoNamespace.newBuilder()
@@ -211,18 +207,6 @@
                 .withTombstonesDisabled()
                 .build();
 
-        clusterCommunicator.addSubscriber(DEVICE_INJECTED,
-                SERIALIZER::decode,
-                this::injectDevice,
-                SERIALIZER::encode,
-                SharedExecutors.getPoolThreadExecutor());
-
-        clusterCommunicator.addSubscriber(PORT_INJECTED,
-                SERIALIZER::decode,
-                this::injectPort,
-                SERIALIZER::encode,
-                SharedExecutors.getPoolThreadExecutor());
-
         availableDevices = storageService.<DeviceId>setBuilder()
                 .withName("onos-online-devices")
                 .withSerializer(Serializer.using(KryoNamespaces.API))
@@ -249,8 +233,6 @@
         portDescriptions.destroy();
         devices.clear();
         devicePorts.clear();
-        clusterCommunicator.removeSubscriber(DEVICE_INJECTED);
-        clusterCommunicator.removeSubscriber(PORT_INJECTED);
         log.info("Stopped");
     }
 
@@ -279,18 +261,7 @@
             deviceDescriptions.put(new DeviceKey(providerId, deviceId), deviceDescription);
             return refreshDeviceCache(providerId, deviceId);
         } else {
-            // Only forward for ConfigProvider
-            // Forwarding was added as a workaround for ONOS-490
-            if (!"cfg".equals(providerId.scheme())) {
                 return null;
-            }
-            DeviceInjectedEvent deviceInjectedEvent = new DeviceInjectedEvent(providerId, deviceId, deviceDescription);
-            return Futures.getUnchecked(
-                    clusterCommunicator.sendAndReceive(deviceInjectedEvent,
-                            DEVICE_INJECTED,
-                            SERIALIZER::encode,
-                            SERIALIZER::decode,
-                            master));
         }
     }
 
@@ -416,21 +387,7 @@
             });
             deviceEvents = refreshDevicePortCache(providerId, deviceId, Optional.empty());
         } else {
-            // Only forward for ConfigProvider
-            // Forwarding was added as a workaround for ONOS-490
-            if (!"cfg".equals(providerId.scheme())) {
-                return Collections.emptyList();
-            }
-            if (master == null) {
-                return Collections.emptyList();
-            }
-            PortInjectedEvent portInjectedEvent = new PortInjectedEvent(providerId, deviceId, descriptions);
-            deviceEvents = Futures.getUnchecked(
-                    clusterCommunicator.sendAndReceive(portInjectedEvent,
-                                    PORT_INJECTED,
-                                    SERIALIZER::encode,
-                                    SERIALIZER::decode,
-                                    master));
+            return Collections.emptyList();
         }
         return deviceEvents == null ? Collections.emptyList() : deviceEvents;
     }
@@ -726,14 +683,6 @@
         return event;
     }
 
-    private DeviceEvent injectDevice(DeviceInjectedEvent event) {
-        return createOrUpdateDevice(event.providerId(), event.deviceId(), event.deviceDescription());
-    }
-
-    private List<DeviceEvent> injectPort(PortInjectedEvent event) {
-        return updatePorts(event.providerId(), event.deviceId(), event.portDescriptions());
-    }
-
     private DefaultAnnotations mergeAnnotations(DeviceId deviceId) {
         ProviderId primaryProviderId = getPrimaryProviderId(deviceId);
         DeviceDescription primaryDeviceDescription =
@@ -811,4 +760,4 @@
             }
         }
     }
-}
\ No newline at end of file
+}
diff --git a/core/store/dist/src/main/java/org/onosproject/store/device/impl/GossipDeviceStore.java b/core/store/dist/src/main/java/org/onosproject/store/device/impl/GossipDeviceStore.java
index eade6e0..4400221 100644
--- a/core/store/dist/src/main/java/org/onosproject/store/device/impl/GossipDeviceStore.java
+++ b/core/store/dist/src/main/java/org/onosproject/store/device/impl/GossipDeviceStore.java
@@ -15,10 +15,27 @@
  */
 package org.onosproject.store.device.impl;
 
-import com.google.common.collect.FluentIterable;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Maps;
-import com.google.common.collect.Sets;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+import java.util.function.Consumer;
+import java.util.stream.Stream;
+
 import org.apache.commons.lang3.RandomUtils;
 import org.apache.felix.scr.annotations.Activate;
 import org.apache.felix.scr.annotations.Component;
@@ -70,26 +87,10 @@
 import org.onosproject.store.service.WallClockTimestamp;
 import org.slf4j.Logger;
 
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Objects;
-import java.util.Optional;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.TimeUnit;
-import java.util.function.Consumer;
-import java.util.stream.Stream;
+import com.google.common.collect.FluentIterable;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Maps;
+import com.google.common.collect.Sets;
 
 import static com.google.common.base.Preconditions.checkArgument;
 import static com.google.common.base.Predicates.notNull;
@@ -106,12 +107,10 @@
 import static org.onosproject.net.device.DeviceEvent.Type.PORT_STATS_UPDATED;
 import static org.onosproject.net.device.DeviceEvent.Type.PORT_UPDATED;
 import static org.onosproject.store.device.impl.GossipDeviceStoreMessageSubjects.DEVICE_ADVERTISE;
-import static org.onosproject.store.device.impl.GossipDeviceStoreMessageSubjects.DEVICE_INJECTED;
 import static org.onosproject.store.device.impl.GossipDeviceStoreMessageSubjects.DEVICE_OFFLINE;
 import static org.onosproject.store.device.impl.GossipDeviceStoreMessageSubjects.DEVICE_REMOVED;
 import static org.onosproject.store.device.impl.GossipDeviceStoreMessageSubjects.DEVICE_REMOVE_REQ;
 import static org.onosproject.store.device.impl.GossipDeviceStoreMessageSubjects.DEVICE_UPDATE;
-import static org.onosproject.store.device.impl.GossipDeviceStoreMessageSubjects.PORT_INJECTED;
 import static org.onosproject.store.device.impl.GossipDeviceStoreMessageSubjects.PORT_STATUS_UPDATE;
 import static org.onosproject.store.device.impl.GossipDeviceStoreMessageSubjects.PORT_UPDATE;
 import static org.onosproject.store.service.EventuallyConsistentMapEvent.Type.PUT;
@@ -184,8 +183,6 @@
                     .register(DeviceAntiEntropyAdvertisement.class)
                     .register(DeviceFragmentId.class)
                     .register(PortFragmentId.class)
-                    .register(DeviceInjectedEvent.class)
-                    .register(PortInjectedEvent.class)
                     .build("GossipDevice"));
 
     private ExecutorService executor;
@@ -210,8 +207,6 @@
         addSubscriber(PORT_UPDATE, this::handlePortEvent);
         addSubscriber(PORT_STATUS_UPDATE, this::handlePortStatusEvent);
         addSubscriber(DEVICE_ADVERTISE, this::handleDeviceAdvertisement);
-        addSubscriber(DEVICE_INJECTED, this::handleDeviceInjectedEvent);
-        addSubscriber(PORT_INJECTED, this::handlePortInjectedEvent);
 
         // start anti-entropy thread
         backgroundExecutor.scheduleAtFixedRate(new SendAdvertisementTask(),
@@ -273,8 +268,6 @@
         clusterCommunicator.removeSubscriber(PORT_UPDATE);
         clusterCommunicator.removeSubscriber(PORT_STATUS_UPDATE);
         clusterCommunicator.removeSubscriber(DEVICE_ADVERTISE);
-        clusterCommunicator.removeSubscriber(DEVICE_INJECTED);
-        clusterCommunicator.removeSubscriber(PORT_INJECTED);
         log.info("Stopped");
     }
 
@@ -328,30 +321,7 @@
             }
 
         } else {
-            // Only forward for ConfigProvider
-            // Forwarding was added as a workaround for ONOS-490
-            if (!"cfg".equals(providerId.scheme())) {
-                return null;
-            }
-            // FIXME Temporary hack for NPE (ONOS-1171).
-            // Proper fix is to implement forwarding to master on ConfigProvider
-            // redo ONOS-490
-            if (deviceNode == null) {
-                // silently ignore
-                return null;
-            }
-
-
-            DeviceInjectedEvent deviceInjectedEvent = new DeviceInjectedEvent(
-                    providerId, deviceId, deviceDescription);
-
-            // TODO check unicast return value
-            clusterCommunicator.unicast(deviceInjectedEvent, DEVICE_INJECTED, SERIALIZER::encode, deviceNode);
-            /* error log:
-            log.warn("Failed to process injected device id: {} desc: {} " +
-                            "(cluster messaging failed: {})",
-                    deviceId, deviceDescription, e);
-            */
+            return null;
         }
 
         return deviceEvent;
@@ -625,28 +595,7 @@
             }
 
         } else {
-            // Only forward for ConfigProvider
-            // Forwarding was added as a workaround for ONOS-490
-            if (!"cfg".equals(providerId.scheme())) {
-                return Collections.emptyList();
-            }
-            // FIXME Temporary hack for NPE (ONOS-1171).
-            // Proper fix is to implement forwarding to master on ConfigProvider
-            // redo ONOS-490
-            if (deviceNode == null) {
-                // silently ignore
-                return Collections.emptyList();
-            }
-
-            PortInjectedEvent portInjectedEvent = new PortInjectedEvent(providerId, deviceId, portDescriptions);
-
-            //TODO check unicast return value
-            clusterCommunicator.unicast(portInjectedEvent, PORT_INJECTED, SERIALIZER::encode, deviceNode);
-            /* error log:
-            log.warn("Failed to process injected ports of device id: {} " +
-                            "(cluster messaging failed: {})",
-                    deviceId, e);
-            */
+            return Collections.emptyList();
         }
 
         return deviceEvents == null ? Collections.emptyList() : deviceEvents;
@@ -1669,40 +1618,6 @@
         }
     }
 
-    private void handleDeviceInjectedEvent(DeviceInjectedEvent event) {
-        ProviderId providerId = event.providerId();
-        DeviceId deviceId = event.deviceId();
-        DeviceDescription deviceDescription = event.deviceDescription();
-        if (!deviceClockService.isTimestampAvailable(deviceId)) {
-            // workaround for ONOS-1208
-            log.warn("Not ready to accept update. Dropping {}", deviceDescription);
-            return;
-        }
-
-        try {
-            createOrUpdateDevice(providerId, deviceId, deviceDescription);
-        } catch (Exception e) {
-            log.warn("Exception thrown handling device injected event.", e);
-        }
-    }
-
-    private void handlePortInjectedEvent(PortInjectedEvent event) {
-        ProviderId providerId = event.providerId();
-        DeviceId deviceId = event.deviceId();
-        List<PortDescription> portDescriptions = event.portDescriptions();
-        if (!deviceClockService.isTimestampAvailable(deviceId)) {
-            // workaround for ONOS-1208
-            log.warn("Not ready to accept update. Dropping {}", portDescriptions);
-            return;
-        }
-
-        try {
-            updatePorts(providerId, deviceId, portDescriptions);
-        } catch (Exception e) {
-            log.warn("Exception thrown handling port injected event.", e);
-        }
-    }
-
     private class InternalPortStatsListener
             implements EventuallyConsistentMapListener<DeviceId, Map<PortNumber, PortStatistics>> {
         @Override
diff --git a/core/store/dist/src/main/java/org/onosproject/store/device/impl/GossipDeviceStoreMessageSubjects.java b/core/store/dist/src/main/java/org/onosproject/store/device/impl/GossipDeviceStoreMessageSubjects.java
index a66be63..ef74b91 100644
--- a/core/store/dist/src/main/java/org/onosproject/store/device/impl/GossipDeviceStoreMessageSubjects.java
+++ b/core/store/dist/src/main/java/org/onosproject/store/device/impl/GossipDeviceStoreMessageSubjects.java
@@ -35,17 +35,4 @@
     // to be used with 3-way anti-entropy process
     public static final MessageSubject DEVICE_REQUEST = new MessageSubject("peer-device-request");
 
-    // Network elements injected (not discovered) by ConfigProvider
-    /**
-     * Remnant of ConfigProvider.
-     * @deprecated in Hummingbird(1.7.0)
-     */
-    @Deprecated
-    public static final MessageSubject DEVICE_INJECTED = new MessageSubject("peer-device-injected");
-    /**
-     * Remnant of ConfigProvider.
-     * @deprecated in Hummingbird(1.7.0)
-     */
-    @Deprecated
-    public static final MessageSubject PORT_INJECTED = new MessageSubject("peer-port-injected");
 }
diff --git a/core/store/dist/src/main/java/org/onosproject/store/device/impl/PortInjectedEvent.java b/core/store/dist/src/main/java/org/onosproject/store/device/impl/PortInjectedEvent.java
deleted file mode 100644
index f1065c3..0000000
--- a/core/store/dist/src/main/java/org/onosproject/store/device/impl/PortInjectedEvent.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Laboratory
- *
- * 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.device.impl;
-
-import com.google.common.base.MoreObjects;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.device.PortDescription;
-import org.onosproject.net.provider.ProviderId;
-
-import java.util.List;
-
-/**
- * Remnant of ConfigProvider.
- * @deprecated in Hummingbird(1.7.0)
- */
-@Deprecated
-public class PortInjectedEvent {
-
-    private ProviderId providerId;
-    private DeviceId deviceId;
-    private List<PortDescription> portDescriptions;
-
-    protected PortInjectedEvent(ProviderId providerId, DeviceId deviceId, List<PortDescription> portDescriptions) {
-        this.providerId = providerId;
-        this.deviceId = deviceId;
-        this.portDescriptions = portDescriptions;
-    }
-
-    public DeviceId deviceId() {
-        return deviceId;
-    }
-
-    public ProviderId providerId() {
-        return providerId;
-    }
-
-    public List<PortDescription> portDescriptions() {
-        return portDescriptions;
-    }
-
-    @Override
-    public String toString() {
-        return MoreObjects.toStringHelper(getClass())
-                .add("providerId", providerId)
-                .add("deviceId", deviceId)
-                .add("portDescriptions", portDescriptions)
-                .toString();
-    }
-
-    // for serializer
-    protected PortInjectedEvent() {
-        this.providerId = null;
-        this.deviceId = null;
-        this.portDescriptions = null;
-    }
-
-}