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
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Optional<SingularityExpiringBounce> maybeExpiringBounce,
Long durationMillis) {
if (!maybeExpiringBounce.isPresent()) {
return maybeExpiringBounce;
}
final SingularityExpiringBounce bounce = maybeExpiringBounce.get();
if (bounce.getExpiringAPIRequestObject().getDurationMillis().isPresent()) {
return maybeExpiringBounce;
}
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()
)
);
}

@Override
public String toString() {
return "SingularityExpiringBounce [toString()=" + super.toString() + "]";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -53,6 +54,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";

Expand Down Expand Up @@ -80,14 +82,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) {
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

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.


this.expiringTranscoderMap = ImmutableMap.of(
SingularityExpiringBounce.class, expiringBounceTranscoder,
Expand Down Expand Up @@ -385,7 +389,9 @@ public <T extends SingularityExpiringParent<? extends SingularityExpiringRequest
}

public Optional<SingularityExpiringBounce> getExpiringBounce(String requestId) {
return getExpiringObject(SingularityExpiringBounce.class, requestId);
return SingularityExpiringBounce.withDefaultExpiringMillis(
getExpiringObject(SingularityExpiringBounce.class, requestId),
TimeUnit.MINUTES.toMillis(singularityConfiguration.getDefaultBounceExpirationMinutes()));
}

public Optional<SingularityExpiringPause> getExpiringPause(String requestId) {
Expand Down