Run a ScalarDL Application Through ScalarDL Ledger
This guide explains how to run a ScalarDL application through ScalarDL Ledger. This document assumes that you have already tried one of the Quickstart tutorials and created your application that integrates ScalarDL by using client SDKs by referring to the Write an Application guides.
Decide on configurations​
Before running ScalarDL applications through Ledger, you first need to configure Ledger and the client that interacts with Ledger.
There are several important options that you must set and decisions to make as described below.
Disable Auditor​
You must disable Auditor since you'll be running your applications through only Ledger. Disabling Auditor has to be done in the client and Ledger configurations as follows.
- In the client configuration, set
scalar.dl.client.auditor.enabledtofalse. (Sincefalseis the default value, you can choose to omit this property.) - In the Ledger configuration, set
scalar.dl.ledger.auditor.enabledtofalse. (Sincefalseis the default value, you can choose to omit this property.)
If you are using the scalardl-samples environment, see the ledger.properties file for the corresponding storage.
For details about the configurations, see the following:
Decide on an authentication method​
You must decide which authentication method to use for clients: digital signature or HMAC. As a simple comparison, the digital-signature method provides non-repudiation in addition to authentication but is slow, whereas the HMAC method provides only authentication but is fast.
You can configure an authentication method as follows. The same method (digital-signature or hmac) must be configured in both the client and Ledger.
- In the client configuration, set
scalar.dl.client.authentication.methodtodigital-signatureorhmac(depending on which method you choose). - In the Ledger configuration, set
scalar.dl.ledger.authentication.methodtodigital-signatureorhmac(depending on which method you choose).
You also need to prepare some secret information. If you're using the digital-signature method you need to prepare a certificate and a private key. If you're using the HMAC method, you need to prepare a secret key. For more details about the authentication in ScalarDL, check out the ScalarDL Authentication Guide.
For details about the configurations, see the following:
Configure your database​
Ledger uses ScalarDB to interact with databases, which enables you to run ScalarDL on top of various databases. So, you need to decide on a database that ScalarDB supports based on your applications' requirements and configure several ScalarDB parameters.
For details about the ScalarDB parameters, see also ScalarDB Configurations.
Underlying database​
You can configure which database to use as follows:
- In the Ledger configuration, set
scalar.db.storage,scalar.db.contact_points,scalar.db.username, andscalar.db.passwordto the appropriate values based on the database that you'll be using.
For databases and their versions supported by ScalarDL via ScalarDB, see Requirements.
If your applications read and write a table through the Function feature, and the table is also directly accessed from ScalarDB applications, you need to properly configure the database chosen here. Specifically, both ScalarDL and ScalarDB applications must refer to the same Coordinator table to guarantee consistency.
Isolation level​
Ledger relies on the Consensus Commit transaction manager of ScalarDB to manage transactions. The transaction manager is responsible for guaranteeing the isolation property of transactions, which is crucial for ensuring the consistency and correctness of transactions.
You can configure the isolation level of Ledger as follows. If you are unsure about which isolation level to use, use SERIALIZABLE.
- In the Ledger configuration, set
scalar.db.consensus_commit.isolation_levelto an isolation level of your choice. The default value isSNAPSHOT.
Limitations​
While ScalarDL leverages ScalarDB, the following ScalarDB features are not compatible with the consistency guarantee mechanism of ScalarDL:
- Group commit for the Coordinator table (
scalar.db.consensus_commit.coordinator.group_commit.enabledmust befalse.) - Coordinator write omission optimization in Performance-related configurations (
scalar.db.consensus_commit.coordinator.write_omission_on_read_only.enabledmust befalse.)
Decide which other configurations to use​
You can also apply other configurations, such as TLS and gRPC configurations, for the client and Ledger. For details about the configurations, see the following:
Start Ledger​
After configuring Ledger and the client, you need to start up Ledger.
For details on how to locally start up Ledger by using Docker Compose, see Start up ScalarDL with your preferred database. For how to start up Ledger in local or cloud-based Kubernetes environments, see Deploy ScalarDL in your local Kubernetes environment or Deploy ScalarDL in a cloud-based Kubernetes environment, respectively.
Set up clients for the HashStore, TableStore, or Ledger abstractions​
Depending on the abstraction that your application is based on (specifically, HashStore, TableStore, or Ledger), the setup instructions are different. Select an abstraction and follow the instructions.
- HashStore
- TableStore
- Ledger
Bootstrap HashStore clients
When creating HashStoreClientService in your application, the client certificate or secret key and the necessary contracts for using HashStore are automatically registered based on the configuration in ClientConfig. Thus, you don't have to manually bootstrap HashStore clients. If you would like to do it manually, for example, for testing purposes, download the HashStore Client SDK by following Download the Client SDK and run the following command.
scalardl-hashstore bootstrap --properties <CLIENT_PROPERTIES_FILE>
Bootstrap TableStore clients
When creating TableStoreClientService in your application, the client certificate or secret key and the necessary contracts for using TableStore are automatically registered based on the configuration in ClientConfig. Thus, you don't have to manually bootstrap TableStore clients. If you would like to do it manually, for example, for testing purposes, download the TableStore Client SDK by following Download the Client SDK and run the following command.
scalardl-tablestore bootstrap --properties <CLIENT_PROPERTIES_FILE>
Download the client commands
When you set up Ledger clients, you need to run the client commands, which are included in the Client SDK. To get the Client SDK, see Download the Client SDK.
Bootstrap Ledger clients
Register the client identity and system contracts by running the following bootstrap command:
scalardl bootstrap --properties <CLIENT_PROPERTIES_FILE>
The bootstrap command registers the client certificate or secret key based on the authentication configuration done in Decide on an authentication method.
You can also bootstrap by using ClientService in the ScalarDL Java Client SDK.
Register contracts and functions
You can register contracts by using the register-contract command.
scalardl register-contract --properties <CLIENT_PROPERTIES_FILE> --contract-id <CONTRACT_ID> --contract-binary-name <CONTRACT_BINARY_NAME> --contract-class-file <CONTRACT_CLASS_FILE>
You can register functions by using the register-function command.
scalardl register-function --properties <CLIENT_PROPERTIES_FILE> --function-id <FUNCTION_ID> --function-binary-name <FUNCTION_BINARY_NAME> --function-class-file <FUNCTION_CLASS_FILE>
You can also register contracts and functions by using ClientService in the ScalarDL Java Client SDK.
Run your application​
Now that you have registered the necessary identities and contracts, you can run your application that integrates ScalarDL.
See also​
For details about each command, see the following command references: