added cache
diff --git a/apps/fpcagent/src/main/java/org/onosproject/fpcagent/FpcConfig.java b/apps/fpcagent/src/main/java/org/onosproject/fpcagent/FpcConfig.java
index b9cbb9f..a47d4a9 100644
--- a/apps/fpcagent/src/main/java/org/onosproject/fpcagent/FpcConfig.java
+++ b/apps/fpcagent/src/main/java/org/onosproject/fpcagent/FpcConfig.java
@@ -3,7 +3,7 @@
import com.fasterxml.jackson.core.JsonProcessingException;
import org.apache.commons.lang.exception.ExceptionUtils;
import org.onosproject.core.ApplicationId;
-import org.onosproject.fpcagent.helpers.ConfigHelper;
+import org.onosproject.fpcagent.util.ConfigHelper;
import org.onosproject.net.config.Config;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/apps/fpcagent/src/main/java/org/onosproject/fpcagent/FpcManager.java b/apps/fpcagent/src/main/java/org/onosproject/fpcagent/FpcManager.java
index 52fbf9d..7c15f01 100644
--- a/apps/fpcagent/src/main/java/org/onosproject/fpcagent/FpcManager.java
+++ b/apps/fpcagent/src/main/java/org/onosproject/fpcagent/FpcManager.java
@@ -22,7 +22,7 @@
import org.onosproject.config.DynamicConfigService;
import org.onosproject.core.ApplicationId;
import org.onosproject.core.CoreService;
-import org.onosproject.fpcagent.helpers.ConfigHelper;
+import org.onosproject.fpcagent.util.ConfigHelper;
import org.onosproject.fpcagent.workers.ZMQSBPublisherManager;
import org.onosproject.fpcagent.workers.ZMQSBSubscriberManager;
import org.onosproject.net.config.*;
@@ -50,7 +50,7 @@
import java.util.Optional;
import java.util.concurrent.TimeUnit;
-import static org.onosproject.fpcagent.FpcUtil.*;
+import static org.onosproject.fpcagent.util.FpcUtil.*;
/**
* Fpc Manager.
diff --git a/apps/fpcagent/src/main/java/org/onosproject/fpcagent/FpcService.java b/apps/fpcagent/src/main/java/org/onosproject/fpcagent/FpcService.java
index 5e4e152..61aa6cf 100644
--- a/apps/fpcagent/src/main/java/org/onosproject/fpcagent/FpcService.java
+++ b/apps/fpcagent/src/main/java/org/onosproject/fpcagent/FpcService.java
@@ -1,6 +1,6 @@
package org.onosproject.fpcagent;
-import org.onosproject.fpcagent.helpers.ConfigHelper;
+import org.onosproject.fpcagent.util.ConfigHelper;
import java.util.Optional;
diff --git a/apps/fpcagent/src/main/java/org/onosproject/fpcagent/FpcUtil.java b/apps/fpcagent/src/main/java/org/onosproject/fpcagent/FpcUtil.java
deleted file mode 100644
index 74373eb..0000000
--- a/apps/fpcagent/src/main/java/org/onosproject/fpcagent/FpcUtil.java
+++ /dev/null
@@ -1,302 +0,0 @@
-/*
- * Copyright 2017-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.fpcagent;
-
-import com.google.common.collect.Maps;
-import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.ClientIdentifier;
-import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.DefaultTenants;
-import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.OpIdentifier;
-import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.tenants.DefaultTenant;
-import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.tenants.TenantKeys;
-import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.yangautoprefixnotify.value.DefaultDownlinkDataNotification;
-import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.yangautoprefixnotify.value.DownlinkDataNotification;
-import org.onosproject.yang.gen.v1.ietfdmmfpcbase.rev20160803.ietfdmmfpcbase.FpcDpnId;
-import org.onosproject.yang.gen.v1.ietfdmmfpcbase.rev20160803.ietfdmmfpcbase.FpcIdentity;
-import org.onosproject.yang.gen.v1.ietfdmmfpcbase.rev20160803.ietfdmmfpcbase.fpcidentity.FpcIdentityUnion;
-import org.onosproject.yang.model.*;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.math.BigInteger;
-import java.util.AbstractMap;
-import java.util.Arrays;
-import java.util.Map;
-
-import static org.onosproject.fpcagent.helpers.Converter.*;
-
-/**
- * Helper class which stores all the static variables.
- */
-public class FpcUtil {
- public static final int MAX_EVENTS = 1000;
- public static final int MAX_BATCH_MS = 5000;
- public static final int MAX_IDLE_MS = 1000;
- public static final String TIMER = "dynamic-config-fpcagent-timer";
- public static final String UNKNOWN_EVENT = "FPC Agent listener: unknown event: {}";
- public static final String EVENT_NULL = "Event cannot be null";
- public static final String FPC_APP_ID = "org.onosproject.fpcagent";
- protected static final Logger log = LoggerFactory.getLogger(FpcUtil.class);
- private static final Map<String, FpcDpnId> uplinkDpnMap = Maps.newConcurrentMap();
- private static final Map<String, Short> nodeToTopicMap = Maps.newConcurrentMap();
- public static ModelConverter modelConverter = null;
- // Resource ID for Configure DPN RPC command
- public static ResourceId configureDpn;
- // Resource ID for Configure RPC command
- public static ResourceId configure;
- // Resource ID for tenants data
- public static ResourceId tenants;
- public static ResourceId defaultTenant;
- public static ResourceId configureBundles;
- public static ResourceId module;
- public static ResourceId registerClientResourceId;
- public static ResourceId deregisterClientResourceId;
-
- public static FpcIdentity defaultIdentity = getFpcIdentity.apply("default");
-
- private static byte DPN_HELLO = 0b0000_0001;
- private static byte DPN_BYE = 0b0000_0010;
- private static byte DOWNLINK_DATA_NOTIFICATION = 0b0000_0101;
- private static byte DPN_STATUS_INDICATION = 0b0000_1100;
- private static byte DPN_OVERLOAD_INDICATION = 0b0000_0101;
- private static byte DPN_REPLY = 0b0000_0100;
- private static String DOWNLINK_DATA_NOTIFICATION_STRING = "Downlink-Data-Notification";
-
- /**
- * Returns resource id from model converter.
- *
- * @param modelId model object id
- * @return resource id
- */
- static ResourceId getResourceVal(ModelObjectId modelId) {
- DefaultModelObjectData.Builder data = DefaultModelObjectData.builder()
- .identifier(modelId);
- ResourceData resData = modelConverter.createDataNode(data.build());
- return resData.resourceId();
- }
-
- /**
- * Returns the resource id, after constructing model object id and
- * converting it.
- */
- static void getResourceId() {
- ModelObjectId moduleId = ModelObjectId.builder().build();
- module = getResourceVal(moduleId);
-
- ModelObjectId tenantsId = ModelObjectId.builder()
- .addChild(DefaultTenants.class)
- .build();
-
- tenants = getResourceVal(tenantsId);
-
- TenantKeys tenantKeys = new TenantKeys();
- tenantKeys.tenantId(defaultIdentity);
-
- ModelObjectId defaultTenantId = ModelObjectId.builder()
- .addChild(DefaultTenants.class)
- .addChild(DefaultTenant.class, tenantKeys)
- .build();
-
- defaultTenant = getResourceVal(defaultTenantId);
-
- configure = ResourceId.builder()
- .addBranchPointSchema("/", null)
- .addBranchPointSchema("configure", "urn:ietf:params:xml:ns:yang:fpcagent")
- .build();
-
- configureDpn = ResourceId.builder()
- .addBranchPointSchema("/", null)
- .addBranchPointSchema("configure-dpn", "urn:ietf:params:xml:ns:yang:fpcagent")
- .build();
-
- configureBundles = ResourceId.builder()
- .addBranchPointSchema("/", null)
- .addBranchPointSchema("configure-bundles", "urn:ietf:params:xml:ns:yang:fpcagent")
- .build();
- }
-
- static ModelObjectId.Builder defaultTenantBuilder() {
- TenantKeys tenantKeys = new TenantKeys();
- tenantKeys.tenantId(defaultIdentity);
-
- return ModelObjectId.builder()
- .addChild(DefaultTenants.class)
- .addChild(DefaultTenant.class, tenantKeys);
- }
-
- /**
- * Returns resource id for the specific tenant ID.
- *
- * @param tenantId tenant id
- * @return resource ids
- */
- static ResourceId getTenantResourceId(FpcIdentity tenantId) {
- TenantKeys tenantKeys = new TenantKeys();
- tenantKeys.tenantId(tenantId);
-
- return getResourceVal(ModelObjectId.builder()
- .addChild(DefaultTenants.class)
- .addChild(DefaultTenant.class, tenantKeys)
- .build());
- }
-
- /**
- * Returns the resource data from the data node and the resource id.
- *
- * @param dataNode data node
- * @param resId resource id
- * @return resource data
- */
- static ResourceData getResourceData(DataNode dataNode, ResourceId resId) {
- if (resId != null) {
- return DefaultResourceData.builder()
- .addDataNode(dataNode)
- .resourceId(resId)
- .build();
- } else {
- return DefaultResourceData.builder()
- .addDataNode(dataNode)
- .build();
- }
- }
-
- /**
- * Ensures the session id is an unsigned 64 bit integer
- *
- * @param sessionId - session id received from the DPN
- * @return unsigned session id
- */
- private static BigInteger checkSessionId(BigInteger sessionId) {
- if (sessionId.compareTo(BigInteger.ZERO) < 0) {
- sessionId = sessionId.add(BigInteger.ONE.shiftLeft(64));
- }
- return sessionId;
- }
-
- /**
- * Decodes a DownlinkDataNotification
- *
- * @param buf - message buffer
- * @param key - Concatenation of node id + / + network id
- * @return DownlinkDataNotification or null if it could not be successfully decoded
- */
- private static DownlinkDataNotification processDDN(byte[] buf, String key) {
- DownlinkDataNotification ddnB = new DefaultDownlinkDataNotification();
- ddnB.sessionId(checkSessionId(toBigInt(buf, 2)));
- ddnB.notificationMessageType(DOWNLINK_DATA_NOTIFICATION_STRING);
- ddnB.clientId(ClientIdentifier.of(FpcIdentity.of(FpcIdentityUnion.of(fromIntToLong(buf, 10)))));
- ddnB.opId(OpIdentifier.of(BigInteger.valueOf(fromIntToLong(buf, 14))));
- ddnB.notificationDpnId(uplinkDpnMap.get(key));
- return ddnB;
- }
-
- /**
- * Decodes a DPN message.
- *
- * @param buf - message buffer
- * @return - A pair with the DPN Id and decoded Object
- */
- public static Map.Entry<FpcDpnId, Object> decode(byte[] buf) {
- if (buf[1] == DPN_REPLY) {
- return null;
- } else if (buf[1] == DOWNLINK_DATA_NOTIFICATION) {
- short nodeIdLen = buf[18];
- short networkIdLen = buf[19 + nodeIdLen];
- String key = new String(Arrays.copyOfRange(buf, 19, 19 + nodeIdLen)) + "/" + new String(Arrays.copyOfRange(buf, 20 + nodeIdLen, 20 + nodeIdLen + networkIdLen));
- return uplinkDpnMap.get(key) == null ? null : new AbstractMap.SimpleEntry<>(uplinkDpnMap.get(key), processDDN(buf, key));
- } else if (buf[1] == DPN_STATUS_INDICATION) {
- DPNStatusIndication.Status status = null;
-
- short nodeIdLen = buf[8];
- short networkIdLen = buf[9 + nodeIdLen];
- String key = new String(Arrays.copyOfRange(buf, 9, 9 + nodeIdLen)) + "/" + new String(Arrays.copyOfRange(buf, 10 + nodeIdLen, 10 + nodeIdLen + networkIdLen));
- if (buf[3] == DPN_OVERLOAD_INDICATION) {
- status = DPNStatusIndication.Status.OVERLOAD_INDICATION;
- } else if (buf[3] == DPN_HELLO) {
- status = DPNStatusIndication.Status.HELLO;
- log.info("Hello {} on topic {}", key, buf[2]);
- nodeToTopicMap.put(key, (short) buf[2]);
- } else if (buf[3] == DPN_BYE) {
- status = DPNStatusIndication.Status.BYE;
- log.info("Bye {}", key);
- nodeToTopicMap.remove(key);
- }
- return new AbstractMap.SimpleEntry<>(uplinkDpnMap.get(key), new DPNStatusIndication(status, key));
- }
- return null;
- }
-
- /**
- * Gets the mapping for node id / network id to ZMQ Topic
- *
- * @param Key - Concatenation of node id + / + network id
- * @return - ZMQ Topic
- */
- public static Short getTopicFromNode(String Key) {
- return nodeToTopicMap.get(Key);
- }
-
- /**
- * Provides basic status changes,
- */
- public static class DPNStatusIndication {
- private final Status status;
- private final String key; //nodeId +"/"+ networkId
- /**
- * Node Reference of the DPN
- */
- public Short nodeRef;
-
- /**
- * Constructor providing the DPN and its associated Status.
- *
- * @param status - DPN Status
- * @param key - Combination of node id and network id
- */
- public DPNStatusIndication(Status status,
- String key) {
- this.status = status;
- this.key = key;
- }
-
- /**
- * Provides DPN Status
- *
- * @return Status associated to the DPN.
- */
- public Status getStatus() {
- return status;
- }
-
- /**
- * Provides the DPN key - nodeId +"/"+ networkId
- *
- * @return FpcDpnId
- */
- public String getKey() {
- return this.key;
- }
-
- /**
- * Basic DPN Status
- */
- public enum Status {
- HELLO,
- BYE,
- OVERLOAD_INDICATION
- }
- }
-}
diff --git a/apps/fpcagent/src/main/java/org/onosproject/fpcagent/TenantManager.java b/apps/fpcagent/src/main/java/org/onosproject/fpcagent/TenantManager.java
index 46d4016..9fb67ff 100644
--- a/apps/fpcagent/src/main/java/org/onosproject/fpcagent/TenantManager.java
+++ b/apps/fpcagent/src/main/java/org/onosproject/fpcagent/TenantManager.java
@@ -16,7 +16,6 @@
package org.onosproject.fpcagent;
-import com.google.common.base.Stopwatch;
import com.google.common.collect.Maps;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.exception.ExceptionUtils;
@@ -29,8 +28,10 @@
import org.onosproject.config.DynamicConfigListener;
import org.onosproject.config.DynamicConfigService;
import org.onosproject.config.Filter;
-import org.onosproject.fpcagent.helpers.DpnCommunicationService;
-import org.onosproject.fpcagent.helpers.DpnNgicCommunicator;
+import org.onosproject.fpcagent.util.CacheManager;
+import org.onosproject.fpcagent.util.DpnCommunicationService;
+import org.onosproject.fpcagent.util.DpnNgicCommunicator;
+import org.onosproject.fpcagent.util.FpcUtil;
import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.*;
import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.configure.DefaultConfigureOutput;
import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.instructions.instructions.instrtype.Instr3GppMob;
@@ -47,6 +48,7 @@
import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.tenants.tenant.DefaultFpcTopology;
import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.tenants.tenant.fpcmobility.ContextsKeys;
import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.tenants.tenant.fpcmobility.DefaultContexts;
+import org.onosproject.yang.gen.v1.ietfdmmfpcbase.rev20160803.ietfdmmfpcbase.FpcContextId;
import org.onosproject.yang.gen.v1.ietfdmmfpcbase.rev20160803.ietfdmmfpcbase.FpcIdentity;
import org.onosproject.yang.gen.v1.ietfdmmfpcbase.rev20160803.ietfdmmfpcbase.fpccontext.Dpns;
import org.onosproject.yang.gen.v1.ietfdmmfpcbase.rev20160803.ietfdmmfpcbase.mobilityinfo.mobprofileparameters.ThreegppTunnel;
@@ -63,12 +65,13 @@
import java.util.concurrent.Executors;
import static com.google.common.base.Preconditions.checkNotNull;
-import static org.onosproject.fpcagent.FpcUtil.*;
-import static org.onosproject.fpcagent.helpers.Converter.convertContext;
+import static org.onosproject.fpcagent.util.Converter.convertContext;
+import static org.onosproject.fpcagent.util.FpcUtil.*;
@Component(immediate = true)
@Service
public class TenantManager implements TenantService {
+
private final Logger log = LoggerFactory.getLogger(getClass());
private final Map<ClientIdentifier, DefaultTenant> clientIdMap = Maps.newHashMap();
@@ -85,8 +88,11 @@
private DpnCommunicationService dpnCommunicationService;
+ private CacheManager cacheManager = CacheManager.getInstance();
+
@Activate
protected void activate() {
+ cacheManager.addManager(this);
FpcUtil.modelConverter = modelConverter;
getResourceId();
@@ -121,18 +127,6 @@
}
@Override
- public Optional<DefaultTenant> getDefaultTenant() {
- Filter filter = Filter.builder().build();
- // TODO implement Cache to avoid searching store
- DataNode dataNode = dynamicConfigService.readNode(defaultTenant, filter);
-
- return getModelObjects(dataNode, tenants)
- .stream()
- .map(modelObject -> (DefaultTenant) modelObject)
- .findFirst();
- }
-
- @Override
public Optional<DefaultTenants> getTenants() {
Filter filter = Filter.builder().build();
DataNode dataNode = dynamicConfigService.readNode(tenants, filter);
@@ -150,16 +144,8 @@
return getModelObjects(dataNode, tenants)
.stream()
- .map(modelObject -> (DefaultTenants) modelObject)
- .findFirst()
- .flatMap(defaultTenants ->
- defaultTenants.tenant()
- .stream()
- .filter(defaultTenant ->
- defaultTenant.tenantId().equals(tenantId))
- .findFirst()
- .map(defaultTenant -> (DefaultTenant) defaultTenant)
- );
+ .map(modelObject -> (DefaultTenant) modelObject)
+ .findFirst();
}
@Override
@@ -225,113 +211,109 @@
defaultCommonSuccess.addToContexts(context);
// check if mobility exists and if the context id exists.
- if (getDefaultTenant().map(
- tenant -> tenant.fpcMobility().contexts() != null && tenant.fpcMobility()
- .contexts()
- .stream()
- .anyMatch(contexts -> contexts.contextId().equals(context.contextId()))
- ).orElse(false)) {
+ if (cacheManager.contextsCache.get(context.contextId()).isPresent()) {
// throw exception if trying to create a Context that already exists.
throw new IllegalStateException("Context tried to create already exists. Please issue update operation..");
}
for (Dpns dpn : context.dpns()) {
// check if dpns exists and if there is a DPN registered for the wanted identifier.
- if (getDefaultTenant().map(
- tenant -> tenant.fpcTopology().dpns() == null ||
- tenant.fpcTopology().dpns().stream()
- .noneMatch(dpns -> dpns.dpnId().equals(dpn.dpnId()))
- ).orElse(false)) {
+ if (!cacheManager.dpnsCache.get(dpn.dpnId()).isPresent()) {
// throw exception if DPN ID is not registered.
throw new IllegalStateException("DPN ID is not registered to the topology.");
}
// handle only 3GPP instructions.
- if (context.instructions().instrType() instanceof Instr3GppMob) {
- // from DPN ID find the Network and Node Identifiers
- Optional<String> key = getDefaultTenant().flatMap(tenant ->
- tenant.fpcTopology()
- .dpns()
- .stream()
- .filter(dpns -> dpns.dpnId().equals(dpn.dpnId()))
- .findFirst()
- .map(node -> node.nodeId() + "/" + node.networkId())
- );
+ if (!(context.instructions().instrType() instanceof Instr3GppMob)) {
+ throw new IllegalArgumentException("No 3GPP instructions where given.");
+ }
- if (key.isPresent()) {
- // get DPN Topic from Node/Network pair
- Short topic_id = getTopicFromNode(key.get());
+ // from DPN ID find the Network and Node Identifiers
+ Optional<String> key = cacheManager.dpnsCache.get(dpn.dpnId())
+ .map(node -> node.nodeId() + "/" + node.networkId());
+ if (!key.isPresent()) {
+ throw new IllegalArgumentException("DPN does not have node and network ID defined.");
+ }
- if (topic_id != null) {
- Instr3GppMob instr3GppMob = (Instr3GppMob) context.instructions().instrType();
- String commands = Bits.toString(instr3GppMob.instr3GppMob().bits());
+ // get DPN Topic from Node/Network pair
+ Short topic_id = getTopicFromNode(key.get());
+ if (topic_id == null) {
+ throw new IllegalArgumentException("Could not find Topic ID");
+ }
- Ip4Address s1u_enodeb_ipv4 = Ip4Address.valueOf(context.ul().tunnelLocalAddress().toString()),
- s1u_sgw_ipv4 = Ip4Address.valueOf(context.ul().tunnelRemoteAddress().toString());
+ // parse tunnel identifiers. throw exception if mobility profile parameters are missing.
+ if (!(context.ul().mobilityTunnelParameters().mobprofileParameters() instanceof ThreegppTunnel)) {
+ throw new IllegalArgumentException("mobprofileParameters are not instance of ThreegppTunnel");
- long s1u_sgw_gtpu_teid, s1u_enb_gtpu_teid,
- client_id = clientId.fpcIdentity().union().int64(),
- session_id = context.contextId().fpcIdentity().union().int64();
+ }
+ if (!(context.dl().mobilityTunnelParameters().mobprofileParameters() instanceof ThreegppTunnel)) {
+ throw new IllegalArgumentException("mobprofileParameters are not instance of ThreegppTunnel");
+ }
- BigInteger op_id = operationId.uint64(),
- imsi = context.imsi().uint64();
+ // Extract variables
+ Instr3GppMob instr3GppMob = (Instr3GppMob) context.instructions().instrType();
+ String commands = Bits.toString(instr3GppMob.instr3GppMob().bits());
- short default_ebi = context.ebi().uint8();
+ Ip4Address s1u_enodeb_ipv4 = Ip4Address.valueOf(context.ul().tunnelLocalAddress().toString()),
+ s1u_sgw_ipv4 = Ip4Address.valueOf(context.ul().tunnelRemoteAddress().toString());
- // parse tunnel identifiers. throw exception if mobility profile parameters are missing.
- if (context.ul().mobilityTunnelParameters().mobprofileParameters() instanceof ThreegppTunnel) {
- s1u_sgw_gtpu_teid = ((ThreegppTunnel) context.ul().mobilityTunnelParameters().mobprofileParameters()).tunnelIdentifier();
- } else {
- throw new IllegalArgumentException("mobprofileParameters are not instance of ThreegppTunnel");
- }
- if (context.dl().mobilityTunnelParameters().mobprofileParameters() instanceof ThreegppTunnel) {
- s1u_enb_gtpu_teid = ((ThreegppTunnel) context.ul().mobilityTunnelParameters().mobprofileParameters()).tunnelIdentifier();
- } else {
- throw new IllegalArgumentException("mobprofileParameters are not instance of ThreegppTunnel");
- }
+ long client_id = clientId.fpcIdentity().union().int64(),
+ session_id = context.contextId().fpcIdentity().union().int64(),
+ s1u_sgw_gtpu_teid = ((ThreegppTunnel) context.ul().mobilityTunnelParameters()
+ .mobprofileParameters()).tunnelIdentifier(),
+ s1u_enb_gtpu_teid = ((ThreegppTunnel) context.ul().mobilityTunnelParameters()
+ .mobprofileParameters()).tunnelIdentifier();
- // TODO try to make sense out of this...
- if (commands.contains("session")) {
- tasks.add(Executors.callable(() -> {
- dpnCommunicationService.create_session(
- topic_id,
- imsi,
- default_ebi,
- Ip4Prefix.valueOf(context.delegatingIpPrefixes().get(0).toString()).address(),
- s1u_sgw_gtpu_teid,
- s1u_sgw_ipv4,
- session_id,
- client_id,
- op_id
- );
+ BigInteger op_id = operationId.uint64(),
+ imsi = context.imsi().uint64();
- ModelObjectId modelObjectId = defaultTenantBuilder()
- .addChild(DefaultFpcMobility.class)
- .build();
- createNode(convertContext(context), modelObjectId);
- }));
+ short default_ebi = context.ebi().uint8();
- if (commands.contains("downlink")) {
- tasks.add(Executors.callable(() -> {
- dpnCommunicationService.modify_bearer(
- topic_id,
- s1u_sgw_ipv4,
- s1u_enb_gtpu_teid,
- s1u_enodeb_ipv4,
- session_id,
- client_id,
- op_id
- );
+ // TODO try to make sense out of this...
+ if (commands.contains("session")) {
+ DefaultContexts convertContext = convertContext(context);
+ tasks.add(Executors.callable(() -> {
+ dpnCommunicationService.create_session(
+ topic_id,
+ imsi,
+ default_ebi,
+ Ip4Prefix.valueOf(context.delegatingIpPrefixes().get(0).toString()).address(),
+ s1u_sgw_gtpu_teid,
+ s1u_sgw_ipv4,
+ session_id,
+ client_id,
+ op_id
+ );
- ModelObjectId modelObjectId = defaultTenantBuilder()
- .addChild(DefaultFpcMobility.class)
- .build();
- createNode(convertContext(context), modelObjectId);
- }));
- }
- } else if (commands.contains("indirect-forward")) {
- // TODO - Modify API for Indirect Forwarding to/from another SGW
- } else if (commands.contains("uplink")) {
+ ModelObjectId modelObjectId = defaultTenantBuilder()
+ .addChild(DefaultFpcMobility.class)
+ .build();
+ createNode(convertContext, modelObjectId);
+ cacheManager.contextsCache.invalidate(context.contextId());
+ }));
+
+ if (commands.contains("downlink")) {
+ tasks.add(Executors.callable(() -> {
+ dpnCommunicationService.modify_bearer(
+ topic_id,
+ s1u_sgw_ipv4,
+ s1u_enb_gtpu_teid,
+ s1u_enodeb_ipv4,
+ session_id,
+ client_id,
+ op_id
+ );
+
+ ModelObjectId modelObjectId = defaultTenantBuilder()
+ .addChild(DefaultFpcMobility.class)
+ .build();
+ createNode(convertContext, modelObjectId);
+ cacheManager.contextsCache.invalidate(context.contextId());
+ }));
+ }
+ } else if (commands.contains("indirect-forward")) {
+ // TODO - Modify API for Indirect Forwarding to/from another SGW
+ } else if (commands.contains("uplink")) {
// tasks.add(Executors.callable(() -> {
// dpnCommunicationService.create_bearer_ul(
// topic_id,
@@ -346,16 +328,8 @@
// tenant -> tenant.fpcMobility().addToContexts(convertContext(context))
// );
// }));
- }
- } else {
- throw new IllegalArgumentException("Could not find Topic ID.");
- }
- } else {
- throw new IllegalArgumentException("DPN does not have node and network ID defined.");
- }
- } else {
- throw new IllegalArgumentException("No 3GPP instructions where given.");
}
+
}
}
@@ -400,127 +374,113 @@
defaultCommonSuccess.addToContexts(context);
// check if contexts are populated and if they include the wanted context to update.
- if (getDefaultTenant().map(
- tenant -> tenant.fpcMobility().contexts() == null ||
- tenant.fpcMobility()
- .contexts()
- .parallelStream()
- .noneMatch(contexts -> contexts.contextId().equals(context.contextId()))
- ).orElse(false)) {
+ if (!cacheManager.contextsCache.get(context.contextId()).isPresent()) {
// throw exception if wanted context does not exist.
throw new IllegalStateException("Context doesn't exist. Please issue create operation..");
}
for (Dpns dpn : context.dpns()) {
// check if dpns exists and if there is a DPN registered for the wanted identifier.
- if (getDefaultTenant().map(
- tenant -> tenant.fpcTopology().dpns() == null ||
- tenant.fpcTopology().dpns()
- .stream()
- .noneMatch(dpns -> dpns.dpnId().equals(dpn.dpnId()))
- ).orElse(false)) {
+ if (!cacheManager.dpnsCache.get(dpn.dpnId()).isPresent()) {
// throw exception if DPN ID is not registered.
throw new IllegalStateException("DPN ID is not registered to the topology.");
}
// handle only 3GPP instructions.
- if (context.instructions().instrType() instanceof Instr3GppMob) {
- // from DPN ID find the Network and Node Identifiers
- Optional<String> key = getDefaultTenant().flatMap(tenant ->
- tenant.fpcTopology()
- .dpns()
- .stream()
- .filter(dpns -> dpns.dpnId().equals(dpn.dpnId()))
- .findFirst().map(node -> node.nodeId() + "/" + node.networkId())
- );
+ if (!(context.instructions().instrType() instanceof Instr3GppMob)) {
+ throw new IllegalArgumentException("No 3GPP instructions where given.");
+ }
- if (key.isPresent()) {
- // get DPN Topic from Node/Network pair
- Short topic_id = getTopicFromNode(key.get());
+ // from DPN ID find the Network and Node Identifiers
+ Optional<String> key = cacheManager.dpnsCache.get(dpn.dpnId())
+ .map(node -> node.nodeId() + "/" + node.networkId());
+ if (!key.isPresent()) {
+ throw new IllegalArgumentException("DPN does not have node and network ID defined.");
+ }
- if (topic_id != null) {
- Instr3GppMob instr3GppMob = (Instr3GppMob) context.instructions().instrType();
- String commands = Bits.toString(instr3GppMob.instr3GppMob().bits());
+ // get DPN Topic from Node/Network pair
+ Short topic_id = getTopicFromNode(key.get());
+ if (topic_id == null) {
+ throw new IllegalArgumentException("Could not find Topic ID");
+ }
- Ip4Address s1u_enodeb_ipv4 = Ip4Address.valueOf(context.ul().tunnelLocalAddress().toString()),
- s1u_sgw_ipv4 = Ip4Address.valueOf(context.ul().tunnelRemoteAddress().toString());
+ if (!(context.dl().mobilityTunnelParameters().mobprofileParameters() instanceof ThreegppTunnel)) {
+ throw new IllegalArgumentException("mobprofileParameters are not instance of ThreegppTunnel");
+ }
- long s1u_enb_gtpu_teid,
- cId = clientId.fpcIdentity().union().int64(),
- contextId = context.contextId().fpcIdentity().union().int64();
+ Instr3GppMob instr3GppMob = (Instr3GppMob) context.instructions().instrType();
+ String commands = Bits.toString(instr3GppMob.instr3GppMob().bits());
- BigInteger opId = operationId.uint64();
+ Ip4Address s1u_enodeb_ipv4 = Ip4Address.valueOf(context.ul().tunnelLocalAddress().toString()),
+ s1u_sgw_ipv4 = Ip4Address.valueOf(context.ul().tunnelRemoteAddress().toString());
- if (context.dl().mobilityTunnelParameters().mobprofileParameters() instanceof ThreegppTunnel) {
- s1u_enb_gtpu_teid = ((ThreegppTunnel) context.dl().mobilityTunnelParameters().mobprofileParameters()).tunnelIdentifier();
- } else {
- throw new IllegalArgumentException("mobprofileParameters are not instance of ThreegppTunnel");
- }
+ long s1u_enb_gtpu_teid = ((ThreegppTunnel) context.dl().mobilityTunnelParameters().mobprofileParameters()).tunnelIdentifier(),
+ cId = clientId.fpcIdentity().union().int64(),
+ contextId = context.contextId().fpcIdentity().union().int64();
- if (commands.contains("downlink")) {
- if (context.dl().lifetime() >= 0L) {
- tasks.add(Executors.callable(() -> {
- dpnCommunicationService.modify_bearer(
- topic_id,
- s1u_sgw_ipv4,
- s1u_enb_gtpu_teid,
- s1u_enodeb_ipv4,
- contextId,
- cId,
- opId
- );
+ BigInteger opId = operationId.uint64();
- ModelObjectId modelObjectId = defaultTenantBuilder()
- .addChild(DefaultFpcMobility.class)
- .build();
- updateNode(convertContext(context), modelObjectId);
- }));
- } else {
+ DefaultContexts convertContext = convertContext(context);
+ if (commands.contains("downlink")) {
+ if (context.dl().lifetime() >= 0L) {
+ tasks.add(Executors.callable(() -> {
+ dpnCommunicationService.modify_bearer(
+ topic_id,
+ s1u_sgw_ipv4,
+ s1u_enb_gtpu_teid,
+ s1u_enodeb_ipv4,
+ contextId,
+ cId,
+ opId
+ );
+
+ ModelObjectId modelObjectId = defaultTenantBuilder()
+ .addChild(DefaultFpcMobility.class)
+ .build();
+ updateNode(convertContext, modelObjectId);
+ cacheManager.contextsCache.invalidate(context.contextId());
+ }));
+ } else {
// tasks.add(Executors.callable(() ->
// dpnCommunicationService.delete_bearer(
// topic_id,
// s1u_enb_gtpu_teid
// )
// ));
- }
- }
- if (commands.contains("uplink")) {
- if (context.ul().lifetime() >= 0L) {
- tasks.add(Executors.callable(() -> {
- dpnCommunicationService.modify_bearer(
- topic_id,
- s1u_sgw_ipv4,
- s1u_enb_gtpu_teid,
- s1u_enodeb_ipv4,
- contextId,
- cId,
- opId
- );
+ }
+ }
+ if (commands.contains("uplink")) {
+ if (context.ul().lifetime() >= 0L) {
+ tasks.add(Executors.callable(() -> {
+ dpnCommunicationService.modify_bearer(
+ topic_id,
+ s1u_sgw_ipv4,
+ s1u_enb_gtpu_teid,
+ s1u_enodeb_ipv4,
+ contextId,
+ cId,
+ opId
+ );
- ModelObjectId modelObjectId = defaultTenantBuilder()
- .addChild(DefaultFpcMobility.class)
- .build();
- updateNode(convertContext(context), modelObjectId);
- }));
- } else {
+ ModelObjectId modelObjectId = defaultTenantBuilder()
+ .addChild(DefaultFpcMobility.class)
+ .build();
+ updateNode(convertContext, modelObjectId);
+ cacheManager.contextsCache.invalidate(context.contextId());
+ }));
+ } else {
// tasks.add(Executors.callable(() ->
// dpnCommunicationService.delete_bearer(
// topic_id,
// s1u_sgw_gtpu_teid
// )
// ));
- }
- }
- } else {
- throw new IllegalArgumentException("Could not find Topic ID");
- }
- } else {
- throw new IllegalArgumentException("DPN does not have node and network ID defined.");
}
- } else {
- throw new IllegalArgumentException("No 3GPP instructions where given.");
}
+
+
}
+
}
// execute all tasks.
@@ -569,62 +529,43 @@
trgt = s != null ? s : StringUtils.substringAfter(targetStr, "contexts=");
// find context that this target is about.
- getDefaultTenant().map(
- tenant -> {
- if (tenant.fpcMobility().contexts() != null) {
- return tenant.fpcMobility()
- .contexts()
- .stream()
- .filter(contexts -> contexts.contextId().toString().equals(trgt))
- .findFirst()
- .orElseThrow(
- () -> new IllegalArgumentException("Context doesn't exist.")
- );
- }
- throw new IllegalArgumentException("Contexts are empty.");
- }
- ).ifPresent(
- context -> context.dpns().forEach(
- dpn -> {
- // check if dpns exists and if there is a DPN registered for the wanted identifier.
- if (getDefaultTenant().map(
- tenant -> tenant.fpcTopology().dpns() == null ||
- tenant.fpcTopology().dpns()
- .stream()
- .noneMatch(dpns -> dpns.dpnId().equals(dpn.dpnId()))
- ).orElse(false)) {
- // throw exception if DPN ID is not registered.
- throw new IllegalStateException("DPN ID is not registered to the topology.");
- }
+ FpcContextId fpcContextId = FpcContextId.of(FpcIdentity.fromString(trgt));
+ Optional<DefaultContexts> defaultContexts = cacheManager.contextsCache.get(fpcContextId);
+ if (!defaultContexts.isPresent()) {
+ throw new IllegalStateException("Context doesn't exist. Please issue create operation..");
+ }
- // from DPN ID find the Network and Node Identifiers
- Optional<String> key = getDefaultTenant().flatMap(tenant ->
- tenant.fpcTopology()
- .dpns()
- .stream()
- .filter(dpns -> dpns.dpnId().equals(dpn.dpnId()))
- .findFirst().map(node -> node.nodeId() + "/" + node.networkId())
- );
+ DefaultContexts context = defaultContexts.get();
+ for (Dpns dpn : context.dpns()) {
+ // check if dpns exists and if there is a DPN registered for the wanted identifier.
+ if (!cacheManager.dpnsCache.get(dpn.dpnId()).isPresent()) {
+ // throw exception if DPN ID is not registered.
+ throw new IllegalStateException("DPN ID is not registered to the topology.");
+ }
- if (key.isPresent()) {
- // find DPN Topic from Node/Network ID pair.
- Short topic_id = getTopicFromNode(key.get());
+ // from DPN ID find the Network and Node Identifiers
+ Optional<String> key = cacheManager.dpnsCache.get(dpn.dpnId())
+ .map(node -> node.nodeId() + "/" + node.networkId());
+ if (!key.isPresent()) {
+ throw new IllegalArgumentException("DPN does not have node and network ID defined.");
+ }
- if (topic_id != null) {
+ // find DPN Topic from Node/Network ID pair.
+ Short topic_id = getTopicFromNode(key.get());
+ if (topic_id == null) {
+ throw new IllegalArgumentException("Could not find Topic ID");
+ }
- Long teid;
+ if (!(context.ul().mobilityTunnelParameters().mobprofileParameters() instanceof ThreegppTunnel)) {
+ throw new IllegalArgumentException("mobprofileParameters are not instance of ThreegppTunnel");
+ }
- if (context.ul().mobilityTunnelParameters().mobprofileParameters() instanceof ThreegppTunnel) {
- teid = ((ThreegppTunnel) context.ul().mobilityTunnelParameters().mobprofileParameters()).tunnelIdentifier();
- } else {
- throw new IllegalArgumentException("mobprofileParameters are not instance of ThreegppTunnel");
- }
+ Long teid = ((ThreegppTunnel) context.ul().mobilityTunnelParameters().mobprofileParameters()).tunnelIdentifier();
+ long client_id = clientId.fpcIdentity().union().int64();
+ BigInteger op_id = operationId.uint64();
- long client_id = clientId.fpcIdentity().union().int64();
- BigInteger op_id = operationId.uint64();
-
- // TODO figure out what is going on.
- if (targetStr.endsWith("ul") || targetStr.endsWith("dl")) {
+ // TODO figure out what is going on.
+ if (targetStr.endsWith("ul") || targetStr.endsWith("dl")) {
// tasks.add(Executors.callable(() -> {
// dpnCommunicationService.delete_bearer(
// topic_id,
@@ -634,38 +575,29 @@
// context.dl(null);
// context.ul(null);
// }));
- } else {
- tasks.add(Executors.callable(() -> {
- dpnCommunicationService.delete_session(
- topic_id,
- context.contextId().fpcIdentity().union().int64(),
- client_id,
- op_id
- );
+ } else {
+ tasks.add(Executors.callable(() -> {
+ dpnCommunicationService.delete_session(
+ topic_id,
+ context.contextId().fpcIdentity().union().int64(),
+ client_id,
+ op_id
+ );
- ContextsKeys contextsKeys = new ContextsKeys();
- contextsKeys.contextId(context.contextId());
+ ContextsKeys contextsKeys = new ContextsKeys();
+ contextsKeys.contextId(context.contextId());
- ResourceId resourceVal = getResourceVal(defaultTenantBuilder()
- .addChild(DefaultFpcMobility.class)
- .addChild(DefaultContexts.class, contextsKeys)
- .build());
- dynamicConfigService.deleteNode(resourceVal);
- }));
- }
-
- } else {
- throw new IllegalArgumentException("Could not find Topic ID");
- }
- } else {
- throw new IllegalArgumentException("DPN does not have node and network ID defined.");
- }
- }
- )
- );
-
+ ResourceId resourceVal = getResourceVal(defaultTenantBuilder()
+ .addChild(DefaultFpcMobility.class)
+ .addChild(DefaultContexts.class, contextsKeys)
+ .build());
+ dynamicConfigService.deleteNode(resourceVal);
+ }));
+ }
+ }
}
+
// execute all tasks
ExecutorService executor = Executors.newWorkStealingPool();
executor.invokeAll(tasks).forEach(
diff --git a/apps/fpcagent/src/main/java/org/onosproject/fpcagent/TenantService.java b/apps/fpcagent/src/main/java/org/onosproject/fpcagent/TenantService.java
index 2542858..5b4ea1a 100644
--- a/apps/fpcagent/src/main/java/org/onosproject/fpcagent/TenantService.java
+++ b/apps/fpcagent/src/main/java/org/onosproject/fpcagent/TenantService.java
@@ -50,13 +50,6 @@
List<ModelObject> getModelObjects(DataNode dataNode, ResourceId appId);
/**
- * Returns the Default Tenant.
- *
- * @return Optional Default Tenant
- */
- Optional<DefaultTenant> getDefaultTenant();
-
- /**
* Get Tenant by its Identifier.
*
* @param tenantId Tenant Identifier
diff --git a/apps/fpcagent/src/main/java/org/onosproject/fpcagent/helpers/ConfigHelper.java b/apps/fpcagent/src/main/java/org/onosproject/fpcagent/helpers/ConfigHelper.java
deleted file mode 100644
index 5a91d52..0000000
--- a/apps/fpcagent/src/main/java/org/onosproject/fpcagent/helpers/ConfigHelper.java
+++ /dev/null
@@ -1,315 +0,0 @@
-package org.onosproject.fpcagent.helpers;
-
-import com.fasterxml.jackson.annotation.*;
-
-import java.util.HashMap;
-import java.util.Map;
-
-@JsonInclude(JsonInclude.Include.NON_NULL)
-@JsonPropertyOrder({
- "monitor-threads",
- "scheduled-monitors-poolsize",
- "dpn-subscriber-uri",
- "dpn-listener-id",
- "dpn-publisher-uri",
- "dpn-client-threads",
- "metricsupdate-ms",
- "mobilityupdate-ms",
- "activation-threads",
- "target-read-limit",
- "http-notifier-clients",
- "zmq-nbi-server-poolsize",
- "zmq-nbi-server-uri",
- "zmq-nbi-inproc-uri",
- "zmq-nbi-handler-poolsize",
- "http-nio2-nb-poolsize",
- "http-nio2-nb-port",
- "node-id",
- "network-id",
- "zmq-broadcast-controllers",
- "zmq-broadcast-dpns",
- "zmq-broadcast-all"
-})
-public class ConfigHelper {
- @JsonProperty("monitor-threads")
- private Integer monitorThreads;
- @JsonProperty("scheduled-monitors-poolsize")
- private Integer scheduledMonitorsPoolsize;
- @JsonProperty("dpn-subscriber-uri")
- private String dpnSubscriberUri;
- @JsonProperty("dpn-listener-id")
- private Integer dpnListenerId;
- @JsonProperty("dpn-publisher-uri")
- private String dpnPublisherUri;
- @JsonProperty("dpn-client-threads")
- private Integer dpnClientThreads;
- @JsonProperty("metricsupdate-ms")
- private Integer metricsupdateMs;
- @JsonProperty("mobilityupdate-ms")
- private Integer mobilityupdateMs;
- @JsonProperty("activation-threads")
- private Integer activationThreads;
- @JsonProperty("target-read-limit")
- private Integer targetReadLimit;
- @JsonProperty("http-notifier-clients")
- private Integer httpNotifierClients;
- @JsonProperty("zmq-nbi-server-poolsize")
- private Integer zmqNbiServerPoolsize;
- @JsonProperty("zmq-nbi-server-uri")
- private String zmqNbiServerUri;
- @JsonProperty("zmq-nbi-inproc-uri")
- private String zmqNbiInprocUri;
- @JsonProperty("zmq-nbi-handler-poolsize")
- private Integer zmqNbiHandlerPoolsize;
- @JsonProperty("http-nio2-nb-poolsize")
- private Integer httpNio2NbPoolsize;
- @JsonProperty("http-nio2-nb-port")
- private Integer httpNio2NbPort;
- @JsonProperty("node-id")
- private String nodeId;
- @JsonProperty("network-id")
- private String networkId;
- @JsonProperty("zmq-broadcast-controllers")
- private String zmqBroadcastControllers;
- @JsonProperty("zmq-broadcast-dpns")
- private String zmqBroadcastDpns;
- @JsonProperty("zmq-broadcast-all")
- private String zmqBroadcastAll;
- @JsonIgnore
- private Map<String, Object> additionalProperties = new HashMap<>();
-
- /**
- * No args constructor for use in serialization
- */
- public ConfigHelper() {
- }
-
-
- public Integer monitorThreads() {
- return monitorThreads;
- }
-
-
- public void setMonitorThreads(Integer monitorThreads) {
- this.monitorThreads = monitorThreads;
- }
-
-
- public Integer scheduledMonitorsPoolsize() {
- return scheduledMonitorsPoolsize;
- }
-
-
- public void setScheduledMonitorsPoolsize(Integer scheduledMonitorsPoolsize) {
- this.scheduledMonitorsPoolsize = scheduledMonitorsPoolsize;
- }
-
-
- public String dpnSubscriberUri() {
- return dpnSubscriberUri;
- }
-
-
- public void setDpnSubscriberUri(String dpnSubscriberUri) {
- this.dpnSubscriberUri = dpnSubscriberUri;
- }
-
-
- public Integer dpnListenerId() {
- return dpnListenerId;
- }
-
-
- public void setDpnListenerId(Integer dpnListenerId) {
- this.dpnListenerId = dpnListenerId;
- }
-
-
- public String dpnPublisherUri() {
- return dpnPublisherUri;
- }
-
- public void setDpnPublisherUri(String dpnPublisherUri) {
- this.dpnPublisherUri = dpnPublisherUri;
- }
-
-
- public Integer dpnClientThreads() {
- return dpnClientThreads;
- }
-
-
- public void setDpnClientThreads(Integer dpnClientThreads) {
- this.dpnClientThreads = dpnClientThreads;
- }
-
-
- public Integer metricUpdateMs() {
- return metricsupdateMs;
- }
-
-
- public void setMetricsupdateMs(Integer metricsupdateMs) {
- this.metricsupdateMs = metricsupdateMs;
- }
-
-
- public Integer mobilityUpdateMs() {
- return mobilityupdateMs;
- }
-
-
- public void setMobilityupdateMs(Integer mobilityupdateMs) {
- this.mobilityupdateMs = mobilityupdateMs;
- }
-
-
- public Integer activationThreads() {
- return activationThreads;
- }
-
-
- public void setActivationThreads(Integer activationThreads) {
- this.activationThreads = activationThreads;
- }
-
-
- public Integer targetReadLimit() {
- return targetReadLimit;
- }
-
-
- public void setTargetReadLimit(Integer targetReadLimit) {
- this.targetReadLimit = targetReadLimit;
- }
-
-
- public Integer httpNotifierClients() {
- return httpNotifierClients;
- }
-
-
- public void setHttpNotifierClients(Integer httpNotifierClients) {
- this.httpNotifierClients = httpNotifierClients;
- }
-
-
- public Integer zmqServerPoolsize() {
- return zmqNbiServerPoolsize;
- }
-
-
- public void setZmqNbiServerPoolsize(Integer zmqNbiServerPoolsize) {
- this.zmqNbiServerPoolsize = zmqNbiServerPoolsize;
- }
-
-
- public String zmqServerUri() {
- return zmqNbiServerUri;
- }
-
-
- public void setZmqNbiServerUri(String zmqNbiServerUri) {
- this.zmqNbiServerUri = zmqNbiServerUri;
- }
-
-
- public String zmqInprocUri() {
- return zmqNbiInprocUri;
- }
-
-
- public void setZmqNbiInprocUri(String zmqNbiInprocUri) {
- this.zmqNbiInprocUri = zmqNbiInprocUri;
- }
-
-
- public Integer zmqHandlerPoolsize() {
- return zmqNbiHandlerPoolsize;
- }
-
-
- public void setZmqNbiHandlerPoolsize(Integer zmqNbiHandlerPoolsize) {
- this.zmqNbiHandlerPoolsize = zmqNbiHandlerPoolsize;
- }
-
-
- public Integer httpNio2Poolsize() {
- return httpNio2NbPoolsize;
- }
-
-
- public void setHttpNio2NbPoolsize(Integer httpNio2NbPoolsize) {
- this.httpNio2NbPoolsize = httpNio2NbPoolsize;
- }
-
-
- public Integer httpNio2Port() {
- return httpNio2NbPort;
- }
-
-
- public void setHttpNio2NbPort(Integer httpNio2NbPort) {
- this.httpNio2NbPort = httpNio2NbPort;
- }
-
-
- public String nodeId() {
- return nodeId;
- }
-
-
- public void setNodeId(String node_id) {
- this.nodeId = node_id;
- }
-
-
- public String networkId() {
- return networkId;
- }
-
-
- public void setNetworkId(String network_id) {
- this.networkId = network_id;
- }
-
-
- public String zmqBroadcastControllers() {
- return zmqBroadcastControllers;
- }
-
-
- public void setZmqBroadcastControllers(String zmqBroadcastControllers) {
- this.zmqBroadcastControllers = zmqBroadcastControllers;
- }
-
- public String zmqBroadcastDpns() {
- return zmqBroadcastDpns;
- }
-
-
- public void setZmqBroadcastDpns(String zmqBroadcastDpns) {
- this.zmqBroadcastDpns = zmqBroadcastDpns;
- }
-
-
- public String zmqBroadcastAll() {
- return zmqBroadcastAll;
- }
-
-
- public void setZmqBroadcastAll(String zmqBroadcastAll) {
- this.zmqBroadcastAll = zmqBroadcastAll;
- }
-
- @JsonAnyGetter
- public Map<String, Object> getAdditionalProperties() {
- return this.additionalProperties;
- }
-
- @JsonAnySetter
- public void setAdditionalProperty(String name, Object value) {
- this.additionalProperties.put(name, value);
- }
-
-}
diff --git a/apps/fpcagent/src/main/java/org/onosproject/fpcagent/helpers/Converter.java b/apps/fpcagent/src/main/java/org/onosproject/fpcagent/helpers/Converter.java
deleted file mode 100644
index c47bdd0..0000000
--- a/apps/fpcagent/src/main/java/org/onosproject/fpcagent/helpers/Converter.java
+++ /dev/null
@@ -1,166 +0,0 @@
-package org.onosproject.fpcagent.helpers;
-
-import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.ClientIdentifier;
-import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.tenants.tenant.fpcmobility.DefaultContexts;
-import org.onosproject.yang.gen.v1.ietfdmmfpcbase.rev20160803.ietfdmmfpcbase.FpcContextId;
-import org.onosproject.yang.gen.v1.ietfdmmfpcbase.rev20160803.ietfdmmfpcbase.FpcDpnGroupId;
-import org.onosproject.yang.gen.v1.ietfdmmfpcbase.rev20160803.ietfdmmfpcbase.FpcIdentity;
-import org.onosproject.yang.gen.v1.ietfdmmfpcbase.rev20160803.ietfdmmfpcbase.FpcPortId;
-import org.onosproject.yang.gen.v1.ietfdmmfpcbase.rev20160803.ietfdmmfpcbase.fpccontext.Dl;
-import org.onosproject.yang.gen.v1.ietfdmmfpcbase.rev20160803.ietfdmmfpcbase.fpccontext.Dpns;
-import org.onosproject.yang.gen.v1.ietfdmmfpcbase.rev20160803.ietfdmmfpcbase.fpccontext.Ul;
-import org.onosproject.yang.gen.v1.ietfdmmfpcbase.rev20160803.ietfdmmfpcbase.fpcidentity.FpcIdentityUnion;
-import org.onosproject.yang.gen.v1.ietfdmmthreegpp.rev20160803.ietfdmmthreegpp.EbiType;
-import org.onosproject.yang.gen.v1.ietfdmmthreegpp.rev20160803.ietfdmmthreegpp.ImsiType;
-import org.onosproject.yang.gen.v1.ietfinettypes.rev20130715.ietfinettypes.IpPrefix;
-
-import java.math.BigInteger;
-import java.util.Arrays;
-import java.util.List;
-import java.util.function.Function;
-
-public class Converter {
- /**
- * Short to Byte
- *
- * @param value - Short
- * @return byte value
- */
- public static byte toUint8(Short value) {
- return value.byteValue();
- }
-
- /**
- * Short to byte array
- *
- * @param value - Short
- * @return byte array
- */
- public static byte[] toUint16(Short value) {
- return new byte[]{(byte) (value >>> 8), (byte) (value & 0xFF)};
- }
-
- /**
- * Lower two bytes of an integer to byte array
- *
- * @param value - integer value
- * @return byte array
- */
- public static byte[] toUint16(Integer value) {
- return new byte[]{(byte) (value >>> 8), (byte) (value & 0xFF)};
- }
-
- /**
- * Long to byte array.
- *
- * @param value - long
- * @return byte array
- */
- public static byte[] toUint32(long value) {
- return new byte[]{(byte) (value >>> 24), (byte) (value >>> 16), (byte) (value >>> 8), (byte) (value & 0xFF)};
- }
-
- /**
- * BigInteger to byte array.
- *
- * @param value - BigInteger
- * @return byte array
- */
- public static byte[] toUint64(BigInteger value) {
- return new byte[]{value.shiftRight(56).byteValue(), value.shiftRight(48).byteValue(), value.shiftRight(40).byteValue(),
- value.shiftRight(32).byteValue(), value.shiftRight(24).byteValue(), value.shiftRight(16).byteValue(),
- value.shiftRight(8).byteValue(), value.and(BigInteger.valueOf(0xFF)).byteValue()};
- }
-
- /**
- * Decodes a 32 bit value
- *
- * @param source - byte array
- * @param offset - offset in the array where the 8 bytes begins
- * @return integer
- */
- public static int toInt(byte[] source, int offset) {
- return new BigInteger(Arrays.copyOfRange(source, offset, offset + 4)).intValue();
- }
-
- /**
- * Converts a byte array to BigInteger
- *
- * @param source - byte array
- * @param offset - offset in the array where the 8 bytes begins
- * @return BigInteger representing a Uint64
- */
- public static BigInteger toBigInt(byte[] source, int offset) {
- return new BigInteger(Arrays.copyOfRange(source, offset, offset + 8));
- }
-
- /**
- * Converts an integer to a long (used for larger unsigned integers)
- *
- * @param source - message buffer (byte array)
- * @param offset - offset in the array where the 4 bytes begins
- * @return Long value of the unsigned integer
- */
- public static long fromIntToLong(byte[] source, int offset) {
- long value = 0;
- for (int i = offset; i < offset + 4; i++) {
- value = (value << 8) + (source[i] & 0xff);
- }
- return value;
- }
-
- public static Function<String, FpcIdentity> getFpcIdentity = (v) -> new FpcIdentity(new FpcIdentityUnion(v));
- public static Function<String, ClientIdentifier> getClientIdentity = (v) -> new ClientIdentifier(getFpcIdentity.apply(v));
-
- public static DefaultContexts convertContext(org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.payload.Contexts contexts) {
- DefaultContexts ctx = new DefaultContexts();
- FpcContextId fpcContextId = contexts.contextId();
- List<IpPrefix> ipPrefixes = contexts.delegatingIpPrefixes();
- Dl dl = contexts.dl();
- Ul ul = contexts.ul();
- boolean dormant = contexts.dormant();
- FpcDpnGroupId fpcDpnGroupId = contexts.dpnGroup();
- List<Dpns> dpns = contexts.dpns();
- EbiType ebi = contexts.ebi();
- EbiType lbi = contexts.lbi();
- ImsiType imsi = contexts.imsi();
- FpcContextId fpcContextId1 = contexts.parentContext();
- List<FpcPortId> ports = contexts.ports();
-
- if (fpcContextId != null) {
- ctx.contextId(fpcContextId);
- }
- if (ipPrefixes != null) {
- ctx.delegatingIpPrefixes(ipPrefixes);
- }
- if (dl != null) {
- ctx.dl(dl);
- }
- if (ul != null) {
- ctx.ul(ul);
- }
- ctx.dormant(dormant);
- if (fpcDpnGroupId != null) {
- ctx.dpnGroup(fpcDpnGroupId);
- }
- if (dpns != null) {
- ctx.dpns(dpns);
- }
- if (ebi != null) {
- ctx.ebi(ebi);
- }
- if (lbi != null) {
- ctx.lbi(lbi);
- }
- if (imsi != null) {
- ctx.imsi(imsi);
- }
- if (fpcContextId1 != null) {
- ctx.parentContext(fpcContextId1);
- }
- if (ports != null) {
- ctx.ports(ports);
- }
- return ctx;
- }
-}
diff --git a/apps/fpcagent/src/main/java/org/onosproject/fpcagent/helpers/DpnCommunicationService.java b/apps/fpcagent/src/main/java/org/onosproject/fpcagent/helpers/DpnCommunicationService.java
deleted file mode 100644
index 9785a41..0000000
--- a/apps/fpcagent/src/main/java/org/onosproject/fpcagent/helpers/DpnCommunicationService.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Copyright 2017-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.fpcagent.helpers;
-
-import org.onlab.packet.Ip4Address;
-
-import java.math.BigInteger;
-
-/**
- * Communication Service which sends packets to desired DPNs.
- */
-public interface DpnCommunicationService {
-
- /**
- * Creates Mobility Session.
- *
- * @param topic_id - DPN Topic ID
- * @param imsi - IMSI identifier
- * @param default_ebi - EBI
- * @param ue_ipv4 - UE IPv4 Address
- * @param s1u_sgw_teid - SGW Tunnel Identifier
- * @param s1u_sgw_ipv4 - SGW IPv4
- * @param session_id - Context Identifier
- * @param client_id - Client Identifier
- * @param op_id - Operation Identifier
- */
- void create_session(
- Short topic_id,
- BigInteger imsi,
- Short default_ebi,
- Ip4Address ue_ipv4,
- Long s1u_sgw_teid,
- Ip4Address s1u_sgw_ipv4,
- Long session_id,
- Long client_id,
- BigInteger op_id
- );
-
- /**
- * Modifies Bearer.
- *
- * @param topic_id - DPN Topic ID
- * @param s1u_sgw_ipv4 - SGW IPv4 Address
- * @param s1u_enodeb_teid - ENodeB Tunnel Identifier
- * @param s1u_enodeb_ipv4 - ENodeB IPv4 Address
- * @param session_id - Context Identifier
- * @param client_id - Client Identifier
- * @param op_id - Operation Identifier
- */
- void modify_bearer(
- Short topic_id,
- Ip4Address s1u_sgw_ipv4,
- Long s1u_enodeb_teid,
- Ip4Address s1u_enodeb_ipv4,
- Long session_id,
- Long client_id,
- BigInteger op_id
- );
-
- /**
- * Deletes Mobility Session.
- *
- * @param topic_id - DPN Topic ID
- * @param session_id - Context Identifier
- * @param client_id - Client Identifier
- * @param op_id - Operation Identifier
- */
- void delete_session(
- Short topic_id,
- Long session_id,
- Long client_id,
- BigInteger op_id
- );
-
- /**
- * Creates the byte buffer to send ADC rules over ZMQ
- *
- * @param topic - DPN Topic ID
- * @param domain_name - domain
- * @param ip - ipaddress/ipprefix (i.e. 127.0.0.1/32)
- * @param drop - Drop if 1
- * @param rating_group - Rating Group
- * @param service_ID - Service ID
- * @param sponsor_ID - Sponsor ID
- */
- void send_ADC_rules(
- Short topic,
- String domain_name,
- String ip,
- Short drop,
- Long rating_group,
- Long service_ID,
- String sponsor_ID
- );
-}
diff --git a/apps/fpcagent/src/main/java/org/onosproject/fpcagent/helpers/DpnNgicCommunicator.java b/apps/fpcagent/src/main/java/org/onosproject/fpcagent/helpers/DpnNgicCommunicator.java
deleted file mode 100644
index 50d3d4a..0000000
--- a/apps/fpcagent/src/main/java/org/onosproject/fpcagent/helpers/DpnNgicCommunicator.java
+++ /dev/null
@@ -1,232 +0,0 @@
-/*
- * Copyright 2017-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.fpcagent.helpers;
-
-import org.onlab.packet.Ip4Address;
-import org.onlab.packet.Ip4Prefix;
-import org.onosproject.fpcagent.workers.ZMQSBPublisherManager;
-import org.onosproject.fpcagent.workers.ZMQSBSubscriberManager;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.math.BigInteger;
-import java.nio.ByteBuffer;
-
-import static org.onosproject.fpcagent.helpers.Converter.*;
-
-/**
- * DPDK DPN API over ZeroMQ for NGIC.
- */
-public class DpnNgicCommunicator implements DpnCommunicationService {
- protected static final Logger log = LoggerFactory.getLogger(DpnNgicCommunicator.class);
-
- @Override
- public void create_session(
- Short topic_id,
- BigInteger imsi,
- Short default_ebi,
- Ip4Address ue_ipv4,
- Long s1u_sgw_teid,
- Ip4Address s1u_sgw_ipv4,
- Long session_id,
- Long client_id,
- BigInteger op_id
- ) {
- /* NGIC Create Session expected buffer:
- uint8_t topic_id;
- uint8_t type;
- struct create_session_t {
- uint64_t imsi;
- uint8_t default_ebi;
- uint32_t ue_ipv4;
- uint32_t s1u_sgw_teid;
- uint32_t s1u_sgw_ipv4;
- uint64_t session_id;
- uint8_t controller_topic;
- uint32_t client_id;
- uint32_t op_id;
- } create_session_msg;
- */
- // TODO: check if subscriber is open.
- ByteBuffer bb = ByteBuffer.allocate(41)
- .put(toUint8(topic_id))
- .put(s11MsgType.CREATE_SESSION.getType())
- .put(toUint64(imsi))
- .put(toUint8(default_ebi))
- .put(toUint32(ue_ipv4.toInt()))
- .put(toUint32(s1u_sgw_teid))
- .put(toUint32(s1u_sgw_ipv4.toInt()))
- .put(toUint64(BigInteger.valueOf(session_id)))
- .put(toUint8(ZMQSBSubscriberManager.getControllerTopic()))
- .put(toUint32(client_id))
- .put(toUint32(op_id.longValue()));
-
- log.debug("create_session: {}", bb.array());
- ZMQSBPublisherManager.getInstance().send(bb);
- }
-
- @Override
- public void modify_bearer(
- Short topic_id,
- Ip4Address s1u_sgw_ipv4,
- Long s1u_enodeb_teid,
- Ip4Address s1u_enodeb_ipv4,
- Long session_id,
- Long client_id,
- BigInteger op_id
- ) {
- /*
- NGIC Modify Session expected buffer:
- uint8_t topic_id;
- uint8_t type;
- struct modify_bearer_t {
- uint32_t s1u_sgw_ipv4;
- uint32_t s1u_enodeb_teid;
- uint32_t s1u_enodeb_ipv4;
- uint64_t session_id;
- uint8_t controller_topic;
- uint32_t client_id;
- uint32_t op_id;
- } modify_bearer_msg;
- */
- ByteBuffer bb = ByteBuffer.allocate(32)
- .put(toUint8(topic_id))
- .put(s11MsgType.MODIFY_BEARER.getType())
- .put(toUint32(s1u_sgw_ipv4.toInt()))
- .put(toUint32(s1u_enodeb_teid))
- .put(toUint32(s1u_enodeb_ipv4.toInt()))
- .put(toUint64(BigInteger.valueOf(session_id)))
- .put(toUint8(ZMQSBSubscriberManager.getControllerTopic()))
- .put(toUint32(client_id))
- .put(toUint32(op_id.longValue()));
-
- log.debug("modify_bearer: {}", bb.array());
- ZMQSBPublisherManager.getInstance().send(bb);
- }
-
- @Override
- public void delete_session(
- Short topic_id,
- Long session_id,
- Long client_id,
- BigInteger op_id
- ) {
- /*
- NGIC Delete Session expected buffer:
- uint8_t topic_id;
- uint8_t type;
- struct delete_session_t {
- uint64_t session_id;
- uint8_t controller_topic;
- uint32_t client_id;
- uint32_t op_id;
- } delete_session_msg;
- */
- ByteBuffer bb = ByteBuffer.allocate(19)
- .put(toUint8(topic_id))
- .put(s11MsgType.DELETE_SESSION.getType())
- .put(toUint64(BigInteger.valueOf(session_id)))
- .put(toUint8(ZMQSBSubscriberManager.getControllerTopic()))
- .put(toUint32(client_id))
- .put(toUint32(op_id.longValue()));
-
- log.debug("delete_session: {}", bb.array());
- ZMQSBPublisherManager.getInstance().send(bb);
- }
-
- @Override
- public void send_ADC_rules(
- Short topic,
- String domain_name,
- String ip,
- Short drop,
- Long rating_group,
- Long service_ID, String sponsor_ID
- ) {
- // TODO take a look for this function. Not tested.
- Ip4Prefix ip_prefix = null;
- if (ip != null) {
- ip_prefix = Ip4Prefix.valueOf(ip);
- }
- Short selector_type = (short) (domain_name != null ? 0 : ip_prefix != null ? 2 : ip_prefix.address() != null ? 1 : 255);
- if (selector_type == 255) {
- log.warn("Domain/IP not found, failed to send rules");
- return;
- }
- ByteBuffer bb = ByteBuffer.allocate(200);
- bb.put(toUint8(topic))
- .put(s11MsgType.ADC_RULE.getType())
- .put(toUint8(selector_type));
- if (selector_type == 0) {
- bb.put(toUint8((short) domain_name.length()))
- .put(domain_name.getBytes());
- }
- if ((selector_type == 1) || (selector_type == 2)) {
- int ip_address_long = ip_prefix.address().toInt();
- bb.put(toUint32(ip_address_long));
- }
- if (selector_type == 2) {
- bb.put(toUint16(ip_prefix.prefixLength()));
- }
- if (drop != null)
- bb.put(toUint8(drop));
- if (rating_group != null)
- bb.put(toUint32(rating_group));
- if (service_ID != null)
- bb.put(toUint32(service_ID));
- if (sponsor_ID != null && (short) sponsor_ID.length() > 0) {
- bb.put(toUint8((short) sponsor_ID.length()))
- .put(sponsor_ID.getBytes());
- }
- bb.put(toUint8(ZMQSBSubscriberManager.getControllerTopic()));
-
- log.info("send_ADC_rules: {}", bb.array());
- ZMQSBPublisherManager.getInstance().send(bb);
- }
-
- /**
- * Following the NGIC message types.
- *
- * This type structure is defined in NGIC at interface/zmq/zmqsub.h:51
- */
- enum s11MsgType {
- CREATE_SESSION(1),
- MODIFY_BEARER(2),
- DELETE_SESSION(3),
- DPN_RESPONSE(4),
- DDN(5),
- ASSIGN_TOPIC(10),
- ASSIGN_CONFLICT(11),
- DPN_STATUS_INDICATION(12),
- DPN_STATUS_ACK(13),
- CONTROLLER_STATUS_INDICATION(14),
- ADC_RULE(17),
- PCC_RULE(18),
- METER_RULE(19),
- SDF_RULE(20);
-
- private byte type;
-
- s11MsgType(int type) {
- this.type = (byte) type;
- }
-
- public byte getType() {
- return type;
- }
- }
-}
\ No newline at end of file
diff --git a/apps/fpcagent/src/main/java/org/onosproject/fpcagent/workers/ZMQSBSubscriberManager.java b/apps/fpcagent/src/main/java/org/onosproject/fpcagent/workers/ZMQSBSubscriberManager.java
index 7a53aaa..f137693 100644
--- a/apps/fpcagent/src/main/java/org/onosproject/fpcagent/workers/ZMQSBSubscriberManager.java
+++ b/apps/fpcagent/src/main/java/org/onosproject/fpcagent/workers/ZMQSBSubscriberManager.java
@@ -1,7 +1,7 @@
package org.onosproject.fpcagent.workers;
import org.apache.commons.lang.exception.ExceptionUtils;
-import org.onosproject.fpcagent.FpcUtil;
+import org.onosproject.fpcagent.util.FpcUtil;
import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.yangautoprefixnotify.value.DownlinkDataNotification;
import org.onosproject.yang.gen.v1.ietfdmmfpcbase.rev20160803.ietfdmmfpcbase.FpcDpnId;
import org.slf4j.Logger;
@@ -16,7 +16,7 @@
import java.util.concurrent.Future;
import java.util.concurrent.ThreadLocalRandom;
-import static org.onosproject.fpcagent.helpers.Converter.*;
+import static org.onosproject.fpcagent.util.Converter.*;
public class ZMQSBSubscriberManager implements AutoCloseable {
private static final Logger log = LoggerFactory.getLogger(ZMQSBSubscriberManager.class);
diff --git a/scripts/benchmark.sh b/scripts/benchmark.sh
index 779875a..1cc3b93 100755
--- a/scripts/benchmark.sh
+++ b/scripts/benchmark.sh
@@ -2,18 +2,18 @@
./addDPN.sh 1 &> /dev/null
-for (( i=1; i<=1000; i++)); do
+for (( i=1; i<=100; i++)); do
./configureCreateOrUpdate.sh create $i 1 &> /dev/null &
- if ! (($i % 100)); then
+ if ! (($i % 10)); then
wait
fi
done
-for (( i=1; i<=1000; i++)); do
- ./configureDeleteOrQuery.sh delete $i &> /dev/null &
- if ! (($i % 100)); then
- wait
- fi
-done
+#for (( i=1; i<=100; i++)); do
+# ./configureDeleteOrQuery.sh delete $i &> /dev/null &
+# if ! (($i % 10)); then
+# wait
+# fi
+#done
-./deleteDPN.sh 1 &> /dev/null
\ No newline at end of file
+./deleteDPN.sh 1 &> /dev/null