Skip to content
Merged
Show file tree
Hide file tree
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
24 changes: 13 additions & 11 deletions src/main/java/io/numaproj/numaflow/batchmapper/Server.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,19 @@ public void start() throws Exception {

log.info("server started, listening on socket path: {}", this.grpcConfig.getSocketPath());

// register shutdown hook to gracefully shut down the server
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
// Use stderr here since the logger may have been reset by its JVM shutdown hook.
System.err.println("*** shutting down gRPC server since JVM is shutting down");
try {
this.stop();
} catch (InterruptedException e) {
Thread.interrupted();
e.printStackTrace(System.err);
}
}));
if (!this.grpcConfig.isLocal()) {
// register shutdown hook to gracefully shut down the server
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
// Use stderr here since the logger may have been reset by its JVM shutdown hook.
System.err.println("*** shutting down gRPC server since JVM is shutting down");
try {
this.stop();
} catch (InterruptedException e) {
Thread.interrupted();
e.printStackTrace(System.err);
}
}));
}

// if there are any exceptions, shutdown the server gracefully.
this.shutdownSignal.whenCompleteAsync((v, e) -> {
Expand Down
30 changes: 15 additions & 15 deletions src/main/java/io/numaproj/numaflow/mapper/Server.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,21 @@ public void start() throws Exception {
this.grpcConfig.getInfoFilePath(),
ContainerType.MAPPER,
Collections.singletonMap(Constants.MAP_MODE_KEY, Constants.MAP_MODE));

// register shutdown hook to gracefully shut down the server
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
// Use stderr here since the logger may have been reset by its JVM shutdown hook.
System.err.println("*** shutting down gRPC server since JVM is shutting down");
try {
this.stop();
// FIXME - this is a workaround to immediately terminate the JVM process
// The correct way to do this is to stop all the actors and wait for them to terminate
System.exit(0);
} catch (InterruptedException e) {
Thread.interrupted();
e.printStackTrace(System.err);
}
}));
}

this.server.start();
Expand All @@ -79,21 +94,6 @@ public void start() throws Exception {
this.grpcConfig.isLocal() ?
"localhost:" + this.grpcConfig.getPort() : this.grpcConfig.getSocketPath());

// register shutdown hook to gracefully shut down the server
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
// Use stderr here since the logger may have been reset by its JVM shutdown hook.
System.err.println("*** shutting down gRPC server since JVM is shutting down");
try {
this.stop();
// FIXME - this is a workaround to immediately terminate the JVM process
// The correct way to do this is to stop all the actors and wait for them to terminate
System.exit(0);
} catch (InterruptedException e) {
Thread.interrupted();
e.printStackTrace(System.err);
}
}));

// if there are any exceptions, shutdown the server gracefully.
this.shutdownSignal.whenCompleteAsync((v, e) -> {
if (e != null) {
Expand Down
24 changes: 13 additions & 11 deletions src/main/java/io/numaproj/numaflow/mapstreamer/Server.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,19 @@ public void start() throws Exception {

log.info("server started, listening on socket path: {}", this.grpcConfig.getSocketPath());

// register shutdown hook to gracefully shut down the server
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
// Use stderr here since the logger may have been reset by its JVM shutdown hook.
System.err.println("*** shutting down map streamer gRPC server since JVM is shutting down");
try {
this.stop();
} catch (InterruptedException e) {
Thread.interrupted();
e.printStackTrace(System.err);
}
}));
if (!this.grpcConfig.isLocal()) {
// register shutdown hook to gracefully shut down the server
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
// Use stderr here since the logger may have been reset by its JVM shutdown hook.
System.err.println("*** shutting down map streamer gRPC server since JVM is shutting down");
try {
this.stop();
} catch (InterruptedException e) {
Thread.interrupted();
e.printStackTrace(System.err);
}
}));
}

// if there are any exceptions, shutdown the server gracefully.
this.shutdownSignal.whenCompleteAsync((v, e) -> {
Expand Down
24 changes: 12 additions & 12 deletions src/main/java/io/numaproj/numaflow/reducer/Server.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,18 @@ public void start() throws Exception {
this.grpcConfig.getSocketPath(),
this.grpcConfig.getInfoFilePath(),
ContainerType.REDUCER);

// register shutdown hook to gracefully shut down the server
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
// Use stderr here since the logger may have been reset by its JVM shutdown hook.
System.err.println("*** shutting down gRPC server since JVM is shutting down");
try {
this.stop();
} catch (InterruptedException e) {
Thread.interrupted();
e.printStackTrace(System.err);
}
}));
}

