-
Notifications
You must be signed in to change notification settings - Fork 202
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
Conversation
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 { |
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.
nit: I'd call out the semantic difference between this and static toJson
in comments.
Also, could we make this static?
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.
I have removed all the static methods.
@RequiredArgsConstructor(access = AccessLevel.PRIVATE) | ||
@Value | ||
public class ClusterID { | ||
String resourceID; |
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.
this should be private?
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.
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 |
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.
constructor?
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.
value annotation creates an "allargsconstructor".
import io.mantisrx.common.JsonSerializer; | ||
import org.junit.Test; | ||
|
||
public class TestTaskExecutorRegistration { |
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.
nit: we should follow convention. call this TaskExecutorRegistrationTest
. Move the heartbeat test to TaskExecutorHeartbeatTest
.
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.
Renamed the class.
public class ClusterID { | ||
String resourceID; | ||
|
||
public static ClusterID of(String clusterIdStr) { |
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.
Just wondering what's your thought on static "of" v.s. lombok builder?
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.
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")
.
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.
Very true. "of" is definitely cleaner on the single arg ctor case.
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.
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?
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.
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 |
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.
nit: extra word?
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.
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.
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./gradlew test
passes all testsCONTRIBUTING.md