Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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 {}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
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;
Expand Down Expand Up @@ -298,6 +299,8 @@ public TsFileMetadata readFileMetadata() throws IOException {
}
}
}
} catch (StopReadTsFileByInterruptException e) {
throw e;
} catch (Exception e) {
logger.error("Something error happened while reading file metadata of file {}", file);
throw e;
Expand Down Expand Up @@ -523,6 +526,8 @@ public List<TimeseriesMetadata> readTimeseriesMetadata(
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);
Expand Down Expand Up @@ -728,6 +733,8 @@ public void getDevicesAndEntriesOfOneLeafNode(
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;
Expand Down Expand Up @@ -795,6 +802,8 @@ private void getAllDeviceLeafNodeOffset(
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;
Expand Down Expand Up @@ -926,6 +935,8 @@ private void getAllPaths(
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;
Expand Down Expand Up @@ -1144,6 +1155,8 @@ private void generateMetadataIndex(
}
}
}
} catch (StopReadTsFileByInterruptException e) {
throw e;
} catch (Exception e) {
logger.error("Something error happened while generating MetadataIndex of file {}", file);
throw e;
Expand Down Expand Up @@ -1193,6 +1206,8 @@ private void generateMetadataIndexUsingTsFileInput(
needChunkMetadata);
}
}
} catch (StopReadTsFileByInterruptException e) {
throw e;
} catch (Exception e) {
logger.error("Something error happened while generating MetadataIndex of file {}", file);
throw e;
Expand Down Expand Up @@ -1314,6 +1329,8 @@ protected Pair<MetadataIndexEntry, Long> getMetadataAndEndOffset(
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;
Expand Down Expand Up @@ -1369,6 +1386,8 @@ public void readPlanIndex() throws IOException {
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;
Expand All @@ -1383,6 +1402,8 @@ public ChunkHeader readChunkHeader(byte chunkType) throws IOException {
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;
Expand All @@ -1399,6 +1420,8 @@ private ChunkHeader readChunkHeader(long position) throws IOException {
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;
Expand All @@ -1415,6 +1438,8 @@ public Chunk readMemChunk(long offset) throws IOException {
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;
Expand All @@ -1434,6 +1459,8 @@ public Chunk readMemChunk(ChunkMetadata metaData) throws IOException {
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;
Expand Down Expand Up @@ -1500,6 +1527,8 @@ public MeasurementSchema getMeasurementSchema(List<IChunkMetadata> chunkMetadata
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;
Expand Down Expand Up @@ -1618,6 +1647,8 @@ protected ByteBuffer readData(long position, int totalSize) throws IOException {
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;
Expand Down Expand Up @@ -1947,6 +1978,8 @@ public long selfCheckWithInfo(
return TsFileCheckStatus.COMPLETE_FILE;
}
}
} catch (StopReadTsFileByInterruptException e) {
throw e;
} catch (IOException e) {
logger.error("Error occurred while fast checking TsFile.");
throw e;
Expand All @@ -1960,6 +1993,8 @@ public long selfCheckWithInfo(
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;
Expand Down Expand Up @@ -2392,6 +2427,8 @@ private void collectEachLeafMeasurementNodeOffsetRange(
}
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public long size() throws IOException {
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;
}
}
Expand All @@ -58,7 +58,7 @@ public long position() throws IOException {
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;
}
}
Expand All @@ -69,7 +69,7 @@ public TsFileInput position(long newPosition) throws IOException {
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;
}
}
Expand Down