Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
a6fd251f
提交
a6fd251f
authored
10 年前
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Pull request #116: Improved concurrency in the trace system.
上级
b3d3defd
隐藏空白字符变更
内嵌
并排
正在显示
11 个修改的文件
包含
122 行增加
和
64 行删除
+122
-64
changelog.html
h2/src/docsrc/html/changelog.html
+2
-1
Database.java
h2/src/main/org/h2/engine/Database.java
+4
-4
DbObjectBase.java
h2/src/main/org/h2/engine/DbObjectBase.java
+3
-3
RightOwner.java
h2/src/main/org/h2/engine/RightOwner.java
+2
-2
Session.java
h2/src/main/org/h2/engine/Session.java
+2
-2
JdbcDataSourceFactory.java
h2/src/main/org/h2/jdbcx/JdbcDataSourceFactory.java
+1
-1
Trace.java
h2/src/main/org/h2/message/Trace.java
+61
-30
TraceSystem.java
h2/src/main/org/h2/message/TraceSystem.java
+28
-18
TraceWriter.java
h2/src/main/org/h2/message/TraceWriter.java
+11
-0
TraceWriterAdapter.java
h2/src/main/org/h2/message/TraceWriterAdapter.java
+5
-0
SchemaObjectBase.java
h2/src/main/org/h2/schema/SchemaObjectBase.java
+3
-3
没有找到文件。
h2/src/docsrc/html/changelog.html
浏览文件 @
a6fd251f
...
...
@@ -20,7 +20,8 @@ Change Log
<h1>
Change Log
</h1>
<h2>
Next Version (unreleased)
</h2>
<ul><li>
Issue 609: the spatial index did not support NULL.
<ul><li>
Pull request #116: Improved concurrency in the trace system.
</li><li>
Issue 609: the spatial index did not support NULL.
</li><li>
Granting a schema is now supported.
</li><li>
Linked tables did not work when a function-based index is present (Oracle).
</li><li>
Creating a user with a null password, salt, or hash threw a NullPointerException.
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/engine/Database.java
浏览文件 @
a6fd251f
...
...
@@ -510,13 +510,13 @@ public class Database implements DataHandler {
}
/**
* Get the trace object for the given module.
* Get the trace object for the given module
id
.
*
* @param module
the module name
* @param module
Id the module id
* @return the trace object
*/
public
Trace
getTrace
(
String
module
)
{
return
traceSystem
.
getTrace
(
module
);
public
Trace
getTrace
(
int
moduleId
)
{
return
traceSystem
.
getTrace
(
module
Id
);
}
@Override
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/engine/DbObjectBase.java
浏览文件 @
a6fd251f
...
...
@@ -40,12 +40,12 @@ public abstract class DbObjectBase implements DbObject {
* @param db the database
* @param objectId the object id
* @param name the name
* @param traceModule
the trace module name
* @param traceModule
Id the trace module id
*/
protected
void
initDbObjectBase
(
Database
db
,
int
objectId
,
String
name
,
String
traceModule
)
{
int
traceModuleId
)
{
this
.
database
=
db
;
this
.
trace
=
db
.
getTrace
(
traceModule
);
this
.
trace
=
db
.
getTrace
(
traceModule
Id
);
this
.
id
=
objectId
;
this
.
objectName
=
name
;
this
.
modificationId
=
db
.
getModificationMetaId
();
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/engine/RightOwner.java
浏览文件 @
a6fd251f
...
...
@@ -26,8 +26,8 @@ public abstract class RightOwner extends DbObjectBase {
private
HashMap
<
DbObject
,
Right
>
grantedRights
;
protected
RightOwner
(
Database
database
,
int
id
,
String
name
,
String
traceModule
)
{
initDbObjectBase
(
database
,
id
,
name
,
traceModule
);
int
traceModuleId
)
{
initDbObjectBase
(
database
,
id
,
name
,
traceModule
Id
);
}
/**
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/engine/Session.java
浏览文件 @
a6fd251f
...
...
@@ -855,11 +855,11 @@ public class Session extends SessionWithState {
if
(
trace
!=
null
&&
!
closed
)
{
return
trace
;
}
String
traceModuleName
=
Trace
.
JDBC
+
"
["
+
id
+
"]"
;
String
traceModuleName
=
"jdbc
["
+
id
+
"]"
;
if
(
closed
)
{
return
new
TraceSystem
(
null
).
getTrace
(
traceModuleName
);
}
trace
=
database
.
getTrace
(
traceModuleName
);
trace
=
database
.
getTrace
System
().
getTrace
(
traceModuleName
);
return
trace
;
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/jdbcx/JdbcDataSourceFactory.java
浏览文件 @
a6fd251f
...
...
@@ -34,7 +34,7 @@ public class JdbcDataSourceFactory implements ObjectFactory {
* The public constructor to create new factory objects.
*/
public
JdbcDataSourceFactory
()
{
trace
=
getTraceSystem
().
getTrace
(
"JDBCX"
);
trace
=
getTraceSystem
().
getTrace
(
Trace
.
JDBCX
);
}
/**
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/message/Trace.java
浏览文件 @
a6fd251f
...
...
@@ -20,85 +20,116 @@ import org.h2.value.Value;
public
class
Trace
{
/**
* The trace module
name
for commands.
* The trace module
id
for commands.
*/
public
static
final
String
COMMAND
=
"command"
;
public
static
final
int
COMMAND
=
0
;
/**
* The trace module
name
for constraints.
* The trace module
id
for constraints.
*/
public
static
final
String
CONSTRAINT
=
"constraint"
;
public
static
final
int
CONSTRAINT
=
1
;
/**
* The trace module
name
for databases.
* The trace module
id
for databases.
*/
public
static
final
String
DATABASE
=
"database"
;
public
static
final
int
DATABASE
=
2
;
/**
* The trace module
name
for functions.
* The trace module
id
for functions.
*/
public
static
final
String
FUNCTION
=
"function"
;
public
static
final
int
FUNCTION
=
3
;
/**
* The trace module
name
for file locks.
* The trace module
id
for file locks.
*/
public
static
final
String
FILE_LOCK
=
"fileLock"
;
public
static
final
int
FILE_LOCK
=
4
;
/**
* The trace module
name
for indexes.
* The trace module
id
for indexes.
*/
public
static
final
String
INDEX
=
"index"
;
public
static
final
int
INDEX
=
5
;
/**
* The trace module
name
for the JDBC API.
* The trace module
id
for the JDBC API.
*/
public
static
final
String
JDBC
=
"jdbc"
;
public
static
final
int
JDBC
=
6
;
/**
* The trace module
name
for locks.
* The trace module
id
for locks.
*/
public
static
final
String
LOCK
=
"lock"
;
public
static
final
int
LOCK
=
7
;
/**
* The trace module
name
for schemas.
* The trace module
id
for schemas.
*/
public
static
final
String
SCHEMA
=
"schema"
;
public
static
final
int
SCHEMA
=
8
;
/**
* The trace module
name
for sequences.
* The trace module
id
for sequences.
*/
public
static
final
String
SEQUENCE
=
"sequence"
;
public
static
final
int
SEQUENCE
=
9
;
/**
* The trace module
name
for settings.
* The trace module
id
for settings.
*/
public
static
final
String
SETTING
=
"setting"
;
public
static
final
int
SETTING
=
10
;
/**
* The trace module
name
for tables.
* The trace module
id
for tables.
*/
public
static
final
String
TABLE
=
"table"
;
public
static
final
int
TABLE
=
11
;
/**
* The trace module
name
for triggers.
* The trace module
id
for triggers.
*/
public
static
final
String
TRIGGER
=
"trigger"
;
public
static
final
int
TRIGGER
=
12
;
/**
* The trace module
name
for users.
* The trace module
id
for users.
*/
public
static
final
String
USER
=
"user"
;
public
static
final
int
USER
=
13
;
/**
* The trace module
name
for the page store.
* The trace module
id
for the page store.
*/
public
static
final
String
PAGE_STORE
=
"pageStore"
;
public
static
final
int
PAGE_STORE
=
14
;
/**
* The trace module id for the JDBCX API
*/
public
static
final
int
JDBCX
=
15
;
/**
* Module names by their ids as array indexes.
*/
public
static
final
String
[]
MODULE_NAMES
=
{
"command"
,
"constraint"
,
"database"
,
"function"
,
"fileLock"
,
"index"
,
"jdbc"
,
"lock"
,
"schema"
,
"sequence"
,
"setting"
,
"table"
,
"trigger"
,
"user"
,
"pageStore"
,
"JDBCX"
};
private
final
TraceWriter
traceWriter
;
private
final
String
module
;
private
final
String
lineSeparator
;
private
int
traceLevel
=
TraceSystem
.
PARENT
;
Trace
(
TraceWriter
traceWriter
,
int
moduleId
)
{
this
(
traceWriter
,
MODULE_NAMES
[
moduleId
]);
}
Trace
(
TraceWriter
traceWriter
,
String
module
)
{
this
.
traceWriter
=
traceWriter
;
this
.
module
=
module
;
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/message/TraceSystem.java
浏览文件 @
a6fd251f
...
...
@@ -10,14 +10,12 @@ import java.io.PrintStream;
import
java.io.PrintWriter
;
import
java.io.Writer
;
import
java.text.SimpleDateFormat
;
import
java.util.HashMap
;
import
java.util.concurrent.atomic.AtomicReferenceArray
;
import
org.h2.api.ErrorCode
;
import
org.h2.engine.Constants
;
import
org.h2.jdbc.JdbcSQLException
;
import
org.h2.store.fs.FileUtils
;
import
org.h2.util.IOUtils
;
import
org.h2.util.New
;
/**
* The trace mechanism is the logging facility of this database. There is
...
...
@@ -83,7 +81,8 @@ public class TraceSystem implements TraceWriter {
private
int
levelMax
;
private
int
maxFileSize
=
DEFAULT_MAX_FILE_SIZE
;
private
String
fileName
;
private
HashMap
<
String
,
Trace
>
traces
;
private
final
AtomicReferenceArray
<
Trace
>
traces
=
new
AtomicReferenceArray
<
Trace
>(
Trace
.
MODULE_NAMES
.
length
);
private
SimpleDateFormat
dateFormat
;
private
Writer
fileWriter
;
private
PrintWriter
printWriter
;
...
...
@@ -117,28 +116,34 @@ public class TraceSystem implements TraceWriter {
}
/**
* Get or create a trace object for this module. Trace modules with names
* such as "JDBC[1]" are not cached (modules where the name ends with "]").
* All others are cached.
* Get or create a trace object for this module id. Trace modules with id
* are cached.
*
* @param module
the module name
* @param module
Id module id
* @return the trace object
*/
public
synchronized
Trace
getTrace
(
String
module
)
{
if
(
module
.
endsWith
(
"]"
))
{
return
new
Trace
(
writer
,
module
);
}
if
(
traces
==
null
)
{
traces
=
New
.
hashMap
(
16
);
}
Trace
t
=
traces
.
get
(
module
);
public
Trace
getTrace
(
int
moduleId
)
{
Trace
t
=
traces
.
get
(
moduleId
);
if
(
t
==
null
)
{
t
=
new
Trace
(
writer
,
module
);
traces
.
put
(
module
,
t
);
t
=
new
Trace
(
writer
,
moduleId
);
if
(!
traces
.
compareAndSet
(
moduleId
,
null
,
t
))
{
t
=
traces
.
get
(
moduleId
);
}
}
return
t
;
}
/**
* Create a trace object for this module. Trace modules with names are not
* cached.
*
* @param module the module name
* @return the trace object
*/
public
Trace
getTrace
(
String
module
)
{
return
new
Trace
(
writer
,
module
);
}
@Override
public
boolean
isEnabled
(
int
level
)
{
return
level
<=
this
.
levelMax
;
...
...
@@ -214,6 +219,11 @@ public class TraceSystem implements TraceWriter {
return
dateFormat
.
format
(
System
.
currentTimeMillis
())
+
module
+
": "
+
s
;
}
@Override
public
void
write
(
int
level
,
int
moduleId
,
String
s
,
Throwable
t
)
{
write
(
level
,
Trace
.
MODULE_NAMES
[
moduleId
],
s
,
t
);
}
@Override
public
void
write
(
int
level
,
String
module
,
String
s
,
Throwable
t
)
{
if
(
level
<=
levelSystemOut
||
level
>
this
.
levelMax
)
{
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/message/TraceWriter.java
浏览文件 @
a6fd251f
...
...
@@ -30,6 +30,17 @@ interface TraceWriter {
*/
void
write
(
int
level
,
String
module
,
String
s
,
Throwable
t
);
/**
* Write a message.
*
* @param level the trace level
* @param moduleId the id of the module
* @param s the message
* @param t the exception (may be null)
*/
void
write
(
int
level
,
int
moduleId
,
String
s
,
Throwable
t
);
/**
* Check the given trace / log level is enabled.
*
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/message/TraceWriterAdapter.java
浏览文件 @
a6fd251f
...
...
@@ -45,6 +45,11 @@ public class TraceWriterAdapter implements TraceWriter {
}
}
@Override
public
void
write
(
int
level
,
int
moduleId
,
String
s
,
Throwable
t
)
{
write
(
level
,
Trace
.
MODULE_NAMES
[
moduleId
],
s
,
t
);
};
@Override
public
void
write
(
int
level
,
String
module
,
String
s
,
Throwable
t
)
{
if
(
isEnabled
(
level
))
{
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/schema/SchemaObjectBase.java
浏览文件 @
a6fd251f
...
...
@@ -21,11 +21,11 @@ public abstract class SchemaObjectBase extends DbObjectBase implements
* @param newSchema the schema
* @param id the object id
* @param name the name
* @param traceModule
the trace module name
* @param traceModule
Id the trace module id
*/
protected
void
initSchemaObjectBase
(
Schema
newSchema
,
int
id
,
String
name
,
String
traceModule
)
{
initDbObjectBase
(
newSchema
.
getDatabase
(),
id
,
name
,
traceModule
);
int
traceModuleId
)
{
initDbObjectBase
(
newSchema
.
getDatabase
(),
id
,
name
,
traceModule
Id
);
this
.
schema
=
newSchema
;
}
...
...
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论