-
Notifications
You must be signed in to change notification settings - Fork 6
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 #38 from ydb-platform/release_v2.0.4
Release v2.0.4
- Loading branch information
Showing
54 changed files
with
941 additions
and
527 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
36 changes: 36 additions & 0 deletions
36
jdbc/src/main/java/tech/ydb/jdbc/exception/ExceptionFactory.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,36 @@ | ||
package tech.ydb.jdbc.exception; | ||
|
||
import java.sql.SQLException; | ||
|
||
import tech.ydb.core.StatusCode; | ||
import tech.ydb.core.UnexpectedResultException; | ||
|
||
/** | ||
* | ||
* @author Aleksandr Gorshenin | ||
*/ | ||
public class ExceptionFactory { | ||
static String getSQLState(StatusCode status) { | ||
// TODO: Add SQLSTATE message with order with https://en.wikipedia.org/wiki/SQLSTATE | ||
return null; | ||
} | ||
|
||
static int getVendorCode(StatusCode code) { | ||
return code.getCode(); | ||
} | ||
|
||
public static SQLException createException(String message, UnexpectedResultException cause) { | ||
StatusCode code = cause.getStatus().getCode(); | ||
String sqlState = getSQLState(code); | ||
int vendorCode = getVendorCode(code); | ||
|
||
if (code.isRetryable(false)) { | ||
return new YdbRetryableException(message, sqlState, vendorCode, cause); | ||
} | ||
if (code.isRetryable(true)) { | ||
return new YdbConditionallyRetryableException(message, sqlState, vendorCode, cause); | ||
} | ||
|
||
return new YdbSQLException(message, sqlState, vendorCode, cause); | ||
} | ||
} |
18 changes: 13 additions & 5 deletions
18
jdbc/src/main/java/tech/ydb/jdbc/exception/YdbConditionallyRetryableException.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 |
---|---|---|
@@ -1,12 +1,20 @@ | ||
package tech.ydb.jdbc.exception; | ||
|
||
import java.sql.SQLTransientException; | ||
|
||
import tech.ydb.core.Status; | ||
import tech.ydb.core.UnexpectedResultException; | ||
|
||
public class YdbConditionallyRetryableException extends SQLTransientException { | ||
private static final long serialVersionUID = 2155728765762467203L; | ||
private final Status status; | ||
|
||
// Treat this as non retryable exception by nature, i.e. need to handle in consciously | ||
public class YdbConditionallyRetryableException extends YdbNonRetryableException { | ||
private static final long serialVersionUID = -2371144941971339449L; | ||
YdbConditionallyRetryableException(String message, String sqlState, int code, UnexpectedResultException cause) { | ||
super(message, sqlState, code, cause); | ||
this.status = cause.getStatus(); | ||
} | ||
|
||
YdbConditionallyRetryableException(String message, String sqlState, Status status) { | ||
super(message, sqlState, status); | ||
public Status getStatus() { | ||
return status; | ||
} | ||
} |
Oops, something went wrong.