[ONOS-5916] Add interfaces with adaptor for mapping management app
Change-Id: I44cec28ec50b77d2a40c3650b59c96f02ec48f4f
diff --git a/apps/mappingmanagement/api/src/main/java/org/onosproject/mapping/DefaultMapping.java b/apps/mappingmanagement/api/src/main/java/org/onosproject/mapping/DefaultMapping.java
new file mode 100644
index 0000000..f51a8d1
--- /dev/null
+++ b/apps/mappingmanagement/api/src/main/java/org/onosproject/mapping/DefaultMapping.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2017-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.mapping;
+
+import org.onosproject.core.ApplicationId;
+import org.onosproject.net.DeviceId;
+
+/**
+ * Default implementation class for mapping.
+ */
+public class DefaultMapping implements Mapping {
+ @Override
+ public MappingId id() {
+ return null;
+ }
+
+ @Override
+ public short appId() {
+ return 0;
+ }
+
+ @Override
+ public DeviceId deviceId() {
+ return null;
+ }
+
+ public static final class Builder implements Mapping.Builder {
+
+ @Override
+ public Mapping.Builder fromApp(ApplicationId appId) {
+ return null;
+ }
+
+ @Override
+ public Mapping.Builder forDevice(DeviceId deviceId) {
+ return null;
+ }
+
+ @Override
+ public Mapping build() {
+ return null;
+ }
+ }
+}
diff --git a/apps/mappingmanagement/api/src/main/java/org/onosproject/mapping/DefaultMappingEntry.java b/apps/mappingmanagement/api/src/main/java/org/onosproject/mapping/DefaultMappingEntry.java
new file mode 100644
index 0000000..4c7ae70
--- /dev/null
+++ b/apps/mappingmanagement/api/src/main/java/org/onosproject/mapping/DefaultMappingEntry.java
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2017-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.mapping;
+
+/**
+ * Default implementation of MappingEntry.
+ */
+public class DefaultMappingEntry extends DefaultMapping implements MappingEntry {
+ @Override
+ public MappingEntryState state() {
+ return null;
+ }
+}
diff --git a/apps/mappingmanagement/api/src/main/java/org/onosproject/mapping/Mapping.java b/apps/mappingmanagement/api/src/main/java/org/onosproject/mapping/Mapping.java
new file mode 100644
index 0000000..1233020
--- /dev/null
+++ b/apps/mappingmanagement/api/src/main/java/org/onosproject/mapping/Mapping.java
@@ -0,0 +1,90 @@
+/*
+ * Copyright 2017-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.mapping;
+
+import org.onosproject.core.ApplicationId;
+import org.onosproject.net.DeviceId;
+
+/**
+ * Abstraction of mapping.
+ */
+public interface Mapping {
+
+ /**
+ * Obtains the identifier of this mapping.
+ *
+ * @return mapping identifier
+ */
+ MappingId id();
+
+ /**
+ * Obtains the application identifier of this mapping.
+ *
+ * @return an application identifier
+ */
+ short appId();
+
+ /**
+ * Obtains the identity of the device where this mapping applies.
+ *
+ * @return device identifier
+ */
+ DeviceId deviceId();
+
+ /**
+ * {@inheritDoc}
+ *
+ * Equality for mappings only considers 'match equality'. This means that
+ * two mappings with the same match conditions will be equal.
+ *
+ * @param obj the reference object with which to compare.
+ * @return {@code true} if this object is the same as the obj
+ * argument; {@code false} otherwise.
+ */
+ boolean equals(Object obj);
+
+ /**
+ * A mapping builder.
+ */
+ interface Builder {
+
+ /**
+ * Assigns the application that built this mapping to this object.
+ * The short value of the appId will be used as a basis for the
+ * cookie value computation. It is expected that application use this
+ * call to set their application id.
+ *
+ * @param appId an application identifier
+ * @return this builder object
+ */
+ Builder fromApp(ApplicationId appId);
+
+ /**
+ * Sets the deviceId for this mapping.
+ *
+ * @param deviceId a device identifier
+ * @return this builder object
+ */
+ Builder forDevice(DeviceId deviceId);
+
+ /**
+ * Builds a mapping object.
+ *
+ * @return a mapping object
+ */
+ Mapping build();
+ }
+}
diff --git a/apps/mappingmanagement/api/src/main/java/org/onosproject/mapping/MappingAdminService.java b/apps/mappingmanagement/api/src/main/java/org/onosproject/mapping/MappingAdminService.java
new file mode 100644
index 0000000..8f41e10
--- /dev/null
+++ b/apps/mappingmanagement/api/src/main/java/org/onosproject/mapping/MappingAdminService.java
@@ -0,0 +1,22 @@
+/*
+ * Copyright 2017-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.mapping;
+
+/**
+ * Service for administering the mapping management.
+ */
+public interface MappingAdminService extends MappingService {
+}
diff --git a/apps/mappingmanagement/api/src/main/java/org/onosproject/mapping/MappingEntry.java b/apps/mappingmanagement/api/src/main/java/org/onosproject/mapping/MappingEntry.java
new file mode 100644
index 0000000..6e6ef94
--- /dev/null
+++ b/apps/mappingmanagement/api/src/main/java/org/onosproject/mapping/MappingEntry.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2017-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.mapping;
+
+/**
+ * Abstraction of mapping entry.
+ */
+public interface MappingEntry extends Mapping {
+
+ enum MappingEntryState {
+
+ /**
+ * Indicates that this mapping has been submitted for addition.
+ * Not necessarily in the map database or map cache.
+ */
+ PENDING_ADD,
+
+ /**
+ * Mapping has been added which means it is either in map database or
+ * in map cache.
+ */
+ ADDED,
+
+ /**
+ * Mapping has been marked for removal, might still be either in map
+ * database or in map cache.
+ */
+ PENDING_REMOVE,
+
+ /**
+ * Mapping has been removed from map database or in map cache, and
+ * ca be purged.
+ */
+ REMOVED,
+
+ /**
+ * Indicates that the installation of this mapping has failed.
+ */
+ FAILED
+ }
+
+ /**
+ * Returns the mapping entry state.
+ *
+ * @return mapping entry state
+ */
+ MappingEntryState state();
+}
diff --git a/apps/mappingmanagement/api/src/main/java/org/onosproject/mapping/MappingEvent.java b/apps/mappingmanagement/api/src/main/java/org/onosproject/mapping/MappingEvent.java
new file mode 100644
index 0000000..4b03d13
--- /dev/null
+++ b/apps/mappingmanagement/api/src/main/java/org/onosproject/mapping/MappingEvent.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2017-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.mapping;
+
+import org.onosproject.event.AbstractEvent;
+
+/**
+ * Describes mapping event.
+ */
+public class MappingEvent extends AbstractEvent<MappingEvent.Type, Mapping> {
+
+ public enum Type {
+
+ /**
+ * Signifies that a new mapping has been detected.
+ */
+ MAPPING_ADDED,
+
+ /**
+ * Signifies that a new mapping has been removed.
+ */
+ MAPPING_REMOVED,
+
+ /**
+ * Signifies that a mapping has been updated.
+ */
+ MAPPING_UPDATED,
+
+ // internal event between Manager <-> Store
+
+ /**
+ * Signifies that a request to add mapping has been added to the store.
+ */
+ MAPPING_ADD_REQUESTED,
+
+ /**
+ * Signifies that a request to update mapping has been added to the store.
+ */
+ MAPPING_UPDATE_REQUESTED,
+
+ /**
+ * Signifies that a request to remove flow rule has been added to the store.
+ */
+ MAPPING_REMOVE_REQUESTED,
+ }
+
+ public MappingEvent(Type type, Mapping mapping) {
+ super(type, mapping);
+ }
+}
diff --git a/apps/mappingmanagement/api/src/main/java/org/onosproject/mapping/MappingId.java b/apps/mappingmanagement/api/src/main/java/org/onosproject/mapping/MappingId.java
new file mode 100644
index 0000000..703012e
--- /dev/null
+++ b/apps/mappingmanagement/api/src/main/java/org/onosproject/mapping/MappingId.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2017-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.mapping;
+
+import org.onlab.util.Identifier;
+
+/**
+ * Representation of a Mapping ID.
+ */
+public final class MappingId extends Identifier<Long> {
+
+ /**
+ * Private constructor that prevents instantiation from external.
+ *
+ * @param id mapping identifier
+ */
+ private MappingId(long id) {
+ super(id);
+ }
+
+ /**
+ * Creates a mapping identifier from a long value.
+ *
+ * @param id mapping identifier in long format
+ * @return mapping identifier
+ */
+ public static MappingId valueOf(long id) {
+ return new MappingId(id);
+ }
+
+ /**
+ * Obtains mapping identifier value.
+ *
+ * @return mapping identifier value as long
+ */
+ public long value() {
+ return this.identifier;
+ }
+
+ @Override
+ public String toString() {
+ return Long.toHexString(identifier);
+ }
+}
diff --git a/apps/mappingmanagement/api/src/main/java/org/onosproject/mapping/MappingListener.java b/apps/mappingmanagement/api/src/main/java/org/onosproject/mapping/MappingListener.java
new file mode 100644
index 0000000..4c41fb8
--- /dev/null
+++ b/apps/mappingmanagement/api/src/main/java/org/onosproject/mapping/MappingListener.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright 2017-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.mapping;
+
+import org.onosproject.event.EventListener;
+
+/**
+ * Entity capable of receiving mapping related event.
+ */
+public interface MappingListener extends EventListener<MappingEvent> {
+}
diff --git a/apps/mappingmanagement/api/src/main/java/org/onosproject/mapping/MappingProvider.java b/apps/mappingmanagement/api/src/main/java/org/onosproject/mapping/MappingProvider.java
new file mode 100644
index 0000000..667f9cb
--- /dev/null
+++ b/apps/mappingmanagement/api/src/main/java/org/onosproject/mapping/MappingProvider.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright 2017-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.mapping;
+
+import org.onosproject.net.provider.Provider;
+
+/**
+ * Abstraction of a mapping provider.
+ */
+public interface MappingProvider extends Provider {
+}
diff --git a/apps/mappingmanagement/api/src/main/java/org/onosproject/mapping/MappingProviderRegistry.java b/apps/mappingmanagement/api/src/main/java/org/onosproject/mapping/MappingProviderRegistry.java
new file mode 100644
index 0000000..d17162c
--- /dev/null
+++ b/apps/mappingmanagement/api/src/main/java/org/onosproject/mapping/MappingProviderRegistry.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2017-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.mapping;
+
+import org.onosproject.net.provider.ProviderRegistry;
+
+/**
+ * Abstraction of a mapping provider registry.
+ */
+public interface MappingProviderRegistry
+ extends ProviderRegistry<MappingProvider, MappingProviderService> {
+}
diff --git a/apps/mappingmanagement/api/src/main/java/org/onosproject/mapping/MappingProviderService.java b/apps/mappingmanagement/api/src/main/java/org/onosproject/mapping/MappingProviderService.java
new file mode 100644
index 0000000..8392ee1
--- /dev/null
+++ b/apps/mappingmanagement/api/src/main/java/org/onosproject/mapping/MappingProviderService.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2017-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.mapping;
+
+import org.onosproject.net.provider.ProviderService;
+
+/**
+ * Service through which mapping providers can inject mapping information into
+ * the core.
+ */
+public interface MappingProviderService extends ProviderService<MappingProvider> {
+
+ /**
+ * Signals that a new mapping has been received.
+ *
+ * @param mappingEntry newly added mapping entry
+ * @param isMapDatabase indicate that where this map entry should be stored
+ */
+ void mappingAdded(MappingEntry mappingEntry, boolean isMapDatabase);
+}
diff --git a/apps/mappingmanagement/api/src/main/java/org/onosproject/mapping/MappingService.java b/apps/mappingmanagement/api/src/main/java/org/onosproject/mapping/MappingService.java
index 608c819..e1862e1 100644
--- a/apps/mappingmanagement/api/src/main/java/org/onosproject/mapping/MappingService.java
+++ b/apps/mappingmanagement/api/src/main/java/org/onosproject/mapping/MappingService.java
@@ -15,8 +15,11 @@
*/
package org.onosproject.mapping;
+import org.onosproject.event.ListenerService;
+
/**
* Interface of mapping management service.
*/
-public interface MappingService {
+public interface MappingService
+ extends ListenerService<MappingEvent, MappingListener> {
}
diff --git a/apps/mappingmanagement/api/src/main/java/org/onosproject/mapping/MappingStore.java b/apps/mappingmanagement/api/src/main/java/org/onosproject/mapping/MappingStore.java
index d3af3f3..e6f59a2 100644
--- a/apps/mappingmanagement/api/src/main/java/org/onosproject/mapping/MappingStore.java
+++ b/apps/mappingmanagement/api/src/main/java/org/onosproject/mapping/MappingStore.java
@@ -15,8 +15,10 @@
*/
package org.onosproject.mapping;
+import org.onosproject.store.Store;
+
/**
* Interface of a distributed store for managing mapping information.
*/
-public interface MappingStore {
+public interface MappingStore extends Store<MappingEvent, MappingStoreDelegate> {
}
diff --git a/apps/mappingmanagement/api/src/main/java/org/onosproject/mapping/MappingStoreDelegate.java b/apps/mappingmanagement/api/src/main/java/org/onosproject/mapping/MappingStoreDelegate.java
new file mode 100644
index 0000000..fd420f0
--- /dev/null
+++ b/apps/mappingmanagement/api/src/main/java/org/onosproject/mapping/MappingStoreDelegate.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright 2017-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.mapping;
+
+import org.onosproject.store.StoreDelegate;
+
+/**
+ * Mapping store delegate abstraction.
+ */
+public interface MappingStoreDelegate extends StoreDelegate<MappingEvent> {
+}