fixed my night crew typoes
This commit is contained in:
parent
68eabf6510
commit
05eac44a4c
3 changed files with 22 additions and 22 deletions
|
|
@ -3,7 +3,7 @@ package JobServ;
|
||||||
import io.grpc.ManagedChannel;
|
import io.grpc.ManagedChannel;
|
||||||
import io.grpc.ManagedChannelBuilder;
|
import io.grpc.ManagedChannelBuilder;
|
||||||
import io.grpc.StatusRuntimeException;
|
import io.grpc.StatusRuntimeException;
|
||||||
|
import java.util.InputMismatchException;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
@ -50,7 +50,7 @@ public class JobServClient {
|
||||||
public String getProcessOutput(int pid) {
|
public String getProcessOutput(int pid) {
|
||||||
logger.info("[+] requesting output");
|
logger.info("[+] requesting output");
|
||||||
|
|
||||||
RequestMessage request = PIDMessage.newBuilder()
|
PIDMessage request = PIDMessage.newBuilder()
|
||||||
.setPid(pid)
|
.setPid(pid)
|
||||||
.build();
|
.build();
|
||||||
OutputMessage response;
|
OutputMessage response;
|
||||||
|
|
@ -60,11 +60,10 @@ public class JobServClient {
|
||||||
response = blockingStub.getOutput(request);
|
response = blockingStub.getOutput(request);
|
||||||
} catch (StatusRuntimeException e) {
|
} catch (StatusRuntimeException e) {
|
||||||
logger.log(Level.WARNING, "[-] Request for output failed: %s", e.getStatus());
|
logger.log(Level.WARNING, "[-] Request for output failed: %s", e.getStatus());
|
||||||
// TODO: refactor this out by throwing here and catching in the shell
|
return "<Error connecting to API>";
|
||||||
return "";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return response.getProcessOutput();
|
return response.getOutput();
|
||||||
}
|
}
|
||||||
|
|
||||||
// sends the server a command for a new job, blocks until response
|
// sends the server a command for a new job, blocks until response
|
||||||
|
|
@ -86,7 +85,7 @@ public class JobServClient {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(response.getpid() == -1) {
|
if(response.getPid() == -1) {
|
||||||
logger.log(Level.WARNING, "New job creation failed server side!");
|
logger.log(Level.WARNING, "New job creation failed server side!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -95,7 +94,7 @@ public class JobServClient {
|
||||||
|
|
||||||
// requests running status of job
|
// requests running status of job
|
||||||
// returns true if job still running else false
|
// returns true if job still running else false
|
||||||
public bool getProcessStatus(int pid) {
|
public Boolean getProcessStatus(int pid) {
|
||||||
logger.info("[+] Requesting status of a job");
|
logger.info("[+] Requesting status of a job");
|
||||||
|
|
||||||
PIDMessage request = PIDMessage.newBuilder()
|
PIDMessage request = PIDMessage.newBuilder()
|
||||||
|
|
@ -108,6 +107,7 @@ public class JobServClient {
|
||||||
response = blockingStub.getStatus(request);
|
response = blockingStub.getStatus(request);
|
||||||
} catch (StatusRuntimeException e) {
|
} catch (StatusRuntimeException e) {
|
||||||
logger.log(Level.WARNING, "[-] Request for status failed!");
|
logger.log(Level.WARNING, "[-] Request for status failed!");
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return response.getIsRunning();
|
return response.getIsRunning();
|
||||||
|
|
@ -167,7 +167,7 @@ public class JobServClient {
|
||||||
// check args
|
// check args
|
||||||
if (args.length < 3) {
|
if (args.length < 3) {
|
||||||
System.out.println("Usage: $ jobservclient host port command");
|
System.out.println("Usage: $ jobservclient host port command");
|
||||||
System.out.println("Or try client --help")
|
System.out.println("Or try client --help");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -191,12 +191,12 @@ public class JobServClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
String command = "";
|
String command = "";
|
||||||
for (int token = 3; i < args.length; i++) {
|
for (int token = 3; token < args.length; token++) {
|
||||||
command += " " + args[token];
|
command += " " + args[token];
|
||||||
}
|
}
|
||||||
|
|
||||||
int newProcess = client.sendNewJobMessage(command);
|
int newProcess = client.sendNewJobMessage(command);
|
||||||
System.out.println("Process started, assigned pid is %d", newProcess);
|
System.out.printf("Process started, assigned pid is %d\n", newProcess);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "output":
|
case "output":
|
||||||
|
|
@ -231,7 +231,7 @@ public class JobServClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
Boolean processStatus = client.getProcessStatus(candidatePid);
|
Boolean processStatus = client.getProcessStatus(candidatePid);
|
||||||
System.out.println("Process is currently running? %b", processStatus);
|
System.out.printf("Process is currently running? %b\n", processStatus);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "kill":
|
case "kill":
|
||||||
|
|
@ -248,7 +248,7 @@ public class JobServClient {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
client.getProcessOutput(candidatePid);
|
client.killProcess(candidatePid);
|
||||||
System.out.println("End process request recieved!");
|
System.out.println("End process request recieved!");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
@ -266,7 +266,7 @@ public class JobServClient {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
int returnCode = client.getProcessOutput(candidatePid);
|
int returnCode = client.getProcessReturn(candidatePid);
|
||||||
|
|
||||||
if (returnCode == 277) {
|
if (returnCode == 277) {
|
||||||
System.out.println("Process is still running");
|
System.out.println("Process is still running");
|
||||||
|
|
@ -277,7 +277,7 @@ public class JobServClient {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
System.out.println("Process Exit Code: %d", returnCode);
|
System.out.printf("Process Exit Code: %d\n", returnCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
@ -288,7 +288,7 @@ public class JobServClient {
|
||||||
|
|
||||||
public static void outputHelp() {
|
public static void outputHelp() {
|
||||||
System.out.println("... new (command)");
|
System.out.println("... new (command)");
|
||||||
System.out.println("Starts a new process on the server")
|
System.out.println("Starts a new process on the server");
|
||||||
System.out.println("... output (pid)");
|
System.out.println("... output (pid)");
|
||||||
System.out.println("Garners output from process on server");
|
System.out.println("Garners output from process on server");
|
||||||
System.out.println("... status (pid)");
|
System.out.println("... status (pid)");
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ public class JobServServer {
|
||||||
server.shutdown();
|
server.shutdown();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// spinlock for main()
|
// spinlock for main()
|
||||||
private void blockUntilShutdown() throws InterruptedException {
|
private void blockUntilShutdown() throws InterruptedException {
|
||||||
if (server != null) {
|
if (server != null) {
|
||||||
|
|
@ -60,7 +60,7 @@ public class JobServServer {
|
||||||
StreamObserver<StatusMessage> responder) {
|
StreamObserver<StatusMessage> responder) {
|
||||||
// TODO: Implement job controller, check request type, do the thing
|
// TODO: Implement job controller, check request type, do the thing
|
||||||
StatusMessage reply = StatusMessage.newBuilder()
|
StatusMessage reply = StatusMessage.newBuilder()
|
||||||
.setStatusCode(-1)
|
.setIsRunning(true)
|
||||||
.build();
|
.build();
|
||||||
responder.onNext(reply);
|
responder.onNext(reply);
|
||||||
responder.onCompleted();
|
responder.onCompleted();
|
||||||
|
|
@ -93,7 +93,7 @@ public class JobServServer {
|
||||||
StreamObserver<ReturnMessage> responder) {
|
StreamObserver<ReturnMessage> responder) {
|
||||||
// TODO: Implement job controller, get return code
|
// TODO: Implement job controller, get return code
|
||||||
ReturnMessage reply = ReturnMessage.newBuilder()
|
ReturnMessage reply = ReturnMessage.newBuilder()
|
||||||
.setprocessReturnCode(277)
|
.setProcessReturnCode(277)
|
||||||
.build();
|
.build();
|
||||||
responder.onNext(reply);
|
responder.onNext(reply);
|
||||||
responder.onCompleted();
|
responder.onCompleted();
|
||||||
|
|
@ -101,11 +101,11 @@ public class JobServServer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void killJob(PIDMessage request,
|
public void killJob(PIDMessage request,
|
||||||
StreamObserver<ReturnMessage> responder) {
|
StreamObserver<StatusMessage> responder) {
|
||||||
// TODO: implement job controller, do the thing
|
// TODO: implement job controller, do the thing
|
||||||
// TODO: kill job here
|
// TODO: kill job here
|
||||||
ReturnMessage reply = ReturnMessage.newBuilder()
|
StatusMessage reply = StatusMessage.newBuilder()
|
||||||
.setprocessReturnCode(-1)
|
.setIsRunning(false)
|
||||||
.build();
|
.build();
|
||||||
responder.onNext(reply);
|
responder.onNext(reply);
|
||||||
responder.onCompleted();
|
responder.onCompleted();
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ service ShellServer {
|
||||||
}
|
}
|
||||||
|
|
||||||
message StatusMessage {
|
message StatusMessage {
|
||||||
bool IsRunning = 1
|
bool IsRunning = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
message ReturnMessage {
|
message ReturnMessage {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue