-
Notifications
You must be signed in to change notification settings - Fork 10
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
chore: formalize gRPC errors in case of UDF exceptions #166
Merged
Merged
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
cd6fd96
chore: formalize gRPC error for transformer
adarsh0728 fd1f19a
handle error case for source exception
adarsh0728 3da64a0
update: tests and gRPC errors for other components
adarsh0728 f5cdee8
handle sideinput exceptions
adarsh0728 2dc0573
Merge branch 'main' into err-streamlining
adarsh0728 42972db
revert sideInput case, handle in sep PR
adarsh0728 60a3386
test for stacktrace fn
adarsh0728 3773b9d
resolve conflicts
adarsh0728 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
src/main/java/io/numaproj/numaflow/shared/ExceptionUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package io.numaproj.numaflow.shared; | ||
|
||
import java.io.PrintWriter; | ||
import java.io.StringWriter; | ||
|
||
public class ExceptionUtils { | ||
/** | ||
* Formalized exception error strings | ||
*/ | ||
public static final String ERR_SOURCE_EXCEPTION = "UDF_EXECUTION_ERROR(source)"; | ||
public static final String ERR_TRANSFORMER_EXCEPTION = "UDF_EXECUTION_ERROR(transformer)"; | ||
public static final String ERR_SINK_EXCEPTION = "UDF_EXECUTION_ERROR(sink)"; | ||
public static final String ERR_MAP_STREAM_EXCEPTION = "UDF_EXECUTION_ERROR(mapstream)"; | ||
public static final String ERR_MAP_EXCEPTION = "UDF_EXECUTION_ERROR(map)"; | ||
public static final String ERR_BATCH_MAP_EXCEPTION = "UDF_EXECUTION_ERROR(batchmap)"; | ||
|
||
/** | ||
* Converts the stack trace of an exception into a String. | ||
* | ||
* @param e the exception to extract the stack trace from | ||
* @return the stack trace as a String | ||
*/ | ||
public static String getStackTrace(Throwable t) { | ||
if (t == null) { | ||
return "No exception provided."; | ||
} | ||
StringWriter sw = new StringWriter(); | ||
t.printStackTrace(new PrintWriter(sw)); | ||
return sw.toString(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,7 +32,7 @@ public Server(SideInputRetriever sideInputRetriever) { | |
/** | ||
* constructor to create gRPC server with gRPC config. | ||
* | ||
* @param grpcConfig to configure the max message size for grpc | ||
* @param grpcConfig to configure the max message size for grpc | ||
* @param sideInputRetriever to retrieve the side input | ||
*/ | ||
public Server(SideInputRetriever sideInputRetriever, GRPCConfig grpcConfig) { | ||
|
@@ -41,7 +41,8 @@ public Server(SideInputRetriever sideInputRetriever, GRPCConfig grpcConfig) { | |
} | ||
|
||
@VisibleForTesting | ||
protected Server(GRPCConfig grpcConfig, SideInputRetriever service, ServerInterceptor interceptor, String serverName) { | ||
protected Server(GRPCConfig grpcConfig, SideInputRetriever service, ServerInterceptor interceptor, | ||
String serverName) { | ||
this.grpcConfig = grpcConfig; | ||
this.server = new GrpcServerWrapper( | ||
interceptor, | ||
|
@@ -67,8 +68,7 @@ public void start() throws Exception { | |
|
||
log.info( | ||
"server started, listening on {}", | ||
this.grpcConfig.isLocal() ? | ||
"localhost:" + this.grpcConfig.getPort() : this.grpcConfig.getSocketPath()); | ||
this.grpcConfig.isLocal() ? "localhost:" + this.grpcConfig.getPort() : this.grpcConfig.getSocketPath()); | ||
|
||
// register shutdown hook to gracefully shut down the server | ||
Runtime.getRuntime().addShutdownHook(new Thread(() -> { | ||
|
@@ -83,11 +83,14 @@ public void start() throws Exception { | |
} | ||
|
||
/** | ||
* Blocks until the server has terminated. If the server is already terminated, this method | ||
* will return immediately. If the server is not yet terminated, this method will block the | ||
* Blocks until the server has terminated. If the server is already terminated, | ||
* this method | ||
* will return immediately. If the server is not yet terminated, this method | ||
* will block the | ||
* calling thread until the server has terminated. | ||
* | ||
* @throws InterruptedException if the current thread is interrupted while waiting | ||
* @throws InterruptedException if the current thread is interrupted while | ||
* waiting | ||
*/ | ||
public void awaitTermination() throws InterruptedException { | ||
log.info("side input server is waiting for termination"); | ||
|
@@ -96,7 +99,8 @@ public void awaitTermination() throws InterruptedException { | |
} | ||
|
||
/** | ||
* Stop serving requests and shutdown resources. Await termination on the main thread since the | ||
* Stop serving requests and shutdown resources. Await termination on the main | ||
* thread since the | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is the reformatting right? it seems we are getting more lines but short. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. need to check why this was happening, reverted at most of the places. |
||
* grpc library uses daemon threads. | ||
* | ||
* @throws InterruptedException if shutdown is interrupted | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we skipping reducers?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, for now (to be taken up later across sdk's) numaproj/numaflow-go#173 (comment)