Skip to content

Commit

Permalink
Release 1.0.7 (#170)
Browse files Browse the repository at this point in the history
* fixed default controller url (#116)

* 1.0.1 (#118)

* fixed default controller url

* 1.0.1 version

* EWC-292 fixed iofog-agent info controller status when access token is expired/invalid

* build for dev env added

* fix travis

* renaming client (#120)

* renaming client

* 1.0.2

* adding dev packages

* invalid error message during provision (#122)

* invalid error message during provision

* invalid error message during provision

* update build packages

* Epankou/feature microservice removal ewc 306 (#123)

* invalid error message during provision

* invalid error message during provision

* microservice removal

* microservice removal EWC-306

* microservice removal EWC-306

* microservice removal EWC-306

* microservice removal EWC-306

* microservice removal EWC-306

* EWC-336 added default device scan frequency value & update error message

* EWC-335 fixed config logging parameters validation (#125)

* EWC-335 fixed config logging parameters validation

* additional warning messages

* microservice update fix (#126)

* WIP:  EWC-345 add notifications (#127)

* add notifications to channel

* Update .travis.yml

* Update .travis.yml

* Update .travis.yml

* Update .travis.yml

* Update .travis.yml

* 1.0.3 version (#129)

* EWC-366 now deprovision works if agent hasn't connection to controller (#132)

* EWC-359 controller status renaming ok -> online (#133)

* Update HornetQ version

* Fix `isolated_docker_container` configuration

* EWC-375 config switcher

* cleanup

* EWC-375 config switcher import fix

* EWC-375 fixed help for iofog-agent client

* updating config switcher

* iofog agent os group fix

* version 1.0.4 (#139)

* remove preprod env

* Update "HttpMime" version (#142)

* update version to 1.0.5 (#143)

* update version to 1.0.5

* update version to 1.0.5 (#146)

* fix(config): validation for watchdog config param

only on and off now available

Closes EWC-407

* Dbusel/feature ewc 398 auto release (#148)

* test GH release automation

* edit build condition to build

* edit travis file to enable build

* fix syntax error in build file

* enable release on all branches to test

* fix allowing deploy stage

* fix tag name

* add autorelease for master branch

* fix(bug) fixed log disk size validation (EWC-335) (#149)

* fix(bug) fixed log disk size validation (EWC-335)

* cleanup

* fix(bug) fixed certificate exception message (EWC-402) (#150)

* fix(bug) stopping agent process while reinstalling iofog-agent (EWC-405) (#151)

* fix(bug) stopping agent process while reinstalling iofog-agent (EWC-405)

* iofog-agent > iofog-agentd process in order to avoid install process of iofog-agent package

* fix(bug) fixed iofog-agent controller connection status (EWC-415)

* add build stage for release branch (#154)

* fix build for release branch (#155)

* add build stage for release branch

* rename build stage for master branch

* Pre-release 1.0.6 (#159)

* add build stage for release branch

* rename build stage for master branch

* remove additional mvn build on stages

* feat(core) version placeholder (EWC-410)

* bug(fix) updated docker url validation (EWC-412) (#157)

* version 1.0.6

* 1.0.7 Release

* add build stage for release branch

* rename build stage for master branch

* remove additional mvn build on stages

* feat(core) version placeholder (EWC-410)

* bug(fix) updated docker url validation (EWC-412) (#157)

* version 1.0.6

* EWC-410 version placeholder

* EWC-414 watchdog feature fix

* bug(core) fixed strace request (#162)

* EWC-421 strace feature bug

* EWC-421 strace feature fix

* Bug(fix) message bug: concurrent usage of session object which isn't thread safe (EWC-433)

* bug(fix) fixed help logs measurement (EWC-431) (#166)

* bug(fix) microservice removal: networking microservice isn't removed (EWC-424)

* Bug(fix) microservice removal: removed extra host mapping (EWC-424)

* Bug(fix) microservice removal: simplified getRunningContainers method (EWC-424)

* version 1.0.7
  • Loading branch information
Railag authored and dbusel committed Dec 21, 2018
1 parent 321e7e6 commit 3879314
Show file tree
Hide file tree
Showing 22 changed files with 333 additions and 229 deletions.
2 changes: 1 addition & 1 deletion client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<parent>
<groupId>org.eclipse</groupId>
<artifactId>iofog-agent</artifactId>
<version>1.0.6</version>
<version>1.0.7</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion client/src/org/eclipse/iofog/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ private static String showHelp() {
" -n <network adapter> Set the name of the network adapter\n" +
" that holds the correct IP address of \n" +
" this machine\n" +
" -l <#MB Limit> Set the limit, in MiB, of disk space\n" +
" -l <#GB Limit> Set the limit, in GiB, of disk space\n" +
" that the log files can consume\n" +
" -ld <dir> Set the directory to use for log file\n" +
" storage\n" +
Expand Down
2 changes: 1 addition & 1 deletion daemon/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<parent>
<groupId>org.eclipse</groupId>
<artifactId>iofog-agent</artifactId>
<version>1.0.6</version>
<version>1.0.7</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ private static String showHelp() {
" -n <network adapter> Set the name of the network adapter\\n" +
" that holds the correct IP address of \\n" +
" this machine\\n" +
" -l <#MB Limit> Set the limit, in MiB, of disk space\\n" +
" -l <#GB Limit> Set the limit, in GiB, of disk space\\n" +
" that the log files can consume\\n" +
" -ld <dir> Set the directory to use for log file\\n" +
" storage\\n" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ public AtomicBoolean getStraceRun() {
return straceRun;
}

public void setStraceRun(boolean straceRun) {
this.straceRun.set(straceRun);
}

@Override
public String toString() {
return "MicroserviceStraceData{" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,46 +56,49 @@ public void updateMonitoringMicroservices(JsonObject diagnosticData) {
JsonArray straceMicroserviceChanges = diagnosticData.getJsonArray("straceValues");
for (JsonValue microserviceValue : straceMicroserviceChanges) {
JsonObject microservice = (JsonObject) microserviceValue;
if (microservice.containsKey("microserviceId")) {
String microserviceUuid = microservice.getString("microserviceId");
boolean strace = microservice.getInt("straceRun", 0) != 0;
if (microservice.containsKey("microserviceUuid")) {
String microserviceUuid = microservice.getString("microserviceUuid");
boolean strace = microservice.getBoolean("straceRun");
manageMicroservice(microserviceUuid, strace);
}
}
}
}

private void manageMicroservice(String microserviceUuid, boolean strace) {
Optional<MicroserviceStraceData> microserviceOptional = getDataByMicroserviceUuid(microserviceUuid);
if (microserviceOptional.isPresent() && !strace) {
offDiagnosticMicroservice(microserviceOptional.get());
} else if (!microserviceOptional.isPresent() && strace) {
createAndRunDiagnosticMicroservice(microserviceUuid);
}
if (strace) {
enableMicroserviceStraceDiagnostics(microserviceUuid);
} else {
disableMicroserviceStraceDiagnostics(microserviceUuid);
}
}

private Optional<MicroserviceStraceData> getStraceDataByMicroserviceUuid(String microserviceUuid) {
return this.monitoringMicroservices.stream()
.filter(microservice -> microservice.getMicroserviceUuid().equals(microserviceUuid))
.findFirst();
}

private void createAndRunDiagnosticMicroservice(String microserviceUuid) {
public void enableMicroserviceStraceDiagnostics(String microserviceUuid) {
try {
int pid = getPidByMicroserviceUuid(microserviceUuid);
MicroserviceStraceData microserviceStraceData = new MicroserviceStraceData(microserviceUuid, pid, true);
this.monitoringMicroservices.add(microserviceStraceData);

runStrace(microserviceStraceData);
MicroserviceStraceData newMicroserviceStraceData = new MicroserviceStraceData(microserviceUuid, pid, true);
this.monitoringMicroservices.removeIf(
oldMicroserviceStraceData -> oldMicroserviceStraceData.getMicroserviceUuid().equals(microserviceUuid)
);
this.monitoringMicroservices.add(newMicroserviceStraceData);
runStrace(newMicroserviceStraceData);
} catch (IllegalArgumentException e) {
logWarning(MODULE_NAME, "Can't get pid of process");
}
}

private void offDiagnosticMicroservice(MicroserviceStraceData microserviceStraceData) {
microserviceStraceData.getStraceRun().set(false);
this.monitoringMicroservices.remove(microserviceStraceData);
}

public Optional<MicroserviceStraceData> getDataByMicroserviceUuid(String microserviceUuid) {
return this.monitoringMicroservices.stream()
.filter(microservice -> microservice.getMicroserviceUuid().equals(microserviceUuid))
.findFirst();
}
}

public void disableMicroserviceStraceDiagnostics(String microserviceUuid) {
getStraceDataByMicroserviceUuid(microserviceUuid).ifPresent(microserviceStraceData -> {
microserviceStraceData.setStraceRun(false);
this.monitoringMicroservices.remove(microserviceStraceData);
});
}

private int getPidByMicroserviceUuid(String microserviceUuid) throws IllegalArgumentException {
CommandShellResultSet<List<String>, List<String>> resultSet = CommandShellExecutor.executeCommand("docker top " + microserviceUuid);
Expand Down
35 changes: 23 additions & 12 deletions daemon/src/org/eclipse/iofog/field_agent/FieldAgent.java
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,13 @@ private JsonObject getFogStatus() {
return json;
}

/**
* executes actions after successful status post request
*/
private void onPostStatusSuccess() {
StatusReporter.getProcessManagerStatus().removeNotRunningMicroserviceStatus();
}

/**
* checks if IOFog is not provisioned
*
Expand Down Expand Up @@ -173,7 +180,7 @@ private boolean notProvisioned() {

logInfo("sending IOFog status...");
orchestrator.request("status", RequestType.PUT, null, status);

onPostStatusSuccess();
} catch (CertificateException | SSLHandshakeException e) {
verificationFailed();
} catch (ForbiddenException e) {
Expand All @@ -187,26 +194,30 @@ private boolean notProvisioned() {
private final Runnable postDiagnostics = () -> {
while (true) {
if (StraceDiagnosticManger.getInstance().getMonitoringMicroservices().size() > 0) {
JsonObjectBuilder builder = Json.createObjectBuilder();
JsonBuilderFactory factory = Json.createBuilderFactory(null);
JsonArrayBuilder arrayBuilder = factory.createArrayBuilder();

for (MicroserviceStraceData microservice : StraceDiagnosticManger.getInstance().getMonitoringMicroservices()) {
builder.add(microservice.getMicroserviceUuid(), microservice.getResultBufferAsString());
arrayBuilder.add(factory.createObjectBuilder()
.add("microserviceUuid", microservice.getMicroserviceUuid())
.add("buffer", microservice.getResultBufferAsString())
);
microservice.getResultBuffer().clear();
}

builder.add("timestamp", new Date().getTime());
JsonObject json = builder.build();
JsonObject json = factory.createObjectBuilder()
.add("straceData", arrayBuilder).build();

try {
orchestrator.request("strace", RequestType.PUT, null, json);
} catch (Exception e) {
logWarning("unable send strace logs : " + e.getMessage());
}
} else {

try {
Thread.sleep(Configuration.getPostDiagnosticsFreq() * 1000);
} catch (InterruptedException e) {
e.printStackTrace();
logWarning(e.getMessage());
}
}
}
Expand Down Expand Up @@ -356,7 +367,7 @@ private void changeVersion() {
}

private void updateDiagnostics() {
LoggingService.logInfo(MODULE_NAME, "get changes is diagnostic list");
LoggingService.logInfo(MODULE_NAME, "getting changes for diagnostics");
if (notProvisioned() || !isControllerConnected(false)) {
return;
}
Expand Down Expand Up @@ -449,14 +460,14 @@ private void processRoutes(List<Microservice> microservices) {
continue;
}

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

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

routes.put(microserviceId, microserviceRoute);
routes.put(microserviceUuid, microserviceRoute);
}

microserviceManager.setRoutes(routes);
Expand Down Expand Up @@ -762,7 +773,7 @@ private void getFogConfig() {
instanceConfig.put(DEVICE_SCAN_FREQUENCY.getCommandName(), deviceScanFrequency);

if (Configuration.isWatchdogEnabled() != watchdogEnabled)
instanceConfig.put(WATCHDOG_ENABLED.getCommandName(), watchdogEnabled);
instanceConfig.put(WATCHDOG_ENABLED.getCommandName(), watchdogEnabled ? "on" : "off");

if (!Configuration.getGpsCoordinates().equals(gpsCoordinates)) {
instanceConfig.put(GPS_COORDINATES.getCommandName(), gpsCoordinates);
Expand Down Expand Up @@ -922,7 +933,7 @@ public String deProvision() {
if (notProvisioned()) {
return "\nFailure - not provisioned";
}

//// TODO: 20.12.18 make deprovision request to controller in order to mark related microservices as not running
StatusReporter.setFieldAgentStatus().setControllerStatus(NOT_PROVISIONED);
try {
Configuration.setIofogUuid("");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.hornetq.api.core.client.ClientMessage;
import org.hornetq.api.core.client.MessageHandler;

import static org.eclipse.iofog.message_bus.MessageBusServer.messageBusSessionLock;
import static org.eclipse.iofog.utils.logging.LoggingService.logWarning;

/**
Expand All @@ -42,7 +43,9 @@ public void onMessage(ClientMessage message) {
response.putObjectProperty("receiver", "iofog.commandline.response");

try {
MessageBusServer.getCommandlineProducer().send(response);
synchronized (messageBusSessionLock) {
MessageBusServer.getCommandlineProducer().send(response);
}
} catch (Exception exp) {
logWarning(MODULE_NAME, exp.getMessage());
}
Expand Down
67 changes: 36 additions & 31 deletions daemon/src/org/eclipse/iofog/message_bus/MessageBusServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,15 @@
*******************************************************************************/
package org.eclipse.iofog.message_bus;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import org.eclipse.iofog.microservice.Microservice;
import org.eclipse.iofog.utils.Constants;
import org.eclipse.iofog.utils.configuration.Configuration;
import org.eclipse.iofog.utils.logging.LoggingService;
import org.hornetq.api.core.HornetQException;
import org.hornetq.api.core.SimpleString;
import org.hornetq.api.core.TransportConfiguration;
import org.hornetq.api.core.client.ClientConsumer;
import org.hornetq.api.core.client.ClientMessage;
import org.hornetq.api.core.client.ClientProducer;
import org.hornetq.api.core.client.ClientSession;
import org.hornetq.api.core.client.*;
import org.hornetq.api.core.client.ClientSession.QueueQuery;
import org.hornetq.api.core.client.ClientSessionFactory;
import org.hornetq.api.core.client.HornetQClient;
import org.hornetq.api.core.client.ServerLocator;
import org.hornetq.core.config.impl.ConfigurationImpl;
import org.hornetq.core.remoting.impl.invm.InVMAcceptorFactory;
import org.hornetq.core.remoting.impl.invm.InVMConnectorFactory;
Expand All @@ -42,14 +31,20 @@
import org.hornetq.core.settings.impl.AddressFullMessagePolicy;
import org.hornetq.core.settings.impl.AddressSettings;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
* HornetQ server
*
* @author saeid
*
*/
public class MessageBusServer {


public static final Object messageBusSessionLock = new Object();
private static final String MODULE_NAME = "Message Bus Server";
private ClientSessionFactory sf;
private HornetQServer server;
Expand Down Expand Up @@ -126,21 +121,23 @@ void startServer() throws Exception {
* @throws Exception
*/
void initialize() throws Exception {
messageBusSession = sf.createSession(true, true, 0);
QueueQuery queueQuery = messageBusSession.queueQuery(new SimpleString(Constants.ADDRESS));
if (queueQuery.isExists())
messageBusSession.deleteQueue(Constants.ADDRESS);
queueQuery = messageBusSession.queueQuery(new SimpleString(Constants.COMMAND_LINE_ADDRESS));
if (queueQuery.isExists())
messageBusSession.deleteQueue(Constants.COMMAND_LINE_ADDRESS);
messageBusSession.createQueue(Constants.ADDRESS, Constants.ADDRESS, false);
messageBusSession.createQueue(Constants.COMMAND_LINE_ADDRESS, Constants.COMMAND_LINE_ADDRESS, false);
synchronized (messageBusSessionLock) {
messageBusSession = sf.createSession(true, true, 0);
QueueQuery queueQuery = messageBusSession.queueQuery(new SimpleString(Constants.ADDRESS));
if (queueQuery.isExists())
messageBusSession.deleteQueue(Constants.ADDRESS);
queueQuery = messageBusSession.queueQuery(new SimpleString(Constants.COMMAND_LINE_ADDRESS));
if (queueQuery.isExists())
messageBusSession.deleteQueue(Constants.COMMAND_LINE_ADDRESS);
messageBusSession.createQueue(Constants.ADDRESS, Constants.ADDRESS, false);
messageBusSession.createQueue(Constants.COMMAND_LINE_ADDRESS, Constants.COMMAND_LINE_ADDRESS, false);

commandlineProducer = messageBusSession.createProducer(Constants.COMMAND_LINE_ADDRESS);

commandlineConsumer = messageBusSession.createConsumer(Constants.COMMAND_LINE_ADDRESS, String.format("receiver = '%s'", "iofog.commandline.command"));
commandlineConsumer.setMessageHandler(new CommandLineHandler());
messageBusSession.start();
commandlineProducer = messageBusSession.createProducer(Constants.COMMAND_LINE_ADDRESS);

commandlineConsumer = messageBusSession.createConsumer(Constants.COMMAND_LINE_ADDRESS, String.format("receiver = '%s'", "iofog.commandline.command"));
commandlineConsumer.setMessageHandler(new CommandLineHandler());
messageBusSession.start();
}
}

/**
Expand All @@ -150,10 +147,14 @@ void initialize() throws Exception {
* @throws Exception
*/
void createCosumer(String name) throws Exception {
if (consumers == null)
if (consumers == null) {
consumers = new ConcurrentHashMap<>();
}

ClientConsumer consumer = messageBusSession.createConsumer(Constants.ADDRESS, String.format("receiver = '%s'", name));
ClientConsumer consumer;
synchronized (messageBusSessionLock) {
consumer = messageBusSession.createConsumer(Constants.ADDRESS, String.format("receiver = '%s'", name));
}
consumers.put(name, consumer);
}

Expand Down Expand Up @@ -191,9 +192,13 @@ void removeConsumer(String name) {
* @throws Exception
*/
void createProducer(String name) throws Exception {
if (producers == null)
if (producers == null) {
producers = new ConcurrentHashMap<>();
ClientProducer producer = messageBusSession.createProducer(Constants.ADDRESS);
}
ClientProducer producer;
synchronized (messageBusSessionLock) {
producer = messageBusSession.createProducer(Constants.ADDRESS);
}
producers.put(name, producer);
}

Expand Down
7 changes: 5 additions & 2 deletions daemon/src/org/eclipse/iofog/message_bus/MessageListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.hornetq.api.core.client.ClientMessage;
import org.hornetq.api.core.client.MessageHandler;

import static org.eclipse.iofog.message_bus.MessageBusServer.messageBusSessionLock;
import static org.eclipse.iofog.utils.logging.LoggingService.logWarning;

/**
Expand All @@ -36,10 +37,12 @@ public MessageListener(MessageCallback callback) {
@Override
public void onMessage(ClientMessage msg) {
try {
msg.acknowledge();
synchronized (messageBusSessionLock) {
msg.acknowledge();
}
} catch (Exception exp) {
logWarning(MODULE_NAME, exp.getMessage());}

Message message = new Message(msg.getBytesProperty("message"));
callback.sendRealtimeMessage(message);
}
Expand Down
Loading

0 comments on commit 3879314

Please sign in to comment.