Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
Iotdb
提交
21a07404
I
Iotdb
项目概览
apache
/
Iotdb
11 个月 前同步成功
通知
25
Star
3344
Fork
916
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
I
Iotdb
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
21a07404
编写于
7月 20, 2020
作者:
Z
Zesong Sun
提交者:
GitHub
7月 20, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[IOTDB-805] Fix BufferUnderflowException when querying TsFile stored in HDFS (#1519)
上级
f1adbb41
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
26 addition
and
25 deletion
+26
-25
hadoop/src/main/java/org/apache/iotdb/hadoop/fileSystem/HDFSOutput.java
...n/java/org/apache/iotdb/hadoop/fileSystem/HDFSOutput.java
+1
-2
server/src/main/java/org/apache/iotdb/db/engine/storagegroup/StorageGroupProcessor.java
...e/iotdb/db/engine/storagegroup/StorageGroupProcessor.java
+6
-7
tsfile/src/main/java/org/apache/iotdb/tsfile/fileSystem/fileOutputFactory/HDFSOutputFactory.java
...sfile/fileSystem/fileOutputFactory/HDFSOutputFactory.java
+1
-2
tsfile/src/main/java/org/apache/iotdb/tsfile/fileSystem/fsFactory/HDFSFactory.java
...apache/iotdb/tsfile/fileSystem/fsFactory/HDFSFactory.java
+8
-4
tsfile/src/main/java/org/apache/iotdb/tsfile/read/TsFileSequenceReader.java
...va/org/apache/iotdb/tsfile/read/TsFileSequenceReader.java
+5
-3
tsfile/src/main/java/org/apache/iotdb/tsfile/write/writer/ForceAppendTsFileWriter.java
...he/iotdb/tsfile/write/writer/ForceAppendTsFileWriter.java
+2
-1
tsfile/src/main/java/org/apache/iotdb/tsfile/write/writer/TsFileIOWriter.java
.../org/apache/iotdb/tsfile/write/writer/TsFileIOWriter.java
+3
-6
未找到文件。
hadoop/src/main/java/org/apache/iotdb/hadoop/fileSystem/HDFSOutput.java
浏览文件 @
21a07404
...
...
@@ -72,7 +72,6 @@ public class HDFSOutput implements TsFileOutput {
@Override
public
void
close
()
throws
IOException
{
flush
();
fsDataOutputStream
.
close
();
}
...
...
@@ -83,7 +82,7 @@ public class HDFSOutput implements TsFileOutput {
@Override
public
void
flush
()
throws
IOException
{
this
.
fsDataOutputStream
.
flush
();
this
.
fsDataOutputStream
.
h
flush
();
}
@Override
...
...
server/src/main/java/org/apache/iotdb/db/engine/storagegroup/StorageGroupProcessor.java
浏览文件 @
21a07404
...
...
@@ -1973,7 +1973,7 @@ public class StorageGroupProcessor {
if
(!
newFileName
.
equals
(
tsfileToBeInserted
.
getName
()))
{
logger
.
info
(
"Tsfile {} must be renamed to {} for loading into the sequence list."
,
tsfileToBeInserted
.
getName
(),
newFileName
);
newTsFileResource
.
setFile
(
new
File
(
tsfileToBeInserted
.
getParentFile
(),
newFileName
));
newTsFileResource
.
setFile
(
fsFactory
.
get
File
(
tsfileToBeInserted
.
getParentFile
(),
newFileName
));
}
}
loadTsFileByType
(
LoadTsFileType
.
LOAD_SEQUENCE
,
tsfileToBeInserted
,
newTsFileResource
,
...
...
@@ -2264,10 +2264,9 @@ public class StorageGroupProcessor {
File
targetFile
;
switch
(
type
)
{
case
LOAD_UNSEQUENCE:
targetFile
=
new
File
(
DirectoryManager
.
getInstance
().
getNextFolderForUnSequenceFile
(),
targetFile
=
fsFactory
.
get
File
(
DirectoryManager
.
getInstance
().
getNextFolderForUnSequenceFile
(),
storageGroupName
+
File
.
separatorChar
+
filePartitionId
+
File
.
separator
+
tsFileResource
.
getTsFile
().
getName
());
+
tsFileResource
.
getTsFile
().
getName
());
tsFileResource
.
setFile
(
targetFile
);
if
(
unSequenceFileList
.
contains
(
tsFileResource
))
{
logger
.
error
(
"The file {} has already been loaded in unsequence list"
,
tsFileResource
);
...
...
@@ -2279,7 +2278,7 @@ public class StorageGroupProcessor {
break
;
case
LOAD_SEQUENCE:
targetFile
=
new
File
(
DirectoryManager
.
getInstance
().
getNextFolderForSequenceFile
(),
fsFactory
.
get
File
(
DirectoryManager
.
getInstance
().
getNextFolderForSequenceFile
(),
storageGroupName
+
File
.
separatorChar
+
filePartitionId
+
File
.
separator
+
tsFileResource
.
getTsFile
().
getName
());
tsFileResource
.
setFile
(
targetFile
);
...
...
@@ -2310,9 +2309,9 @@ public class StorageGroupProcessor {
syncedTsFile
.
getAbsolutePath
(),
targetFile
.
getAbsolutePath
(),
e
.
getMessage
()));
}
File
syncedResourceFile
=
new
File
(
File
syncedResourceFile
=
fsFactory
.
get
File
(
syncedTsFile
.
getAbsolutePath
()
+
TsFileResource
.
RESOURCE_SUFFIX
);
File
targetResourceFile
=
new
File
(
File
targetResourceFile
=
fsFactory
.
get
File
(
targetFile
.
getAbsolutePath
()
+
TsFileResource
.
RESOURCE_SUFFIX
);
try
{
FileUtils
.
moveFile
(
syncedResourceFile
,
targetResourceFile
);
...
...
tsfile/src/main/java/org/apache/iotdb/tsfile/fileSystem/fileOutputFactory/HDFSOutputFactory.java
浏览文件 @
21a07404
...
...
@@ -50,8 +50,7 @@ public class HDFSOutputFactory implements FileOutputFactory {
}
catch
(
InstantiationException
|
InvocationTargetException
|
IllegalAccessException
e
)
{
logger
.
error
(
"Failed to get TsFile output of file: {}. Please check your dependency of Hadoop module."
,
filePath
,
e
);
filePath
,
e
);
return
null
;
}
}
...
...
tsfile/src/main/java/org/apache/iotdb/tsfile/fileSystem/fsFactory/HDFSFactory.java
浏览文件 @
21a07404
...
...
@@ -28,7 +28,6 @@ import java.lang.reflect.Constructor;
import
java.lang.reflect.InvocationTargetException
;
import
java.lang.reflect.Method
;
import
java.net.URI
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -45,6 +44,7 @@ public class HDFSFactory implements FSFactory {
private
static
Method
getBufferedOutputStream
;
private
static
Method
listFilesBySuffix
;
private
static
Method
listFilesByPrefix
;
private
static
Method
renameTo
;
static
{
try
{
...
...
@@ -59,6 +59,7 @@ public class HDFSFactory implements FSFactory {
getBufferedOutputStream
=
clazz
.
getMethod
(
"getBufferedOutputStream"
,
String
.
class
);
listFilesBySuffix
=
clazz
.
getMethod
(
"listFilesBySuffix"
,
String
.
class
,
String
.
class
);
listFilesByPrefix
=
clazz
.
getMethod
(
"listFilesByPrefix"
,
String
.
class
,
String
.
class
);
renameTo
=
clazz
.
getMethod
(
"renameTo"
,
File
.
class
);
}
catch
(
ClassNotFoundException
|
NoSuchMethodException
e
)
{
logger
.
error
(
"Failed to get Hadoop file system. Please check your dependency of Hadoop module."
,
...
...
@@ -173,9 +174,12 @@ public class HDFSFactory implements FSFactory {
}
public
void
moveFile
(
File
srcFile
,
File
destFile
)
{
boolean
rename
=
srcFile
.
renameTo
(
destFile
);
if
(!
rename
)
{
logger
.
error
(
"Failed to rename file from {} to {}. "
,
srcFile
.
getName
(),
destFile
.
getName
());
try
{
renameTo
.
invoke
(
constructorWithPathname
.
newInstance
(
srcFile
.
getAbsolutePath
()),
destFile
);
}
catch
(
InstantiationException
|
InvocationTargetException
|
IllegalAccessException
e
)
{
logger
.
error
(
"Failed to rename file from {} to {}. Please check your dependency of Hadoop module."
,
srcFile
.
getName
(),
destFile
.
getName
());
}
}
...
...
tsfile/src/main/java/org/apache/iotdb/tsfile/read/TsFileSequenceReader.java
浏览文件 @
21a07404
...
...
@@ -33,7 +33,6 @@ import java.util.TreeSet;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.concurrent.locks.ReadWriteLock
;
import
java.util.concurrent.locks.ReentrantReadWriteLock
;
import
org.apache.iotdb.tsfile.common.conf.TSFileConfig
;
import
org.apache.iotdb.tsfile.common.conf.TSFileDescriptor
;
import
org.apache.iotdb.tsfile.compress.IUnCompressor
;
...
...
@@ -768,8 +767,11 @@ public class TsFileSequenceReader implements AutoCloseable {
throw
new
IOException
(
"reach the end of the data"
);
}
}
else
{
if
(
ReadWriteIOUtils
.
readAsPossible
(
tsFileInput
,
buffer
,
position
,
size
)
!=
size
)
{
throw
new
IOException
(
"reach the end of the data"
);
long
actualReadSize
=
ReadWriteIOUtils
.
readAsPossible
(
tsFileInput
,
buffer
,
position
,
size
);
if
(
actualReadSize
!=
size
)
{
throw
new
IOException
(
String
.
format
(
"reach the end of the data. Size of data that want to read: %s,"
+
"actual read size: %s, posiotion: %s"
,
size
,
actualReadSize
,
position
));
}
}
buffer
.
flip
();
...
...
tsfile/src/main/java/org/apache/iotdb/tsfile/write/writer/ForceAppendTsFileWriter.java
浏览文件 @
21a07404
...
...
@@ -27,6 +27,7 @@ import org.apache.iotdb.tsfile.exception.write.TsFileNotCompleteException;
import
org.apache.iotdb.tsfile.file.metadata.ChunkGroupMetadata
;
import
org.apache.iotdb.tsfile.file.metadata.ChunkMetadata
;
import
org.apache.iotdb.tsfile.file.metadata.TsFileMetadata
;
import
org.apache.iotdb.tsfile.fileSystem.FSFactoryProducer
;
import
org.apache.iotdb.tsfile.read.TsFileSequenceReader
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -44,7 +45,7 @@ public class ForceAppendTsFileWriter extends TsFileIOWriter {
if
(
logger
.
isDebugEnabled
())
{
logger
.
debug
(
"{} writer is opened."
,
file
.
getName
());
}
this
.
out
=
new
LocalTsFileOutput
(
file
,
true
);
this
.
out
=
FSFactoryProducer
.
getFileOutputFactory
().
getTsFileOutput
(
file
.
getPath
()
,
true
);
this
.
file
=
file
;
// file doesn't exist
...
...
tsfile/src/main/java/org/apache/iotdb/tsfile/write/writer/TsFileIOWriter.java
浏览文件 @
21a07404
...
...
@@ -177,14 +177,11 @@ public class TsFileIOWriter {
* @throws IOException if I/O error occurs
*/
public
void
startFlushChunk
(
MeasurementSchema
measurementSchema
,
CompressionType
compressionCodecName
,
TSDataType
tsDataType
,
TSEncoding
encodingType
,
Statistics
<?>
statistics
,
int
dataSize
,
int
numOfPages
)
throws
IOException
{
CompressionType
compressionCodecName
,
TSDataType
tsDataType
,
TSEncoding
encodingType
,
Statistics
<?>
statistics
,
int
dataSize
,
int
numOfPages
)
throws
IOException
{
currentChunkMetadata
=
new
ChunkMetadata
(
measurementSchema
.
getMeasurementId
(),
tsDataType
,
out
.
getPosition
(),
statistics
);
out
.
getPosition
(),
statistics
);
ChunkHeader
header
=
new
ChunkHeader
(
measurementSchema
.
getMeasurementId
(),
dataSize
,
tsDataType
,
compressionCodecName
,
encodingType
,
numOfPages
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录