-
Notifications
You must be signed in to change notification settings - Fork 66
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
Fix type cast issue in transport action call #223
Fix type cast issue in transport action call #223
Conversation
Signed-off-by: Chen Dai <daichen@amazon.com>
Signed-off-by: Chen Dai <daichen@amazon.com>
Does this require opensearch-project/common-utils#38? Can you please explain in this and the other PR what's going on? Also a good blog post idea as this is getting technically complicated and fun ;) |
Sounds good! Will put more details in the PR description. Thanks! |
Good work! |
This still needs tests, I am worried that nothing was failing before and nothing is succeeding after this change. |
Sure, will check if UT is missing or not. |
Signed-off-by: Chen Dai <daichen@amazon.com>
Signed-off-by: Chen Dai <daichen@amazon.com>
Signed-off-by: Chen Dai <daichen@amazon.com>
Signed-off-by: Chen Dai <daichen@amazon.com>
Signed-off-by: Chen Dai <daichen@amazon.com>
Signed-off-by: Chen Dai <daichen@amazon.com>
@dblock I've added all missing UT. |
Signed-off-by: bowenlan-amzn <bowenlan23@gmail.com>
Signed-off-by: Chen Dai daichen@amazon.com
Description
Problem Statement
OpenSearch loads each plugin by different class loader separately. When two plugins need to communicate by transport action, it’s common to put request and response class into a module shared by both. However, as per the forum post, this may cause problem because OpenSearch does "optimization to avoid serialization" for local request between plugins on same JVM.
Here is the sample error when Reporting plugin tries to call Notification plugin by common code in common-utils module. You can see the full class names are exactly the same, though type cast happened and failed due to the 2 classes loaded by different
FactoryURLClassLoader
.The
common-utils
jar is shared by Reporting and Notification plugin and loaded by different class loaders. When Reporting tries to call send notification API, OpenSearch passes instance of classSendNotificationRequest
loaded by reporting class loader. However, Notification plugin expects an instance of same class though loaded by its own class loader. The same problem forSendNotificationResponse
class inActionListener
.Proposed Solutions
The following solutions are proposed as discussed in opensearch-project/common-utils#37:
The options 4 is chosen although it has small overhead. It is favored because it’s not hacky as the first 2 options and much less complex than the option 3 (design and feasibility is unclear).
Implementation
To force (de-)serialization for request and response class, a type checking and object recreating logic needs to add at the beginning of request/response handling. Actually this logic is already existing in Notification codebase. In the case of Notification plugin, the root cause is the wrong generic type. Concrete request/response class is used in
executeRequest(XXXRequest)
andonResponse(XXXResponse)
respectively. This leads to type cast exception occurred before entering the main logic of the function (which includes the type checking and object recreating logic).Thus this PR is to change the generic type to base class
ActionRequest
(andActionResponse
in the other PR in common-utils). This enables the control flow enters the method, does the type check and recreates request/response object if needed.Issues Resolved
opensearch-project/common-utils#37
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.