Skip to content

Commit

Permalink
add a REST api for triggering sysgc
Browse files Browse the repository at this point in the history
  • Loading branch information
jingjingwang committed May 12, 2017
1 parent a68dad5 commit ebbcc67
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 11 deletions.
17 changes: 17 additions & 0 deletions src/edu/washington/escience/myria/api/WorkerCollection.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import edu.washington.escience.myria.parallel.Server;
import edu.washington.escience.myria.parallel.SocketInfo;
import edu.washington.escience.myria.util.IPCUtils;

/**
* This is the class that handles API calls that return workers.
Expand Down Expand Up @@ -64,4 +65,20 @@ public Response getWorkers() {
/* Don't cache the answer. */
return Response.ok(ret).cacheControl(MyriaApiUtils.doNotCache()).build();
}

/**
* @param workerId identifier of the worker.
* @return an HTTP OK
*/
@GET
@Path("/sysgc-{workerId:\\d+}")
public Response callWorkerSysGC(@PathParam("workerId") final int workerId) {
SocketInfo workerInfo = server.getWorkers().get(workerId);
if (workerInfo == null) {
/* Not found, throw a 404 (Not Found) */
throw new MyriaApiException(Status.NOT_FOUND, "Worker " + workerId);
}
server.getIPCConnectionPool().sendShortMessage(workerId, IPCUtils.CONTROL_SYSTEM_GC);
return Response.ok().build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ private LocalSubQueryFuture advanceQuery(final Query queryState) throws DbExcept
queryState.markSuccess();
/* Trigger GC on workers to avoid affecting the performance of the next query. */
for (int workerId : server.getAliveWorkers()) {
server.getIPCConnectionPool().sendShortMessage(workerId, IPCUtils.systemGC());
server.getIPCConnectionPool().sendShortMessage(workerId, IPCUtils.CONTROL_SYSTEM_GC);
}
finishQuery(queryState);
return null;
Expand Down
2 changes: 1 addition & 1 deletion src/edu/washington/escience/myria/parallel/Server.java
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ ExecutorService getQueryExecutor() {
public static final int NUM_SECONDS_FOR_ELEGANT_CLEANUP = 10;

/** @return my connection pool for IPC. */
IPCConnectionPool getIPCConnectionPool() {
public IPCConnectionPool getIPCConnectionPool() {
return connectionPool;
}

Expand Down
15 changes: 6 additions & 9 deletions src/edu/washington/escience/myria/util/IPCUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -475,15 +475,12 @@ public static TransportMessage queryMessage(final SubQueryId taskId, final SubQu
.build();
}

/**
* @return a SYSTEM GC message.
* */
public static TransportMessage systemGC() {
return TransportMessage.newBuilder()
.setType(TransportMessage.Type.CONTROL)
.setControlMessage(ControlMessage.newBuilder().setType(ControlMessage.Type.SYSTEM_GC))
.build();
}
/** a SYSTEM GC message. * */
public static TransportMessage CONTROL_SYSTEM_GC =
TransportMessage.newBuilder()
.setType(TransportMessage.Type.CONTROL)
.setControlMessage(ControlMessage.newBuilder().setType(ControlMessage.Type.SYSTEM_GC))
.build();

/**
* @param taskId the query/subquery task to be killed.
Expand Down

0 comments on commit ebbcc67

Please sign in to comment.