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

Introduce manual job restart #693

Merged
merged 1 commit into from Feb 6, 2018
Merged

Conversation

metanet
Copy link
Contributor

@metanet metanet commented Jan 31, 2018

A new method is added to the Job interface. If the user calls job.restart() while a job is running, the job is restarted on the current member list of the cluster from the last successful snapshot. The new method can be used as a non-graceful way of achieving elasticity.

@metanet metanet added this to the 0.6 milestone Jan 31, 2018
@devOpsHazelcast
Copy link
Contributor

Test FAILed.

boolean cancelCurrentExecution() {
ExecutionCallback<Object> callback = this.executionCancellationCallback;
if (callback != null) {
callback.onFailure(null);
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 add a comment here. Do you think having an explict exception would be better? I.e. JobRestartRequestedException ? Also naming is still a bit ambiguous between cancelExecute and cancelCurrentExecution`.

invoke(operationCtor, this::onExecuteStepCompleted, callback);
Consumer<Map<MemberInfo, Object>> completionCallback = results -> {
executionCancellationCallback = null;
onExecuteStepCompleted(results);
Copy link
Contributor

Choose a reason for hiding this comment

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

I can see that the job is only restarted when it's TopologyChangedException and auto-restart is enabled, otherwise a restart will not be scheduled.

@cangencer
Copy link
Contributor

verify

@devOpsHazelcast
Copy link
Contributor

Test PASSed.

@metanet
Copy link
Contributor Author

metanet commented Feb 2, 2018

verify

@devOpsHazelcast
Copy link
Contributor

Test PASSed.

1 similar comment
@devOpsHazelcast
Copy link
Contributor

Test PASSed.

* Cancels the execution invocation in order to restart it afterwards if the job is currently being executed
*/
boolean cancelCurrentExecution() {
CompletionToken restartFuture = this.executionRestartToken;
Copy link
Contributor

Choose a reason for hiding this comment

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

name still says "future"


/**
* Wraps a CompletableFuture that is expected to be completed
* only in a single way and provides methods for easy of use
Copy link
Contributor

Choose a reason for hiding this comment

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

typo "ease"

}

public void whenCompleted(Runnable runnable) {
future.whenComplete((result, throwable) -> runnable.run());
Copy link
Contributor

Choose a reason for hiding this comment

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

it should use withTryCatch here, otherwise any exceptions in callback are lost and won't be visible.

private final CompletableFuture<Void> future = new CompletableFuture<>();

public boolean complete() {
return completeVoidFuture(future);
Copy link
Contributor

Choose a reason for hiding this comment

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

this method is now deleted after spotbugs change, you need to rebase

@devOpsHazelcast
Copy link
Contributor

Test PASSed.

@devOpsHazelcast
Copy link
Contributor

Test FAILed.

@metanet
Copy link
Contributor Author

metanet commented Feb 2, 2018

verify

@devOpsHazelcast
Copy link
Contributor

Test PASSed.

@devOpsHazelcast
Copy link
Contributor

Test PASSed.

Copy link
Contributor

@viliam-durina viliam-durina left a comment

Choose a reason for hiding this comment

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

Since all my comments are only about naming/documentation I approve.

/**
* Cancels the job execution invocations in order to restart it afterwards if the job is currently being executed
*/
boolean cancelCurrentExecution() {
Copy link
Contributor

Choose a reason for hiding this comment

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

You use the terms "restart" and "cancel current execution" for the same thing. I would be good to use one, "restart" is easier to understand for me.


// We must set executionRestartToken before we call invoke() method because once all invocations
// are done, executionRestartToken will be reset. Therefore, setting it after the invoke() call is racy.
this.executionRestartToken = executionRestartFuture;
Copy link
Contributor

Choose a reason for hiding this comment

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

The local variable could also be named executionRestartToken

*
* @throws IllegalStateException if the job has been already completed
*
* @return true if the current execution of the job is cancelled
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be good to mention when false is returned. I guess it's when job is not yet started or is already restarting.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We already mention when it returns true: "Cancels the current execution if the job is currently in running". Do we need to mention when it returns false?

Copy link
Contributor

Choose a reason for hiding this comment

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

Now I got your point. But anyway, i mean it would be good to mention it in the @return clause.

A new method is added to the Job interface. If the user calls job.restart() while a job is running, the job is restarted on the current member list of the cluster from the last successful snapshot. The new method can be used as a non-graceful way of achieving elasticity.
@devOpsHazelcast
Copy link
Contributor

Test PASSed.

2 similar comments
@devOpsHazelcast
Copy link
Contributor

Test PASSed.

@devOpsHazelcast
Copy link
Contributor

Test PASSed.

@metanet metanet merged commit 6d2bd5a into hazelcast:master Feb 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants