Skip to content

Commit

Permalink
[Improve][Connector-V2][Iotdb] Unified exception for iotdb source & s…
Browse files Browse the repository at this point in the history
…ink connector
  • Loading branch information
wuchunfu committed Nov 25, 2022
1 parent eb63a95 commit ead98c2
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
2 changes: 0 additions & 2 deletions docs/en/connector-v2/Error-Quick-Reference-Manual.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,5 +98,3 @@ This document records some common error codes and corresponding solutions of Sea
| IOTDB-01 | Close IoTDB session failed | When the user encounters this error code, it indicates that closing the session failed. Please check |
| IOTDB-02 | Initialize IoTDB client failed | When the user encounters this error code, it indicates that the client initialization failed. Please check |
| IOTDB-03 | Close IoTDB client failed | When the user encounters this error code, it indicates that closing the client failed. Please check |
| IOTDB-04 | Writing records to IoTDB failed | When the user encounters this error code, it indicates that the record writing failed. Please check |
| IOTDB-05 | Unable to flush; interrupted while doing another attempt | When the user encounters this error code, it indicates that the record flushing failed. Please check |
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ public enum IotdbConnectorErrorCode implements SeaTunnelErrorCode {

CLOSE_SESSION_FAILED("IOTDB-01", "Close IoTDB session failed"),
INITIALIZE_CLIENT_FAILED("IOTDB-02", "Initialize IoTDB client failed"),
CLOSE_CLIENT_FAILED("IOTDB-03", "Close IoTDB client failed"),
WRITING_RECORDS_FAILED("IOTDB-04", "Writing records to IoTDB failed"),
FLUSH_RECORDS_FAILED("IOTDB-05", "Unable to flush; interrupted while doing another attempt.");
CLOSE_CLIENT_FAILED("IOTDB-03", "Close IoTDB client failed");

private final String code;
private final String description;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package org.apache.seatunnel.connectors.seatunnel.iotdb.sink;

import org.apache.seatunnel.common.exception.CommonErrorCode;
import org.apache.seatunnel.connectors.seatunnel.iotdb.config.SinkConfig;
import org.apache.seatunnel.connectors.seatunnel.iotdb.exception.IotdbConnectorErrorCode;
import org.apache.seatunnel.connectors.seatunnel.iotdb.exception.IotdbConnectorException;
Expand Down Expand Up @@ -161,7 +162,7 @@ synchronized void flush() throws IOException {
} catch (IoTDBConnectionException | StatementExecutionException e) {
log.error("Writing records to IoTDB failed, retry times = {}", i, e);
if (i >= sinkConfig.getMaxRetries()) {
throw new IotdbConnectorException(IotdbConnectorErrorCode.WRITING_RECORDS_FAILED,
throw new IotdbConnectorException(CommonErrorCode.FLUSH_DATA_FAILED,
"Writing records to IoTDB failed.", e);
}

Expand All @@ -171,7 +172,7 @@ synchronized void flush() throws IOException {
Thread.sleep(backoff);
} catch (InterruptedException ex) {
Thread.currentThread().interrupt();
throw new IotdbConnectorException(IotdbConnectorErrorCode.FLUSH_RECORDS_FAILED,
throw new IotdbConnectorException(CommonErrorCode.FLUSH_DATA_FAILED,
"Unable to flush; interrupted while doing another attempt.", e);
}
}
Expand All @@ -182,7 +183,7 @@ synchronized void flush() throws IOException {

private void checkFlushException() {
if (flushException != null) {
throw new IotdbConnectorException(IotdbConnectorErrorCode.WRITING_RECORDS_FAILED,
throw new IotdbConnectorException(CommonErrorCode.FLUSH_DATA_FAILED,
"Writing records to IoTDB failed.", flushException);
}
}
Expand Down

0 comments on commit ead98c2

Please sign in to comment.