Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
JDChain
Bftsmart
提交
64233ac8
B
Bftsmart
项目概览
JDChain
/
Bftsmart
通知
0
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
B
Bftsmart
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
64233ac8
编写于
4月 07, 2012
作者:
L
liquidsnake@sapo.pt
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Copied bug fixes from branch to main trunk, part 1
上级
8e6247b6
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
55 addition
and
36 deletion
+55
-36
src/navigators/smart/statemanagment/StateManager.java
src/navigators/smart/statemanagment/StateManager.java
+1
-2
src/navigators/smart/tom/core/timer/RequestsTimer.java
src/navigators/smart/tom/core/timer/RequestsTimer.java
+1
-1
src/navigators/smart/tom/demo/keyvalue/BFTMap.java
src/navigators/smart/tom/demo/keyvalue/BFTMap.java
+9
-3
src/navigators/smart/tom/demo/keyvalue/BFTMapImpl.java
src/navigators/smart/tom/demo/keyvalue/BFTMapImpl.java
+8
-5
src/navigators/smart/tom/demo/keyvalue/BFTTableMap.java
src/navigators/smart/tom/demo/keyvalue/BFTTableMap.java
+7
-6
src/navigators/smart/tom/demo/keyvalue/KVClient.java
src/navigators/smart/tom/demo/keyvalue/KVClient.java
+2
-2
src/navigators/smart/tom/demo/listvalue/BFTListImpl.java
src/navigators/smart/tom/demo/listvalue/BFTListImpl.java
+1
-1
src/navigators/smart/tom/server/defaultservices/CommandsInfo.java
...gators/smart/tom/server/defaultservices/CommandsInfo.java
+1
-1
src/navigators/smart/tom/server/defaultservices/DefaultApplicationState.java
...t/tom/server/defaultservices/DefaultApplicationState.java
+15
-7
src/navigators/smart/tom/server/defaultservices/DefaultRecoverable.java
.../smart/tom/server/defaultservices/DefaultRecoverable.java
+3
-3
src/navigators/smart/tom/server/defaultservices/StateLog.java
...navigators/smart/tom/server/defaultservices/StateLog.java
+7
-5
未找到文件。
src/navigators/smart/statemanagment/StateManager.java
浏览文件 @
64233ac8
...
...
@@ -40,7 +40,6 @@ import navigators.smart.tom.core.DeliveryThread;
import
navigators.smart.tom.core.TOMLayer
;
import
navigators.smart.tom.demo.keyvalue.BFTTableMap
;
import
navigators.smart.tom.leaderchange.LCManager
;
import
navigators.smart.tom.server.DefaultApplicationState
;
import
navigators.smart.tom.server.Recoverable
;
import
navigators.smart.tom.util.Logger
;
import
navigators.smart.tom.util.TOMUtil
;
...
...
@@ -306,7 +305,7 @@ public class StateManager {
for
(
int
i
=
0
;
i
<
st
.
length
;
i
++)
{
for
(
int
j
=
i
;
j
<
st
.
length
;
j
++)
{
for
(
int
j
=
0
;
j
<
st
.
length
;
j
++)
{
if
(
st
[
i
].
state
.
equals
(
st
[
j
].
state
)
&&
st
[
j
].
state
.
hasState
())
count
++;
...
...
src/navigators/smart/tom/core/timer/RequestsTimer.java
浏览文件 @
64233ac8
...
...
@@ -154,7 +154,7 @@ public class RequestsTimer {
long
t
=
(
shortTimeout
>
-
1
?
shortTimeout
:
timeout
);
System
.
out
.
println
(
"(RequestTimerTask.run) I SOULD NEVER RUN WHEN THERE IS NO TIMEOUT"
);
//
System.out.println("(RequestTimerTask.run) I SOULD NEVER RUN WHEN THERE IS NO TIMEOUT");
rwLock
.
readLock
().
lock
();
LinkedList
<
TOMMessage
>
pendingRequests
=
new
LinkedList
<
TOMMessage
>();
...
...
src/navigators/smart/tom/demo/keyvalue/BFTMap.java
浏览文件 @
64233ac8
...
...
@@ -18,8 +18,8 @@ import navigators.smart.tom.ServiceProxy;
import
java.io.ObjectInputStream
;
import
java.io.ObjectOutputStream
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.TreeMap
;
/**
*
...
...
@@ -77,7 +77,13 @@ public class BFTMap implements Map<String, Map<String,byte[]>> {
dos
.
writeInt
(
KVRequestType
.
TAB_CREATE
);
dos
.
writeUTF
(
key
);
ObjectOutputStream
out1
=
new
ObjectOutputStream
(
out
)
;
out1
.
writeObject
(
value
);
if
(
value
!=
null
)
{
out1
.
writeBoolean
(
true
);
out1
.
writeObject
(
value
);
}
else
{
out1
.
writeBoolean
(
false
);
}
out1
.
close
();
byte
[]
rep
=
KVProxy
.
invokeOrdered
(
out
.
toByteArray
());
ByteArrayInputStream
bis
=
new
ByteArrayInputStream
(
rep
)
;
...
...
@@ -240,7 +246,7 @@ public class BFTMap implements Map<String, Map<String,byte[]>> {
throw
new
UnsupportedOperationException
(
"Not supported yet."
);
}
public
Hash
Map
<
String
,
byte
[]>
get
(
Object
key
)
{
public
Tree
Map
<
String
,
byte
[]>
get
(
Object
key
)
{
throw
new
UnsupportedOperationException
(
"Not supported yet."
);
}
...
...
src/navigators/smart/tom/demo/keyvalue/BFTMapImpl.java
浏览文件 @
64233ac8
...
...
@@ -4,6 +4,7 @@
*/
package
navigators.smart.tom.demo.keyvalue
;
import
navigators.smart.tom.server.defaultservices.DefaultApplicationState
;
import
java.io.ByteArrayInputStream
;
import
java.io.ByteArrayOutputStream
;
import
java.io.DataInputStream
;
...
...
@@ -14,7 +15,7 @@ import java.io.ObjectOutputStream;
import
java.security.MessageDigest
;
import
java.security.NoSuchAlgorithmException
;
import
java.util.Collection
;
import
java.util.
Hash
Map
;
import
java.util.
Tree
Map
;
import
java.util.Map
;
import
java.util.concurrent.locks.ReentrantLock
;
import
java.util.logging.Level
;
...
...
@@ -23,10 +24,9 @@ import navigators.smart.statemanagment.ApplicationState;
import
navigators.smart.tom.MessageContext
;
import
navigators.smart.tom.ReplicaContext
;
import
navigators.smart.tom.ServiceReplica
;
import
navigators.smart.tom.server.DefaultApplicationState
;
import
navigators.smart.tom.server.Recoverable
;
import
navigators.smart.tom.server.SingleExecutable
;
import
navigators.smart.tom.server.StateLog
;
import
navigators.smart.tom.server.
defaultservices.
StateLog
;
import
navigators.smart.tom.server.defaultservices.DefaultRecoverable
;
import
navigators.smart.tom.util.Logger
;
...
...
@@ -54,12 +54,15 @@ public class BFTMapImpl implements SingleExecutable, Recoverable {
super
();
replica
=
new
ServiceReplica
(
id
,
this
,
this
);
checkpointPeriod
=
replicaContext
.
getStaticConfiguration
().
getCheckpointPeriod
();
log
=
new
StateLog
(
checkpointPeriod
);
try
{
md
=
MessageDigest
.
getInstance
(
"MD5"
);
// TODO: shouldn't it be SHA?
}
catch
(
NoSuchAlgorithmException
ex
)
{
java
.
util
.
logging
.
Logger
.
getLogger
(
DefaultRecoverable
.
class
.
getName
()).
log
(
Level
.
SEVERE
,
null
,
ex
);
}
byte
[]
initialState
=
getSnapshot
();
log
=
new
StateLog
(
checkpointPeriod
,
initialState
,
computeHash
(
initialState
));
}
public
static
void
main
(
String
[]
args
){
...
...
@@ -270,7 +273,7 @@ public class BFTMapImpl implements SingleExecutable, Recoverable {
DataInputStream
dis
=
new
DataInputStream
(
bais
);
while
(
dis
.
available
()
>
0
)
{
Map
<
String
,
byte
[]>
table
=
new
Hash
Map
<
String
,
byte
[]>();
Map
<
String
,
byte
[]>
table
=
new
Tree
Map
<
String
,
byte
[]>();
String
tableName
=
dis
.
readUTF
();
tableMap
.
addTable
(
tableName
,
table
);
int
tableSize
=
dis
.
readInt
();
...
...
src/navigators/smart/tom/demo/keyvalue/BFTTableMap.java
浏览文件 @
64233ac8
...
...
@@ -4,10 +4,11 @@
*/
package
navigators.smart.tom.demo.keyvalue
;
import
java.util.HashMap
;
//
import java.util.HashMap;
import
java.util.Map
;
import
java.io.Serializable
;
import
java.util.TreeMap
;
/**
*
...
...
@@ -20,9 +21,13 @@ public class BFTTableMap implements Serializable {
private
Map
<
String
,
Map
<
String
,
byte
[]>>
tableMap
=
null
;
public
BFTTableMap
()
{
tableMap
=
new
Hash
Map
<
String
,
Map
<
String
,
byte
[]>>();
tableMap
=
new
Tree
Map
<
String
,
Map
<
String
,
byte
[]>>();
}
public
Map
<
String
,
Map
<
String
,
byte
[]>>
getTables
()
{
return
tableMap
;
}
public
Map
<
String
,
byte
[]>
addTable
(
String
key
,
Map
<
String
,
byte
[]>
table
)
{
return
tableMap
.
put
(
key
,
table
);
}
...
...
@@ -50,10 +55,6 @@ public class BFTTableMap implements Serializable {
return
tableMap
.
size
();
}
public
Map
<
String
,
Map
<
String
,
byte
[]>>
getTables
()
{
return
tableMap
;
}
public
int
getSize
(
String
tableName
)
{
Map
<
String
,
byte
[]>
table
=
tableMap
.
get
(
tableName
);
return
table
.
size
();
...
...
src/navigators/smart/tom/demo/keyvalue/KVClient.java
浏览文件 @
64233ac8
...
...
@@ -9,7 +9,7 @@ import java.util.Random;
import
java.util.Scanner
;
import
java.io.Console
;
import
java.util.
Hash
Map
;
import
java.util.
Tree
Map
;
/**
*
...
...
@@ -53,7 +53,7 @@ public class KVClient {
tableExists
=
bftMap
.
containsKey
(
tableName
);
if
(!
tableExists
)
{
//if the table name does not exist then create the table
bftMap
.
put
(
tableName
,
new
Hash
Map
<
String
,
byte
[]>());
bftMap
.
put
(
tableName
,
new
Tree
Map
<
String
,
byte
[]>());
}
}
while
(
tableExists
);
break
;
...
...
src/navigators/smart/tom/demo/listvalue/BFTListImpl.java
浏览文件 @
64233ac8
...
...
@@ -26,7 +26,7 @@ import java.util.logging.Logger;
import
navigators.smart.tom.MessageContext
;
import
navigators.smart.tom.ReplicaContext
;
import
navigators.smart.tom.ServiceReplica
;
import
navigators.smart.tom.server.DefaultRecoverable
;
import
navigators.smart.tom.server.
defaultservices.
DefaultRecoverable
;
/**
*
...
...
src/navigators/smart/tom/server/CommandsInfo.java
→
src/navigators/smart/tom/server/
defaultservices/
CommandsInfo.java
浏览文件 @
64233ac8
...
...
@@ -21,7 +21,7 @@
* and open the template in the editor.
*/
package
navigators.smart.tom.server
;
package
navigators.smart.tom.server
.defaultservices
;
import
java.io.Serializable
;
import
java.util.Arrays
;
...
...
src/navigators/smart/tom/server/DefaultApplicationState.java
→
src/navigators/smart/tom/server/
defaultservices/
DefaultApplicationState.java
浏览文件 @
64233ac8
package
navigators.smart.tom.server.defaultservices
;
/**
* Copyright (c) 2007-2009 Alysson Bessani, Eduardo Alchieri, Paulo Sousa, and the authors indicated in the @author tags
*
...
...
@@ -16,11 +18,23 @@
* You should have received a copy of the GNU General Public License along with SMaRt. If not, see <http://www.gnu.org/licenses/>.
*/
package
navigators.smart.tom.server
;
import
java.io.ByteArrayInputStream
;
import
java.io.ByteArrayOutputStream
;
import
java.io.DataInputStream
;
import
java.io.DataOutputStream
;
import
java.io.IOException
;
import
java.io.ObjectInput
;
import
java.io.ObjectInputStream
;
import
java.io.Serializable
;
import
java.util.Arrays
;
import
java.util.Collection
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.logging.Level
;
import
navigators.smart.statemanagment.ApplicationState
;
import
navigators.smart.tom.demo.keyvalue.BFTTableMap
;
/**
* This classe represents a state tranfered from a replica to another. The state associated with the last
...
...
@@ -210,12 +224,6 @@ public class DefaultApplicationState implements ApplicationState {
}
}
}
//System.out.print("[DefaultApplicationState] returing.........");
//System.out.println(Arrays.equals(this.stateHash, tState.stateHash) + " && " +
// (tState.lastCheckpointEid == this.lastCheckpointEid) + " && " +
// (tState.lastCheckpointRound == this.lastCheckpointRound) + " && " +
// (tState.lastCheckpointLeader == this.lastCheckpointLeader) + " && " +
// (tState.lastEid == this.lastEid) + " && " + (tState.hasState == this.hasState));
return
(
Arrays
.
equals
(
this
.
stateHash
,
tState
.
stateHash
)
&&
tState
.
lastCheckpointEid
==
this
.
lastCheckpointEid
&&
tState
.
lastCheckpointRound
==
this
.
lastCheckpointRound
&&
...
...
src/navigators/smart/tom/server/defaultservices/DefaultRecoverable.java
浏览文件 @
64233ac8
...
...
@@ -11,9 +11,7 @@ import java.util.logging.Level;
import
navigators.smart.statemanagment.ApplicationState
;
import
navigators.smart.tom.MessageContext
;
import
navigators.smart.tom.server.BatchExecutable
;
import
navigators.smart.tom.server.DefaultApplicationState
;
import
navigators.smart.tom.server.Recoverable
;
import
navigators.smart.tom.server.StateLog
;
import
navigators.smart.tom.util.Logger
;
/**
...
...
@@ -33,12 +31,14 @@ public abstract class DefaultRecoverable implements Recoverable, BatchExecutable
private
StateLog
log
;
public
DefaultRecoverable
()
{
log
=
new
StateLog
(
CHECKPOINT_PERIOD
);
try
{
md
=
MessageDigest
.
getInstance
(
"MD5"
);
// TODO: shouldn't it be SHA?
}
catch
(
NoSuchAlgorithmException
ex
)
{
java
.
util
.
logging
.
Logger
.
getLogger
(
DefaultRecoverable
.
class
.
getName
()).
log
(
Level
.
SEVERE
,
null
,
ex
);
}
byte
[]
state
=
getSnapshot
();
log
=
new
StateLog
(
CHECKPOINT_PERIOD
,
state
,
computeHash
(
state
));
}
public
byte
[][]
executeBatch
(
byte
[][]
commands
,
MessageContext
[]
msgCtxs
)
{
...
...
src/navigators/smart/tom/server/StateLog.java
→
src/navigators/smart/tom/server/
defaultservices/
StateLog.java
浏览文件 @
64233ac8
...
...
@@ -16,8 +16,10 @@
* You should have received a copy of the GNU General Public License along with SMaRt. If not, see <http://www.gnu.org/licenses/>.
*/
package
navigators.smart.tom.server
;
package
navigators.smart.tom.server
.defaultservices
;
import
navigators.smart.tom.server.defaultservices.CommandsInfo
;
import
navigators.smart.tom.server.defaultservices.DefaultApplicationState
;
import
org.apache.commons.codec.binary.Base64
;
/**
...
...
@@ -43,14 +45,14 @@ public class StateLog {
* Constructs a State log
* @param k The chekpoint period
*/
public
StateLog
(
int
k
)
{
public
StateLog
(
int
k
,
byte
[]
initialState
,
byte
[]
initialHash
)
{
this
.
messageBatches
=
new
CommandsInfo
[
k
-
1
];
this
.
lastCheckpointEid
=
-
1
;
this
.
lastCheckpointRound
=
-
1
;
this
.
lastCheckpointLeader
=
-
1
;
this
.
state
=
null
;
this
.
stateHash
=
null
;
this
.
state
=
initialState
;
this
.
stateHash
=
initialHash
;
this
.
position
=
0
;
this
.
lastEid
=
-
1
;
}
...
...
@@ -208,7 +210,7 @@ public class StateLog {
public
DefaultApplicationState
getApplicationState
(
int
eid
,
boolean
setState
)
{
System
.
out
.
println
(
"lastCheckpointEid: "
+
lastCheckpointEid
+
"eid: "
+
eid
);
if
(
lastCheckpointEid
>
-
1
&&
eid
>=
lastCheckpointEid
)
{
if
(
/*lastCheckpointEid > -1 && */
eid
>=
lastCheckpointEid
)
{
CommandsInfo
[]
batches
=
null
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录