-
Notifications
You must be signed in to change notification settings - Fork 188
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
Guarantee durationMillis is present in getExpiringBounce response #1197
Conversation
@@ -385,7 +390,31 @@ public SingularityDeleteResult deleteLbCleanupRequest(String requestId) { | |||
} | |||
|
|||
public Optional<SingularityExpiringBounce> getExpiringBounce(String requestId) { | |||
return getExpiringObject(SingularityExpiringBounce.class, requestId); | |||
final Optional<SingularityExpiringBounce> optionalBounce = getExpiringObject(SingularityExpiringBounce.class, requestId); |
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.
more of a convention thing, we tend to name vars for optionals as maybe..., so in this case maybeExpiringBounce
or something similar
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.
Will fix
|
@@ -20,6 +20,34 @@ public String getDeployId() { | |||
return deployId; | |||
} | |||
|
|||
public static Optional<SingularityExpiringBounce> withDefaultExpiringMillis( |
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.
we should make a SingularityExpiringBounceBuilder
object instead... that way you can do something like:
SingularityExpiringBounceBuilder.buildUpon(myExpiringBounceObject).setDurationMillis(Optional.of(7)).build()
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.
nevermind, i didn't realize this was so nested (edit: we talked offline and we're gonna do builders for both classes)
@@ -201,8 +202,17 @@ public SingularityRequestParent bounce(@ApiParam("The request ID to bounce") @Pa | |||
|
|||
requestManager.bounce(requestWithState.getRequest(), System.currentTimeMillis(), JavaUtils.getUserEmail(user), message); | |||
|
|||
SingularityBounceRequest defaultBounceRequest = bounceRequest.or(SingularityBounceRequest.defaultRequest()); | |||
if (!defaultBounceRequest.getDurationMillis().isPresent()) { | |||
final Long durationMillis = TimeUnit.MINUTES.toMillis(configuration.getDefaultBounceExpirationMinutes()); |
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 is a nitpick, but you should utilize primitive types wherever possible (i.e. long
instead of Long
)
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.
In this case I was following the convention established in the constructor of the SingularityBounceRequest
class (@JsonProperty("durationMillis") Optional<Long> durationMillis
). If I change it here, should I change it in the constructor as well?
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.
When using it as a type in the Optional<> you have to use the generic object (Long
) in that case. A primitive does not extend any Object
so it cannot be the type argument there. But, when it isn't required to have the generic object (like in your case, just setting a variable and using the value) it is preferred to use the primitive. You can pass that primitive (long
) as an arg for something that takes Long
just fine. (i.e. Optional.of(yourVar)
)
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.
^ 👍. The JVM's ability to hop between primitives (long
) and "boxed" types (Long
) is called auto-boxing. This is just one of those style things everyone learns the hard way 😃
super(curator, configuration, metricRegistry); | ||
this.requestTranscoder = requestTranscoder; | ||
this.requestCleanupTranscoder = requestCleanupTranscoder; | ||
this.pendingRequestTranscoder = pendingRequestTranscoder; | ||
this.requestHistoryTranscoder = requestHistoryTranscoder; | ||
this.singularityEventListener = singularityEventListener; | ||
this.requestLbCleanupTranscoder = requestLbCleanupTranscoder; | ||
this.singularityConfiguration = singularityConfiguration; |
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.
it doesn't look like singularityConfiguration
is in use in this class anymore, can you remove it?
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.
Oops, sure thing. The perils of moving methods around.
@@ -80,7 +80,8 @@ | |||
public RequestManager(CuratorFramework curator, SingularityConfiguration configuration, MetricRegistry metricRegistry, SingularityEventListener singularityEventListener, | |||
Transcoder<SingularityRequestCleanup> requestCleanupTranscoder, Transcoder<SingularityRequestWithState> requestTranscoder, Transcoder<SingularityRequestLbCleanup> requestLbCleanupTranscoder, | |||
Transcoder<SingularityPendingRequest> pendingRequestTranscoder, Transcoder<SingularityRequestHistory> requestHistoryTranscoder, Transcoder<SingularityExpiringBounce> expiringBounceTranscoder, | |||
Transcoder<SingularityExpiringScale> expiringScaleTranscoder, Transcoder<SingularityExpiringPause> expiringPauseTranscoder, Transcoder<SingularityExpiringSkipHealthchecks> expiringSkipHealthchecksTranscoder) { | |||
Transcoder<SingularityExpiringScale> expiringScaleTranscoder, Transcoder<SingularityExpiringPause> expiringPauseTranscoder, Transcoder<SingularityExpiringSkipHealthchecks> expiringSkipHealthchecksTranscoder, | |||
SingularityConfiguration singularityConfiguration) { |
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.
singularityConfiguration
is not in use
LGTM after last 2 comments are addressed |
Both comments have been addressed. Does this look good to go? |
Looks good @MattCCS |
LGTM, good to merge once this has been re-merged / redeployed through the 3 environments |
", actionId='" + actionId + '\'' + | ||
", message=" + message + '\'' + | ||
", incremental=" + incremental + '\'' + | ||
", skipHealthchecks=" + skipHealthchecks + '\'' + |
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: you might have changed this already, but the last three parts are missing the first apostrophe ", incremental="
=> ", incremental='"
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.
Will fix
This PR guarantees that a bounce request's result always includes the durationMillis, whether a value was given or not. If no value was given, the durationMillis value is the appropriate default.
/cc @ssalinas @wolfd @tpetr