Skip to content

Commit

Permalink
Simplify Container interface (apache#95)
Browse files Browse the repository at this point in the history
  • Loading branch information
srkukarni authored and sijie committed Mar 4, 2018
1 parent 72a9804 commit 9abeef2
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,11 @@ void runCmd() throws Exception {
containerFactory);

spawner.start();
spawner.join();
Runtime.getRuntime().addShutdownHook(new Thread() {
public void run() {
spawner.close();
}
});
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,8 @@
*/
public interface FunctionContainer {

String getId();

void start() throws Exception;

void join() throws InterruptedException;

void stop();

CompletableFuture<FunctionStatus> getFunctionStatus();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,7 @@ class ThreadFunctionContainer implements FunctionContainer {
// The thread that invokes the function
@Getter
private final Thread fnThread;

// The id of the thread
private final String id;


private JavaInstanceRunnable javaInstanceRunnable;

ThreadFunctionContainer(JavaInstanceConfig instanceConfig,
Expand All @@ -53,13 +50,8 @@ class ThreadFunctionContainer implements FunctionContainer {
PulsarClient pulsarClient) {
this.javaInstanceRunnable = new JavaInstanceRunnable(instanceConfig, maxBufferedTuples,
fnCache, jarFile, pulsarClient);
this.id = instanceConfig.getFunctionConfig().getFullyQualifiedName();
this.fnThread = new Thread(threadGroup, javaInstanceRunnable, this.id);
}

@Override
public String getId() {
return id;
this.fnThread = new Thread(threadGroup, javaInstanceRunnable,
instanceConfig.getFunctionConfig().getFullyQualifiedName());
}

/**
Expand All @@ -70,11 +62,6 @@ public void start() throws Exception {
this.fnThread.start();
}

@Override
public void join() throws InterruptedException {
fnThread.join();
}

@Override
public void stop() {
javaInstanceRunnable.close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,6 @@ public void start() throws Exception {
functionContainer.start();
}

public void join() throws Exception {
if (null != functionContainer) {
functionContainer.join();
}
}

public CompletableFuture<FunctionStatus> getFunctionStatus() {
return functionContainer.getFunctionStatus();
}
Expand Down

0 comments on commit 9abeef2

Please sign in to comment.