-
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 1 commit
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 |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
import java.util.Collection; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
import org.apache.curator.framework.CuratorFramework; | ||
import org.apache.curator.utils.ZKPaths; | ||
|
@@ -31,6 +32,7 @@ | |
import com.hubspot.singularity.SingularityRequestHistory.RequestHistoryType; | ||
import com.hubspot.singularity.SingularityRequestLbCleanup; | ||
import com.hubspot.singularity.SingularityRequestWithState; | ||
import com.hubspot.singularity.api.SingularityBounceRequest; | ||
import com.hubspot.singularity.api.SingularityExpiringRequestParent; | ||
import com.hubspot.singularity.config.SingularityConfiguration; | ||
import com.hubspot.singularity.data.transcoders.Transcoder; | ||
|
@@ -53,6 +55,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 +83,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) { | ||
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, | ||
|
@@ -385,7 +390,31 @@ public <T extends SingularityExpiringParent<? extends SingularityExpiringRequest | |
} | ||
|
||
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 commentThe 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 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. Will fix |
||
if (!optionalBounce.isPresent()) { | ||
return optionalBounce; | ||
} | ||
final SingularityExpiringBounce bounce = optionalBounce.get(); | ||
if (bounce.getExpiringAPIRequestObject().getDurationMillis().isPresent()) { | ||
return optionalBounce; | ||
} | ||
final Long durationMillis = TimeUnit.MINUTES.toMillis(singularityConfiguration.getDefaultBounceExpirationMinutes()); | ||
return Optional.of( | ||
new SingularityExpiringBounce( | ||
bounce.getRequestId(), | ||
bounce.getDeployId(), | ||
bounce.getUser(), | ||
bounce.getStartMillis(), | ||
new SingularityBounceRequest( | ||
bounce.getExpiringAPIRequestObject().getIncremental(), | ||
bounce.getExpiringAPIRequestObject().getSkipHealthchecks(), | ||
Optional.of(durationMillis), | ||
bounce.getExpiringAPIRequestObject().getActionId(), | ||
bounce.getExpiringAPIRequestObject().getMessage() | ||
), | ||
bounce.getActionId() | ||
) | ||
); | ||
} | ||
|
||
public Optional<SingularityExpiringPause> getExpiringPause(String 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.
singularityConfiguration
is not in use