Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {

allprojects {
group = 'org.eclipse'
version = '3.6.0'
version = '3.7.0'
}

subprojects {
Expand Down
4 changes: 2 additions & 2 deletions iofog-agent-daemon/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ dependencies {
implementation 'org.junit.jupiter:junit-jupiter-api:5.10.0'
implementation 'com.github.oshi:oshi-core:6.8.1'
implementation 'org.slf4j:slf4j-nop:2.0.16'
implementation 'org.apache.qpid:qpid-jms-client:2.6.0'
implementation 'jakarta.jms:jakarta.jms-api:3.1.0'
// implementation 'org.apache.qpid:qpid-jms-client:2.6.0'
// implementation 'jakarta.jms:jakarta.jms-api:3.1.0'
implementation 'jakarta.json:jakarta.json-api:2.1.3'
implementation 'org.eclipse.parsson:parsson:1.1.7'
implementation 'com.nimbusds:nimbus-jose-jwt:9.37.3'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,12 @@ public enum CommandLineConfigParam {
POST_DIAGNOSTICS_FREQ ("10", "df", "post_diagnostics_freq", "postdiagnosticsfreq"),
ARCH ("auto", "ft", "arch", ""),
SECURE_MODE ("off", "sec", "secure_mode", ""),
ROUTER_HOST ("", "", "router_host", "routerHost"),
ROUTER_PORT ("0", "", "router_port", "routerPort"),
DOCKER_PRUNING_FREQUENCY ("1", "pf", "docker_pruning_freq", "dockerPruningFrequency"),
AVAILABLE_DISK_THRESHOLD ("20", "dt", "available_disk_threshold", "availableDiskThreshold"),
READY_TO_UPGRADE_SCAN_FREQUENCY ("24", "uf", "upgrade_scan_frequency", "readyToUpgradeScanFrequency"),
DEV_MODE ("off", "dev", "dev_mode", ""),
TIME_ZONE("", "tz", "time_zone", "timeZone"),
NAMESPACE("default", "", "namespace", "namespace"),
CA_CERT("", "", "ca_cert", "caCert"),
TLS_CERT("", "", "tls_cert", "tlsCert"),
TLS_KEY("", "", "tls_key", "tlsKey"),
HW_SIGNATURE("", "", "hw_signature", "hwSignature");

private final String commandName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import org.eclipse.iofog.exception.AgentUserException;
import org.eclipse.iofog.field_agent.enums.RequestType;
import org.eclipse.iofog.local_api.LocalApi;
import org.eclipse.iofog.message_bus.MessageBus;
import org.eclipse.iofog.microservice.*;
import org.eclipse.iofog.network.IOFogNetworkInterfaceManager;
import org.eclipse.iofog.process_manager.ProcessManager;
Expand Down Expand Up @@ -167,10 +166,6 @@ private JsonObject getFogStatus() {
"UNKNOWN" : IOFogNetworkInterfaceManager.getInstance().getCurrentIpAddress())
.add("ipAddressExternal", Configuration.getIpAddressExternal() == null ?
"UNKNOWN" : Configuration.getIpAddressExternal())
.add("processedMessages", StatusReporter.getMessageBusStatus().getProcessedMessages())
.add("microserviceMessageCounts", StatusReporter.getMessageBusStatus().getJsonPublishedMessagesPerMicroservice() == null ?
"UNKNOWN" : StatusReporter.getMessageBusStatus().getJsonPublishedMessagesPerMicroservice())
.add("messageSpeed", StatusReporter.getMessageBusStatus().getAverageSpeed())
.add("lastCommandTime", StatusReporter.getFieldAgentStatus().getLastCommandTime())
.add("tunnelStatus", StatusReporter.getSshManagerStatus().getJsonProxyStatus() == null ?
"UNKNOWN" : StatusReporter.getSshManagerStatus().getJsonProxyStatus())
Expand Down Expand Up @@ -400,14 +395,12 @@ private final Future<Boolean> processChanges(JsonObject changes) {
loadVolumeMounts();
}
if (changes.getBoolean("microserviceConfig",false) || changes.getBoolean("microserviceList",false) ||
changes.getBoolean("routing",false) || changes.getBoolean("execSessions",false) || initialization) {
changes.getBoolean("execSessions",false) || initialization) {
logDebug("Processing microservice related changes - microserviceConfig: " + changes.getBoolean("microserviceConfig",false) +
", microserviceList: " + changes.getBoolean("microserviceList",false) +
", routing: " + changes.getBoolean("routing",false) +
", execSessions: " + changes.getBoolean("execSessions",false));
logDebug("Changes object structure: " + changes.toString());
boolean microserviceConfig = changes.getBoolean("microserviceConfig");
boolean routing = changes.getBoolean("routing");
boolean execSessions = changes.getBoolean("execSessions");
int defaultFreq = Configuration.getStatusFrequency();
Configuration.setStatusFrequency(1);
Expand All @@ -426,19 +419,6 @@ private final Future<Boolean> processChanges(JsonObject changes) {
}
}

if (routing) {
logDebug("Processing routing changes");
try {
processRoutes(microservices);
if (!changes.getBoolean("routerChanged",false) || initialization) {
MessageBus.getInstance().update();
}
} catch (Exception e) {
logError("Unable to update microservices routes", e);
resetChanges = false;
}
}

// Notify ProcessManager to immediately restart monitoring thread
// This ensures containers are processed without waiting for the next scheduled interval
ProcessManager.getInstance().update();
Expand Down Expand Up @@ -478,15 +458,6 @@ private final Future<Boolean> processChanges(JsonObject changes) {
resetChanges = false;
}
}
if (changes.getBoolean("routerChanged",false) && !initialization) {
logDebug("Processing routerChanged change");
try {
MessageBus.getInstance().update();
} catch (Exception e) {
logError("Unable to update router info", e);
resetChanges = false;
}
}
if (changes.getBoolean("linkedEdgeResources",false) && !initialization) {
logDebug("Processing linkedEdgeResources change");
boolean linkedEdgeResources = changes.getBoolean("linkedEdgeResources");
Expand Down Expand Up @@ -905,31 +876,6 @@ private void processMicroserviceConfig(List<Microservice> microservices) {
logDebug("Finished process microservice configuration");
}

/**
* gets list of Microservice routings from file or IOFog controller
*/
private void processRoutes(List<Microservice> microservices) {
Map<String, Route> routes = new HashMap<>();
for (Microservice microservice : microservices) {
List<String> jsonRoutes = microservice.getRoutes();
if (jsonRoutes == null || jsonRoutes.size() == 0) {
continue;
}

String microserviceUuid = microservice.getMicroserviceUuid();
Route microserviceRoute = new Route();

for (String jsonRoute : jsonRoutes) {
microserviceRoute.getReceivers().add(jsonRoute);
}

routes.put(microserviceUuid, microserviceRoute);
}

microserviceManager.setRoutes(routes);
logDebug("Finished process routes");
}

private JsonArray loadMicroservicesJsonFile() {
String filename = MICROSERVICE_FILE;
JsonArray microservicesJson = readFile(filesPath + filename);
Expand Down Expand Up @@ -1021,7 +967,7 @@ private List<String> getStringList(JsonValue jsonValue) {

private Function<JsonObject, Microservice> containerJsonObjectToMicroserviceFunction() {
return jsonObj -> {
Microservice microservice = new Microservice(jsonObj.getString("uuid"), jsonObj.getString("imageId"));
Microservice microservice = new Microservice(jsonObj.getString("uuid"), jsonObj.getString("imageId"), jsonObj.getString("name"), jsonObj.getString("application"));
microservice.setConfig(jsonObj.getString("config"));
if (!jsonObj.isNull("runAsUser")) {
microservice.setRunAsUser(jsonObj.getString("runAsUser"));
Expand All @@ -1042,11 +988,8 @@ private Function<JsonObject, Microservice> containerJsonObjectToMicroserviceFunc
microservice.setDelete(jsonObj.getBoolean("delete"));
microservice.setDeleteWithCleanup(jsonObj.getBoolean("deleteWithCleanup"));

JsonValue routesValue = jsonObj.get("routes");
microservice.setRoutes(getStringList(routesValue));

microservice.setConsumer(jsonObj.getBoolean("isConsumer"));
microservice.setRouter(jsonObj.getBoolean("isRouter"));
microservice.setNats(jsonObj.getBoolean("isNats"));
if (jsonObj.getBoolean("isRouter")) {
Configuration.setRouterUuid(jsonObj.getString("uuid"));
Configuration.setRouterInterior(jsonObj.getBoolean("hostNetworkMode"));
Expand Down Expand Up @@ -1778,11 +1721,6 @@ private JsonObject buildProvisionFailResponse(String message, Exception e) {
*/
private void notifyModules() {
logInfo("Notifying modules for configuration update");
try {
MessageBus.getInstance().update();
} catch (Exception e) {
logWarning("Unable to update Message Bus" + " : " + e.getMessage());
}
LocalApi.getInstance().update();
ProcessManager.getInstance().update();
}
Expand Down Expand Up @@ -1870,9 +1808,9 @@ public String deProvision(boolean isTokenExpired) {
// Clear microservice manager
microserviceManager.clear();

// Stop running microservices
// Stop and remove all agent containers (and volumes) so no sensitive data remains
try {
ProcessManager.getInstance().stopRunningMicroservices(false, iofogUuid);
ProcessManager.getInstance().stopRunningMicroservices(true, iofogUuid);
} catch (Exception e) {
logError("Error stopping running microservices",
new AgentSystemException(e.getMessage(), e));
Expand Down Expand Up @@ -1984,7 +1922,6 @@ public void start() {
loadVolumeMounts();
List<Microservice> microservices = loadMicroservices(!isConnected);
processMicroserviceConfig(microservices);
processRoutes(microservices);
// Notify ProcessManager to immediately restart monitoring thread
// This ensures containers are processed during initialization without waiting
ProcessManager.getInstance().update();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public void run() {
StatusReporter.setSupervisorStatus().setModuleStatus(Constants.LOCAL_API, ModulesStatus.STARTING);

StatusReporter.setLocalApiStatus().setOpenConfigSocketsCount(WebSocketMap.controlWebsocketMap.size());
StatusReporter.setLocalApiStatus().setOpenMessageSocketsCount(WebSocketMap.messageWebsocketMap.size());
StatusReporter.setLocalApiStatus().setOpenMessageSocketsCount(0);
retrieveContainerConfig();

server = new LocalApiServer();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ public void start() throws Exception {

ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
scheduler.scheduleAtFixedRate(new ControlWebsocketWorker(), 10, 10, TimeUnit.SECONDS);
scheduler.scheduleAtFixedRate(new MessageWebsocketWorker(), 10, 10, TimeUnit.SECONDS);
ch.closeFuture().sync();
}finally{
bossGroup.shutdownGracefully();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,6 @@ public void channelRead0(ChannelHandlerContext ctx, Object msg) {
if (mapName != null && mapName.equals("control")) {
ControlWebsocketHandler controlSocket = new ControlWebsocketHandler();
controlSocket.handleWebSocketFrame(ctx, (WebSocketFrame) msg);
} else if (mapName != null && mapName.equals("message")) {
MessageWebsocketHandler messageSocket = new MessageWebsocketHandler();
messageSocket.handleWebSocketFrame(ctx, (WebSocketFrame) msg);
} else {
LoggingService.logError(MODULE_NAME, "Cannot initiate real-time service: Context not found",
new AgentSystemException("Cannot initiate real-time service: Context not found"));
Expand Down Expand Up @@ -156,30 +153,6 @@ private void handleHttpRequest(ChannelHandlerContext ctx) {
return;
}

if (request.uri().equals("/v2/messages/next")) {
LoggingService.logInfo(MODULE_NAME, "Start Processing messages/next request");
Callable<FullHttpResponse> callable = new MessageReceiverHandler(request, ctx.alloc().buffer(), content);
runTask(callable, ctx, request);
LoggingService.logInfo(MODULE_NAME, "Finished Processing messages/next request");
return;
}

if (request.uri().equals("/v2/messages/new")) {
LoggingService.logInfo(MODULE_NAME, "Start Processing messages/new request");
Callable<FullHttpResponse> callable = new MessageSenderHandler(request, ctx.alloc().buffer(), content);
runTask(callable, ctx, request);
LoggingService.logInfo(MODULE_NAME, "Finished Processing messages/new request");
return;
}

if (request.uri().equals("/v2/messages/query")) {
LoggingService.logInfo(MODULE_NAME, "Start Processing messages/query request");
Callable<FullHttpResponse> callable = new QueryMessageReceiverHandler(request, ctx.alloc().buffer(), content);
runTask(callable, ctx, request);
LoggingService.logInfo(MODULE_NAME, "Finished Processing messages/query request");
return;
}

if (request.uri().startsWith("/v2/restblue")) {
LoggingService.logInfo(MODULE_NAME, "Start Processing restblue request");
Callable<FullHttpResponse> callable = new BluetoothApiHandler((FullHttpRequest) request, ctx.alloc().buffer(), content);
Expand Down Expand Up @@ -220,14 +193,6 @@ private void handleHttpRequest(ChannelHandlerContext ctx) {
return;
}

if (request.uri().startsWith("/v2/message/socket")) {
LoggingService.logInfo(MODULE_NAME, "Start Processing message/socket request");
MessageWebsocketHandler messageSocket = new MessageWebsocketHandler();
messageSocket.handle(ctx, request);
LoggingService.logInfo(MODULE_NAME, "finished Processing message/socket request");
return;
}

if (request.uri().startsWith("/v2/config")) {
LoggingService.logInfo(MODULE_NAME, "Start Processing config request");
Callable<FullHttpResponse> callable = new ConfigApiHandler(request, ctx.alloc().buffer(), content);
Expand Down Expand Up @@ -294,21 +259,12 @@ private void handleHttpRequest(ChannelHandlerContext ctx) {
}

private String findContextMapName(ChannelHandlerContext ctx) {

if (WebsocketUtil.hasContextInMap(ctx, WebSocketMap.controlWebsocketMap)) {
LoggingService.logDebug(MODULE_NAME, "Context map name : control");
return "control";
}
else if (WebsocketUtil.hasContextInMap(ctx, WebSocketMap.messageWebsocketMap)) {
LoggingService.logDebug(MODULE_NAME, "Context map name : message");
return "message";
}

else {
LoggingService.logDebug(MODULE_NAME, "Context map name : null");
return null;
}

LoggingService.logDebug(MODULE_NAME, "Context map name : null");
return null;
}

/**
Expand Down

This file was deleted.

Loading
Loading