Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
kvdb
rocksdb
提交
a77e97c5
R
rocksdb
项目概览
kvdb
/
rocksdb
12 个月 前同步成功
通知
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,发现更多精彩内容 >>
提交
a77e97c5
编写于
11月 15, 2014
作者:
Y
Yueh-Hsuan Chiang
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #396 from fyrz/RocksJava-LogLevel
[RocksJava] LogLevel support in Options
上级
a122a42b
4947a067
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
237 addition
and
0 deletion
+237
-0
java/Makefile
java/Makefile
+1
-0
java/org/rocksdb/DBOptions.java
java/org/rocksdb/DBOptions.java
+17
-0
java/org/rocksdb/DBOptionsInterface.java
java/org/rocksdb/DBOptionsInterface.java
+14
-0
java/org/rocksdb/InfoLogLevel.java
java/org/rocksdb/InfoLogLevel.java
+47
-0
java/org/rocksdb/Options.java
java/org/rocksdb/Options.java
+16
-0
java/org/rocksdb/test/InfoLogLevelTest.java
java/org/rocksdb/test/InfoLogLevelTest.java
+98
-0
java/rocksjni/options.cc
java/rocksjni/options.cc
+44
-0
未找到文件。
java/Makefile
浏览文件 @
a77e97c5
...
...
@@ -57,6 +57,7 @@ JAVA_TESTS = org.rocksdb.test.BackupableDBTest\
org.rocksdb.test.DirectComparatorTest
\
org.rocksdb.test.FilterTest
\
org.rocksdb.test.FlushTest
\
org.rocksdb.test.InfoLogLevelTest
\
org.rocksdb.test.KeyMayExistTest
\
org.rocksdb.test.MemTableTest
\
org.rocksdb.test.MergeTest
\
...
...
java/org/rocksdb/DBOptions.java
浏览文件 @
a77e97c5
...
...
@@ -83,11 +83,26 @@ public class DBOptions extends RocksObject implements DBOptionsInterface {
@Override
public
DBOptions
setRateLimiterConfig
(
RateLimiterConfig
config
)
{
assert
(
isInitialized
());
rateLimiterConfig_
=
config
;
setRateLimiter
(
nativeHandle_
,
config
.
newRateLimiterHandle
());
return
this
;
}
@Override
public
DBOptions
setInfoLogLevel
(
InfoLogLevel
infoLogLevel
)
{
assert
(
isInitialized
());
setInfoLogLevel
(
nativeHandle_
,
infoLogLevel
.
getValue
());
return
this
;
}
@Override
public
InfoLogLevel
infoLogLevel
()
{
assert
(
isInitialized
());
return
InfoLogLevel
.
getInfoLogLevel
(
infoLogLevel
(
nativeHandle_
));
}
@Override
public
DBOptions
setMaxOpenFiles
(
int
maxOpenFiles
)
{
assert
(
isInitialized
());
...
...
@@ -487,6 +502,8 @@ public class DBOptions extends RocksObject implements DBOptionsInterface {
private
native
boolean
paranoidChecks
(
long
handle
);
private
native
void
setRateLimiter
(
long
handle
,
long
rateLimiterHandle
);
private
native
void
setInfoLogLevel
(
long
handle
,
byte
logLevel
);
private
native
byte
infoLogLevel
(
long
handle
);
private
native
void
setMaxOpenFiles
(
long
handle
,
int
maxOpenFiles
);
private
native
int
maxOpenFiles
(
long
handle
);
private
native
void
setMaxTotalWalSize
(
long
handle
,
...
...
java/org/rocksdb/DBOptionsInterface.java
浏览文件 @
a77e97c5
...
...
@@ -113,6 +113,20 @@ public interface DBOptionsInterface {
*/
Object
setRateLimiterConfig
(
RateLimiterConfig
config
);
/**
* <p>Sets the RocksDB log level. Default level is INFO</p>
*
* @param infoLogLevel log level to set.
* @return the instance of the current Object.
*/
Object
setInfoLogLevel
(
InfoLogLevel
infoLogLevel
);
/**
* <p>Returns currently set log level.</p>
* @return {@link org.rocksdb.InfoLogLevel} instance.
*/
InfoLogLevel
infoLogLevel
();
/**
* Number of open files that can be used by the DB. You may need to
* increase this if your database has a large working set. Value -1 means
...
...
java/org/rocksdb/InfoLogLevel.java
0 → 100644
浏览文件 @
a77e97c5
package
org.rocksdb
;
/**
* RocksDB log levels.
*/
public
enum
InfoLogLevel
{
DEBUG_LEVEL
((
byte
)
0
),
INFO_LEVEL
((
byte
)
1
),
WARN_LEVEL
((
byte
)
2
),
ERROR_LEVEL
((
byte
)
3
),
FATAL_LEVEL
((
byte
)
4
),
NUM_INFO_LOG_LEVELS
((
byte
)
5
);
private
final
byte
value_
;
private
InfoLogLevel
(
byte
value
)
{
value_
=
value
;
}
/**
* Returns the byte value of the enumerations value
*
* @return byte representation
*/
public
byte
getValue
()
{
return
value_
;
}
/**
* Get InfoLogLevel by byte value.
*
* @param value byte representation of InfoLogLevel.
*
* @return {@link org.rocksdb.InfoLogLevel} instance or null.
* @throws java.lang.IllegalArgumentException if an invalid
* value is provided.
*/
public
static
InfoLogLevel
getInfoLogLevel
(
byte
value
)
{
for
(
InfoLogLevel
infoLogLevel
:
InfoLogLevel
.
values
())
{
if
(
infoLogLevel
.
getValue
()
==
value
){
return
infoLogLevel
;
}
}
throw
new
IllegalArgumentException
(
"Illegal value provided for InfoLogLevel."
);
}
}
java/org/rocksdb/Options.java
浏览文件 @
a77e97c5
...
...
@@ -616,6 +616,20 @@ public class Options extends RocksObject
return
this
;
}
@Override
public
Options
setInfoLogLevel
(
InfoLogLevel
infoLogLevel
)
{
assert
(
isInitialized
());
setInfoLogLevel
(
nativeHandle_
,
infoLogLevel
.
getValue
());
return
this
;
}
@Override
public
InfoLogLevel
infoLogLevel
()
{
assert
(
isInitialized
());
return
InfoLogLevel
.
getInfoLogLevel
(
infoLogLevel
(
nativeHandle_
));
}
@Override
public
String
memTableFactoryName
()
{
assert
(
isInitialized
());
...
...
@@ -1025,6 +1039,8 @@ public class Options extends RocksObject
private
native
boolean
paranoidChecks
(
long
handle
);
private
native
void
setRateLimiter
(
long
handle
,
long
rateLimiterHandle
);
private
native
void
setInfoLogLevel
(
long
handle
,
byte
logLevel
);
private
native
byte
infoLogLevel
(
long
handle
);
private
native
void
setMaxOpenFiles
(
long
handle
,
int
maxOpenFiles
);
private
native
int
maxOpenFiles
(
long
handle
);
private
native
void
setMaxTotalWalSize
(
long
handle
,
...
...
java/org/rocksdb/test/InfoLogLevelTest.java
0 → 100644
浏览文件 @
a77e97c5
package
org.rocksdb.test
;
import
org.junit.ClassRule
;
import
org.junit.Rule
;
import
org.junit.Test
;
import
org.junit.rules.TemporaryFolder
;
import
org.rocksdb.*
;
import
java.io.IOException
;
import
static
java
.
nio
.
file
.
Files
.
readAllBytes
;
import
static
java
.
nio
.
file
.
Paths
.
get
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
public
class
InfoLogLevelTest
{
@ClassRule
public
static
final
RocksMemoryResource
rocksMemoryResource
=
new
RocksMemoryResource
();
@Rule
public
TemporaryFolder
dbFolder
=
new
TemporaryFolder
();
@Test
public
void
testInfoLogLevel
()
throws
RocksDBException
,
IOException
{
RocksDB
db
=
null
;
try
{
db
=
RocksDB
.
open
(
dbFolder
.
getRoot
().
getAbsolutePath
());
db
.
put
(
"key"
.
getBytes
(),
"value"
.
getBytes
());
assertThat
(
getLogContents
()).
isNotEmpty
();
}
finally
{
if
(
db
!=
null
)
{
db
.
close
();
}
}
}
@Test
public
void
testFatalLogLevel
()
throws
RocksDBException
,
IOException
{
RocksDB
db
=
null
;
Options
options
=
null
;
try
{
options
=
new
Options
().
setCreateIfMissing
(
true
).
setInfoLogLevel
(
InfoLogLevel
.
FATAL_LEVEL
);
assertThat
(
options
.
infoLogLevel
()).
isEqualTo
(
InfoLogLevel
.
FATAL_LEVEL
);
db
=
RocksDB
.
open
(
options
,
dbFolder
.
getRoot
().
getAbsolutePath
());
db
.
put
(
"key"
.
getBytes
(),
"value"
.
getBytes
());
assertThat
(
getLogContents
()).
isEmpty
();
}
finally
{
if
(
db
!=
null
)
{
db
.
close
();
}
}
}
@Test
public
void
testFatalLogLevelWithDBOptions
()
throws
RocksDBException
,
IOException
{
RocksDB
db
=
null
;
Options
options
=
null
;
DBOptions
dbOptions
=
null
;
try
{
dbOptions
=
new
DBOptions
().
setInfoLogLevel
(
InfoLogLevel
.
FATAL_LEVEL
);
options
=
new
Options
(
dbOptions
,
new
ColumnFamilyOptions
()).
setCreateIfMissing
(
true
);
assertThat
(
dbOptions
.
infoLogLevel
()).
isEqualTo
(
InfoLogLevel
.
FATAL_LEVEL
);
assertThat
(
options
.
infoLogLevel
()).
isEqualTo
(
InfoLogLevel
.
FATAL_LEVEL
);
db
=
RocksDB
.
open
(
options
,
dbFolder
.
getRoot
().
getAbsolutePath
());
db
.
put
(
"key"
.
getBytes
(),
"value"
.
getBytes
());
assertThat
(
getLogContents
()).
isEmpty
();
}
finally
{
if
(
db
!=
null
)
{
db
.
close
();
}
}
}
/**
* Read LOG file contents into String.
*
* @return LOG file contents as String.
* @throws IOException if file is not found.
*/
private
String
getLogContents
()
throws
IOException
{
return
new
String
(
readAllBytes
(
get
(
dbFolder
.
getRoot
().
getAbsolutePath
()+
"/LOG"
)));
}
}
java/rocksjni/options.cc
浏览文件 @
a77e97c5
...
...
@@ -625,6 +625,28 @@ void Java_org_rocksdb_Options_setRateLimiter(
reinterpret_cast
<
rocksdb
::
RateLimiter
*>
(
jrate_limiter_handle
));
}
/*
* Class: org_rocksdb_Options
* Method: setInfoLogLevel
* Signature: (JB)V
*/
void
Java_org_rocksdb_Options_setInfoLogLevel
(
JNIEnv
*
env
,
jobject
jobj
,
jlong
jhandle
,
jbyte
jlog_level
)
{
reinterpret_cast
<
rocksdb
::
Options
*>
(
jhandle
)
->
info_log_level
=
static_cast
<
rocksdb
::
InfoLogLevel
>
(
jlog_level
);
}
/*
* Class: org_rocksdb_Options
* Method: infoLogLevel
* Signature: (J)B
*/
jbyte
Java_org_rocksdb_Options_infoLogLevel
(
JNIEnv
*
env
,
jobject
jobj
,
jlong
jhandle
)
{
return
static_cast
<
jbyte
>
(
reinterpret_cast
<
rocksdb
::
Options
*>
(
jhandle
)
->
info_log_level
);
}
/*
* Class: org_rocksdb_Options
* Method: tableCacheNumshardbits
...
...
@@ -2835,6 +2857,28 @@ void Java_org_rocksdb_DBOptions_setRateLimiter(
reinterpret_cast
<
rocksdb
::
RateLimiter
*>
(
jrate_limiter_handle
));
}
/*
* Class: org_rocksdb_DBOptions
* Method: setInfoLogLevel
* Signature: (JB)V
*/
void
Java_org_rocksdb_DBOptions_setInfoLogLevel
(
JNIEnv
*
env
,
jobject
jobj
,
jlong
jhandle
,
jbyte
jlog_level
)
{
reinterpret_cast
<
rocksdb
::
DBOptions
*>
(
jhandle
)
->
info_log_level
=
static_cast
<
rocksdb
::
InfoLogLevel
>
(
jlog_level
);
}
/*
* Class: org_rocksdb_DBOptions
* Method: infoLogLevel
* Signature: (J)B
*/
jbyte
Java_org_rocksdb_DBOptions_infoLogLevel
(
JNIEnv
*
env
,
jobject
jobj
,
jlong
jhandle
)
{
return
static_cast
<
jbyte
>
(
reinterpret_cast
<
rocksdb
::
DBOptions
*>
(
jhandle
)
->
info_log_level
);
}
/*
* Class: org_rocksdb_DBOptions
* Method: setMaxTotalWalSize
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录