[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.
@vitvakatu method signature for ECR-4134
dmitry-timofeev
left a comment
There was a problem hiding this comment.
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.
| 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.
An instance artifact may be upgraded before resuming, but with no data changes.
(may also insert the uses cases from the epic/ECR-3773).
| } | ||
|
|
||
| /** | ||
| * Performs resuming of previously stopped service instance. This method is called <em>once</em> |
There was a problem hiding this comment.
* 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.
@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.
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.
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.
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.
Add the offending instance?
|
|
||
| @Test | ||
| void deployCorrectArtifact() throws Exception { | ||
| serviceRuntime.initialize(mock(Node.class)); |
There was a problem hiding this comment.
(Here and elsewhere) Why is this removed? No operation shall occur before SR is initialized.
There was a problem hiding this comment.
ok, I will add a null check to the decorator then
There was a problem hiding this comment.
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.
// but not registered in the runtime yet:
assertThat(serviceRuntime.findService(TEST_NAME)).isEmpty();
dmitry-timofeev
left a comment
There was a problem hiding this comment.
configuration does not seem appropriate in the #resume method.
| "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.
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.
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.
As we've discussed, those are hardly configuration parameters, just generic 'arguments'.
There was a problem hiding this comment.
there are 2 questions here:
- should we use
Configurationtype 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.
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 |
| * 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.
Arguments are not applied to a database.
Overview
See: https://jira.bf.local/browse/ECR-4133
Definition of Done