RD: Updated SAL communication classes
Change-Id: Iee17853ebbf570a6576553eaeab2445821deadf8
This commit is contained in:
parent
68b8bc9f34
commit
a0b1e1d08b
@ -142,7 +142,7 @@ public class SALCommunicator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static String get_device_registration_json(String internal_ip_address, String external_ip_address, int cpu_cores, int ram_gb, int disk_gb, String device_name,String provider_id, String city_name, String country_name, String device_username, String device_password, double device_longitude, double device_latitude) {
|
public static String get_device_registration_json(String internal_ip_address, String external_ip_address, int external_access_port, String os_family, String os_architecture, int os_version, int cpu_cores, int ram_gb, int disk_gb, String device_name,String provider_id, String city_name, String country_name, String device_username, String device_password, String private_key, double device_longitude, double device_latitude) {
|
||||||
|
|
||||||
JSONObject root_json_object = new JSONObject();
|
JSONObject root_json_object = new JSONObject();
|
||||||
JSONObject loginCredential = new JSONObject();
|
JSONObject loginCredential = new JSONObject();
|
||||||
@ -154,7 +154,7 @@ public class SALCommunicator {
|
|||||||
|
|
||||||
loginCredential.put("username", device_username);
|
loginCredential.put("username", device_username);
|
||||||
loginCredential.put("password", device_password);
|
loginCredential.put("password", device_password);
|
||||||
loginCredential.put("privateKey", "");
|
loginCredential.put("privateKey", private_key);
|
||||||
|
|
||||||
|
|
||||||
ipAddress1.put("IpAddressType", "PUBLIC_IP");
|
ipAddress1.put("IpAddressType", "PUBLIC_IP");
|
||||||
@ -166,9 +166,9 @@ public class SALCommunicator {
|
|||||||
ipAddress2.put("value", internal_ip_address);
|
ipAddress2.put("value", internal_ip_address);
|
||||||
|
|
||||||
|
|
||||||
operatingSystem.put("operatingSystemFamily", "UBUNTU");
|
operatingSystem.put("operatingSystemFamily", os_family);
|
||||||
operatingSystem.put("operatingSystemArchitecture", "ARMv8");
|
operatingSystem.put("operatingSystemArchitecture", os_architecture);
|
||||||
operatingSystem.put("operatingSystemVersion", 2204);
|
operatingSystem.put("operatingSystemVersion", os_version);
|
||||||
|
|
||||||
geoLocation.put("city", city_name);
|
geoLocation.put("city", city_name);
|
||||||
geoLocation.put("country", country_name);
|
geoLocation.put("country", country_name);
|
||||||
@ -184,6 +184,7 @@ public class SALCommunicator {
|
|||||||
|
|
||||||
root_json_object.put("name", device_name);
|
root_json_object.put("name", device_name);
|
||||||
root_json_object.put("loginCredential", loginCredential);
|
root_json_object.put("loginCredential", loginCredential);
|
||||||
|
root_json_object.put("port", external_access_port);
|
||||||
|
|
||||||
JSONArray ipAddresses = new JSONArray();
|
JSONArray ipAddresses = new JSONArray();
|
||||||
ipAddresses.add(ipAddress1);
|
ipAddresses.add(ipAddress1);
|
||||||
@ -191,7 +192,7 @@ public class SALCommunicator {
|
|||||||
root_json_object.put("ipAddresses", ipAddresses);
|
root_json_object.put("ipAddresses", ipAddresses);
|
||||||
|
|
||||||
root_json_object.put("nodeProperties", nodeProperties);
|
root_json_object.put("nodeProperties", nodeProperties);
|
||||||
root_json_object.put("systemArch", "ARMv8");
|
root_json_object.put("systemArch", os_architecture); //TODO refine - for now assuming that the architecture of the device is the same as that of the OS installed on top of it, could be a wrong assumption
|
||||||
root_json_object.put("scriptURL", "https://www.google.com");
|
root_json_object.put("scriptURL", "https://www.google.com");
|
||||||
root_json_object.put("jarURL", "https://www.activeeon.com/public_content/7cde3381417ff3784639dc41fa7e7cd0544a5234-morphemic-7bulls/node_13.1.0-SNAPSHOT_armv8.jar");
|
root_json_object.put("jarURL", "https://www.activeeon.com/public_content/7cde3381417ff3784639dc41fa7e7cd0544a5234-morphemic-7bulls/node_13.1.0-SNAPSHOT_armv8.jar");
|
||||||
|
|
||||||
|
@ -35,12 +35,12 @@ public class SynchronousBrokerPublisher {
|
|||||||
HashSet<String> topics_to_publish_to = new HashSet<>();
|
HashSet<String> topics_to_publish_to = new HashSet<>();
|
||||||
topics_to_publish_to.add(topic);
|
topics_to_publish_to.add(topic);
|
||||||
broker_and_topics_to_publish_to.put(broker_ip,topics_to_publish_to);
|
broker_and_topics_to_publish_to.put(broker_ip,topics_to_publish_to);
|
||||||
log.error("changed1");
|
//log.error("changed1");
|
||||||
publisher_configuration_changed = true;
|
publisher_configuration_changed = true;
|
||||||
}else{
|
}else{
|
||||||
if (!broker_and_topics_to_publish_to.get(broker_ip).contains(topic)){
|
if (!broker_and_topics_to_publish_to.get(broker_ip).contains(topic)){
|
||||||
broker_and_topics_to_publish_to.get(broker_ip).add(topic);
|
broker_and_topics_to_publish_to.get(broker_ip).add(topic);
|
||||||
log.error("changed2");
|
//log.error("changed2");
|
||||||
publisher_configuration_changed = true;
|
publisher_configuration_changed = true;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
@ -48,9 +48,9 @@ public class SynchronousBrokerPublisher {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
log.error("preliminary_outside");
|
//log.error("preliminary_outside");
|
||||||
if (publisher_configuration_changed){
|
if (publisher_configuration_changed){
|
||||||
log.error("preliminary_inside1");
|
//log.error("preliminary_inside1");
|
||||||
// for (String current_broker_ip : broker_and_topics_to_publish_to.keySet()){
|
// for (String current_broker_ip : broker_and_topics_to_publish_to.keySet()){
|
||||||
log.info("Publisher configuration changed, creating new connector at "+broker_ip+" for topic "+topic);
|
log.info("Publisher configuration changed, creating new connector at "+broker_ip+" for topic "+topic);
|
||||||
if (active_connector!=null) {
|
if (active_connector!=null) {
|
||||||
@ -58,7 +58,7 @@ public class SynchronousBrokerPublisher {
|
|||||||
}
|
}
|
||||||
publishers.clear();
|
publishers.clear();
|
||||||
for (String broker_topic : broker_and_topics_to_publish_to.get(broker_ip)){
|
for (String broker_topic : broker_and_topics_to_publish_to.get(broker_ip)){
|
||||||
log.error("preliminary_inside2");
|
//log.error("preliminary_inside2");
|
||||||
//ArrayList<Publisher> publishers = new ArrayList<>();
|
//ArrayList<Publisher> publishers = new ArrayList<>();
|
||||||
SyncedPublisher publisher = new SyncedPublisher("resource_manager_"+broker_topic, broker_topic, true, true);
|
SyncedPublisher publisher = new SyncedPublisher("resource_manager_"+broker_topic, broker_topic, true, true);
|
||||||
publishers.add(publisher);
|
publishers.add(publisher);
|
||||||
|
@ -72,6 +72,11 @@ public class SALRegistrationService implements InitializingBean {
|
|||||||
String city_name = ""; //TODO improve this
|
String city_name = ""; //TODO improve this
|
||||||
String country_name = ""; //TODO improve this
|
String country_name = ""; //TODO improve this
|
||||||
String internal_ip = ""; //TODO improve this
|
String internal_ip = ""; //TODO improve this
|
||||||
|
String os_family = "UBUNTU"; //TODO improve this
|
||||||
|
String os_architecture = "ARMv8"; //TODO improve this
|
||||||
|
int os_version = 2204; //TODO improve this
|
||||||
|
String private_key = ""; //TODO improve this
|
||||||
|
int external_access_port = device.getPort();
|
||||||
double device_longitude = 0,device_latitude =0;
|
double device_longitude = 0,device_latitude =0;
|
||||||
if (device.getLocation()!=null){
|
if (device.getLocation()!=null){
|
||||||
String location_name = "";
|
String location_name = "";
|
||||||
@ -94,7 +99,8 @@ public class SALRegistrationService implements InitializingBean {
|
|||||||
//register_device_message.put("device_name",device_name);
|
//register_device_message.put("device_name",device_name);
|
||||||
//register_device_message.put("timestamp",(int)(clock.millis()/1000));
|
//register_device_message.put("timestamp",(int)(clock.millis()/1000));
|
||||||
|
|
||||||
String register_device_message_string = get_device_registration_json(internal_ip,external_ip_address,cores,ram_gb,disk_gb,device_name,provider_id,city_name,country_name, device_username, device_password,device_longitude, device_latitude);
|
|
||||||
|
String register_device_message_string = get_device_registration_json(internal_ip,external_ip_address,external_access_port,os_family,os_architecture,os_version,cores,ram_gb,disk_gb,device_name,provider_id,city_name,country_name, device_username, device_password,private_key,device_longitude, device_latitude);
|
||||||
log.info("topic is {}", get_registration_topic_name(application_name));
|
log.info("topic is {}", get_registration_topic_name(application_name));
|
||||||
log.info("broker ip is {}", processorProperties.getNebulous_broker_ip_address());
|
log.info("broker ip is {}", processorProperties.getNebulous_broker_ip_address());
|
||||||
log.info("broker port is {}", processorProperties.getNebulous_broker_port());
|
log.info("broker port is {}", processorProperties.getNebulous_broker_port());
|
||||||
@ -106,7 +112,7 @@ public class SALRegistrationService implements InitializingBean {
|
|||||||
SynchronousBrokerPublisher register_device_publisher = new SynchronousBrokerPublisher(get_registration_topic_name(application_name), processorProperties.getNebulous_broker_ip_address(),processorProperties.getNebulous_broker_port(), processorProperties.getNebulous_broker_username(), processorProperties.getNebulous_broker_password(), "");
|
SynchronousBrokerPublisher register_device_publisher = new SynchronousBrokerPublisher(get_registration_topic_name(application_name), processorProperties.getNebulous_broker_ip_address(),processorProperties.getNebulous_broker_port(), processorProperties.getNebulous_broker_username(), processorProperties.getNebulous_broker_password(), "");
|
||||||
//TODO handle the response here
|
//TODO handle the response here
|
||||||
Map response = register_device_publisher.publish_for_response(register_device_message_string, Collections.singleton(application_name));
|
Map response = register_device_publisher.publish_for_response(register_device_message_string, Collections.singleton(application_name));
|
||||||
log.info("The response received while trying to register device " + device_name);
|
log.info("The response received while trying to register device " + device_name + " is "+response.toString());
|
||||||
//}
|
//}
|
||||||
|
|
||||||
/* This is some realtime information, could be retrieved with a different call to the EMS.
|
/* This is some realtime information, could be retrieved with a different call to the EMS.
|
||||||
|
Loading…
Reference in New Issue
Block a user