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

[Part 1]: Support for hot task executors in Mantis #145

Merged
merged 7 commits into from
Mar 21, 2022

Conversation

sundargates
Copy link
Collaborator

@sundargates sundargates commented Mar 20, 2022

Context

As we are approaching adding support for Mantis on Titus, one of the first goals is to be able to support task executors that are fully loaded (hot) and capable of executing Mantis stages on demand. This diff is the first step in that direction. This change introduces a new API on the server-side that establishes the protocol that the task executor needs to use to communicate with the server.

Checklist

  • ./gradlew build compiles code correctly
  • Added new tests where applicable
  • ./gradlew test passes all tests
  • Extended README or added javadocs where applicable
  • Added copyright headers for new files from CONTRIBUTING.md

As we are approaching adding support for Mantis on Titus, one of the first goals is to be able to support task executors that are fully loaded (hot) and capable of executing Mantis stages on demand. This diff is the first step in that direction. This change introduces a new API on the server-side that establishes the protocol that the task executor needs to use to communicate with the server.
return defaultObjectMapper.readerFor(expectedType).readValue(json);
}

public String toJson(Object object) throws IOException {
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: I'd call out the semantic difference between this and static toJson in comments.
Also, could we make this static?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I have removed all the static methods.

@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
@Value
public class ClusterID {
String resourceID;
Copy link
Collaborator

Choose a reason for hiding this comment

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

this should be private?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

value classes by default in Lombok treat the fields as "private final".

Here's the documentation: https://projectlombok.org/features/Value

/**
* Datastructure representing the task executor that needs to be disconnected from the resource cluster.
*/
@Value
Copy link
Collaborator

Choose a reason for hiding this comment

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

constructor?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

value annotation creates an "allargsconstructor".

import io.mantisrx.common.JsonSerializer;
import org.junit.Test;

public class TestTaskExecutorRegistration {
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: we should follow convention. call this TaskExecutorRegistrationTest. Move the heartbeat test to TaskExecutorHeartbeatTest.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Renamed the class.

public class ClusterID {
String resourceID;

public static ClusterID of(String clusterIdStr) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just wondering what's your thought on static "of" v.s. lombok builder?

Copy link
Contributor

Choose a reason for hiding this comment

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

I really love the way static factory methods named of read in client code. ClusterId.of("m5.2xl-1") reads so cleanly to a user even compared to the builder ClusterId.builder().name("m5.2xl-1").build(). However I think this can be achieved with Lombok using @RequiredArgsConstructor(staticName="of").

Copy link
Collaborator

Choose a reason for hiding this comment

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

Very true. "of" is definitely cleaner on the single arg ctor case.

Copy link
Contributor

Choose a reason for hiding this comment

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

That is actually a good point, it can get confusing on the multi-arg constructor case. Especially if parameters are of the same type, which string represents what?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks for the suggestion. I have used the Lombok annotation in both the places where it makes sense.

public interface ResourceClusterGateway {
/**
* triggered at the start of a task executor or when the task executor has lost connection to the resource cluster
* previously
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: extra word?

Copy link
Contributor

@codyrioux codyrioux left a comment

Choose a reason for hiding this comment

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

LGTM but would consider pushing the limits of what we can use Lombok for to decrease the verbosity. Ie: @RequiredArgsConstructor(staticName="of") for the of static factories.

@sundargates sundargates merged commit 0be3228 into Netflix:master Mar 21, 2022
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.

5 participants