Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
kvdb
rocksdb
提交
d788bb8f
R
rocksdb
项目概览
kvdb
/
rocksdb
11 个月 前同步成功
通知
0
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rocksdb
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
d788bb8f
编写于
5月 21, 2014
作者:
M
Mike Orr
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
- hdfs cleanup; fix to NewDirectory to comply with definition in env.h
- fix compile error with env_test; static casts added
上级
c2fda55c
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
20 addition
and
25 deletion
+20
-25
util/env_hdfs.cc
util/env_hdfs.cc
+16
-21
util/env_test.cc
util/env_test.cc
+4
-4
未找到文件。
util/env_hdfs.cc
浏览文件 @
d788bb8f
...
...
@@ -401,16 +401,9 @@ Status HdfsEnv::NewRandomRWFile(const std::string& fname,
class
HdfsDirectory
:
public
Directory
{
public:
explicit
HdfsDirectory
(
int
fd
)
:
fd_
(
fd
)
{}
~
HdfsDirectory
()
{
//close(fd_);
}
~
HdfsDirectory
()
{}
virtual
Status
Fsync
()
{
//if (fsync(fd_) == -1) {
// return IOError("directory", errno);
// }
return
Status
::
OK
();
}
virtual
Status
Fsync
()
{
return
Status
::
OK
();
}
private:
int
fd_
;
...
...
@@ -418,20 +411,21 @@ class HdfsDirectory : public Directory {
Status
HdfsEnv
::
NewDirectory
(
const
std
::
string
&
name
,
unique_ptr
<
Directory
>*
result
)
{
int
value
=
hdfsCreateDirectory
(
fileSys_
,
name
.
c_str
());
result
->
reset
(
new
HdfsDirectory
(
0
));
int
value
=
hdfsExists
(
fileSys_
,
name
.
c_str
());
switch
(
value
)
{
case
HDFS_SUCCESS
:
// directory created
return
Status
::
OK
();
default:
Log
(
mylog
,
"directory already exists "
);
case
HDFS_EXISTS
:
result
->
reset
(
new
HdfsDirectory
(
0
));
return
Status
::
OK
();
default:
// fail if the directory doesn't exist
Log
(
mylog
,
"NewDirectory hdfsExists call failed"
);
throw
HdfsFatalException
(
"hdfsExists call failed with error "
+
std
::
to_string
(
value
)
+
" on path "
+
name
+
".
\n
"
);
}
}
bool
HdfsEnv
::
FileExists
(
const
std
::
string
&
fname
)
{
int
value
=
hdfsExists
(
fileSys_
,
fname
.
c_str
());
switch
(
value
)
{
case
HDFS_EXISTS
:
...
...
@@ -440,8 +434,9 @@ bool HdfsEnv::FileExists(const std::string& fname) {
return
false
;
default:
// anything else should be an error
Log
(
mylog
,
"FileExists hdfsExists call failed"
);
throw
HdfsFatalException
(
"1. hdfsExists call failed with error "
+
std
::
to_string
(
value
)
+
" on path "
+
fname
+
".
\n
"
);
throw
HdfsFatalException
(
"hdfsExists call failed with error "
+
std
::
to_string
(
value
)
+
" on path "
+
fname
+
".
\n
"
);
}
}
...
...
@@ -477,13 +472,13 @@ Status HdfsEnv::GetChildren(const std::string& path,
default:
// anything else should be an error
Log
(
mylog
,
"GetChildren hdfsExists call failed"
);
throw
HdfsFatalException
(
"hdfsExists call failed with error "
+
std
::
to_string
(
value
)
+
"
on path "
+
path
.
c_str
()
+
"
.
\n
"
);
std
::
to_string
(
value
)
+
".
\n
"
);
}
return
Status
::
OK
();
}
Status
HdfsEnv
::
DeleteFile
(
const
std
::
string
&
fname
)
{
if
(
hdfsDelete
(
fileSys_
,
fname
.
c_str
(),
1
)
==
0
)
{
if
(
hdfsDelete
(
fileSys_
,
fname
.
c_str
(),
1
)
==
0
)
{
return
Status
::
OK
();
}
return
IOError
(
fname
,
errno
);
...
...
util/env_test.cc
浏览文件 @
d788bb8f
...
...
@@ -285,7 +285,7 @@ TEST(EnvPosixTest, DecreaseNumBgThreads) {
// Increase to 5 threads. Task 0 and 2 running.
env_
->
SetBackgroundThreads
(
5
,
Env
::
Priority
::
HIGH
);
Env
::
Default
()
->
SleepForMicroseconds
(
kDelayMicros
);
ASSERT_EQ
(
0
,
env_
->
GetThreadPoolQueueLen
(
Env
::
Priority
::
HIGH
));
ASSERT_EQ
(
(
unsigned
int
)
0
,
env_
->
GetThreadPoolQueueLen
(
Env
::
Priority
::
HIGH
));
ASSERT_TRUE
(
tasks
[
0
].
IsSleeping
());
ASSERT_TRUE
(
tasks
[
2
].
IsSleeping
());
...
...
@@ -330,7 +330,7 @@ TEST(EnvPosixTest, DecreaseNumBgThreads) {
tasks
[
4
].
WakeUp
();
Env
::
Default
()
->
SleepForMicroseconds
(
kDelayMicros
);
ASSERT_EQ
(
0
,
env_
->
GetThreadPoolQueueLen
(
Env
::
Priority
::
HIGH
));
ASSERT_EQ
(
(
unsigned
int
)
0
,
env_
->
GetThreadPoolQueueLen
(
Env
::
Priority
::
HIGH
));
for
(
size_t
i
=
5
;
i
<
8
;
i
++
)
{
ASSERT_TRUE
(
tasks
[
i
].
IsSleeping
());
}
...
...
@@ -360,13 +360,13 @@ TEST(EnvPosixTest, DecreaseNumBgThreads) {
env_
->
Schedule
(
&
SleepingBackgroundTask
::
DoSleepTask
,
&
tasks
[
9
],
Env
::
Priority
::
HIGH
);
Env
::
Default
()
->
SleepForMicroseconds
(
kDelayMicros
);
ASSERT_GT
(
env_
->
GetThreadPoolQueueLen
(
Env
::
Priority
::
HIGH
),
0
);
ASSERT_GT
(
env_
->
GetThreadPoolQueueLen
(
Env
::
Priority
::
HIGH
),
(
unsigned
int
)
0
);
ASSERT_TRUE
(
!
tasks
[
8
].
IsSleeping
()
||
!
tasks
[
9
].
IsSleeping
());
// Increase to 4 threads. Task 5, 8, 9 running.
env_
->
SetBackgroundThreads
(
4
,
Env
::
Priority
::
HIGH
);
Env
::
Default
()
->
SleepForMicroseconds
(
kDelayMicros
);
ASSERT_EQ
(
0
,
env_
->
GetThreadPoolQueueLen
(
Env
::
Priority
::
HIGH
));
ASSERT_EQ
(
(
unsigned
int
)
0
,
env_
->
GetThreadPoolQueueLen
(
Env
::
Priority
::
HIGH
));
ASSERT_TRUE
(
tasks
[
8
].
IsSleeping
());
ASSERT_TRUE
(
tasks
[
9
].
IsSleeping
());
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录