Add skeletal CPMan manager component interfaces

Change-Id: Ica16e43849dd3bb0b90936a20ef4af477045b376
diff --git a/apps/cpman/api/src/main/java/org/onosproject/cpman/ControlMessage.java b/apps/cpman/api/src/main/java/org/onosproject/cpman/ControlMessage.java
new file mode 100644
index 0000000..ffcb9dd
--- /dev/null
+++ b/apps/cpman/api/src/main/java/org/onosproject/cpman/ControlMessage.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2016 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.cpman;
+
+/**
+ * Abstraction of control message.
+ */
+public interface ControlMessage {
+
+    enum Type {
+        INCOMING_PACKET, OUTGOING_PACKET, FLOW_MOD_PACKET,
+        FLOW_REMOVED_PACKET, REQUEST_PACKET, REPLY_PACKET
+    }
+
+    /**
+     * Returns the control message type.
+     *
+     * @return control message type
+     */
+    Type type();
+
+    /**
+     * Returns the latest control message load.
+     *
+     * @return control message load
+     */
+    long load();
+
+    /**
+     * Returns the latest control message rate.
+     *
+     * @return control message rate
+     */
+    long rate();
+
+    /**
+     * Returns the latest control message packet count.
+     *
+     * @return packet count
+     */
+    long count();
+
+    /**
+     * Returns the time that this control message stats collected.
+     *
+     * @return
+     */
+    long timeStamp();
+}
diff --git a/apps/cpman/api/src/main/java/org/onosproject/cpman/DefaultControlMessage.java b/apps/cpman/api/src/main/java/org/onosproject/cpman/DefaultControlMessage.java
new file mode 100644
index 0000000..e63c0ee
--- /dev/null
+++ b/apps/cpman/api/src/main/java/org/onosproject/cpman/DefaultControlMessage.java
@@ -0,0 +1,72 @@
+/*
+ * Copyright 2016 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.cpman;
+
+/**
+ * Default control message implementation.
+ */
+public class DefaultControlMessage implements ControlMessage {
+
+    private final Type type;
+    private final long load;
+    private final long rate;
+    private final long count;
+    private final long timeStamp;
+
+    /**
+     * Generates a control message instance using given type and statistic
+     * information.
+     *
+     * @param type control message type
+     * @param load control message load
+     * @param rate control message rate
+     * @param count control message count
+     * @param timeStamp time stamp of the control message stats
+     */
+    public DefaultControlMessage(Type type, long load, long rate,
+                                 long count, long timeStamp) {
+        this.type = type;
+        this.load = load;
+        this.rate = rate;
+        this.count = count;
+        this.timeStamp = timeStamp;
+    }
+
+    @Override
+    public Type type() {
+        return type;
+    }
+
+    @Override
+    public long load() {
+        return load;
+    }
+
+    @Override
+    public long rate() {
+        return rate;
+    }
+
+    @Override
+    public long count() {
+        return count;
+    }
+
+    @Override
+    public long timeStamp() {
+        return timeStamp;
+    }
+}
diff --git a/apps/cpman/api/src/main/java/org/onosproject/cpman/message/ControlMessageAdminService.java b/apps/cpman/api/src/main/java/org/onosproject/cpman/message/ControlMessageAdminService.java
new file mode 100644
index 0000000..01d040e
--- /dev/null
+++ b/apps/cpman/api/src/main/java/org/onosproject/cpman/message/ControlMessageAdminService.java
@@ -0,0 +1,22 @@
+/*
+ * Copyright 2016 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.cpman.message;
+
+/**
+ * Service for administering the control message monitoring.
+ */
+public interface ControlMessageAdminService extends ControlMessageService {
+}
diff --git a/apps/cpman/api/src/main/java/org/onosproject/cpman/message/ControlMessageEvent.java b/apps/cpman/api/src/main/java/org/onosproject/cpman/message/ControlMessageEvent.java
new file mode 100644
index 0000000..b2412b7
--- /dev/null
+++ b/apps/cpman/api/src/main/java/org/onosproject/cpman/message/ControlMessageEvent.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2016 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.cpman.message;
+
+import org.onosproject.event.AbstractEvent;
+import org.onosproject.cpman.ControlMessage;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+
+/**
+ * Describes control message event.
+ */
+public class ControlMessageEvent
+        extends AbstractEvent<ControlMessageEvent.Type, ControlMessage> {
+
+    /**
+     * Type of control message events.
+     */
+    public enum Type {
+        /**
+         * signifies that the control message stats has been updated.
+         */
+        STATS_UPDATE
+    }
+
+    /**
+     * Creates an event of given type and the current time.
+     *
+     * @param type  control message event type
+     * @param controlMessage event control message subject
+     */
+    public ControlMessageEvent(Type type, ControlMessage controlMessage) {
+        super(type, controlMessage);
+    }
+
+    @Override
+    public String toString() {
+        return toStringHelper(this)
+                .add("type", type())
+                .add("subject", subject())
+                .toString();
+    }
+}
diff --git a/apps/cpman/api/src/main/java/org/onosproject/cpman/message/ControlMessageListener.java b/apps/cpman/api/src/main/java/org/onosproject/cpman/message/ControlMessageListener.java
new file mode 100644
index 0000000..7f85d05
--- /dev/null
+++ b/apps/cpman/api/src/main/java/org/onosproject/cpman/message/ControlMessageListener.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2016 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.cpman.message;
+
+import org.onosproject.event.EventListener;
+
+/**
+ * Entity capable of receiving control message related event.
+ */
+public interface ControlMessageListener extends EventListener<ControlMessageEvent> {
+
+}
diff --git a/apps/cpman/api/src/main/java/org/onosproject/cpman/message/ControlMessageProvider.java b/apps/cpman/api/src/main/java/org/onosproject/cpman/message/ControlMessageProvider.java
new file mode 100644
index 0000000..94e7e27
--- /dev/null
+++ b/apps/cpman/api/src/main/java/org/onosproject/cpman/message/ControlMessageProvider.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright 2016 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.cpman.message;
+
+import org.onosproject.net.provider.Provider;
+
+/**
+ * Abstraction of a control message provider.
+ */
+public interface ControlMessageProvider extends Provider {
+}
diff --git a/apps/cpman/api/src/main/java/org/onosproject/cpman/message/ControlMessageProviderRegistry.java b/apps/cpman/api/src/main/java/org/onosproject/cpman/message/ControlMessageProviderRegistry.java
new file mode 100644
index 0000000..5768c02
--- /dev/null
+++ b/apps/cpman/api/src/main/java/org/onosproject/cpman/message/ControlMessageProviderRegistry.java
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2016 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.cpman.message;
+
+import org.onosproject.net.provider.ProviderRegistry;
+
+/**
+ * Abstraction of a control message provider registry.
+ */
+public interface ControlMessageProviderRegistry
+        extends ProviderRegistry<ControlMessageProvider,
+                                 ControlMessageProviderService> {
+}
diff --git a/apps/cpman/api/src/main/java/org/onosproject/cpman/message/ControlMessageProviderService.java b/apps/cpman/api/src/main/java/org/onosproject/cpman/message/ControlMessageProviderService.java
new file mode 100644
index 0000000..7a702c2
--- /dev/null
+++ b/apps/cpman/api/src/main/java/org/onosproject/cpman/message/ControlMessageProviderService.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2016 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.cpman.message;
+
+import org.onosproject.cpman.ControlMessage;
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.provider.ProviderService;
+
+import java.util.Collection;
+
+/**
+ * Service through which control message providers can inject control message
+ * stats into the core.
+ */
+public interface ControlMessageProviderService
+        extends ProviderService<ControlMessageProvider> {
+
+    /**
+     * Used to notify the core about the control message statistic information.
+     *
+     * @param deviceId device identifier
+     * @param controlMessages a collection of control message stats
+     */
+    void updateStatsInfo(DeviceId deviceId, Collection<ControlMessage> controlMessages);
+}
\ No newline at end of file
diff --git a/apps/cpman/api/src/main/java/org/onosproject/cpman/message/ControlMessageService.java b/apps/cpman/api/src/main/java/org/onosproject/cpman/message/ControlMessageService.java
new file mode 100644
index 0000000..302a446
--- /dev/null
+++ b/apps/cpman/api/src/main/java/org/onosproject/cpman/message/ControlMessageService.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright 2016 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.cpman.message;
+
+import org.onosproject.event.ListenerService;
+
+/**
+ * Service for obtaining control message statistic information.
+ */
+public interface ControlMessageService extends ListenerService {
+}
diff --git a/apps/cpman/api/src/main/java/org/onosproject/cpman/message/ControlMessageStore.java b/apps/cpman/api/src/main/java/org/onosproject/cpman/message/ControlMessageStore.java
new file mode 100644
index 0000000..baeb327
--- /dev/null
+++ b/apps/cpman/api/src/main/java/org/onosproject/cpman/message/ControlMessageStore.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2016 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.cpman.message;
+
+import org.onosproject.cpman.ControlMessage;
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.provider.ProviderId;
+import org.onosproject.store.Store;
+
+import java.util.Collection;
+
+/**
+ * Manages inventory of control message.
+ */
+public interface ControlMessageStore
+        extends Store<ControlMessageEvent, ControlMessageStoreDelegate> {
+
+    /**
+     * Updates the control message statistics of the specified device.
+     *
+     * @param providerId  provider identifier
+     * @param deviceId    device identifier
+     * @param controlMessages a collection of control message stats
+     * @return ready to send event describing what occurred
+     */
+    ControlMessageEvent updateStatsInfo(ProviderId providerId,
+                                        DeviceId deviceId,
+                                        Collection<ControlMessage> controlMessages);
+
+}
diff --git a/apps/cpman/api/src/main/java/org/onosproject/cpman/message/ControlMessageStoreDelegate.java b/apps/cpman/api/src/main/java/org/onosproject/cpman/message/ControlMessageStoreDelegate.java
new file mode 100644
index 0000000..61fba2d
--- /dev/null
+++ b/apps/cpman/api/src/main/java/org/onosproject/cpman/message/ControlMessageStoreDelegate.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright 2016 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.cpman.message;
+
+import org.onosproject.store.StoreDelegate;
+
+/**
+ * Control message store delegate abstraction.
+ */
+public interface ControlMessageStoreDelegate extends StoreDelegate<ControlMessageEvent> {
+}
diff --git a/apps/cpman/api/src/main/java/org/onosproject/cpman/message/package-info.java b/apps/cpman/api/src/main/java/org/onosproject/cpman/message/package-info.java
new file mode 100644
index 0000000..2900d3d
--- /dev/null
+++ b/apps/cpman/api/src/main/java/org/onosproject/cpman/message/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2016 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.
+ */
+
+/**
+ * Service for looking up control message stats.
+ */
+package org.onosproject.cpman.message;
\ No newline at end of file