-
Notifications
You must be signed in to change notification settings - Fork 29
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
[ECR-4133] Add service resume #1372
Conversation
* message | ||
* @see ServiceRuntime#initializeResumingService(ServiceInstanceSpec, byte[]) | ||
*/ | ||
void initializeResumingService(byte[] instanceSpec, byte[] configuration) { |
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.
@vitvakatu method signature for ECR-4134
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.
I don't understand the Service#resume operation at all — it is inconsistent with node restarts; it is not possible to do anything from it — see the inline discussion.
exonum-java-binding/CHANGELOG.md
Outdated
@@ -36,7 +36,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. | |||
- `supervisor-mode` CLI parameter added for `generate-template` command. It | |||
allows to configure the mode of the Supervisor service. Possible values are | |||
"simple" and "decentralized". (#1361) | |||
- Service instances can be stopped now. (#1358) | |||
- Service instances can be stopped and resumed now. (#1358, #1372) |
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.
An instance artifact may be upgraded before resuming, but with no data changes.
(may also insert the uses cases from the epic/ECR-3773).
@@ -53,6 +53,24 @@ default void initialize(Fork fork, Configuration configuration) { | |||
// No configuration | |||
} | |||
|
|||
/** | |||
* Performs resuming of previously stopped service instance. This method is called <em>once</em> |
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.
* Resumes the previously stopped service instance. This method is called when
* a stopped service instance is restarted.
* the registry of call errors} if the resuming fails | ||
* @see Configurable | ||
*/ | ||
default void resume(Configuration configuration) { |
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.
@slowli, @bullet-tooth In which cases the service needs to be notified of that, if it can't do anything with this configuration, just look at them? I remember that the service instance objects are not supposed to have much state, therefore,
"As an example, arguments can be used to update the service configuration."
does not seem to make much sense — that configuration must be normally kept in the persistent storage. On top of that, we do not provide a similar operation for node restarts, when a fresh service instance object is also created, hence "update in the object instance" argument cannot be valid.
* | ||
* @param configuration the service configuration parameters | ||
* @throws ExecutionException if the configuration parameters are not valid (e.g., | ||
* malformed, or do not meet the preconditions). Exonum will save the error into |
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.
It will not save them.
* malformed, or do not meet the preconditions). Exonum will save the error into | ||
* {@linkplain com.exonum.binding.core.blockchain.Blockchain#getCallErrors(long) | ||
* the registry of call errors} if the resuming fails | ||
* @see Configurable |
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.
Configurable is not related to this, but initialize (if we decide to keep the method at all)
checkStoppedService(instanceSpec.getId()); | ||
ServiceWrapper service = createServiceInstance(instanceSpec); | ||
service.resume(new ServiceConfiguration(configuration)); | ||
} |
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.
Currently this class is responsible to log errors, though there is ECR-3813 to shift that.
/** Checks that the service with the given id is not active in this runtime. */ | ||
private void checkStoppedService(Integer serviceId) { | ||
checkArgument(!servicesById.containsKey(serviceId), | ||
"Service with id=%s should be stopped, but actually active", serviceId); |
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.
Add the offending instance?
@@ -96,8 +96,6 @@ void startsServerOnInitialization() { | |||
|
|||
@Test | |||
void deployCorrectArtifact() throws Exception { | |||
serviceRuntime.initialize(mock(Node.class)); |
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.
(Here and elsewhere) Why is this removed? No operation shall occur before SR is initialized.
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.
ok, I will add a null check to the decorator then
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.
Not sure I understand — the SR expects that it is first initialized with a non-null Node before any other operations are performed.
// and the service was configured | ||
Configuration expectedConfig = new ServiceConfiguration(configuration); | ||
verify(serviceWrapper).resume(expectedConfig); | ||
} |
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.
// but not registered in the runtime yet:
assertThat(serviceRuntime.findService(TEST_NAME)).isEmpty();
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.
configuration
does not seem appropriate in the #resume method.
exonum-java-binding/CHANGELOG.md
Outdated
@@ -36,7 +36,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. | |||
- `supervisor-mode` CLI parameter added for `generate-template` command. It | |||
allows to configure the mode of the Supervisor service. Possible values are | |||
"simple" and "decentralized". (#1361) | |||
- Service instances can be stopped now. (#1358) | |||
- Support of service instances lifecycle: they can be activated, stopped and resumed now. | |||
Also, service instance artifacts can be upgraded before resuming (but with no data changes) |
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.
No data changes, according to the recent discussions, is no longer correct.
I'd add to the list below 'synchronous data migration'.
* parameters, deprecate old entries etc. | ||
* | ||
* <p>Also, note that performing any bulk operations or data migration | ||
* <em>is not recommended</em> here. |
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.
I'd add short motivation, as Ostrovski clarified in the discussion.
* <!--TODO: Add a link to the migration procedure --> | ||
* | ||
* @param fork a database fork to apply changes to. Not valid after this method returns | ||
* @param configuration the service configuration parameters |
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.
As we've discussed, those are hardly configuration parameters, just generic 'arguments'.
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.
there are 2 questions here:
- should we use
Configuration
type orbyte[]
? Configuration looks more convenient - If we use Configuration class for the resume operation then it's javadoc and, probably, name (
ServiceArgumests
,ServiceParameters
?) should be updated.
Also, talking about Configuration, what is the reason for having interface + implementation(ServiceConfiguration), not just VO class?
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.
byte[]
since is it is not configuration. We shall not use Configuration for this operation — it is for configuration parameters.
It could be made one, it is made in this way probably to give more flexibility in terms of implementation (e.g., if we went with also properties).
verify(servicesFactory).createService(eq(serviceDefinition), eq(instanceSpec), | ||
any(MultiplexingNodeDecorator.class)); | ||
|
||
// and the service was configured |
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.
resumed
* Initiates resuming of previously stopped service instance. Service instance artifact could | ||
* be upgraded in advance to bring some new functionality. | ||
* | ||
* @param fork a database view to apply arguments |
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.
Arguments are not applied to a database.
Overview
See: https://jira.bf.local/browse/ECR-4133
Definition of Done