Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions auth/access_token_credentials/src/main/resources/log4j2.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN" shutdownHook="disable">
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="%d{HH:mm:ss.SSS} %-5level %logger{1} - %msg%n"/>
</Console>
</Appenders>

<Loggers>
<Logger name="io.netty" level="warn" additivity="false">
<AppenderRef ref="Console"/>
</Logger>
<Logger name="io.grpc.netty" level="warn" additivity="false">
<AppenderRef ref="Console"/>
</Logger>
<Logger name="tech.ydb.core.grpc" level="info" additivity="false">
<AppenderRef ref="Console"/>
</Logger>
<Logger name="tech.ydb.table" level="info" additivity="false">
<AppenderRef ref="Console"/>
</Logger>
<Logger name="tech.ydb.table.SessionRetryContext" level="info" additivity="false">
<AppenderRef ref="Console"/>
</Logger>
<Logger name="tech.ydb.table.Session" level="info" additivity="false">
<AppenderRef ref="Console"/>
</Logger>

<Root level="debug" >
<AppenderRef ref="Console"/>
</Root>
</Loggers>
</Configuration>
2 changes: 1 addition & 1 deletion jdbc/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<packaging>pom</packaging>

<properties>
<ydb.jdbc.version>2.3.13</ydb.jdbc.version>
<ydb.jdbc.version>2.3.16</ydb.jdbc.version>
<slf4j.version>1.7.36</slf4j.version>
</properties>

Expand Down
76 changes: 76 additions & 0 deletions jdbc/ydb-token-app/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
## YDB Token Application
## A simple example of Spring Boot 2 Application working with YDB Database

### How to build

Requirements
* Java 17 or newer
* Maven 3.0.0 or newer

To build the application as a single executable jar file, run the command:
```
cd ydb-java-examples/jdbc/ydb-token-app
mvn clean package spring-boot:repackage
```
After that, the compiled `ydb-token-app-1.1.0-SNAPSHOT.jar` can be found in the target folder.

### What this application does

This application allows you to create a test table called `app_token` in the YDB database, populate it with data, and
launch a test workload for parallel reading and writing to this table. During the test, the following operations will be
performed in parallel in several threads:
* Read a random token from the database - 50% of operations
* Read and update a random token in the database - 40% of operations
* Read and update 100 random tokens in the database - 10% of operations

The statistics collected during the test include the number of operations performed, RPS (requests per second), and
average execution time for each type of operation. There is also support for exporting application metrics in Prometheus
format.

### How to launch

The application is built as a single executable jar file and can be run with the command:
```
java -jar ydb-token-app-1.1.0-SNAPSHOT.jar <options> <commands>
```
Where `options` are application parameters (see the Application Parameters section), and `commands` are the sequence of
commands the application will execute one after the other. Currently, the following commands are supported:
* clean - clean the database, the `app_token` table will be deleted
* init - prepare the database, the empty `app_token` table will be created
* load - load test data, the `app_token` table will be filled with initial data
* run - start the test workload
* validate - validate current data stored in database

Commands can be used individually or sequenced, for example:

Recreate the `app_token` table and initialize it with initial data:
```
java -jar ydb-token-app-1.1.0-SNAPSHOT.jar --app.connection=grpcs://my-ydb:2135/my-database clean init load
```

Start the test and then clean the database:
```
java -jar ydb-token-app-1.1.0-SNAPSHOT.jar --app.connection=grpcs://my-ydb:2135/my-database run clean
```

Recreate the `app_token` table, initialize it with data, and start the test:
```
java -jar ydb-token-app-1.1.0-SNAPSHOT.jar --app.connection=grpcs://my-ydb:2135/my-database clean init load run
```

### Application parameters

Application parameters allow you to configure different aspects of the application's operation, primarily the database connection address.
The main parameters list:

* `app.connection` - database connection address. Specified as `<schema>://<endpoint>:<port>/<database>`
* `app.threadsCount` - number of threads the application creates. Defaults to the number of CPU cores on the host.
* `app.recordsCount` - number of records in the table used for testing. Default is 1 million.
* `app.load.batchSize` - batch size for loading data when running the load command. Default is 1000.
* `app.workload.duration` - test duration in seconds when running the run command. Default is 60 seconds.
* `app.rpsLimit` - limit on the number of operations per second during the run command. By default, there is no limit (-1).
* `app.pushMetrics` - flag indicating whether metrics should be exported to Prometheus; disabled by default.
* `app.prometheusUrl` - endpoint of Prometheus to export metrics to. Default is http://localhost:9091.

All parameters can be passed directly when launching the application (in the format `--param_name=value`) or can be
preconfigured in an `application.properties` file saved next to the executable jar of the application.
50 changes: 47 additions & 3 deletions jdbc/ydb-token-app/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,38 @@
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<version>${spring.boot.version}</version>
</dependency>
<!-- <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>-->

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
</dependency>
<dependency>
<groupId>io.prometheus</groupId>
<artifactId>simpleclient_pushgateway</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.retry</groupId>
<artifactId>spring-retry</artifactId>
<version>2.0.7</version>
</dependency>
<dependency>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
<version>2.3.2</version>
</dependency>

<dependency>
<groupId>tech.ydb.jdbc</groupId>
<artifactId>ydb-jdbc-driver</artifactId>
</dependency>

<dependency>
<groupId>tech.ydb.dialects</groupId>
<artifactId>hibernate-ydb-dialect-v5</artifactId>
Expand All @@ -57,6 +72,35 @@
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring.boot.version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.12.1</version>
<configuration>
<release>17</release>
<compilerArgs>
<arg>-Xlint</arg>
</compilerArgs>
</configuration>
</plugin>
</plugins>
</build>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>${spring.boot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>

<dependency>
<groupId>org.springframework.retry</groupId>
<artifactId>spring-retry</artifactId>
<version>2.0.12</version>
</dependency>
</dependencies>
</dependencyManagement>
</project>
Loading