-
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
Changes from 5 commits
77cb958
5afce17
298f71c
008eaa2
a469d15
0845b80
e1ee388
cb5cd7f
f7d5211
0d767d2
df9182f
2036fb6
591e238
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
package com.hubspot.singularity.api; | ||
|
||
import com.google.common.base.Optional; | ||
|
||
public class SingularityBounceRequestBuilder { | ||
|
||
private Optional<Boolean> incremental; | ||
private Optional<Boolean> skipHealthchecks; | ||
|
||
private Optional<Long> durationMillis; | ||
private Optional<String> actionId; | ||
private Optional<String> message; | ||
|
||
public SingularityBounceRequestBuilder() { | ||
this.incremental = Optional.absent(); | ||
this.skipHealthchecks = Optional.absent(); | ||
|
||
this.durationMillis = Optional.absent(); | ||
this.actionId = Optional.absent(); | ||
this.message = Optional.absent(); | ||
} | ||
|
||
public SingularityBounceRequest build() { | ||
return new SingularityBounceRequest(incremental, skipHealthchecks, durationMillis, actionId, message); | ||
} | ||
|
||
public Optional<Long> getDurationMillis() { | ||
return durationMillis; | ||
} | ||
|
||
public SingularityBounceRequestBuilder setDurationMillis(Optional<Long> durationMillis) { | ||
this.durationMillis = durationMillis; | ||
return this; | ||
} | ||
|
||
public Optional<String> getActionId() { | ||
return actionId; | ||
} | ||
|
||
public SingularityBounceRequestBuilder setActionId(Optional<String> actionId) { | ||
this.actionId = actionId; | ||
return this; | ||
} | ||
|
||
public Optional<String> getMessage() { | ||
return message; | ||
} | ||
|
||
public SingularityBounceRequestBuilder setMessage(Optional<String> message) { | ||
this.message = message; | ||
return this; | ||
} | ||
|
||
public Optional<Boolean> getIncremental() { | ||
return incremental; | ||
} | ||
|
||
public SingularityBounceRequestBuilder setIncremental(Optional<Boolean> incremental) { | ||
this.incremental = incremental; | ||
return this; | ||
} | ||
|
||
public Optional<Boolean> getSkipHealthchecks() { | ||
return skipHealthchecks; | ||
} | ||
|
||
public SingularityBounceRequestBuilder setSkipHealthchecks(Optional<Boolean> skipHealthchecks) { | ||
this.skipHealthchecks = skipHealthchecks; | ||
return this; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "SingularityBounceRequestBuilder{" + | ||
"durationMillis='" + durationMillis + '\'' + | ||
", actionId='" + actionId + '\'' + | ||
", message=" + message + '\'' + | ||
", incremental=" + incremental + '\'' + | ||
", skipHealthchecks=" + skipHealthchecks + '\'' + | ||
"}"; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,6 +53,7 @@ public class RequestManager extends CuratorAsyncManager { | |
private final Transcoder<SingularityRequestLbCleanup> requestLbCleanupTranscoder; | ||
|
||
private final SingularityEventListener singularityEventListener; | ||
private final SingularityConfiguration singularityConfiguration; | ||
|
||
private static final String REQUEST_ROOT = "/requests"; | ||
|
||
|
@@ -80,14 +81,16 @@ public class RequestManager extends CuratorAsyncManager { | |
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 commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
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 commentThe reason will be displayed to describe this comment to others. Learn more. it doesn't look like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oops, sure thing. The perils of moving methods around. |
||
|
||
this.expiringTranscoderMap = ImmutableMap.of( | ||
SingularityExpiringBounce.class, expiringBounceTranscoder, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
import java.util.List; | ||
import java.util.Map; | ||
import java.util.UUID; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
import javax.ws.rs.Consumes; | ||
import javax.ws.rs.DELETE; | ||
|
@@ -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()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. last nitpick on this, since this can be the user-provided data or the default, |
||
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 commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 ( There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ^ 👍. The JVM's ability to hop between primitives ( |
||
defaultBounceRequest = defaultBounceRequest | ||
.toBuilder() | ||
.setDurationMillis(Optional.of(durationMillis)) | ||
.build(); | ||
} | ||
|
||
requestManager.saveExpiringObject(new SingularityExpiringBounce(requestId, deployId, JavaUtils.getUserEmail(user), | ||
System.currentTimeMillis(), bounceRequest.or(SingularityBounceRequest.defaultRequest()), actionId.get())); | ||
System.currentTimeMillis(), defaultBounceRequest, actionId.get())); | ||
|
||
return fillEntireRequest(requestWithState); | ||
} | ||
|
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