Git Product home page Git Product logo

ydb-java-sdk's Introduction

License Maven metadata URL Build CI Codecov

The Java SDK for YDB enables Java developers to work with YDB.

Getting Started

Connection setup

Before you begin, you need to create a database and setup authorization. Please see the Prerequisites section of the connection guide in documentation for information on how to do that.

Minimum requirements

To use YDB Java SDK you will need Java 1.8+.

Install the SDK

The recommended way to use the YDB Java SDK in your project is to consume it from Maven. Firstly you can import YDB Java BOM to specify correct versions of SDK modules.

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>tech.ydb</groupId>
            <artifactId>ydb-sdk-bom</artifactId>
            <version>2.2.5</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

After that you can specify the SDK modules that your project needs in the dependencies:

<dependencies>
    <!-- Scheme service client -->
    <dependency>
        <groupId>tech.ydb</groupId>
        <artifactId>ydb-sdk-scheme</artifactId>
    </dependency>

    <!-- Table service client -->
    <dependency>
        <groupId>tech.ydb</groupId>
        <artifactId>ydb-sdk-table</artifactId>
    </dependency>

    <!-- Topic service client -->
    <dependency>
        <groupId>tech.ydb</groupId>
        <artifactId>ydb-sdk-topic</artifactId>
    </dependency>

    <!-- Coordination service client -->
    <dependency>
        <groupId>tech.ydb</groupId>
        <artifactId>ydb-sdk-coordination</artifactId>
    </dependency>
</dependencies>

Examples

Using Maven

In basic example folder there is simple example application that uses YDB Java SDK from Maven. See the Connect to a database section of the documentation for an instruction on how to setup and launch it.

Generic examples

In examples folder you can find more example applications with YDB Java SDK usage.

How to build

To build the YDB Java SDK artifacts locally, see Building YDB Java SDK.

ydb-java-sdk's People

Contributors

alex268 avatar alexv-smirnov avatar arcadia-devtools avatar dcherednik avatar dependabot[bot] avatar fomichev3000 avatar frazenshtein avatar georgthegreat avatar gordiychuk avatar halyavin avatar hpple avatar ivanrudn0303 avatar jamel avatar kirillkurdyukov avatar nemo-cpt avatar piece-of-tart avatar pnv1 avatar resetius avatar shadchin avatar smertnik3sh avatar snaury avatar snermolaev avatar spuchin avatar tigo avatar ubyte avatar vestnik avatar yandex-contrib-robot avatar ydbdev avatar zhukoff-pavel avatar zinal avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ydb-java-sdk's Issues

Leaks in SyncReader when it is shutdown with full message queue

When a SyncReader is shutdown with full messageQueue, there is a single thread left which infinately waits trying to put a message into blocking queue which is full. This thread is not stopped on shutDown and holds references to messages and PartitionSessions. That leads to memory leaks.

keyRanges in TableDescription don't affect anything

Hi guys,

There is a field keyRanges in TableDescription. I don't see that it is used in CreateTableRequest, though I would expect that somehow it would be mapped to partition_at_keys (though semantics differs).

Build issue due to missing org.bouncycastle dependency

In the develop branch, build fails on test execution due to org.bouncycastle classes missing:

Errors: 
  ManagedChannelFactoryTest.customSslFactory:138 » Certificate No provider succeeded to generate a self-signed certificate. See debug log for the root cause.

Tests run: 50, Failures: 0, Errors: 1, Skipped: 0

------------------------------------------------------------------------
Reactor Summary:

Java SDK for YDB 2.1.0-SNAPSHOT .................... SUCCESS [  0.996 s]
Java SDK Bill of Materials 2.1.0-SNAPSHOT .......... SUCCESS [  0.069 s]
Auth API module 1.0.0 .............................. SUCCESS [  1.427 s]
Core module of Java SDK for YDB 2.1.0-SNAPSHOT ..... FAILURE [  3.661 s]
Tests common module 2.1.0-SNAPSHOT ................. SKIPPED
JUnit 4 support module 2.1.0-SNAPSHOT .............. SKIPPED
Table client implementation 2.1.0-SNAPSHOT ......... SKIPPED
Scheme client implementation 2.1.0-SNAPSHOT ........ SKIPPED
JUnit 5 support module 2.1.0-SNAPSHOT .............. SKIPPED
------------------------------------------------------------------------
BUILD FAILURE

The stacktraces contain the following:

