Skip to content
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

Open source memq actions #272

Merged
merged 4 commits into from
May 23, 2024
Merged

Open source memq actions #272

merged 4 commits into from
May 23, 2024

Conversation

yisheng-zhou
Copy link
Contributor

@yisheng-zhou yisheng-zhou commented May 15, 2024

Open source orion memq broker actions: reboot / replace / decommission

The PR includes 3 memq actions

  • Replace node
  • Restart node
  • Decomission node

And a helper classes to achieve thos actions

  • EC2 helper

Add teletraan client, which is a wrapper of teletraan http api call.

It also includes the parallel action abstract class. They can be used to run the above actions in parallel.

To use the actions, the internal package needs to override the EC2 helper in the main classes. For details, there's a readme.

@yisheng-zhou yisheng-zhou requested a review from a team as a code owner May 15, 2024 22:19
Copy link
Contributor

@vahidhashemian vahidhashemian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some comments.

return METHOD_NAME;
}

public HttpDeleteWithBody(final String uri) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the uri going to be the body of the request?
I'm confused by the class definition claiming to allow a body in the request, but not providing any additional interfaces to support that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. That's the target URI of this HTTP request.

For regular HttpDelete request, I cannot run setEntity and attach the instance id to it.

With this HttpDeleteWithBody class, it will be executed as HttpDelete request by the http client because of the getMethod value, and extends HttpEntityEnclosingRequestBase allows me to attach body (entity) to it.

* @param overrideTeletraanToken
* @return boolean indicating if the instance is pending termination
*/
public boolean isInstancePendingTermination(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not have one function for this status check? There was another one above.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which one? isHostPendingTermination is getting the status and parse the response to know the host status. isHostTerminated is checking the host cannot be found. They cannot be merged together. The shared part (HTTP call) is in getHostStatusHistory

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason I asked is both functions return a boolean.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One is for parsing http entity to get the result, another one is for to make http call itself. Any suggestion for method names? I use isInstancePendingTermination/IsInstancePendingTermination as you suggested.

import com.pinterest.orion.core.actions.Action;
import com.pinterest.orion.core.actions.generic.GenericClusterWideAction;

public abstract class MemqClusterDecommissionBrokers extends GenericClusterWideAction.ParallelDecommissionNodeAction {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This abstract class is not used anywhere; do we need a basic implementation of it? Same for below two classes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This class will be inheritant to run multiple MemqBrokerDecommissionActions in parallel (ClusterDecomission->BrokerDecomission). I will add more details in javadoc.

import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;

public abstract class MemqTeletraanBrokerReplacementAction extends NodeAction {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to combine replacement and decommissioning, or make one dependent on the other? I feel the termination part should be the same between the two.

Or this change has to be done at the parent side?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to merge the common parts of these two classes into one parent class. It looks ugly. The wait check looks similar but the APIs are different. Plus there're extra steps in replacement workflow. And the existing parent classes are also different. So I rather keep them in two classes and inherant from different parent classes, following existing kafka oop structure.

import java.net.HttpURLConnection;
import java.util.logging.Logger;

public class TeletraanClient {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we introduce an interface for instance operations (if there is not one already)? With this interface, we can have Kafka's way of instance operations and Teletraan based operations be implementations of that interface. Then each user will be able to pick which option to choose for which type of system.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sense. I will include the operations in EC2 helper as well

/**
* Constants for Teletraan client
*/
public class TeletraanConstants {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Change to Constants since teletraan is already in the package?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sense. Changed

* @param region the region of the host
* @return the instance id
*/
public abstract String getHostIdUsingHostName(String fullHostName, String region);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for bringing this up again. The Java doc says the function gets instance id but the name has host id. If host id it the same as EC2 instance id, I suggest using the term instance id as it's more commonly used and not confusing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sense. Changed

Copy link
Contributor

@vahidhashemian vahidhashemian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some comments.

@yisheng-zhou yisheng-zhou merged commit 6b0ed39 into master May 23, 2024
1 check passed
@yisheng-zhou yisheng-zhou deleted the OpenSourceMemqActions branch May 23, 2024 22:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants