-
Notifications
You must be signed in to change notification settings - Fork 30
Add initial ServiceRuntime for Dynamic Services [ECR-3404] #1065
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
Add initial ServiceRuntime for Dynamic Services [ECR-3404] #1065
Conversation
7c135d4
to
0ba481a
Compare
How to review:
|
|
public abstract String getName(); | ||
|
||
/** | ||
* Returns the numeric id of the service instance. Exonum assigns it to the service |
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.
Exonum assigns it to the service on instantiation.
As I remember, a user must provide id for its service which is unique within the network. Does it change?
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.
Yes, it has been changed in dynamic services. As administrators can create several instances from the same artifact, the service id cannot be hardcoded in the service definition, but must be assigned on instantiation, so that the transaction messages can be routed to the correct instance. The id assignment is done by the core; the name is provided by the administrators (and is considered the primary identifier of the service instance).
this.frameworkInjector = checkNotNull(frameworkInjector); | ||
this.serviceLoader = checkNotNull(serviceLoader); | ||
this.servicesFactory = checkNotNull(servicesFactory); | ||
services = new TreeMap<>(); |
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 would move instantiations to the field ^
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.
What is the reasoning behind your suggestion? I can think of bringing the definition closer to the field declaration 🤔
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.
exactly
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.
👍
static mut CLASS_GET_NAME: Option<JMethodID> = None; | ||
static mut THROWABLE_GET_MESSAGE: Option<JMethodID> = None; | ||
|
||
// todo: Remove transaction and service adapter items when native JavaServiceRuntime is implemented |
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.
Link to the task?
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 is one 'Implement JavaServiceRuntime' in the native, but it isn't in Jira till some questions on it are clarified: https://wiki.bf.local/display/EJB/Java+Dynamic+Services+P1+Design#JavaDynamicServicesP1Design-%D0%97%D0%B0%D0%B4%D0%B0%D1%87%D0%B8
@@ -0,0 +1,43 @@ | |||
package com.exonum.binding.core.runtime; |
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.
Copyright
} | ||
|
||
private static ServiceId extractServiceId(String pluginId) throws ServiceLoadingException { | ||
private static ServiceArtifactId extractServiceId(String pluginId) |
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.
extractServiceArtifactId
?
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 suggest keeping it as is for brevity — it must be clear from the context.
@@ -0,0 +1,23 @@ | |||
package com.exonum.binding.core.runtime; |
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.
Copyright
@@ -0,0 +1,35 @@ | |||
package com.exonum.binding.core.runtime; |
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.
Copyright
@@ -0,0 +1,77 @@ | |||
package com.exonum.binding.core.runtime; |
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.
Copyright
@@ -0,0 +1,25 @@ | |||
package com.exonum.binding.core.runtime; |
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.
Copyright
/** | ||
* Converts an Exonum raw transaction to an executable transaction of <em>this</em> service. | ||
* Returns a list of hashes representing the state of this service, as of the given snapshot | ||
* of the blockchain state. Usually, it includes the root hashes of all Merkelized collections |
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.
Root hashes or object/index hashes?
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.
Yes, thanks!
* @param arguments the {@linkplain TransactionMessage#getPayload() serialized transaction | ||
* arguments} | ||
* @return an executable transaction of the service | ||
* @throws IllegalArgumentException if the raw transaction is malformed or not known |
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.
Shouldn't we rephrase this exception description?
@@ -0,0 +1,93 @@ | |||
package com.exonum.binding.core.runtime; |
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.
Copyright
Looks good to me, but where is |
(or keep as is?)
- Perform the expected/actual id verification
* Remove: - getId — this one might be reconsidered - getName * Update configure to take configuration parameters and return void * Make getStateHashes implementation required (as no state hashes usually means "you don't need the blockchain or do it wrong"). Obviously, it neither compiles nor works.
#createService does not connect it to the Server yet — that is delayed till some questions are resolved.
It has a potential issue with memory usage which we shall consider together with the updates in Fork required for isolation of database modifications from different services in prospective beforeCommit
Also, pass them to native in Protobuf. No 3D arrays any longer.
ViewFactory is moved to the runtime package, as its main usages are there. Code mounting the API is still to be taken from UserServiceAdapter when the appropriate operation is added to the ServiceRuntime. Usages of UserServiceAdapter in the Testkit are left as is.
Move ServiceRuntime to integration tests as it uses the native library. Don't initialize the method ids of no longer existing classes when the native library is loaded. Setup some invocations.
Add Jira references where appropriate
aadf8a7
to
4f54926
Compare
Overview
Adds initial implementation of ServiceRuntime operations for dynamic services.
The code in dependent on core modules has not been migrated as the ServiceRuntime interface is not finalized yet, neither are the user-facing interfaces (like Service, Transaction, etc.).
See: https://jira.bf.local/browse/ECR-3404
Definition of Done