Skip to content

Commit

Permalink
Release merge (#184)
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

* Release 1.0.8 (#173)

* 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

* Epankou/bug routes update ewc 374 (#171)

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

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

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

* Bug(fix) route update: added missing method for route update (EWC-374)

* version 1.0.8 (#172)

* Release merge (#180)

* 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

* Epankou/bug routes update ewc 374 (#171)

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

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

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

* Bug(fix) route update: added missing method for route update (EWC-374)

* version 1.0.8 (#172)

* update package before build on prod env

* Epankou/bug mic removal sync ewc 374 (#174)

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

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

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

* Bug(fix) route update: added missing method for route update (EWC-374)

* Bug(fix) mic removal update: added synchronization (EWC-374)

* Bug(fix) mic removal update: added synchronization (EWC-374)

* Bug(fix) mic removal update: added synchronization (EWC-374)

* Epankou/bug strace get pid ewc 421 (#176)

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

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

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

* Bug(fix) route update: added missing method for route update (EWC-374)

* Bug(fix) mic removal update: added synchronization (EWC-374)

* Bug(fix) strace: fixed method getpid (EWC-421)

* Epankou/bug strace kill orphaned processes ewc 421 (#177)

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

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

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

* Bug(fix) route update: added missing method for route update (EWC-374)

* Bug(fix) mic removal update: added synchronization (EWC-374)

* Bug(fix) mic removal update: added synchronization (EWC-374)

* Bug(fix) mic removal update: added synchronization (EWC-374)

* Bug(fix) strace: fixed method getpid (EWC-421)

* Bug(fix) strace: fixed method getpid (EWC-421)

* Bug(fix) strace: added method to kill orphaned processes (EWC-421)

* Bug(fix) strace: added method to kill orphaned processes (EWC-421)

* Upgrade/rollback issue (#178)

* update upgrade script

* update backup directory name

* update rollback script

* update upgrade script

* update rollback script

* Update upgrade.sh

* version 1.0.9 (#179)

* Merge release (#181)

* 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

* Epankou/bug routes update ewc 374 (#171)

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

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

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

* Bug(fix) route update: added missing method for route update (EWC-374)

* version 1.0.8 (#172)

* update package before build on prod env

* Epankou/bug mic removal sync ewc 374 (#174)

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

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

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

* Bug(fix) route update: added missing method for route update (EWC-374)

* Bug(fix) mic removal update: added synchronization (EWC-374)

* Bug(fix) mic removal update: added synchronization (EWC-374)

* Bug(fix) mic removal update: added synchronization (EWC-374)

* Epankou/bug strace get pid ewc 421 (#176)

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

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

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

* Bug(fix) route update: added missing method for route update (EWC-374)

* Bug(fix) mic removal update: added synchronization (EWC-374)

* Bug(fix) strace: fixed method getpid (EWC-421)

* Epankou/bug strace kill orphaned processes ewc 421 (#177)

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

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

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

* Bug(fix) route update: added missing method for route update (EWC-374)

* Bug(fix) mic removal update: added synchronization (EWC-374)

* Bug(fix) mic removal update: added synchronization (EWC-374)

* Bug(fix) mic removal update: added synchronization (EWC-374)

* Bug(fix) strace: fixed method getpid (EWC-421)

* Bug(fix) strace: fixed method getpid (EWC-421)

* Bug(fix) strace: added method to kill orphaned processes (EWC-421)

* Bug(fix) strace: added method to kill orphaned processes (EWC-421)

* Upgrade/rollback issue (#178)

* update upgrade script

* update backup directory name

* update rollback script

* update upgrade script

* update rollback script

* Update upgrade.sh

* version 1.0.9 (#179)

* Update .travis.yml

* merge release (#182)

* 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

* Epankou/bug routes update ewc 374 (#171)

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

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

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

* Bug(fix) route update: added missing method for route update (EWC-374)

* version 1.0.8 (#172)

* update package before build on prod env

* Epankou/bug mic removal sync ewc 374 (#174)

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

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

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

* Bug(fix) route update: added missing method for route update (EWC-374)

* Bug(fix) mic removal update: added synchronization (EWC-374)

* Bug(fix) mic removal update: added synchronization (EWC-374)

* Bug(fix) mic removal update: added synchronization (EWC-374)

* Epankou/bug strace get pid ewc 421 (#176)

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

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

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

* Bug(fix) route update: added missing method for route update (EWC-374)

* Bug(fix) mic removal update: added synchronization (EWC-374)

* Bug(fix) strace: fixed method getpid (EWC-421)

* Epankou/bug strace kill orphaned processes ewc 421 (#177)

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

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

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

* Bug(fix) route update: added missing method for route update (EWC-374)

* Bug(fix) mic removal update: added synchronization (EWC-374)

* Bug(fix) mic removal update: added synchronization (EWC-374)

* Bug(fix) mic removal update: added synchronization (EWC-374)

* Bug(fix) strace: fixed method getpid (EWC-421)

* Bug(fix) strace: fixed method getpid (EWC-421)

* Bug(fix) strace: added method to kill orphaned processes (EWC-421)

* Bug(fix) strace: added method to kill orphaned processes (EWC-421)

* Upgrade/rollback issue (#178)

* update upgrade script

* update backup directory name

* update rollback script

* update upgrade script

* update rollback script

* Update upgrade.sh

* version 1.0.9 (#179)

* Update .travis.yml

* Update .travis.yml
  • Loading branch information
Railag authored Jan 4, 2019
1 parent 557f587 commit 2129c07
Show file tree
Hide file tree
Showing 16 changed files with 259 additions and 210 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
- sudo apt-get install sshpass xml-twig-tools
script:
- sshpass -p $PROD_MACHINE_PASSWORD ssh -o StrictHostKeyChecking=no $PROD_MACHINE_USERNAME@$PROD_MACHINE_IP
"service iofog-agent stop"
"service iofog-agent stop; sudo apt-get install --only-upgrade -y iofog-agent"
- sshpass -p $PROD_MACHINE_PASSWORD scp -o StrictHostKeyChecking=no daemon/target/iofog-agent-daemon-jar-with-dependencies.jar
$PROD_MACHINE_USERNAME@$PROD_MACHINE_IP:/usr/bin/iofog-agentd.jar
- sshpass -p $PROD_MACHINE_PASSWORD scp -o StrictHostKeyChecking=no client/target/iofog-agent-client-jar-with-dependencies.jar
Expand Down
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.8</version>
<version>1.0.9</version>
<relativePath>../pom.xml</relativePath>
</parent>

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.8</version>
<version>1.0.9</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
243 changes: 131 additions & 112 deletions daemon/src/org/eclipse/iofog/command_line/util/CommandShellExecutor.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,116 +34,135 @@
* on 2/7/18.
*/
public class CommandShellExecutor {
private static final String MODULE_NAME = "CommandShellExecutor";
private static final String CMD = "/bin/sh";
private static final String CMD_WIN = "powershell";


public static CommandShellResultSet<List<String>, List<String>> executeCommand(String command) {
String[] fullCommand = computeCommand(command);
return execute(fullCommand);
}

public static CommandShellResultSet<List<String>, List<String>> executeScript(String script, String... args) {
String[] fullCommand = computeScript(script, args);
return execute(fullCommand);
}

public static void executeDynamicCommand(String command, CommandShellResultSet<List<String>, List<String>> resultSet, AtomicBoolean isRun) {
String[] fullCommand = computeCommand(command);
executeDynamic(fullCommand, resultSet, isRun);
}

private static CommandShellResultSet<List<String>, List<String>> execute( String[] fullCommand) {
CommandShellResultSet<List<String>, List<String>> resultSet = null;
try {
Process process = Runtime.getRuntime().exec(fullCommand);
List<String> value = readOutput(process, Process::getInputStream);
List<String> errors = readOutput(process, Process::getErrorStream);
resultSet = new CommandShellResultSet<>(value, errors);
} catch (IOException e) {
LoggingService.logWarning(MODULE_NAME, e.getMessage());
}
return resultSet;
}

private static void executeDynamic( String[] fullCommand, CommandShellResultSet<List<String>, List<String>> resultSet, AtomicBoolean isRun) {
try {
Process process = Runtime.getRuntime().exec(fullCommand);

Runnable readVal = () -> {
readOutputDynamic(process, Process::getInputStream, resultSet.getValue(), isRun);
};
new Thread(readVal).start();

Runnable readErr = () -> {
readOutputDynamic(process, Process::getErrorStream, resultSet.getError(), isRun);
};
new Thread(readErr).start();

} catch (IOException e) {
LoggingService.logWarning(MODULE_NAME, e.getMessage());
}
}


public static <V, E> CommandShellResultSet<V, E> executeCommand(String command, Function<CommandShellResultSet<List<String>, List<String>>, CommandShellResultSet<V, E>> mapper) {
return executeCommand(command).map(mapper);
}

private static String[] computeCommand(String command) {
return new String[]{
SystemUtils.IS_OS_WINDOWS ? CMD_WIN : CMD,
"-c",
command
};
}

private static String[] computeScript(String script, String... args) {
String[] command = {
SystemUtils.IS_OS_WINDOWS ? CMD_WIN : CMD,
script
};

Stream<String> s1 = Arrays.stream(command);
Stream<String> s2 = Arrays.stream(args);
return Stream.concat(s1, s2).toArray(String[]::new);
}

private static List<String> readOutput(Process process, Function<Process, InputStream> streamExtractor) throws IOException {
List<String> result = new ArrayList<>();
String line;
try (BufferedReader stdInput = new BufferedReader(new
InputStreamReader(streamExtractor.apply(process), UTF_8))) {
while ((line = stdInput.readLine()) != null) {
result.add(line);
}
}
return result;
}

private static void readOutputDynamic(Process process, Function<Process,
InputStream> streamExtractor, List<String> result,
AtomicBoolean isRun) {
String line;
if (result == null) {
return;
}
try (BufferedReader stdInput = new BufferedReader(new
InputStreamReader(streamExtractor.apply(process)))) {

while (isRun != null && isRun.get()) {
line = stdInput.readLine();
if (line != null) {
result.add(line);
} else {
Thread.sleep(3000);
}
}
} catch (InterruptedException | IOException e) {
LoggingService.logWarning(MODULE_NAME, e.getMessage());
} finally {
process.destroy();
}
}
private static final String MODULE_NAME = "CommandShellExecutor";
private static final String CMD = "/bin/sh";
private static final String CMD_WIN = "powershell";


public static CommandShellResultSet<List<String>, List<String>> executeCommand(String command) {
String[] fullCommand = computeCommand(command);
return execute(fullCommand);
}

public static CommandShellResultSet<List<String>, List<String>> executeScript(String script, String... args) {
String[] fullCommand = computeScript(script, args);
return execute(fullCommand);
}

public static void executeDynamicCommand(String command,
CommandShellResultSet<List<String>, List<String>> resultSet,
AtomicBoolean isRun,
Runnable killOrphanedProcessesRunnable) {
String[] fullCommand = computeCommand(command);
executeDynamic(fullCommand, resultSet, isRun, killOrphanedProcessesRunnable);
}

private static CommandShellResultSet<List<String>, List<String>> execute(String[] fullCommand) {
CommandShellResultSet<List<String>, List<String>> resultSet = null;
try {
Process process = Runtime.getRuntime().exec(fullCommand);
List<String> value = readOutput(process, Process::getInputStream);
List<String> errors = readOutput(process, Process::getErrorStream);
resultSet = new CommandShellResultSet<>(value, errors);
} catch (IOException e) {
LoggingService.logWarning(MODULE_NAME, e.getMessage());
}
return resultSet;
}

private static void executeDynamic(String[] fullCommand,
CommandShellResultSet<List<String>, List<String>> resultSet,
AtomicBoolean isRun,
Runnable killOrphanedProcessesRunnable) {
try {
Process process = Runtime.getRuntime().exec(fullCommand);

Runnable readVal = () -> {
readOutputDynamic(process, Process::getInputStream, resultSet.getValue(), isRun, killOrphanedProcessesRunnable);
};
new Thread(readVal).start();

Runnable readErr = () -> {
readOutputDynamic(process, Process::getErrorStream, resultSet.getError(), isRun, killOrphanedProcessesRunnable);
};
new Thread(readErr).start();

} catch (IOException e) {
LoggingService.logWarning(MODULE_NAME, e.getMessage());
}
}


public static <V, E> CommandShellResultSet<V, E> executeCommand(String command, Function<CommandShellResultSet<List<String>, List<String>>, CommandShellResultSet<V, E>> mapper) {
return executeCommand(command).map(mapper);
}

private static String[] computeCommand(String command) {
return new String[]{
SystemUtils.IS_OS_WINDOWS ? CMD_WIN : CMD,
"-c",
command
};
}

private static String[] computeScript(String script, String... args) {
String[] command = {
SystemUtils.IS_OS_WINDOWS ? CMD_WIN : CMD,
script
};

Stream<String> s1 = Arrays.stream(command);
Stream<String> s2 = Arrays.stream(args);
return Stream.concat(s1, s2).toArray(String[]::new);
}

private static List<String> readOutput(Process process, Function<Process, InputStream> streamExtractor) throws IOException {
List<String> result = new ArrayList<>();
String line;
try (BufferedReader stdInput = new BufferedReader(new
InputStreamReader(streamExtractor.apply(process), UTF_8))) {
while ((line = stdInput.readLine()) != null) {
result.add(line);
}
}
return result;
}

private static void readOutputDynamic(Process process,
Function<Process, InputStream> streamExtractor,
List<String> result,
AtomicBoolean isRun,
Runnable killOrphanedProcessesRunnable) {
StringBuilder line = new StringBuilder();
if (result == null) {
return;
}
try (BufferedReader reader = new BufferedReader(new
InputStreamReader(streamExtractor.apply(process)))) {

while (isRun != null && isRun.get()) {
if (reader.ready()) {
int c = reader.read();
if (c == -1) {
break;
}
if (System.lineSeparator().contains(Character.toString((char)c)) && line.length() != 0) {
result.add(line.toString());
line.setLength(0);
} else {
line.append((char)c);
}
} else {
Thread.sleep(3000);
}
}
} catch (InterruptedException | IOException e) {
LoggingService.logWarning(MODULE_NAME, e.getMessage());
} finally {
process.destroy();
if (killOrphanedProcessesRunnable != null) {
killOrphanedProcessesRunnable.run();
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@

import org.eclipse.iofog.command_line.util.CommandShellExecutor;
import org.eclipse.iofog.command_line.util.CommandShellResultSet;
import org.eclipse.iofog.process_manager.DockerUtil;
import org.eclipse.iofog.utils.logging.LoggingService;

import javax.json.*;
import javax.json.JsonArray;
import javax.json.JsonObject;
import javax.json.JsonValue;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.CopyOnWriteArrayList;
Expand Down Expand Up @@ -81,7 +84,7 @@ private Optional<MicroserviceStraceData> getStraceDataByMicroserviceUuid(String

public void enableMicroserviceStraceDiagnostics(String microserviceUuid) {
try {
int pid = getPidByMicroserviceUuid(microserviceUuid);
int pid = getPidByMicroserviceUuid(DockerUtil.getContainerName(microserviceUuid));
MicroserviceStraceData newMicroserviceStraceData = new MicroserviceStraceData(microserviceUuid, pid, true);
this.monitoringMicroservices.removeIf(
oldMicroserviceStraceData -> oldMicroserviceStraceData.getMicroserviceUuid().equals(microserviceUuid)
Expand Down Expand Up @@ -114,7 +117,21 @@ private int getPidByMicroserviceUuid(String microserviceUuid) throws IllegalArgu
private void runStrace(MicroserviceStraceData microserviceStraceData) {
String straceCommand = "strace -p " + microserviceStraceData.getPid();
CommandShellResultSet<List<String>, List<String>> resultSet = new CommandShellResultSet<>(null, microserviceStraceData.getResultBuffer());
CommandShellExecutor.executeDynamicCommand(straceCommand, resultSet, microserviceStraceData.getStraceRun());
CommandShellExecutor.executeDynamicCommand(
straceCommand,
resultSet,
microserviceStraceData.getStraceRun(),
killOrphanedStraceProcessesRunnable()
);
}

private Runnable killOrphanedStraceProcessesRunnable() {
return () -> {
CommandShellResultSet<List<String>, List<String>> resultSet = CommandShellExecutor.executeCommand("pgrep strace");
if (resultSet.getValue() != null) {
resultSet.getValue().forEach(value -> CommandShellExecutor.executeCommand(String.format("kill -9 %s", value)));
}
};
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class VersionHandler {
private static final String MODULE_NAME = "Version Handler";

private final static String PACKAGE_NAME = "iofog-agent";
private final static String BACKUPS_DIR = SystemUtils.IS_OS_WINDOWS ? SNAP_COMMON + "./var/backups/iofog-agent" : SNAP_COMMON + "/var/backups/iofog";
private final static String BACKUPS_DIR = SystemUtils.IS_OS_WINDOWS ? SNAP_COMMON + "./var/backups/iofog-agent" : SNAP_COMMON + "/var/backups/iofog-agent";
private final static String MAX_RESTARTING_TIMEOUT = "60";

private final static String GET_LINUX_DISTRIBUTION_NAME = "grep = /etc/os-release | awk -F\"[=]\" '{print $2}' | sed -n 1p";
Expand Down
6 changes: 4 additions & 2 deletions daemon/src/org/eclipse/iofog/microservice/Microservice.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
*/
public class Microservice {

public static final Object deleteLock = new Object();
private final String microserviceUuid; //container name
private final String imageName;
private List<PortMapping> portMappings;
Expand All @@ -34,6 +35,7 @@ public class Microservice {
private long logSize;
private List<VolumeMapping> volumeMappings;
private boolean isUpdating;

private boolean delete;
private boolean deleteWithCleanup;

Expand Down Expand Up @@ -123,11 +125,11 @@ public void setVolumeMappings(List<VolumeMapping> volumeMappings) {
this.volumeMappings = volumeMappings;
}

public boolean isUpdating() {
public synchronized boolean isUpdating() {
return isUpdating;
}

public void setUpdating(boolean updating) {
public synchronized void setUpdating(boolean updating) {
isUpdating = updating;
}

Expand Down
Loading

0 comments on commit 2129c07

Please sign in to comment.