diff --git a/auth-api/src/main/java/tech/ydb/auth/AuthIdentity.java b/auth-api/src/main/java/tech/ydb/auth/AuthIdentity.java index cda0ad8b5..e86580836 100644 --- a/auth-api/src/main/java/tech/ydb/auth/AuthIdentity.java +++ b/auth-api/src/main/java/tech/ydb/auth/AuthIdentity.java @@ -1,12 +1,27 @@ package tech.ydb.auth; /** - * Provides an authentication token for every request. + * Supplies authentication tokens for requests made by the YDB transport layer. + * + *

An identity may return a fixed token or obtain and refresh tokens as needed. + * The transport closes the identity when it no longer needs it. */ public interface AuthIdentity extends AutoCloseable { + /** + * Returns the authentication token to use for a request. + * + *

Implementations may obtain or refresh the token during this call. + * + * @return the authentication token, or {@code null} if no token should be sent + */ String getToken(); + /** + * Releases resources used by this identity. + * + *

The default implementation does nothing. + */ @Override default void close() { } diff --git a/auth-api/src/main/java/tech/ydb/auth/AuthProvider.java b/auth-api/src/main/java/tech/ydb/auth/AuthProvider.java index 454022807..2fd204f6d 100644 --- a/auth-api/src/main/java/tech/ydb/auth/AuthProvider.java +++ b/auth-api/src/main/java/tech/ydb/auth/AuthProvider.java @@ -1,15 +1,25 @@ package tech.ydb.auth; /** - * Provides AuthIdentity instances for use in the operation of the YDB transport layer. + * Provides authentication identities without requiring a transport rpc. */ public interface AuthProvider extends AuthRpcProvider { /** - * Create new instance of AuthIdentity - * @return new instance of AuthIdentity + * Returns an authentication identity for use by the transport. + * + *

Implementations may create an identity or reuse an existing one. The transport + * closes the returned identity when it no longer needs it. + * + * @return an authentication identity, or {@code null} for an anonymous connection */ AuthIdentity createAuthIdentity(); + /** + * Returns an authentication identity by delegating to {@link #createAuthIdentity()}. + * + * @param rpc transport-provided helper; ignored by this implementation + * @return an authentication identity, or {@code null} for an anonymous connection + */ @Override default AuthIdentity createAuthIdentity(Object rpc) { return createAuthIdentity(); diff --git a/auth-api/src/main/java/tech/ydb/auth/AuthRpcProvider.java b/auth-api/src/main/java/tech/ydb/auth/AuthRpcProvider.java index cff2da6bf..256600b4f 100644 --- a/auth-api/src/main/java/tech/ydb/auth/AuthRpcProvider.java +++ b/auth-api/src/main/java/tech/ydb/auth/AuthRpcProvider.java @@ -1,15 +1,20 @@ package tech.ydb.auth; /** - * Provides AuthIdentity instances for use in the operation of the YDB transport layer. + * Provides authentication identities using a helper supplied by the YDB transport. * - * @param Optional type specification for a transport-provided helper. + * @param the type of helper supplied by the transport */ public interface AuthRpcProvider { /** - * Create new instance of AuthIdentity - * @param rpc helper provided by a transport implementation - * @return new instance of AuthIdentity + * Returns an authentication identity for use by the transport. + * + *

The helper can be used to perform authentication requests. Implementations may + * create an identity or reuse an existing one. The transport closes the returned + * identity when it no longer needs it. + * + * @param rpc helper provided by the transport implementation + * @return an authentication identity, or {@code null} for an anonymous connection */ AuthIdentity createAuthIdentity(T rpc); } diff --git a/auth-api/src/main/java/tech/ydb/auth/NopAuthProvider.java b/auth-api/src/main/java/tech/ydb/auth/NopAuthProvider.java index ecd6b212b..cc1e519f1 100644 --- a/auth-api/src/main/java/tech/ydb/auth/NopAuthProvider.java +++ b/auth-api/src/main/java/tech/ydb/auth/NopAuthProvider.java @@ -2,14 +2,27 @@ /** - * Implementation of AuthProvider for anonymous connections + * Authentication provider for anonymous connections. + * + *

This provider returns no identity, so the transport sends no authentication token. */ public class NopAuthProvider implements AuthProvider { + /** + * Shared provider instance for anonymous connections. + */ public static final NopAuthProvider INSTANCE = new NopAuthProvider(); + /** + * Creates a provider for anonymous connections. + */ protected NopAuthProvider() { } + /** + * Returns no identity for an anonymous connection. + * + * @return {@code null} + */ @Override public AuthIdentity createAuthIdentity() { return null; diff --git a/auth-api/src/main/java/tech/ydb/auth/TokenAuthProvider.java b/auth-api/src/main/java/tech/ydb/auth/TokenAuthProvider.java index b86e259ad..376667a72 100644 --- a/auth-api/src/main/java/tech/ydb/auth/TokenAuthProvider.java +++ b/auth-api/src/main/java/tech/ydb/auth/TokenAuthProvider.java @@ -1,15 +1,29 @@ package tech.ydb.auth; /** - * Implementation of AuthProvider for connections with static token value + * Authentication provider that uses a fixed token value. + * + *

The token is returned unchanged and is never refreshed by this provider. */ public class TokenAuthProvider implements AuthProvider { private final TokenIdentity identity; + /** + * Creates a provider that uses the supplied token for every request. + * + * @param token the authentication token, or {@code null} to send no token + */ public TokenAuthProvider(String token) { this.identity = new TokenIdentity(token); } + /** + * Returns the identity holding this provider's fixed token. + * + *

Every call returns the same identity. Closing it has no effect. + * + * @return the shared identity holding the token supplied to the constructor + */ @Override public AuthIdentity createAuthIdentity() { return identity; diff --git a/core/src/main/java/tech/ydb/core/auth/AuthIdentity.java b/core/src/main/java/tech/ydb/core/auth/AuthIdentity.java deleted file mode 100644 index 0177272ec..000000000 --- a/core/src/main/java/tech/ydb/core/auth/AuthIdentity.java +++ /dev/null @@ -1,10 +0,0 @@ -package tech.ydb.core.auth; - -/** - * @deprecated - * Use {@link tech.ydb.auth.AuthIdentity} instead. - */ -@Deprecated -public interface AuthIdentity extends tech.ydb.auth.AuthIdentity { -} - diff --git a/core/src/main/java/tech/ydb/core/auth/AuthProvider.java b/core/src/main/java/tech/ydb/core/auth/AuthProvider.java deleted file mode 100644 index 588e4ee90..000000000 --- a/core/src/main/java/tech/ydb/core/auth/AuthProvider.java +++ /dev/null @@ -1,13 +0,0 @@ -package tech.ydb.core.auth; - -import tech.ydb.auth.AuthRpcProvider; - -/** - * @deprecated - * Use {@link tech.ydb.auth.AuthProvider} instead. - */ -@Deprecated -public interface AuthProvider extends AuthRpcProvider { - @Override - AuthIdentity createAuthIdentity(AuthRpc rpc); -} diff --git a/core/src/main/java/tech/ydb/core/auth/AuthRpc.java b/core/src/main/java/tech/ydb/core/auth/AuthRpc.java deleted file mode 100644 index 041f6db27..000000000 --- a/core/src/main/java/tech/ydb/core/auth/AuthRpc.java +++ /dev/null @@ -1,8 +0,0 @@ -package tech.ydb.core.auth; - -/** - * @deprecated - */ -@Deprecated -public interface AuthRpc { -} diff --git a/core/src/main/java/tech/ydb/core/auth/NopAuthProvider.java b/core/src/main/java/tech/ydb/core/auth/NopAuthProvider.java deleted file mode 100644 index adec3e57d..000000000 --- a/core/src/main/java/tech/ydb/core/auth/NopAuthProvider.java +++ /dev/null @@ -1,9 +0,0 @@ -package tech.ydb.core.auth; - -/** - * @deprecated - * Use {@link tech.ydb.auth.NopAuthProvider} instead. - */ -@Deprecated -public class NopAuthProvider extends tech.ydb.auth.NopAuthProvider { -} diff --git a/core/src/main/java/tech/ydb/core/auth/TokenAuthProvider.java b/core/src/main/java/tech/ydb/core/auth/TokenAuthProvider.java deleted file mode 100644 index 1323dece0..000000000 --- a/core/src/main/java/tech/ydb/core/auth/TokenAuthProvider.java +++ /dev/null @@ -1,12 +0,0 @@ -package tech.ydb.core.auth; - -/** - * @deprecated - * Use {@link tech.ydb.auth.TokenAuthProvider} instead. - */ -@Deprecated -public class TokenAuthProvider extends tech.ydb.auth.TokenAuthProvider { - public TokenAuthProvider(String token) { - super(token); - } -} diff --git a/topic/src/main/java/tech/ydb/topic/write/WriteAck.java b/topic/src/main/java/tech/ydb/topic/write/WriteAck.java index 7d8b21075..441a5b5ed 100644 --- a/topic/src/main/java/tech/ydb/topic/write/WriteAck.java +++ b/topic/src/main/java/tech/ydb/topic/write/WriteAck.java @@ -78,11 +78,11 @@ public static class Statistics { /** * Create the messages batch statistics object, for a single messages batch. * - * @param persistingTime - * @param partitionQuotaWaitTime - * @param topicQuotaWaitTime - * @param maxQueueWaitTime - * @param minQueueWaitTime + * @param persistingTime time spent in persisting of data + * @param partitionQuotaWaitTime time spent awaiting for partition write quota. + * @param topicQuotaWaitTime time spent awaiting for topic write quota + * @param maxQueueWaitTime maximal time spent in queue before persisting + * @param minQueueWaitTime minimal time spent in queue before persisting */ public Statistics(Duration persistingTime, Duration partitionQuotaWaitTime, Duration topicQuotaWaitTime, diff --git a/topic/src/test/java/tech/ydb/topic/TopicReadersIntegrationTest.java b/topic/src/test/java/tech/ydb/topic/TopicReadersIntegrationTest.java index cc0c64efe..40e49d37a 100644 --- a/topic/src/test/java/tech/ydb/topic/TopicReadersIntegrationTest.java +++ b/topic/src/test/java/tech/ydb/topic/TopicReadersIntegrationTest.java @@ -733,13 +733,13 @@ public void onMessages(DataReceivedEvent event) { ReadEventHandler handler2 = new ReadEventHandler() { @Override public void onStartPartitionSession(StartPartitionSessionEvent event) { - events.add(event); partitions2.countDown(); + event.confirm(); } @Override public void onMessages(DataReceivedEvent event) { - int pid = (int) event.getPartitionSession().getPartitionId(); + int pid = (int) event.getPartitionSession().getPartitionId(); for (Message msg : event.getMessages()) { Assert.assertEquals(offsets[pid].getAndIncrement(), msg.getOffset()); read[pid].countDown();