Caused by: java.lang.NoClassDefFoundError: org/bouncycastle/jce/provider/BouncyCastleProvider
	at io.grpc.netty.shaded.io.netty.handler.ssl.util.SelfSignedCertificate.<init>(SelfSignedCertificate.java:246)
	... 33 more
Caused by: java.lang.ClassNotFoundException: org.bouncycastle.jce.provider.BouncyCastleProvider
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
	... 34 more

Add integration tests support

SDK examples have a few helpers for integration tests with YDB service in docker container. These helpers contain similar code and do similar work.
It will be a good decision to make a reference implementation of a helper for integration tests. It would also be nice to have bindings to JUnit4/JUnit5 for easier use of the helper in tests.

  • Add helper to setup the docker container with YDB instance.
  • Add bindings to JUnit4/JUnit5
  • Add integration tests in SDK

Add more settings for GrpcTrasnport

We would like to have some additional settings for GrpcTransport

  1. Single-endpoint mode
  2. Possibility to set the timeout of ready watching
  3. Possibility to configure DNS resolver

Add SLO test workload and CI

CI example is here: https://github.com/ydb-platform/ydb-nodejs-sdk/blob/main/.github/workflows/slo.yml
Workload sample and description is here: https://github.com/ydb-platform/ydb-nodejs-sdk/tree/main/slo-workload
As you can see from the repository, you will need to create a directory for the workload package and provide a Dockerfile inside it.

Important note: Do not run SLO tests in pull requests. You will either have to open secrets for pull requests, or give rights to each contributor (which is not a safe method either). The way I see it, the best option is to run tests on the main branch

URL-style endpoints in 2.1.0-SNAPSHOT

In the current development version (2.1.0-SNAPSHOT) the URL-style endpoints (e.g. those with grpc:// and grpcs:// prefixes) do not work as expected.

R2DBC driver

R2DBC (Reactive Relational Database Connectivity) is a reactive API specification for SQL databases. It provides a non-blocking and reactive way to interact with relational databases.

https://r2dbc.io

Roadmap below:

  1. Research and understand the database dialect
  1. SQL syntax
  2. YDB Data types map to Java Types, implement io.r2dbc.spi.Type
  3. other language-specific features YQL
  1. Study R2DBC specification. Existing dialect implementations.
  1. PostgreSQL R2DBC - https://github.com/pgjdbc/r2dbc-postgresql. The perfect solution from the founders of R2DBC.
  2. Clickhouse R2DBC - https://github.com/ClickHouse/clickhouse-java/tree/main/clickhouse-r2dbc. Community implementation. Don't support transactions, and more features.
  1. Design the architecture
  1. The driver implementation will be built using the YDB Java SDK v2.
  2. Connection != YDB Session. Because the connection is active until the close method is called.
    Connection have next state - InTransaction, OutTransaction, Close.
  1. Implement the core API - R2DBC SPI
  1. io.r2dbc.spi.ConnectionFactory
  2. io.r2dbc.spi.ConnectionFactoryMetadata
  3. io.r2dbc.spi.ConnectionFactoryProvider
  4. io.r2dbc.spi.Result
  5. io.r2dbc.spi.Row
  6. io.r2dbc.spi.RowMetadata
  7. io.r2dbc.spi.Batch
  8. io.r2dbc.spi.Connection
  9. io.r2dbc.spi.Statement
  1. Testing

  2. Documentation.

  3. Release candidate.

Document the usage, configuration options, and any database-specific features of YDB R2DBC driver to help users and developers understand how to use it effectively.

Split modules by functionality

It is necessary to split the separate functionality into separate modules

  1. Authentication provider api - from core to module auth
  2. Scheme client - from table to module scheme
  3. Maybe it's a good idea to make a separate module for YDB types
  4. It would also be nice to have a separate bom module to easily import dependencies, like there and there

Add CopyTableS support

Support the consistent snapshot-style copying on the set of tables, based on the available YDB CopyTables GRPC method.
A pre-requisite for Spark datasource support.

Scheduler may be shut down when scheduling stream retries

If a thread is waiting infinitely for a message to read from SyncReader and its transport is already stopped in another thread, reader stream will get transport error and won't be able to retry it because it uses the scheduler from stopped transport which is also already shut down. Therefore, it won't be shut down and the SyncReader.receive() method will run infinitely without any chance to complete

CVE-2021-43797

tech.ydb:ydb-sdk-core:2.0.1 Provides transitive vulnerable dependency maven:io.netty:netty-codec-http:4.1.63.Final

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.