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

Guarantee durationMillis is present in getExpiringBounce response #1197

Merged
merged 13 commits into from
Aug 25, 2016

Conversation

MattCCS
Copy link
Contributor

@MattCCS MattCCS commented Aug 9, 2016

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

@@ -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);
Copy link
Member

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will fix

@tpetr
Copy link
Contributor

tpetr commented Aug 9, 2016

  • Are more than just expring bounces affected by the missing field issue? I feel like all expiring objects that have an absent durationMillis field could benefit.
  • What happens when you create an expiring bounce with no durationMillis set, and then you redeploy Singularity with a different default value? Will the right thing happen in every case?
  • Expanding on above, why not populate durationMillis right before it's written in ZK, instead of populating it after every read?

@@ -20,6 +20,34 @@ public String getDeployId() {
return deployId;
}

public static Optional<SingularityExpiringBounce> withDefaultExpiringMillis(
Copy link
Contributor

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()

Copy link
Contributor

@tpetr tpetr Aug 9, 2016

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());
Copy link
Contributor

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)

Copy link
Contributor Author

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?

Copy link
Member

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))

Copy link
Contributor

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;
Copy link
Contributor

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?

Copy link
Contributor Author

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.

@ssalinas ssalinas modified the milestone: 0.11.0 Aug 19, 2016
@@ -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) {
Copy link
Contributor

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

@tpetr
Copy link
Contributor

tpetr commented Aug 24, 2016

LGTM after last 2 comments are addressed

@MattCCS
Copy link
Contributor Author

MattCCS commented Aug 24, 2016

Both comments have been addressed. Does this look good to go?

@ssalinas
Copy link
Member

Looks good @MattCCS

@tpetr
Copy link
Contributor

tpetr commented Aug 25, 2016

LGTM, good to merge once this has been re-merged / redeployed through the 3 environments

", actionId='" + actionId + '\'' +
", message=" + message + '\'' +
", incremental=" + incremental + '\'' +
", skipHealthchecks=" + skipHealthchecks + '\'' +
Copy link
Contributor

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='"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will fix

@MattCCS MattCCS merged commit 5839bda into master Aug 25, 2016
@tpetr tpetr removed hs_qa labels Aug 25, 2016
@MattCCS MattCCS deleted the bounce_millis_fix branch August 25, 2016 17:24
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.

4 participants