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

[ECR-4133] Add service resume #1372

Merged
merged 9 commits into from
Jan 23, 2020
Merged

[ECR-4133] Add service resume #1372

merged 9 commits into from
Jan 23, 2020

Conversation

bullet-tooth
Copy link
Contributor

Overview


See: https://jira.bf.local/browse/ECR-4133

Definition of Done

  • There are no TODOs left in the code
  • Change is covered by automated tests
  • The coding guidelines are followed
  • Public API has Javadoc
  • Method preconditions are checked and documented in the Javadoc of the method
  • Changelog is updated if needed (in case of notable or breaking changes)
  • The continuous integration build passes

* message
* @see ServiceRuntime#initializeResumingService(ServiceInstanceSpec, byte[])
*/
void initializeResumingService(byte[] instanceSpec, byte[] configuration) {
Copy link
Contributor Author

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

@coveralls
Copy link

coveralls commented Jan 21, 2020

Coverage Status

Coverage increased (+0.02%) to 85.064% when pulling 367b32e on ecr-4133 into 6aabf29 on master.

Copy link
Contributor

@dmitry-timofeev dmitry-timofeev left a 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.

@@ -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)
Copy link
Contributor

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>
Copy link
Contributor

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) {
Copy link
Contributor

@dmitry-timofeev dmitry-timofeev Jan 21, 2020

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
Copy link
Contributor

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
Copy link
Contributor

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));
}
Copy link
Contributor

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);
Copy link
Contributor

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));
Copy link
Contributor

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.

Copy link
Contributor Author

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

Copy link
Contributor

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);
}
Copy link
Contributor

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();

Copy link
Contributor

@dmitry-timofeev dmitry-timofeev left a 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.

@@ -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)
Copy link
Contributor

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.
Copy link
Contributor

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
Copy link
Contributor

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'.

Copy link
Contributor Author

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 or byte[]? 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?

Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Contributor

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.

@dmitry-timofeev dmitry-timofeev merged commit eb2b5f6 into master Jan 23, 2020
@dmitry-timofeev dmitry-timofeev deleted the ecr-4133 branch January 23, 2020 19:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants