This is an automated email from the ASF dual-hosted git repository.
jackietien pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/tsfile.git
The following commit(s) were added to refs/heads/develop by this push:
new f7ba0637 fix error log caused by ClosedByInterruptException
f7ba0637 is described below
commit f7ba06376801169a559246b013a5ab38c49a7d3a
Author: shuwenwei <[email protected]>
AuthorDate: Wed Mar 13 14:42:30 2024 +0800
fix error log caused by ClosedByInterruptException
---
.../StopReadTsFileByInterruptException.java | 24 ++++++++++++++
.../apache/tsfile/read/TsFileSequenceReader.java | 37 ++++++++++++++++++++++
.../tsfile/read/reader/LocalTsFileInput.java | 6 ++--
3 files changed, 64 insertions(+), 3 deletions(-)
diff --git
a/tsfile/src/main/java/org/apache/tsfile/exception/StopReadTsFileByInterruptException.java
b/tsfile/src/main/java/org/apache/tsfile/exception/StopReadTsFileByInterruptException.java
new file mode 100644
index 00000000..6af4aad8
--- /dev/null
+++
b/tsfile/src/main/java/org/apache/tsfile/exception/StopReadTsFileByInterruptException.java
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+package org.apache.tsfile.exception;
+
+import java.io.IOException;
+
+public class StopReadTsFileByInterruptException extends IOException {}
diff --git
a/tsfile/src/main/java/org/apache/tsfile/read/TsFileSequenceReader.java
b/tsfile/src/main/java/org/apache/tsfile/read/TsFileSequenceReader.java
index 5a934a60..70795469 100644
--- a/tsfile/src/main/java/org/apache/tsfile/read/TsFileSequenceReader.java
+++ b/tsfile/src/main/java/org/apache/tsfile/read/TsFileSequenceReader.java
@@ -25,6 +25,7 @@ import org.apache.tsfile.common.constant.TsFileConstant;
import org.apache.tsfile.compress.IUnCompressor;
import org.apache.tsfile.encoding.decoder.Decoder;
import org.apache.tsfile.enums.TSDataType;
+import org.apache.tsfile.exception.StopReadTsFileByInterruptException;
import org.apache.tsfile.exception.TsFileRuntimeException;
import org.apache.tsfile.exception.TsFileStatisticsMistakesException;
import org.apache.tsfile.file.MetaMarker;
@@ -298,6 +299,8 @@ public class TsFileSequenceReader implements AutoCloseable {
}
}
}
+ } catch (StopReadTsFileByInterruptException e) {
+ throw e;
} catch (Exception e) {
logger.error("Something error happened while reading file metadata of
file {}", file);
throw e;
@@ -523,6 +526,8 @@ public class TsFileSequenceReader implements AutoCloseable {
TimeseriesMetadata timeseriesMetadata;
try {
timeseriesMetadata =
TimeseriesMetadata.deserializeFrom(tsFileInput, true);
+ } catch (StopReadTsFileByInterruptException e) {
+ throw e;
} catch (Exception e1) {
logger.error(
"Something error happened while deserializing
TimeseriesMetadata of file {}", file);
@@ -728,6 +733,8 @@ public class TsFileSequenceReader implements AutoCloseable {
ByteBuffer nextBuffer = readData(startOffset, endOffset);
MetadataIndexNode deviceLeafNode =
MetadataIndexNode.deserializeFrom(nextBuffer);
getDevicesOfLeafNode(deviceLeafNode, measurementNodeOffsetQueue);
+ } catch (StopReadTsFileByInterruptException e) {
+ throw e;
} catch (Exception e) {
logger.error("Something error happened while getting all devices of file
{}", file);
throw e;
@@ -795,6 +802,8 @@ public class TsFileSequenceReader implements AutoCloseable {
getAllDeviceLeafNodeOffset(
MetadataIndexNode.deserializeFrom(nextBuffer),
leafDeviceNodeOffsets);
}
+ } catch (StopReadTsFileByInterruptException e) {
+ throw e;
} catch (Exception e) {
logger.error("Something error happened while getting all devices of file
{}", file);
throw e;
@@ -926,6 +935,8 @@ public class TsFileSequenceReader implements AutoCloseable {
metadataIndexNode.getNodeType(),
queue);
}
+ } catch (StopReadTsFileByInterruptException e) {
+ throw e;
} catch (Exception e) {
logger.error("Something error happened while getting all paths of file
{}", file);
throw e;
@@ -1144,6 +1155,8 @@ public class TsFileSequenceReader implements
AutoCloseable {
}
}
}
+ } catch (StopReadTsFileByInterruptException e) {
+ throw e;
} catch (Exception e) {
logger.error("Something error happened while generating MetadataIndex of
file {}", file);
throw e;
@@ -1193,6 +1206,8 @@ public class TsFileSequenceReader implements
AutoCloseable {
needChunkMetadata);
}
}
+ } catch (StopReadTsFileByInterruptException e) {
+ throw e;
} catch (Exception e) {
logger.error("Something error happened while generating MetadataIndex of
file {}", file);
throw e;
@@ -1314,6 +1329,8 @@ public class TsFileSequenceReader implements
AutoCloseable {
return getMetadataAndEndOffset(
MetadataIndexNode.deserializeFrom(buffer), name, isDeviceLevel,
exactSearch);
}
+ } catch (StopReadTsFileByInterruptException e) {
+ throw e;
} catch (Exception e) {
logger.error("Something error happened while deserializing MetadataIndex
of file {}", file);
throw e;
@@ -1369,6 +1386,8 @@ public class TsFileSequenceReader implements
AutoCloseable {
public ChunkHeader readChunkHeader(byte chunkType) throws IOException {
try {
return ChunkHeader.deserializeFrom(tsFileInput.wrapAsInputStream(),
chunkType);
+ } catch (StopReadTsFileByInterruptException e) {
+ throw e;
} catch (Throwable t) {
logger.warn("Exception {} happened while reading chunk header of {}",
t.getMessage(), file);
throw t;
@@ -1383,6 +1402,8 @@ public class TsFileSequenceReader implements
AutoCloseable {
private ChunkHeader readChunkHeader(long position) throws IOException {
try {
return ChunkHeader.deserializeFrom(tsFileInput, position);
+ } catch (StopReadTsFileByInterruptException e) {
+ throw e;
} catch (Throwable t) {
logger.warn("Exception {} happened while reading chunk header of {}",
t.getMessage(), file);
throw t;
@@ -1399,6 +1420,8 @@ public class TsFileSequenceReader implements
AutoCloseable {
public ByteBuffer readChunk(long position, int dataSize) throws IOException {
try {
return readData(position, dataSize);
+ } catch (StopReadTsFileByInterruptException e) {
+ throw e;
} catch (Throwable t) {
logger.warn("Exception {} happened while reading chunk of {}",
t.getMessage(), file);
throw t;
@@ -1415,6 +1438,8 @@ public class TsFileSequenceReader implements
AutoCloseable {
ChunkHeader header = readChunkHeader(offset);
ByteBuffer buffer = readChunk(offset + header.getSerializedSize(),
header.getDataSize());
return new Chunk(header, buffer);
+ } catch (StopReadTsFileByInterruptException e) {
+ throw e;
} catch (Throwable t) {
logger.warn("Exception {} happened while reading chunk of {}",
t.getMessage(), file);
throw t;
@@ -1434,6 +1459,8 @@ public class TsFileSequenceReader implements
AutoCloseable {
readChunk(
metaData.getOffsetOfChunkHeader() + header.getSerializedSize(),
header.getDataSize());
return new Chunk(header, buffer, metaData.getDeleteIntervalList(),
metaData.getStatistics());
+ } catch (StopReadTsFileByInterruptException e) {
+ throw e;
} catch (Throwable t) {
logger.warn("Exception {} happened while reading chunk of {}",
t.getMessage(), file);
throw t;
@@ -1500,6 +1527,8 @@ public class TsFileSequenceReader implements
AutoCloseable {
public PageHeader readPageHeader(TSDataType type, boolean hasStatistic)
throws IOException {
try {
return PageHeader.deserializeFrom(tsFileInput.wrapAsInputStream(), type,
hasStatistic);
+ } catch (StopReadTsFileByInterruptException e) {
+ throw e;
} catch (Throwable t) {
logger.warn("Exception {} happened while reading page header of {}",
t.getMessage(), file);
throw t;
@@ -1618,6 +1647,8 @@ public class TsFileSequenceReader implements
AutoCloseable {
protected ByteBuffer readData(long start, long end) throws IOException {
try {
return readData(start, (int) (end - start));
+ } catch (StopReadTsFileByInterruptException e) {
+ throw e;
} catch (Throwable t) {
logger.warn("Exception {} happened while reading data of {}",
t.getMessage(), file);
throw t;
@@ -1947,6 +1978,8 @@ public class TsFileSequenceReader implements
AutoCloseable {
return TsFileCheckStatus.COMPLETE_FILE;
}
}
+ } catch (StopReadTsFileByInterruptException e) {
+ throw e;
} catch (IOException e) {
logger.error("Error occurred while fast checking TsFile.");
throw e;
@@ -1960,6 +1993,8 @@ public class TsFileSequenceReader implements
AutoCloseable {
long tscheckStatus = TsFileCheckStatus.COMPLETE_FILE;
try {
tscheckStatus = checkChunkAndPagesStatistics(chunkMetadata);
+ } catch (StopReadTsFileByInterruptException e) {
+ throw e;
} catch (IOException e) {
logger.error("Error occurred while checking the statistics of chunk
and its pages");
throw e;
@@ -2392,6 +2427,8 @@ public class TsFileSequenceReader implements
AutoCloseable {
}
collectEachLeafMeasurementNodeOffsetRange(readData(startOffset,
endOffset), queue);
}
+ } catch (StopReadTsFileByInterruptException e) {
+ throw e;
} catch (Exception e) {
logger.error(
"Error occurred while collecting offset ranges of measurement nodes
of file {}", file);
diff --git
a/tsfile/src/main/java/org/apache/tsfile/read/reader/LocalTsFileInput.java
b/tsfile/src/main/java/org/apache/tsfile/read/reader/LocalTsFileInput.java
index a7769c0d..0ee73bd5 100644
--- a/tsfile/src/main/java/org/apache/tsfile/read/reader/LocalTsFileInput.java
+++ b/tsfile/src/main/java/org/apache/tsfile/read/reader/LocalTsFileInput.java
@@ -48,7 +48,7 @@ public class LocalTsFileInput implements TsFileInput {
try {
return channel.size();
} catch (IOException e) {
- logger.error("Error happened while getting {} size", filePath);
+ logger.warn("Error happened while getting {} size", filePath);
throw e;
}
}
@@ -58,7 +58,7 @@ public class LocalTsFileInput implements TsFileInput {
try {
return channel.position();
} catch (IOException e) {
- logger.error("Error happened while getting {} current position",
filePath);
+ logger.warn("Error happened while getting {} current position",
filePath);
throw e;
}
}
@@ -69,7 +69,7 @@ public class LocalTsFileInput implements TsFileInput {
channel.position(newPosition);
return this;
} catch (IOException e) {
- logger.error("Error happened while changing {} position to {}",
filePath, newPosition);
+ logger.warn("Error happened while changing {} position to {}", filePath,
newPosition);
throw e;
}
}