Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
2d4f153e
提交
2d4f153e
authored
1月 30, 2018
作者:
Noel Grandin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
use enum for file lock method
上级
469a69ea
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
80 行增加
和
71 行删除
+80
-71
Database.java
h2/src/main/org/h2/engine/Database.java
+23
-22
Engine.java
h2/src/main/org/h2/engine/Engine.java
+3
-3
FileLister.java
h2/src/main/org/h2/store/FileLister.java
+1
-1
FileLock.java
h2/src/main/org/h2/store/FileLock.java
+11
-38
FileLockMethod.java
h2/src/main/org/h2/store/FileLockMethod.java
+35
-0
TestFileLock.java
h2/src/test/org/h2/test/unit/TestFileLock.java
+7
-7
没有找到文件。
h2/src/main/org/h2/engine/Database.java
浏览文件 @
2d4f153e
...
@@ -44,6 +44,7 @@ import org.h2.schema.Sequence;
...
@@ -44,6 +44,7 @@ import org.h2.schema.Sequence;
import
org.h2.schema.TriggerObject
;
import
org.h2.schema.TriggerObject
;
import
org.h2.store.DataHandler
;
import
org.h2.store.DataHandler
;
import
org.h2.store.FileLock
;
import
org.h2.store.FileLock
;
import
org.h2.store.FileLockMethod
;
import
org.h2.store.FileStore
;
import
org.h2.store.FileStore
;
import
org.h2.store.InDoubtTransaction
;
import
org.h2.store.InDoubtTransaction
;
import
org.h2.store.LobStorageBackend
;
import
org.h2.store.LobStorageBackend
;
...
@@ -139,7 +140,7 @@ public class Database implements DataHandler {
...
@@ -139,7 +140,7 @@ public class Database implements DataHandler {
private
boolean
starting
;
private
boolean
starting
;
private
TraceSystem
traceSystem
;
private
TraceSystem
traceSystem
;
private
Trace
trace
;
private
Trace
trace
;
private
final
int
fileLockMethod
;
private
final
FileLockMethod
fileLockMethod
;
private
Role
publicRole
;
private
Role
publicRole
;
private
final
AtomicLong
modificationDataId
=
new
AtomicLong
();
private
final
AtomicLong
modificationDataId
=
new
AtomicLong
();
private
final
AtomicLong
modificationMetaId
=
new
AtomicLong
();
private
final
AtomicLong
modificationMetaId
=
new
AtomicLong
();
...
@@ -235,14 +236,14 @@ public class Database implements DataHandler {
...
@@ -235,14 +236,14 @@ public class Database implements DataHandler {
}
}
if
(
dbSettings
.
mvStore
&&
lockMethodName
==
null
)
{
if
(
dbSettings
.
mvStore
&&
lockMethodName
==
null
)
{
if
(
autoServerMode
)
{
if
(
autoServerMode
)
{
fileLockMethod
=
FileLock
.
LOCK_
FILE
;
fileLockMethod
=
FileLock
Method
.
FILE
;
}
else
{
}
else
{
fileLockMethod
=
FileLock
.
LOCK_
FS
;
fileLockMethod
=
FileLock
Method
.
FS
;
}
}
}
else
{
}
else
{
fileLockMethod
=
FileLock
.
getFileLockMethod
(
lockMethodName
);
fileLockMethod
=
FileLock
.
getFileLockMethod
(
lockMethodName
);
}
}
if
(
dbSettings
.
mvStore
&&
fileLockMethod
==
FileLock
.
LOCK_
SERIALIZED
)
{
if
(
dbSettings
.
mvStore
&&
fileLockMethod
==
FileLock
Method
.
SERIALIZED
)
{
throw
DbException
.
getUnsupportedException
(
throw
DbException
.
getUnsupportedException
(
"MV_STORE combined with FILE_LOCK=SERIALIZED"
);
"MV_STORE combined with FILE_LOCK=SERIALIZED"
);
}
}
...
@@ -407,7 +408,7 @@ public class Database implements DataHandler {
...
@@ -407,7 +408,7 @@ public class Database implements DataHandler {
*/
*/
private
synchronized
boolean
reconnectModified
(
boolean
pending
)
{
private
synchronized
boolean
reconnectModified
(
boolean
pending
)
{
if
(
readOnly
||
lock
==
null
||
if
(
readOnly
||
lock
==
null
||
fileLockMethod
!=
FileLock
.
LOCK_
SERIALIZED
)
{
fileLockMethod
!=
FileLock
Method
.
SERIALIZED
)
{
return
true
;
return
true
;
}
}
try
{
try
{
...
@@ -516,7 +517,7 @@ public class Database implements DataHandler {
...
@@ -516,7 +517,7 @@ public class Database implements DataHandler {
}
}
if
(
lock
!=
null
)
{
if
(
lock
!=
null
)
{
stopServer
();
stopServer
();
if
(
fileLockMethod
!=
FileLock
.
LOCK_
SERIALIZED
)
{
if
(
fileLockMethod
!=
FileLock
Method
.
SERIALIZED
)
{
// allow testing shutdown
// allow testing shutdown
lock
.
unlock
();
lock
.
unlock
();
}
}
...
@@ -646,9 +647,9 @@ public class Database implements DataHandler {
...
@@ -646,9 +647,9 @@ public class Database implements DataHandler {
trace
.
info
(
"opening {0} (build {1})"
,
databaseName
,
Constants
.
BUILD_ID
);
trace
.
info
(
"opening {0} (build {1})"
,
databaseName
,
Constants
.
BUILD_ID
);
if
(
autoServerMode
)
{
if
(
autoServerMode
)
{
if
(
readOnly
||
if
(
readOnly
||
fileLockMethod
==
FileLock
.
LOCK_
NO
||
fileLockMethod
==
FileLock
Method
.
NO
||
fileLockMethod
==
FileLock
.
LOCK_
SERIALIZED
||
fileLockMethod
==
FileLock
Method
.
SERIALIZED
||
fileLockMethod
==
FileLock
.
LOCK_
FS
||
fileLockMethod
==
FileLock
Method
.
FS
||
!
persistent
)
{
!
persistent
)
{
throw
DbException
.
getUnsupportedException
(
throw
DbException
.
getUnsupportedException
(
"autoServerMode && (readOnly || "
+
"autoServerMode && (readOnly || "
+
...
@@ -665,8 +666,8 @@ public class Database implements DataHandler {
...
@@ -665,8 +666,8 @@ public class Database implements DataHandler {
"Lock file exists: "
+
lockFileName
);
"Lock file exists: "
+
lockFileName
);
}
}
}
}
if
(!
readOnly
&&
fileLockMethod
!=
FileLock
.
LOCK_
NO
)
{
if
(!
readOnly
&&
fileLockMethod
!=
FileLock
Method
.
NO
)
{
if
(
fileLockMethod
!=
FileLock
.
LOCK_
FS
)
{
if
(
fileLockMethod
!=
FileLock
Method
.
FS
)
{
lock
=
new
FileLock
(
traceSystem
,
lockFileName
,
Constants
.
LOCK_SLEEP
);
lock
=
new
FileLock
(
traceSystem
,
lockFileName
,
Constants
.
LOCK_SLEEP
);
lock
.
lock
(
fileLockMethod
);
lock
.
lock
(
fileLockMethod
);
if
(
autoServerMode
)
{
if
(
autoServerMode
)
{
...
@@ -1260,7 +1261,7 @@ public class Database implements DataHandler {
...
@@ -1260,7 +1261,7 @@ public class Database implements DataHandler {
return
;
return
;
}
}
throwLastBackgroundException
();
throwLastBackgroundException
();
if
(
fileLockMethod
==
FileLock
.
LOCK_
SERIALIZED
&&
if
(
fileLockMethod
==
FileLock
Method
.
SERIALIZED
&&
!
reconnectChangePending
)
{
!
reconnectChangePending
)
{
// another connection may have written something - don't write
// another connection may have written something - don't write
try
{
try
{
...
@@ -1437,8 +1438,8 @@ public class Database implements DataHandler {
...
@@ -1437,8 +1438,8 @@ public class Database implements DataHandler {
}
}
closeFiles
();
closeFiles
();
if
(
persistent
&&
lock
==
null
&&
if
(
persistent
&&
lock
==
null
&&
fileLockMethod
!=
FileLock
.
LOCK_
NO
&&
fileLockMethod
!=
FileLock
Method
.
NO
&&
fileLockMethod
!=
FileLock
.
LOCK_
FS
)
{
fileLockMethod
!=
FileLock
Method
.
FS
)
{
// everything already closed (maybe in checkPowerOff)
// everything already closed (maybe in checkPowerOff)
// don't delete temp files in this case because
// don't delete temp files in this case because
// the database could be open now (even from within another process)
// the database could be open now (even from within another process)
...
@@ -1456,7 +1457,7 @@ public class Database implements DataHandler {
...
@@ -1456,7 +1457,7 @@ public class Database implements DataHandler {
lobSession
=
null
;
lobSession
=
null
;
}
}
if
(
lock
!=
null
)
{
if
(
lock
!=
null
)
{
if
(
fileLockMethod
==
FileLock
.
LOCK_
SERIALIZED
)
{
if
(
fileLockMethod
==
FileLock
Method
.
SERIALIZED
)
{
// wait before deleting the .lock file,
// wait before deleting the .lock file,
// otherwise other connections can not detect that
// otherwise other connections can not detect that
if
(
lock
.
load
().
containsKey
(
"changePending"
))
{
if
(
lock
.
load
().
containsKey
(
"changePending"
))
{
...
@@ -1985,7 +1986,7 @@ public class Database implements DataHandler {
...
@@ -1985,7 +1986,7 @@ public class Database implements DataHandler {
if
(
readOnly
)
{
if
(
readOnly
)
{
throw
DbException
.
get
(
ErrorCode
.
DATABASE_IS_READ_ONLY
);
throw
DbException
.
get
(
ErrorCode
.
DATABASE_IS_READ_ONLY
);
}
}
if
(
fileLockMethod
==
FileLock
.
LOCK_
SERIALIZED
)
{
if
(
fileLockMethod
==
FileLock
Method
.
SERIALIZED
)
{
if
(!
reconnectChangePending
)
{
if
(!
reconnectChangePending
)
{
throw
DbException
.
get
(
ErrorCode
.
DATABASE_IS_READ_ONLY
);
throw
DbException
.
get
(
ErrorCode
.
DATABASE_IS_READ_ONLY
);
}
}
...
@@ -2542,7 +2543,7 @@ public class Database implements DataHandler {
...
@@ -2542,7 +2543,7 @@ public class Database implements DataHandler {
if
(
pageSize
!=
Constants
.
DEFAULT_PAGE_SIZE
)
{
if
(
pageSize
!=
Constants
.
DEFAULT_PAGE_SIZE
)
{
pageStore
.
setPageSize
(
pageSize
);
pageStore
.
setPageSize
(
pageSize
);
}
}
if
(!
readOnly
&&
fileLockMethod
==
FileLock
.
LOCK_
FS
)
{
if
(!
readOnly
&&
fileLockMethod
==
FileLock
Method
.
FS
)
{
pageStore
.
setLockFile
(
true
);
pageStore
.
setLockFile
(
true
);
}
}
pageStore
.
setLogMode
(
logMode
);
pageStore
.
setLogMode
(
logMode
);
...
@@ -2578,7 +2579,7 @@ public class Database implements DataHandler {
...
@@ -2578,7 +2579,7 @@ public class Database implements DataHandler {
* @return true if reconnecting is required
* @return true if reconnecting is required
*/
*/
public
boolean
isReconnectNeeded
()
{
public
boolean
isReconnectNeeded
()
{
if
(
fileLockMethod
!=
FileLock
.
LOCK_
SERIALIZED
)
{
if
(
fileLockMethod
!=
FileLock
Method
.
SERIALIZED
)
{
return
false
;
return
false
;
}
}
if
(
reconnectChangePending
)
{
if
(
reconnectChangePending
)
{
...
@@ -2632,7 +2633,7 @@ public class Database implements DataHandler {
...
@@ -2632,7 +2633,7 @@ public class Database implements DataHandler {
* the .lock.db file.
* the .lock.db file.
*/
*/
public
void
checkpointIfRequired
()
{
public
void
checkpointIfRequired
()
{
if
(
fileLockMethod
!=
FileLock
.
LOCK_
SERIALIZED
||
if
(
fileLockMethod
!=
FileLock
Method
.
SERIALIZED
||
readOnly
||
!
reconnectChangePending
||
closing
)
{
readOnly
||
!
reconnectChangePending
||
closing
)
{
return
;
return
;
}
}
...
@@ -2661,7 +2662,7 @@ public class Database implements DataHandler {
...
@@ -2661,7 +2662,7 @@ public class Database implements DataHandler {
}
}
public
boolean
isFileLockSerialized
()
{
public
boolean
isFileLockSerialized
()
{
return
fileLockMethod
==
FileLock
.
LOCK_
SERIALIZED
;
return
fileLockMethod
==
FileLock
Method
.
SERIALIZED
;
}
}
private
void
flushSequences
()
{
private
void
flushSequences
()
{
...
@@ -2695,7 +2696,7 @@ public class Database implements DataHandler {
...
@@ -2695,7 +2696,7 @@ public class Database implements DataHandler {
* false if another connection was faster
* false if another connection was faster
*/
*/
public
boolean
beforeWriting
()
{
public
boolean
beforeWriting
()
{
if
(
fileLockMethod
!=
FileLock
.
LOCK_
SERIALIZED
)
{
if
(
fileLockMethod
!=
FileLock
Method
.
SERIALIZED
)
{
return
true
;
return
true
;
}
}
while
(
checkpointRunning
)
{
while
(
checkpointRunning
)
{
...
@@ -2724,7 +2725,7 @@ public class Database implements DataHandler {
...
@@ -2724,7 +2725,7 @@ public class Database implements DataHandler {
* This method is called after updates are finished.
* This method is called after updates are finished.
*/
*/
public
void
afterWriting
()
{
public
void
afterWriting
()
{
if
(
fileLockMethod
!=
FileLock
.
LOCK_
SERIALIZED
)
{
if
(
fileLockMethod
!=
FileLock
Method
.
SERIALIZED
)
{
return
;
return
;
}
}
synchronized
(
reconnectSync
)
{
synchronized
(
reconnectSync
)
{
...
...
h2/src/main/org/h2/engine/Engine.java
浏览文件 @
2d4f153e
...
@@ -7,7 +7,6 @@ package org.h2.engine;
...
@@ -7,7 +7,6 @@ package org.h2.engine;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.Objects
;
import
java.util.Objects
;
import
org.h2.api.ErrorCode
;
import
org.h2.api.ErrorCode
;
import
org.h2.command.CommandInterface
;
import
org.h2.command.CommandInterface
;
import
org.h2.command.Parser
;
import
org.h2.command.Parser
;
...
@@ -15,6 +14,7 @@ import org.h2.command.dml.SetTypes;
...
@@ -15,6 +14,7 @@ import org.h2.command.dml.SetTypes;
import
org.h2.message.DbException
;
import
org.h2.message.DbException
;
import
org.h2.message.Trace
;
import
org.h2.message.Trace
;
import
org.h2.store.FileLock
;
import
org.h2.store.FileLock
;
import
org.h2.store.FileLockMethod
;
import
org.h2.util.MathUtils
;
import
org.h2.util.MathUtils
;
import
org.h2.util.ThreadDeadlockDetector
;
import
org.h2.util.ThreadDeadlockDetector
;
import
org.h2.util.Utils
;
import
org.h2.util.Utils
;
...
@@ -141,8 +141,8 @@ public class Engine implements SessionFactory {
...
@@ -141,8 +141,8 @@ public class Engine implements SessionFactory {
try
{
try
{
ConnectionInfo
backup
=
null
;
ConnectionInfo
backup
=
null
;
String
lockMethodName
=
ci
.
getProperty
(
"FILE_LOCK"
,
null
);
String
lockMethodName
=
ci
.
getProperty
(
"FILE_LOCK"
,
null
);
int
fileLockMethod
=
FileLock
.
getFileLockMethod
(
lockMethodName
);
FileLockMethod
fileLockMethod
=
FileLock
.
getFileLockMethod
(
lockMethodName
);
if
(
fileLockMethod
==
FileLock
.
LOCK_
SERIALIZED
)
{
if
(
fileLockMethod
==
FileLock
Method
.
SERIALIZED
)
{
// In serialized mode, database instance sharing is not possible
// In serialized mode, database instance sharing is not possible
ci
.
setProperty
(
"OPEN_NEW"
,
"TRUE"
);
ci
.
setProperty
(
"OPEN_NEW"
,
"TRUE"
);
try
{
try
{
...
...
h2/src/main/org/h2/store/FileLister.java
浏览文件 @
2d4f153e
...
@@ -41,7 +41,7 @@ public class FileLister {
...
@@ -41,7 +41,7 @@ public class FileLister {
FileLock
lock
=
new
FileLock
(
new
TraceSystem
(
null
),
fileName
,
FileLock
lock
=
new
FileLock
(
new
TraceSystem
(
null
),
fileName
,
Constants
.
LOCK_SLEEP
);
Constants
.
LOCK_SLEEP
);
try
{
try
{
lock
.
lock
(
FileLock
.
LOCK_
FILE
);
lock
.
lock
(
FileLock
Method
.
FILE
);
lock
.
unlock
();
lock
.
unlock
();
}
catch
(
DbException
e
)
{
}
catch
(
DbException
e
)
{
throw
DbException
.
get
(
throw
DbException
.
get
(
...
...
h2/src/main/org/h2/store/FileLock.java
浏览文件 @
2d4f153e
...
@@ -35,33 +35,6 @@ import org.h2.value.Transfer;
...
@@ -35,33 +35,6 @@ import org.h2.value.Transfer;
*/
*/
public
class
FileLock
implements
Runnable
{
public
class
FileLock
implements
Runnable
{
/**
* This locking method means no locking is used at all.
*/
public
static
final
int
LOCK_NO
=
0
;
/**
* This locking method means the cooperative file locking protocol should be
* used.
*/
public
static
final
int
LOCK_FILE
=
1
;
/**
* This locking method means a socket is created on the given machine.
*/
public
static
final
int
LOCK_SOCKET
=
2
;
/**
* This locking method means multiple writers are allowed, and they
* synchronize themselves.
*/
public
static
final
int
LOCK_SERIALIZED
=
3
;
/**
* Use the file system to lock the file; don't use a separate lock file.
*/
public
static
final
int
LOCK_FS
=
4
;
private
static
final
String
MAGIC
=
"FileLock"
;
private
static
final
String
MAGIC
=
"FileLock"
;
private
static
final
String
FILE
=
"file"
;
private
static
final
String
FILE
=
"file"
;
private
static
final
String
SOCKET
=
"socket"
;
private
static
final
String
SOCKET
=
"socket"
;
...
@@ -125,22 +98,22 @@ public class FileLock implements Runnable {
...
@@ -125,22 +98,22 @@ public class FileLock implements Runnable {
* @param fileLockMethod the file locking method to use
* @param fileLockMethod the file locking method to use
* @throws DbException if locking was not successful
* @throws DbException if locking was not successful
*/
*/
public
synchronized
void
lock
(
int
fileLockMethod
)
{
public
synchronized
void
lock
(
FileLockMethod
fileLockMethod
)
{
checkServer
();
checkServer
();
if
(
locked
)
{
if
(
locked
)
{
DbException
.
throwInternalError
(
"already locked"
);
DbException
.
throwInternalError
(
"already locked"
);
}
}
switch
(
fileLockMethod
)
{
switch
(
fileLockMethod
)
{
case
LOCK_
FILE:
case
FILE:
lockFile
();
lockFile
();
break
;
break
;
case
LOCK_
SOCKET:
case
SOCKET:
lockSocket
();
lockSocket
();
break
;
break
;
case
LOCK_
SERIALIZED:
case
SERIALIZED:
lockSerialized
();
lockSerialized
();
break
;
break
;
case
LOCK_
FS:
case
FS:
break
;
break
;
}
}
locked
=
true
;
locked
=
true
;
...
@@ -480,17 +453,17 @@ public class FileLock implements Runnable {
...
@@ -480,17 +453,17 @@ public class FileLock implements Runnable {
* @return the method type
* @return the method type
* @throws DbException if the method name is unknown
* @throws DbException if the method name is unknown
*/
*/
public
static
int
getFileLockMethod
(
String
method
)
{
public
static
FileLockMethod
getFileLockMethod
(
String
method
)
{
if
(
method
==
null
||
method
.
equalsIgnoreCase
(
"FILE"
))
{
if
(
method
==
null
||
method
.
equalsIgnoreCase
(
"FILE"
))
{
return
FileLock
.
LOCK_
FILE
;
return
FileLock
Method
.
FILE
;
}
else
if
(
method
.
equalsIgnoreCase
(
"NO"
))
{
}
else
if
(
method
.
equalsIgnoreCase
(
"NO"
))
{
return
FileLock
.
LOCK_
NO
;
return
FileLock
Method
.
NO
;
}
else
if
(
method
.
equalsIgnoreCase
(
"SOCKET"
))
{
}
else
if
(
method
.
equalsIgnoreCase
(
"SOCKET"
))
{
return
FileLock
.
LOCK_
SOCKET
;
return
FileLock
Method
.
SOCKET
;
}
else
if
(
method
.
equalsIgnoreCase
(
"SERIALIZED"
))
{
}
else
if
(
method
.
equalsIgnoreCase
(
"SERIALIZED"
))
{
return
FileLock
.
LOCK_
SERIALIZED
;
return
FileLock
Method
.
SERIALIZED
;
}
else
if
(
method
.
equalsIgnoreCase
(
"FS"
))
{
}
else
if
(
method
.
equalsIgnoreCase
(
"FS"
))
{
return
FileLock
.
LOCK_
FS
;
return
FileLock
Method
.
FS
;
}
else
{
}
else
{
throw
DbException
.
get
(
throw
DbException
.
get
(
ErrorCode
.
UNSUPPORTED_LOCK_METHOD_1
,
method
);
ErrorCode
.
UNSUPPORTED_LOCK_METHOD_1
,
method
);
...
...
h2/src/main/org/h2/store/FileLockMethod.java
0 → 100644
浏览文件 @
2d4f153e
/*
* Copyright 2004-2018 H2 Group. Multiple-Licensed under the MPL 2.0,
* and the EPL 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package
org
.
h2
.
store
;
public
enum
FileLockMethod
{
/**
* This locking method means no locking is used at all.
*/
NO
,
/**
* This locking method means the cooperative file locking protocol should be
* used.
*/
FILE
,
/**
* This locking method means a socket is created on the given machine.
*/
SOCKET
,
/**
* This locking method means multiple writers are allowed, and they
* synchronize themselves.
*/
SERIALIZED
,
/**
* Use the file system to lock the file; don't use a separate lock file.
*/
FS
;
}
h2/src/test/org/h2/test/unit/TestFileLock.java
浏览文件 @
2d4f153e
...
@@ -7,11 +7,11 @@ package org.h2.test.unit;
...
@@ -7,11 +7,11 @@ package org.h2.test.unit;
import
java.io.File
;
import
java.io.File
;
import
java.sql.Connection
;
import
java.sql.Connection
;
import
org.h2.api.ErrorCode
;
import
org.h2.api.ErrorCode
;
import
org.h2.engine.Constants
;
import
org.h2.engine.Constants
;
import
org.h2.message.TraceSystem
;
import
org.h2.message.TraceSystem
;
import
org.h2.store.FileLock
;
import
org.h2.store.FileLock
;
import
org.h2.store.FileLockMethod
;
import
org.h2.test.TestBase
;
import
org.h2.test.TestBase
;
/**
/**
...
@@ -77,7 +77,7 @@ public class TestFileLock extends TestBase implements Runnable {
...
@@ -77,7 +77,7 @@ public class TestFileLock extends TestBase implements Runnable {
f
.
setLastModified
(
System
.
currentTimeMillis
()
+
10000
);
f
.
setLastModified
(
System
.
currentTimeMillis
()
+
10000
);
FileLock
lock
=
new
FileLock
(
new
TraceSystem
(
null
),
getFile
(),
FileLock
lock
=
new
FileLock
(
new
TraceSystem
(
null
),
getFile
(),
Constants
.
LOCK_SLEEP
);
Constants
.
LOCK_SLEEP
);
lock
.
lock
(
FileLock
.
LOCK_
FILE
);
lock
.
lock
(
FileLock
Method
.
FILE
);
lock
.
unlock
();
lock
.
unlock
();
}
}
...
@@ -86,14 +86,14 @@ public class TestFileLock extends TestBase implements Runnable {
...
@@ -86,14 +86,14 @@ public class TestFileLock extends TestBase implements Runnable {
Constants
.
LOCK_SLEEP
);
Constants
.
LOCK_SLEEP
);
FileLock
lock2
=
new
FileLock
(
new
TraceSystem
(
null
),
getFile
(),
FileLock
lock2
=
new
FileLock
(
new
TraceSystem
(
null
),
getFile
(),
Constants
.
LOCK_SLEEP
);
Constants
.
LOCK_SLEEP
);
lock1
.
lock
(
FileLock
.
LOCK_
FILE
);
lock1
.
lock
(
FileLock
Method
.
FILE
);
createClassProxy
(
FileLock
.
class
);
createClassProxy
(
FileLock
.
class
);
assertThrows
(
ErrorCode
.
DATABASE_ALREADY_OPEN_1
,
lock2
).
lock
(
assertThrows
(
ErrorCode
.
DATABASE_ALREADY_OPEN_1
,
lock2
).
lock
(
FileLock
.
LOCK_
FILE
);
FileLock
Method
.
FILE
);
lock1
.
unlock
();
lock1
.
unlock
();
lock2
=
new
FileLock
(
new
TraceSystem
(
null
),
getFile
(),
lock2
=
new
FileLock
(
new
TraceSystem
(
null
),
getFile
(),
Constants
.
LOCK_SLEEP
);
Constants
.
LOCK_SLEEP
);
lock2
.
lock
(
FileLock
.
LOCK_
FILE
);
lock2
.
lock
(
FileLock
Method
.
FILE
);
lock2
.
unlock
();
lock2
.
unlock
();
}
}
...
@@ -123,8 +123,8 @@ public class TestFileLock extends TestBase implements Runnable {
...
@@ -123,8 +123,8 @@ public class TestFileLock extends TestBase implements Runnable {
while
(!
stop
)
{
while
(!
stop
)
{
lock
=
new
FileLock
(
new
TraceSystem
(
null
),
getFile
(),
100
);
lock
=
new
FileLock
(
new
TraceSystem
(
null
),
getFile
(),
100
);
try
{
try
{
lock
.
lock
(
allowSockets
?
FileLock
.
LOCK_
SOCKET
lock
.
lock
(
allowSockets
?
FileLock
Method
.
SOCKET
:
FileLock
.
LOCK_
FILE
);
:
FileLock
Method
.
FILE
);
base
.
trace
(
lock
+
" locked"
);
base
.
trace
(
lock
+
" locked"
);
locks
++;
locks
++;
if
(
locks
>
1
)
{
if
(
locks
>
1
)
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论