-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #252 from ydb-platform/develop
Release v2.2.0
- Loading branch information
Showing
238 changed files
with
11,912 additions
and
3,832 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
Copyright 2019 YANDEX LLC | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<project | ||
xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
|
||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>tech.ydb</groupId> | ||
<artifactId>ydb-sdk-parent</artifactId> | ||
<version>2.2.0</version> | ||
</parent> | ||
|
||
<artifactId>ydb-sdk-common</artifactId> | ||
<name>Common module of Java SDK for YDB</name> | ||
<description>Common module of Java SDK for YDB</description> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>tech.ydb</groupId> | ||
<artifactId>ydb-sdk-core</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.slf4j</groupId> | ||
<artifactId>slf4j-api</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.logging.log4j</groupId> | ||
<artifactId>log4j-slf4j-impl</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
</project> |
30 changes: 30 additions & 0 deletions
30
common/src/main/java/tech/ydb/common/retry/ErrorPolicy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package tech.ydb.common.retry; | ||
|
||
/** | ||
* Recipes should use the configured error policy to decide how to retry | ||
* errors like unsuccessful {@link tech.ydb.core.StatusCode}. | ||
* | ||
* @author Aleksandr Gorshenin | ||
* @param <T> Type of errors to check | ||
*/ | ||
public interface ErrorPolicy<T> { | ||
|
||
/** | ||
* Returns true if the given value should be retried | ||
* | ||
* @param value value to check | ||
* @return true if value is retryable | ||
*/ | ||
boolean isRetryable(T value); | ||
|
||
/** | ||
* Returns true if the given exception should be retried | ||
* Usually exceptions are never retried, but some policies can implement more difficult logic | ||
* | ||
* @param ex exception to check | ||
* @return true if exception is retryable | ||
*/ | ||
default boolean isRetryable(Exception ex) { | ||
return false; | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
common/src/main/java/tech/ydb/common/retry/ExponentialBackoffRetry.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package tech.ydb.common.retry; | ||
|
||
import java.util.concurrent.ThreadLocalRandom; | ||
|
||
|
||
/** | ||
* | ||
* @author Aleksandr Gorshenin | ||
*/ | ||
public abstract class ExponentialBackoffRetry implements RetryPolicy { | ||
private final long backoffMs; | ||
private final int backoffCeiling; | ||
|
||
protected ExponentialBackoffRetry(long backoffMs, int backoffCeiling) { | ||
this.backoffMs = backoffMs; | ||
this.backoffCeiling = backoffCeiling; | ||
} | ||
|
||
protected long backoffTimeMillis(int retryNumber) { | ||
int slots = 1 << Math.min(retryNumber, backoffCeiling); | ||
long delay = backoffMs * slots; | ||
return delay + ThreadLocalRandom.current().nextLong(delay); | ||
} | ||
|
||
/** | ||
* Return current base of backoff delays | ||
* @return backoff base duration in milliseconds | ||
*/ | ||
public long getBackoffMillis() { | ||
return backoffMs; | ||
} | ||
|
||
/** | ||
* Return current maximal level of backoff exponent | ||
* @return maximal level of backoff exponent | ||
*/ | ||
public int getBackoffCeiling() { | ||
return backoffCeiling; | ||
} | ||
} |
Oops, something went wrong.