this.server.start();
Expand All @@ -69,18 +81,6 @@ public void start() throws Exception {
"server started, listening on {}",
grpcConfig.isLocal() ?
"localhost:" + grpcConfig.getPort() : grpcConfig.getSocketPath());

// register shutdown hook to gracefully shut down the server
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
// Use stderr here since the logger may have been reset by its JVM shutdown hook.
System.err.println("*** shutting down gRPC server since JVM is shutting down");
try {
this.stop();
} catch (InterruptedException e) {
Thread.interrupted();
e.printStackTrace(System.err);
}
}));
}

/**
Expand Down
24 changes: 12 additions & 12 deletions src/main/java/io/numaproj/numaflow/reducestreamer/Server.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,18 @@ public void start() throws Exception {
this.grpcConfig.getSocketPath(),
this.grpcConfig.getInfoFilePath(),
ContainerType.REDUCE_STREAMER);

// register shutdown hook to gracefully shut down the server
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
// Use stderr here since the logger may have been reset by its JVM shutdown hook.
System.err.println("*** shutting down gRPC server since JVM is shutting down");
try {
this.stop();
} catch (InterruptedException e) {
Thread.interrupted();
e.printStackTrace(System.err);
}
}));
}

this.server.start();
Expand All @@ -72,18 +84,6 @@ public void start() throws Exception {
"server started, listening on {}",
this.grpcConfig.isLocal() ?
"localhost:" + this.grpcConfig.getPort() : this.grpcConfig.getSocketPath());

// register shutdown hook to gracefully shut down the server
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
// Use stderr here since the logger may have been reset by its JVM shutdown hook.
System.err.println("*** shutting down gRPC server since JVM is shutting down");
try {
this.stop();
} catch (InterruptedException e) {
Thread.interrupted();
e.printStackTrace(System.err);
}
}));
}

/**
Expand Down
26 changes: 13 additions & 13 deletions src/main/java/io/numaproj/numaflow/servingstore/Server.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,19 @@ public void start() throws Exception {
this.grpcConfig.getSocketPath(),
this.grpcConfig.getInfoFilePath(),
ContainerType.SERVING);

// register shutdown hook to gracefully shut down the server
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
// Use stderr here since the logger may have been reset by its JVM shutdown
// hook.
System.err.println("*** shutting down gRPC server since JVM is shutting down");
try {
this.stop();
} catch (InterruptedException e) {
Thread.interrupted();
e.printStackTrace(System.err);
}
}));
}

this.server.start();
Expand All @@ -85,19 +98,6 @@ public void start() throws Exception {
this.grpcConfig.isLocal() ?
"localhost:" + this.grpcConfig.getPort() : this.grpcConfig.getSocketPath());

// register shutdown hook to gracefully shut down the server
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
// Use stderr here since the logger may have been reset by its JVM shutdown
// hook.
System.err.println("*** shutting down gRPC server since JVM is shutting down");
try {
this.stop();
} catch (InterruptedException e) {
Thread.interrupted();
e.printStackTrace(System.err);
}
}));

// if there are any exceptions, shutdown the server gracefully.
this.shutdownSignal.whenCompleteAsync((v, e) -> {
if (e != null) {
Expand Down
24 changes: 12 additions & 12 deletions src/main/java/io/numaproj/numaflow/sessionreducer/Server.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,18 @@ public void start() throws Exception {
this.grpcConfig.getSocketPath(),
this.grpcConfig.getInfoFilePath(),
ContainerType.SESSION_REDUCER);

// register shutdown hook to gracefully shut down the server
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
// Use stderr here since the logger may have been reset by its JVM shutdown hook.
System.err.println("*** shutting down gRPC server since JVM is shutting down");
try {
this.stop();
} catch (InterruptedException e) {
Thread.interrupted();
e.printStackTrace(System.err);
}
}));
}

this.server.start();
Expand All @@ -72,18 +84,6 @@ public void start() throws Exception {
"server started, listening on {}",
this.grpcConfig.isLocal() ?
"localhost:" + this.grpcConfig.getPort() : this.grpcConfig.getSocketPath());

// register shutdown hook to gracefully shut down the server
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
// Use stderr here since the logger may have been reset by its JVM shutdown hook.
System.err.println("*** shutting down gRPC server since JVM is shutting down");
try {
this.stop();
} catch (InterruptedException e) {
Thread.interrupted();
e.printStackTrace(System.err);
}
}));
}

/**
Expand Down
22 changes: 11 additions & 11 deletions src/main/java/io/numaproj/numaflow/sideinput/Server.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,24 +62,24 @@ public void start() throws Exception {
this.grpcConfig.getSocketPath(),
this.grpcConfig.getInfoFilePath(),
ContainerType.SIDEINPUT);

// register shutdown hook to gracefully shut down the server
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
// Use stderr here since the logger may have been reset by its JVM shutdown hook.
try {
this.stop();
} catch (InterruptedException e) {
Thread.interrupted();
e.printStackTrace(System.err);
}
}));
}

this.server.start();

log.info(
"server started, listening on {}",
this.grpcConfig.isLocal() ? "localhost:" + this.grpcConfig.getPort() : this.grpcConfig.getSocketPath());

// register shutdown hook to gracefully shut down the server
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
// Use stderr here since the logger may have been reset by its JVM shutdown hook.
try {
this.stop();
} catch (InterruptedException e) {
Thread.interrupted();
e.printStackTrace(System.err);
}
}));
}

/**
Expand Down
24 changes: 12 additions & 12 deletions src/main/java/io/numaproj/numaflow/sinker/Server.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,18 @@ public void start() throws Exception {
grpcConfig.getSocketPath(),
grpcConfig.getInfoFilePath(),
ContainerType.SINKER);

// register shutdown hook to gracefully shut down the server
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
// Use stderr here since the logger may have been reset by its JVM shutdown hook.
System.err.println("*** shutting down sink gRPC server since JVM is shutting down");
try {
this.stop();
} catch (InterruptedException e) {
Thread.interrupted();
e.printStackTrace(System.err);
}
}));
}

server.start();
Expand All @@ -67,18 +79,6 @@ public void start() throws Exception {
grpcConfig.isLocal() ?
"localhost:" + grpcConfig.getPort() : grpcConfig.getSocketPath());

// register shutdown hook to gracefully shut down the server
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
// Use stderr here since the logger may have been reset by its JVM shutdown hook.
System.err.println("*** shutting down sink gRPC server since JVM is shutting down");
try {
this.stop();
} catch (InterruptedException e) {
Thread.interrupted();
e.printStackTrace(System.err);
}
}));

// if there are any exceptions, shutdown the server gracefully.
shutdownSignal.whenCompleteAsync((v, e) -> {
if (e != null) {
Expand Down
24 changes: 12 additions & 12 deletions src/main/java/io/numaproj/numaflow/sourcer/Server.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,18 @@ public void start() throws Exception {
this.grpcConfig.getSocketPath(),
this.grpcConfig.getInfoFilePath(),
ContainerType.SOURCER);

// register shutdown hook to gracefully shut down the server
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
// Use stderr here since the logger may have been reset by its JVM shutdown hook.
System.err.println("*** shutting down source gRPC server since JVM is shutting down");
try {
this.stop();
} catch (InterruptedException e) {
Thread.interrupted();
e.printStackTrace(System.err);
}
}));
}

this.server.start();
Expand All @@ -75,18 +87,6 @@ public void start() throws Exception {
this.grpcConfig.isLocal() ?
"localhost:" + this.grpcConfig.getPort() : this.grpcConfig.getSocketPath());

// register shutdown hook to gracefully shut down the server
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
// Use stderr here since the logger may have been reset by its JVM shutdown hook.
System.err.println("*** shutting down source gRPC server since JVM is shutting down");
try {
this.stop();
} catch (InterruptedException e) {
Thread.interrupted();
e.printStackTrace(System.err);
}
}));

// if there are any exceptions, shutdown the server gracefully.
this.shutdownSignal.whenCompleteAsync((v, e) -> {
if (e != null) {
Expand Down
Loading
Loading