added comments and dpn ack
diff --git a/apps/fpcagent/src/main/java/org/onosproject/fpcagent/ActivationManager.java b/apps/fpcagent/src/main/java/org/onosproject/fpcagent/ActivationManager.java
deleted file mode 100644
index a32fe12..0000000
--- a/apps/fpcagent/src/main/java/org/onosproject/fpcagent/ActivationManager.java
+++ /dev/null
@@ -1,4 +0,0 @@
-package org.onosproject.fpcagent;
-
-public class ActivationManager {
-}
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 4ae0847..d7d88e6 100644
--- a/apps/fpcagent/src/main/java/org/onosproject/fpcagent/FpcManager.java
+++ b/apps/fpcagent/src/main/java/org/onosproject/fpcagent/FpcManager.java
@@ -108,7 +108,7 @@
notificationIds = coreService.getIdGenerator("fpc-notification-ids");
- HTTPNotifier.getInstance().open();
+ HTTPNotifier.createInstance(modelConverter).open();
log.info("FPC Service Started");
}
diff --git a/apps/fpcagent/src/main/java/org/onosproject/fpcagent/FpcRpcManager.java b/apps/fpcagent/src/main/java/org/onosproject/fpcagent/FpcRpcManager.java
index 63bcd25..4e9b3bb 100644
--- a/apps/fpcagent/src/main/java/org/onosproject/fpcagent/FpcRpcManager.java
+++ b/apps/fpcagent/src/main/java/org/onosproject/fpcagent/FpcRpcManager.java
@@ -179,11 +179,14 @@
final DefaultConnectionInfo defaultConnectionInfo = new DefaultConnectionInfo();
+ // instatiate DC Store with empty fields
createNode(tenants, root);
createNode(fpcAgentInfo, root);
createNode(defaultConnectionInfo, root);
}
+ // TODO check if DPN is abstract and replicate
+
@Override
public DefaultConfigureOutput configureCreate(
CreateOrUpdate create,
@@ -192,8 +195,10 @@
) throws Exception {
DefaultConfigureOutput configureOutput = new DefaultConfigureOutput();
Collection<Callable<Object>> tasks = new ArrayList<>();
+ // Get this clients tenant.
FpcIdentity tenantId = clientInfo.tenantId();
DefaultCommonSuccess defaultCommonSuccess = new DefaultCommonSuccess();
+ // Load cache for specific tenant.
CacheManager cacheManager = CacheManager.getInstance(tenantId);
for (Contexts context : create.contexts()) {
@@ -220,6 +225,7 @@
final DpnCommunicationService dpnCommunicationService;
Class<? extends FpcDpnControlProtocol> controlProtocol = optionalDpn.get().controlProtocol();
+ // Check if the DPN supports NGIC or P4 protocol
if (controlProtocol.isAssignableFrom(ZmqDpnControlProtocol.class)) {
dpnCommunicationService = new DpnNgicCommunicator();
} else if (controlProtocol.isAssignableFrom(P4DpnControlProtocol.class)) {
@@ -351,9 +357,12 @@
) throws Exception {
DefaultConfigureOutput configureOutput = new DefaultConfigureOutput();
Collection<Callable<Object>> tasks = new ArrayList<>();
+ // Get this clients tenant.
FpcIdentity tenantId = clientInfo.tenantId();
DefaultCommonSuccess defaultCommonSuccess = new DefaultCommonSuccess();
+ // Load cache for specific tenant.
CacheManager cacheManager = CacheManager.getInstance(tenantId);
+
for (Contexts context : update.contexts()) {
Instructions instructions = context.instructions();
if (instructions == null) {
@@ -378,6 +387,7 @@
final DpnCommunicationService dpnCommunicationService;
Class<? extends FpcDpnControlProtocol> controlProtocol = optionalDpn.get().controlProtocol();
+ // Check if the DPN supports NGIC or P4 protocol
if (controlProtocol.isAssignableFrom(ZmqDpnControlProtocol.class)) {
dpnCommunicationService = new DpnNgicCommunicator();
} else if (controlProtocol.isAssignableFrom(P4DpnControlProtocol.class)) {
@@ -420,7 +430,7 @@
BigInteger opId = operationId.uint64();
- // TODO dpn.direction()
+ // TODO do we care about dpn.direction()?
DefaultContexts convertContext = convertContext(context);
if (commands.contains("downlink")) {
@@ -498,7 +508,9 @@
) throws Exception {
DefaultConfigureOutput configureOutput = new DefaultConfigureOutput();
Collection<Callable<Object>> tasks = new ArrayList<>();
+ // get client's tenant.
FpcIdentity tenantId = clientInfo.tenantId();
+ // get cache for specific tenant.
CacheManager cacheManager = CacheManager.getInstance(tenantId);
DefaultDeleteSuccess defaultDeleteSuccess = new DefaultDeleteSuccess();
for (Targets target : delete.targets()) {
@@ -606,12 +618,14 @@
DefaultConfigureDpnOutput defaultConfigureDpnOutput = new DefaultConfigureDpnOutput();
boolean done = false;
+ // get DPN and abstract DPN
final FpcDpnId fpcDpnId = input.inputDpnId(),
abstractDpnId = input.abstractDpnId();
if (fpcDpnId == null || abstractDpnId == null) {
throw new RuntimeException("DPN and Abstract DPN must be provided.");
}
+ // search in the Cache for the specified DPN
for (CacheManager cacheManager : CacheManager.cacheInfo.values()) {
final Optional<DefaultDpns> optionalDpn = cacheManager.dpnsCache.get(fpcDpnId),
optionalvDpn = cacheManager.dpnsCache.get(abstractDpnId);
@@ -632,6 +646,7 @@
vdpn.dpnIds(new ArrayList<>());
}
+ // add DPN to the abstract DPN and then replicate all the messages.
if (!vdpn.dpnIds().contains(dpn.dpnId())) {
// TODO copy contexts
vdpn.addToDpnIds(dpn.dpnId());
@@ -654,12 +669,14 @@
DefaultConfigureDpnOutput defaultConfigureDpnOutput = new DefaultConfigureDpnOutput();
boolean done = false;
+ // get DPN and abstract DPN
final FpcDpnId fpcDpnId = input.inputDpnId(),
abstractDpnId = input.abstractDpnId();
if (fpcDpnId == null || abstractDpnId == null) {
throw new RuntimeException("DPN and Abstract DPN must be provided.");
}
+ // search in the Cache for the specified DPN
for (CacheManager cacheManager : CacheManager.cacheInfo.values()) {
final Optional<DefaultDpns> optionalDpn = cacheManager.dpnsCache.get(fpcDpnId),
optionalvDpn = cacheManager.dpnsCache.get(abstractDpnId);
@@ -679,6 +696,7 @@
throw new RuntimeException("DPN is not part of the vDPN");
}
+ // remove DPN from the abstract DPN.
vdpn.dpnIds().remove(dpn.dpnId());
// TODO remove contexts
done = true;
@@ -899,7 +917,9 @@
if (clientInfo.containsKey(input.clientId())) {
throw new RuntimeException("Client already registered.");
}
+ // keep information for each client. this can be moved to the DC Store and use Cache.
clientInfo.put(input.clientId(), input);
+ // keep clients for each tenant
HashSet<ClientIdentifier> hashSet = tenantInfo.getOrDefault(input.tenantId(), Sets.newHashSet());
hashSet.add(input.clientId());
tenantInfo.put(input.tenantId(), hashSet);
@@ -992,6 +1012,7 @@
public void event(DeviceEvent event) {
if (event.subject().manufacturer().equals("fpc")) {
switch (event.type()) {
+ // in case an FPC device is added or restarted send DPN availability to all connected clients
case DEVICE_UPDATED:
case DEVICE_ADDED: {
tenantInfo.forEach(
@@ -1001,11 +1022,12 @@
DefaultTenant tenant = defaultTenant.get();
if (tenant.fpcTopology().dpns() != null) {
tenant.fpcTopology().dpns().forEach(dpn -> {
- CacheManager.getInstance(tenantId).nodeNetworkCache.put(
- dpn.nodeId() + "/" + dpn.networkId(),
- Optional.of(dpn.dpnId())
- );
if (!dpnInfo.contains(dpn.dpnId())) {
+ CacheManager.getInstance(tenantId).nodeNetworkCache.put(
+ dpn.nodeId() + "/" + dpn.networkId(),
+ Optional.of(dpn.dpnId())
+ );
+
DefaultYangAutoPrefixNotify notify = new DefaultYangAutoPrefixNotify();
notify.notificationId(NotificationId.of(notificationIds.getNewId()));
@@ -1033,6 +1055,7 @@
);
break;
}
+ // in case an FPC device is removed or shutdown send DPN availability to all connected clients
case DEVICE_AVAILABILITY_CHANGED:
case DEVICE_REMOVED: {
String nodeNetwork = event.subject().id().toString().split(":")[1];
@@ -1062,7 +1085,6 @@
clients.forEach(client -> sendNotification(notify, client));
dpnInfo.remove(fpcDpnId);
-
}
} catch (Exception e) {
log.error(ExceptionUtils.getFullStackTrace(e));
diff --git a/apps/fpcagent/src/main/java/org/onosproject/fpcagent/FpcRpcService.java b/apps/fpcagent/src/main/java/org/onosproject/fpcagent/FpcRpcService.java
index 8d5c150..d0b1217 100644
--- a/apps/fpcagent/src/main/java/org/onosproject/fpcagent/FpcRpcService.java
+++ b/apps/fpcagent/src/main/java/org/onosproject/fpcagent/FpcRpcService.java
@@ -9,6 +9,9 @@
import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.opinput.opbody.CreateOrUpdate;
import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.opinput.opbody.DeleteOrQuery;
+/**
+ * Main service that handles RPC events and DC Store modifications.
+ */
@Beta
public interface FpcRpcService {
@@ -16,9 +19,10 @@
* Handles create Configure operations that are invoked through RPC.
*
* @param create RPC Input converted
- * @param clientInfo Client Identifier
+ * @param clientInfo Client info
* @param operationId Operation Identifier
* @return Result of the configuration
+ * @throws Exception Runtime exception
*/
DefaultConfigureOutput configureCreate(
CreateOrUpdate create,
@@ -30,9 +34,10 @@
* Handles update Configure operations that are invoked through RPC.
*
* @param update RPC Input converted
- * @param clientInfo Client Identifier
+ * @param clientInfo Client info
* @param operationId Operation Identifier
* @return Result of the configuration
+ * @throws Exception Runtime exception
*/
DefaultConfigureOutput configureUpdate(
CreateOrUpdate update,
@@ -44,9 +49,10 @@
* Handles delete Configure operations that are invoked through RPC.
*
* @param delete RPC Input converted
- * @param clientInfo Client Identifier
+ * @param clientInfo Client info
* @param operationId Operation Identifier
* @return Result of the configuration
+ * @throws Exception Runtime exception
*/
DefaultConfigureOutput configureDelete(
DeleteOrQuery delete,
@@ -54,7 +60,21 @@
OpIdentifier operationId
) throws Exception;
+ /**
+ * Configures a DPN if it is abstract or not.
+ *
+ * @param input RPC Input converted
+ * @return Result of the configuration
+ * @throws Exception Runtime exception
+ */
DefaultConfigureDpnOutput configureDpnAdd(DefaultConfigureDpnInput input) throws Exception;
+ /**
+ * Configures a DPN if it is abstract or not.
+ *
+ * @param input RPC Input converted
+ * @return Result of the configuration
+ * @throws Exception Runtime exception
+ */
DefaultConfigureDpnOutput configureDpnRemove(DefaultConfigureDpnInput input) throws Exception;
}
diff --git a/apps/fpcagent/src/main/java/org/onosproject/fpcagent/protocols/DpnCommunicationService.java b/apps/fpcagent/src/main/java/org/onosproject/fpcagent/protocols/DpnCommunicationService.java
index 17df670..c44a18b 100644
--- a/apps/fpcagent/src/main/java/org/onosproject/fpcagent/protocols/DpnCommunicationService.java
+++ b/apps/fpcagent/src/main/java/org/onosproject/fpcagent/protocols/DpnCommunicationService.java
@@ -27,7 +27,8 @@
/**
* Creates Mobility Session.
- * @param topic_id - DPN Topic ID
+ *
+ * @param topic_id - DPN Topic ID
* @param imsi - IMSI identifier
* @param default_ebi - EBI
* @param ue_ipv4 - UE IPv4 Address
@@ -51,7 +52,8 @@
/**
* Modifies Bearer.
- * @param topic_id - DPN Topic ID
+ *
+ * @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
@@ -71,7 +73,8 @@
/**
* Deletes Mobility Session.
- * @param topic_id - DPN Topic ID
+ *
+ * @param topic_id - DPN Topic ID
* @param session_id - Context Identifier
* @param client_id - Client Identifier
* @param op_id - Operation Identifier
diff --git a/apps/fpcagent/src/main/java/org/onosproject/fpcagent/protocols/DpnNgicCommunicator.java b/apps/fpcagent/src/main/java/org/onosproject/fpcagent/protocols/DpnNgicCommunicator.java
index 78f1171..b030967 100644
--- a/apps/fpcagent/src/main/java/org/onosproject/fpcagent/protocols/DpnNgicCommunicator.java
+++ b/apps/fpcagent/src/main/java/org/onosproject/fpcagent/protocols/DpnNgicCommunicator.java
@@ -16,11 +16,15 @@
package org.onosproject.fpcagent.protocols;
+import org.apache.commons.lang.exception.ExceptionUtils;
+import org.json.JSONObject;
import org.onlab.packet.Ip4Address;
import org.onlab.packet.Ip4Prefix;
import org.onosproject.fpcagent.workers.ZMQSBPublisherManager;
import org.onosproject.fpcagent.workers.ZMQSBSubscriberManager;
import org.onosproject.yang.gen.v1.fpc.rev20150105.fpc.ZmqDpnControlProtocol;
+import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.ClientIdentifier;
+import org.onosproject.yang.gen.v1.ietfdmmfpcbase.rev20160803.ietfdmmfpcbase.FpcDpnId;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -120,6 +124,35 @@
ZMQSBPublisherManager.getInstance().send(bb);
}
+ /**
+ * Parses the JSON returned from the Control Plane and sends the ACK to the DPN
+ *
+ * @param body - The JSON body returned by the Control Plane in the DDN ACK
+ */
+ public static void ddnAck(JSONObject body) {
+ try {
+ ByteBuffer bb = ByteBuffer.allocate(14);
+ Short dpn = DpnAPIListener.getTopicFromDpnId(new FpcDpnId((String) body.get("dpn-id")));
+ bb.put(toUint8(dpn))
+ .put(s11MsgType.DDN_ACK.getType());
+
+ if (body.has("dl-buffering-duration")) {
+ bb.put(toUint8((short) body.getInt("dl-buffering-duration")));
+ }
+ if (body.has("dl-buffering-suggested-count")) {
+ bb.put(toUint16((int) body.getInt("dl-buffering-suggested-count")));
+ }
+ bb.put(ZMQSBSubscriberManager.getInstance().getControllerTopic())
+ .put(toUint32(Long.parseLong(new ClientIdentifier(body.getString("client-id")).getString())))
+ .put(toUint32(body.getLong("op-id")));
+
+ ZMQSBPublisherManager.getInstance().send(bb);
+ } catch (InterruptedException e) {
+ log.error("{}", ExceptionUtils.getFullStackTrace(e));
+ }
+
+ }
+
@Override
public void create_session(
byte topic_id,
diff --git a/apps/fpcagent/src/main/java/org/onosproject/fpcagent/util/FpcUtil.java b/apps/fpcagent/src/main/java/org/onosproject/fpcagent/util/FpcUtil.java
index 98585bf..2b45678 100644
--- a/apps/fpcagent/src/main/java/org/onosproject/fpcagent/util/FpcUtil.java
+++ b/apps/fpcagent/src/main/java/org/onosproject/fpcagent/util/FpcUtil.java
@@ -16,19 +16,14 @@
package org.onosproject.fpcagent.util;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ObjectNode;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
-import org.apache.commons.lang.exception.ExceptionUtils;
import org.onosproject.config.DynamicConfigService;
import org.onosproject.config.Filter;
import org.onosproject.core.IdGenerator;
import org.onosproject.fpcagent.workers.HTTPNotifier;
import org.onosproject.net.Device;
import org.onosproject.net.device.DeviceStore;
-import org.onosproject.restconf.utils.RestconfUtils;
import org.onosproject.yang.gen.v1.fpc.rev20150105.fpc.registerclient.DefaultRegisterClientInput;
import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.ClientIdentifier;
import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.DefaultTenants;
@@ -55,12 +50,15 @@
public class FpcUtil {
public static final String FPC_APP_ID = "org.onosproject.fpcagent";
public static final FpcIdentity defaultIdentity = FpcIdentity.fromString("default");
+ public static final ConcurrentMap<ClientIdentifier, DefaultRegisterClientInput> clientInfo = Maps.newConcurrentMap();
+ public static final ConcurrentMap<FpcIdentity, HashSet<ClientIdentifier>> tenantInfo = Maps.newConcurrentMap();
+ public static final HashSet<FpcDpnId> dpnInfo = Sets.newHashSet();
private static final Logger log = LoggerFactory.getLogger(FpcUtil.class);
-
+ // Services
public static DynamicConfigService dynamicConfigService = null;
public static ModelConverter modelConverter = null;
public static DeviceStore deviceStore = null;
-
+ // Resource IDs
public static ResourceId configureDpn;
public static ResourceId configure;
public static ResourceId tenants;
@@ -69,13 +67,9 @@
public static ResourceId deregisterClient;
public static ResourceId module;
public static ResourceId notification;
-
+ // Notification IDs generator
public static IdGenerator notificationIds;
- public static final ConcurrentMap<ClientIdentifier, DefaultRegisterClientInput> clientInfo = Maps.newConcurrentMap();
- public static final ConcurrentMap<FpcIdentity, HashSet<ClientIdentifier>> tenantInfo = Maps.newConcurrentMap();
- public static final HashSet<FpcDpnId> dpnInfo = Sets.newHashSet();
-
/**
* Returns resource id from model converter.
*
@@ -169,6 +163,12 @@
}
}
+ /**
+ * Get model object for specific tenant.
+ *
+ * @param fpcIdentity Tenant ID
+ * @return tenants model object
+ */
public static ModelObjectId.Builder tenantBuilder(FpcIdentity fpcIdentity) {
TenantKeys tenantKeys = new TenantKeys();
tenantKeys.tenantId(fpcIdentity);
@@ -297,25 +297,19 @@
);
}
+ /**
+ * Sends a HTTP Post request to specified client.
+ *
+ * @param notify message
+ * @param client HTTP client to receive message
+ */
public static void sendNotification(DefaultYangAutoPrefixNotify notify, ClientIdentifier client) {
- ResourceData dataNode = modelConverter.createDataNode(
- DefaultModelObjectData.builder()
- .addModelObject(notify)
- .build()
+ log.info("Sending HTTP notification {} to {}", notify, client);
+ HTTPNotifier.getInstance().send(
+ new AbstractMap.SimpleEntry<>(
+ clientInfo.get(client).endpointUri().toString(),
+ notify
+ )
);
- ObjectNode jsonNodes = RestconfUtils.convertDataNodeToJson(module, dataNode.dataNodes().get(0));
- ObjectMapper mapper = new ObjectMapper();
-
- try {
- log.info("Sending HTTP notification {} to {}", notify, client);
- HTTPNotifier.getInstance().send(
- new AbstractMap.SimpleEntry<>(
- clientInfo.get(client).endpointUri().toString(),
- mapper.writeValueAsString(jsonNodes)
- )
- );
- } catch (JsonProcessingException e) {
- log.error(ExceptionUtils.getFullStackTrace(e));
- }
}
}
diff --git a/apps/fpcagent/src/main/java/org/onosproject/fpcagent/workers/HTTPNotifier.java b/apps/fpcagent/src/main/java/org/onosproject/fpcagent/workers/HTTPNotifier.java
index 995d6f3..a45b5d4 100644
--- a/apps/fpcagent/src/main/java/org/onosproject/fpcagent/workers/HTTPNotifier.java
+++ b/apps/fpcagent/src/main/java/org/onosproject/fpcagent/workers/HTTPNotifier.java
@@ -16,12 +16,22 @@
package org.onosproject.fpcagent.workers;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ObjectNode;
import org.apache.commons.lang.exception.ExceptionUtils;
import org.apache.http.HttpResponse;
+import org.apache.http.client.ResponseHandler;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.BasicResponseHandler;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
+import org.onosproject.restconf.utils.RestconfUtils;
+import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.DefaultYangAutoPrefixNotify;
+import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.yangautoprefixnotify.value.DownlinkDataNotification;
+import org.onosproject.yang.model.DefaultModelObjectData;
+import org.onosproject.yang.model.ModelConverter;
+import org.onosproject.yang.model.ResourceData;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -31,25 +41,34 @@
import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingQueue;
+import static org.onosproject.fpcagent.util.FpcUtil.module;
+
public class HTTPNotifier implements AutoCloseable {
private static final Logger log = LoggerFactory.getLogger(HTTPNotifier.class);
private static HTTPNotifier _instance = null;
- private final BlockingQueue<Map.Entry<String, String>> blockingQueue;
+ private final BlockingQueue<Map.Entry<String, DefaultYangAutoPrefixNotify>> blockingQueue;
+ public ModelConverter modelConverter = null;
private boolean run;
+ private ResponseHandler<String> handler = new BasicResponseHandler();
- protected HTTPNotifier() {
+ protected HTTPNotifier(ModelConverter modelConverter) {
this.run = true;
this.blockingQueue = new LinkedBlockingQueue<>();
+ this.modelConverter = modelConverter;
}
- public static HTTPNotifier getInstance() {
+ public static HTTPNotifier createInstance(ModelConverter modelConverter) {
if (_instance == null) {
- _instance = new HTTPNotifier();
+ _instance = new HTTPNotifier(modelConverter);
}
return _instance;
}
- public void send(Map.Entry<String, String> buf) {
+ public static HTTPNotifier getInstance() {
+ return _instance;
+ }
+
+ public void send(Map.Entry<String, DefaultYangAutoPrefixNotify> buf) {
try {
blockingQueue.put(buf);
} catch (InterruptedException e) {
@@ -57,23 +76,37 @@
}
}
+
public void open() {
ExecutorService executorService = Executors.newSingleThreadExecutor();
executorService.submit(() -> {
while ((!Thread.currentThread().isInterrupted()) && run) {
try {
- Map.Entry<String, String> entry = blockingQueue.take();
+ Map.Entry<String, DefaultYangAutoPrefixNotify> entry = blockingQueue.take();
+ DefaultYangAutoPrefixNotify notify = entry.getValue();
CloseableHttpClient client = HttpClients.createDefault();
HttpPost httpPost = new HttpPost(entry.getKey());
httpPost.addHeader("User-Agent", "ONOS Notification Agent");
httpPost.addHeader("Charset", "utf-8");
httpPost.addHeader("Content-type", "application/json");
- StringEntity params = new StringEntity(entry.getValue());
+
+ ResourceData dataNode = modelConverter.createDataNode(
+ DefaultModelObjectData.builder()
+ .addModelObject(notify)
+ .build()
+ );
+ ObjectNode jsonNodes = RestconfUtils.convertDataNodeToJson(module, dataNode.dataNodes().get(0));
+ ObjectMapper mapper = new ObjectMapper();
+
+ StringEntity params = new StringEntity(mapper.writeValueAsString(jsonNodes.get(0)));
httpPost.setEntity(params);
HttpResponse response = client.execute(httpPost);
- log.info("Response {}", response);
+ if (notify.value() instanceof DownlinkDataNotification) {
+ String msg = handler.handleResponse(response);
+ log.info("Response {}", response);
+ }
} catch (Exception e) {
log.error(ExceptionUtils.getFullStackTrace(e));
}