Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

close remote upload shell and threadpools for proper process shutdown #219

Closed
wants to merge 1 commit into from
Closed
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
13 changes: 8 additions & 5 deletions src/main/java/io/hyperfoil/tools/qdup/Local.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,14 @@ public boolean upload(String path, String destination, Host host) {
} else if (!host.isLocal() && host.hasContainerId()){
logger.info("Local.upload({},{}:{})", path, host.getSafeString(), destination);
Host remoteHost = host.withoutContainer();
AbstractShell shell = AbstractShell.getShell(
ScheduledThreadPoolExecutor stpe = new ScheduledThreadPoolExecutor(1);
AbstractShell uploadShell = AbstractShell.getShell(
remoteHost,
"",
new ScheduledThreadPoolExecutor(1),
stpe,
new SecretFilter(),
false);
String remoteDestination = shell.shSync("mktemp -d");
String remoteDestination = uploadShell.shSync("mktemp -d");
boolean uploaded = upload(path,remoteDestination,remoteHost);
if(!uploaded){
logger.error("failed to upload "+path+" to remote host as part of upload to "+host);
Expand All @@ -136,10 +137,12 @@ public boolean upload(String path, String destination, Host host) {
return false;
}
String mergedUpload = populated.stream().collect(Collectors.joining(" "));
String mergedResponse = shell.shSync(mergedUpload);
String mergedResponse = uploadShell.shSync(mergedUpload);
//output
//cleanup the folder we created on the remoteHost
String rmResponse = shell.shSync("rm -rf "+remoteDestination);
String rmResponse = uploadShell.shSync("rm -rf "+remoteDestination);
uploadShell.close();
stpe.shutdownNow();
//
return true;
} else {
Expand Down
Loading