增加时间统计,时间统计分成两个日志文件,statis_time是统计共识每个阶段的花费时间,outputtime是打印共识每个阶段的开始时刻和结束时刻。

在系统的system.conf文件中的statistic_enable来控制是否输出时间日志,0=禁止;1=打开。
This commit is contained in:
wuwei1972 2019-05-14 09:41:48 +08:00
parent 8bb486ad9d
commit 0c4e4d0b69
16 changed files with 115 additions and 54 deletions

View File

@ -164,6 +164,27 @@
</encoder>
</appender>
<appender name="OutputTime_Appender" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>logs/OutputTime-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
<!-- each file should be at most 100MB, keep 30 days worth of history, but at most 3GB -->
<maxFileSize>100MB</maxFileSize>
<maxHistory>30</maxHistory>
<totalSizeCap>3GB</totalSizeCap>
</rollingPolicy>
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>TRACE</level>
</filter>
<immediateFlush>false</immediateFlush>
<append>false</append>
<encoder charset="UTF-8">
<pattern>%date{ISO8601} %-5level %logger{36} %X{akkaSource} - %msg%n</pattern>
<charset>UTF-8</charset>
</encoder>
</appender>
<appender name="Sandbox_Appender" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>logs/RepChain-Sandbox-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
@ -228,6 +249,10 @@
<appender-ref ref="StatisTime_Appender"/>
</logger>
<logger name="OutputTime_Logger" additivity="false" level="TRACE">
<appender-ref ref="OutputTime_Appender"/>
</logger>
<logger name="Sandbox_Logger" additivity="false" level="TRACE">
<appender-ref ref="Sandbox_Appender"/>
</logger>

View File

@ -73,7 +73,7 @@ system {
//如果是单机多节点测试模式Repchain则选择0默认节点1会开启
ws_enable = 1//api 0,不开启;1,开启
//交易生产方式
trans_create_type = 1 //0,手动;1,自动
trans_create_type = 0 //0,手动;1,自动
//是否进行TPS测试
statistic_enable = 0 // 0,unable;able
//实时图的事件是否发送,如果不发送,前端实时图将收不到任何消息。

View File

@ -57,6 +57,9 @@ object Repchain {
for(i <- 2 to node_max) {
Thread.sleep(2000)
//if(i == 5){
// Thread.sleep(60000)
//}
val len = nodes.size
val sys = new ClusterSystem(nodelist(i-2),InitType.MULTI_INIT,true)
sys.init

View File

@ -34,6 +34,7 @@ object RepLogger {
def StatisTime_Logger = LoggerFactory.getLogger("StatisTime_Logger")
def Sandbox_Logger = LoggerFactory.getLogger("Sandbox_Logger")
def Vote_Logger = LoggerFactory.getLogger("Vote_Logger")
def OutputTime_Logger = LoggerFactory.getLogger("OutputTime_Logger")
def trace(logger:Logger,msg:String)={
logger.trace(msg)

View File

@ -37,18 +37,22 @@ object RepTimeTracer {
this.isOpenTrace.set(false)
}
def setStartTime(nodeName: String, flag: String, t: Long) = {
if (this.isOpenTrace.get)
this.times.put(nodeName + "-" + flag, t);
def setStartTime(nodeName: String, flag: String, t: Long,bheight:Long,trannum:Int) = {
if (this.isOpenTrace.get){
val key = nodeName + "-" + flag
this.times.put(key, t);
RepLogger.trace(RepLogger.OutputTime_Logger, s"${key}_bheight=${bheight}_start_time=${t},transcount=${trannum}")
}
}
def setEndTime(nodeName: String, flag: String, t: Long) = {
def setEndTime(nodeName: String, flag: String, t: Long,bheight:Long,trannum:Int) = {
if (this.isOpenTrace.get) {
val key = nodeName + "-" + flag;
if (this.times.contains(key)) {
val tl = t - this.times(key);
RepLogger.trace(RepLogger.StatisTime_Logger, key + "=" + tl)
RepLogger.trace(RepLogger.StatisTime_Logger, s"${key}_bheight=${bheight}_spent_time=${tl},transcount=${trannum}")
}
RepLogger.trace(RepLogger.OutputTime_Logger, s"${key}_bheight=${bheight}_end_time=${t},transcount=${trannum}")
}
}

View File

@ -95,11 +95,11 @@ abstract class ModuleBase(name: String) extends Actor with ClusterActor with B
* @param step
* @param actorRef
*/
def logTime(timetag:String,time:Long,isstart:Boolean): Unit = {
def logTime(timetag:String,time:Long,isstart:Boolean,bheight:Long,trannum:Int): Unit = {
if(isstart){
RepTimeTracer.setStartTime(pe.getSysTag, timetag, time)
RepTimeTracer.setStartTime(pe.getSysTag, timetag, time,bheight,trannum)
}else{
RepTimeTracer.setEndTime(pe.getSysTag, timetag, time)
RepTimeTracer.setEndTime(pe.getSysTag, timetag, time,bheight,trannum)
}
}
}

View File

@ -137,18 +137,18 @@ class Blocker(moduleName: String) extends ModuleBase(moduleName) {
}
private def CreateBlock: Block = {
RepTimeTracer.setStartTime(pe.getSysTag, "Block", System.currentTimeMillis())
RepTimeTracer.setStartTime(pe.getSysTag, "createBlock", System.currentTimeMillis())
RepTimeTracer.setStartTime(pe.getSysTag, "collectTransToBlock", System.currentTimeMillis())
RepTimeTracer.setStartTime(pe.getSysTag, "Block", System.currentTimeMillis(),pe.getCurrentHeight + 1,0)
RepTimeTracer.setStartTime(pe.getSysTag, "createBlock", System.currentTimeMillis(),pe.getCurrentHeight + 1,0)
RepTimeTracer.setStartTime(pe.getSysTag, "collectTransToBlock", System.currentTimeMillis(),pe.getCurrentHeight + 1,0)
val trans = CollectedTransOfBlock(SystemProfile.getLimitBlockTransNum, SystemProfile.getBlockLength)
//todo 交易排序
if (trans.size >= SystemProfile.getMinBlockTransNum) {
RepTimeTracer.setEndTime(pe.getSysTag, "collectTransToBlock", System.currentTimeMillis())
RepTimeTracer.setEndTime(pe.getSysTag, "collectTransToBlock", System.currentTimeMillis(),pe.getCurrentHeight + 1,trans.size)
var blc = BlockHelp.WaitingForExecutionOfBlock(pe.getCurrentBlockHash, pe.getCurrentHeight + 1, trans)
RepLogger.trace(RepLogger.Consensus_Logger, this.getLogMsgPrefix(s"create new block,height=${blc.height},local height=${pe.getCurrentHeight}" + "~" + selfAddr))
RepTimeTracer.setStartTime(pe.getSysTag, "PreloadTrans", System.currentTimeMillis())
RepTimeTracer.setStartTime(pe.getSysTag, "PreloadTrans", System.currentTimeMillis(),blc.height,blc.transactions.size)
blc = ExecuteTransactionOfBlock(blc)
RepTimeTracer.setEndTime(pe.getSysTag, "PreloadTrans", System.currentTimeMillis())
RepTimeTracer.setEndTime(pe.getSysTag, "PreloadTrans", System.currentTimeMillis(),blc.height,blc.transactions.size)
if (blc != null) {
RepLogger.trace(RepLogger.Consensus_Logger, this.getLogMsgPrefix(s"create new block,prelaod success,height=${blc.height},local height=${pe.getCurrentHeight}" + "~" + selfAddr))
blc = BlockHelp.AddBlockHash(blc)
@ -165,12 +165,12 @@ class Blocker(moduleName: String) extends ModuleBase(moduleName) {
//if (preblock == null) {
val blc = CreateBlock
if (blc != null) {
RepTimeTracer.setEndTime(pe.getSysTag, "createBlock", System.currentTimeMillis())
RepTimeTracer.setEndTime(pe.getSysTag, "createBlock", System.currentTimeMillis(),blc.height,blc.transactions.size)
this.preblock = blc
schedulerLink = clearSched()
//在发出背书时告诉对方我是当前出块人取出系统的名称
//pe.getActorRef(ActorType.endorsementcollectioner) ! EndorseMsg.CollectEndorsement(this.preblock, pe.getBlocker.blocker)
RepTimeTracer.setStartTime(pe.getSysTag, "Endorsement", System.currentTimeMillis())
RepTimeTracer.setStartTime(pe.getSysTag, "Endorsement", System.currentTimeMillis(),blc.height,blc.transactions.size)
pe.getActorRef(ActorType.endorsementcollectioner) ! EndorseMsg.CollectEndorsement(this.preblock, pe.getSysTag)
//schedulerLink = scheduler.scheduleOnce(TimePolicy.getTimeoutEndorse seconds, self, Blocker.EndorseOfBlockTimeOut)
}

View File

@ -132,9 +132,9 @@ class ConfirmOfBlock(moduleName: String) extends ModuleBase(moduleName) {
override def receive = {
//Endorsement block
case ConfirmedBlock(block, actRefOfBlock) =>
RepTimeTracer.setStartTime(pe.getSysTag, "blockconfirm", System.currentTimeMillis())
RepTimeTracer.setStartTime(pe.getSysTag, "blockconfirm", System.currentTimeMillis(),block.height,block.transactions.size)
checkedOfConfirmBlock(block, actRefOfBlock)
RepTimeTracer.setEndTime(pe.getSysTag, "blockconfirm", System.currentTimeMillis())
RepTimeTracer.setEndTime(pe.getSysTag, "blockconfirm", System.currentTimeMillis(),block.height,block.transactions.size)
case _ => //ignore
}

View File

@ -108,7 +108,7 @@ class EndorseCollector(moduleName: String) extends ModuleBase(moduleName) {
BlockVerify.sort(consensus)
RepLogger.trace(RepLogger.Consensus_Logger, this.getLogMsgPrefix("collectioner endorsement sort"))
this.block = this.block.withEndorsements(consensus)
RepTimeTracer.setEndTime(pe.getSysTag, "Endorsement", System.currentTimeMillis())
RepTimeTracer.setEndTime(pe.getSysTag, "Endorsement", System.currentTimeMillis(),this.block.height,this.block.transactions.size)
mediator ! Publish(Topic.Block, new ConfirmedBlock(this.block, sender))
RepLogger.trace(RepLogger.Consensus_Logger, this.getLogMsgPrefix( "collectioner endorsementt finish"))
clearEndorseInfo

View File

@ -238,9 +238,9 @@ class Endorser4Future(moduleName: String) extends ModuleBase(moduleName) {
//Endorsement block
case EndorsementInfo(block, blocker) =>
if(!pe.isSynching){
RepTimeTracer.setStartTime(pe.getSysTag, "recvendorsement", System.currentTimeMillis())
RepTimeTracer.setStartTime(pe.getSysTag, "recvendorsement", System.currentTimeMillis(),block.height,block.transactions.size)
EndorseHandler(EndorsementInfo(block, blocker))
RepTimeTracer.setEndTime(pe.getSysTag, "recvendorsement", System.currentTimeMillis())
RepTimeTracer.setEndTime(pe.getSysTag, "recvendorsement", System.currentTimeMillis(),block.height,block.transactions.size)
}else{
RepLogger.trace(RepLogger.Consensus_Logger, this.getLogMsgPrefix(s"do not endorse,it is synching,recv endorse request,endorse height=${block.height},local height=${pe.getCurrentHeight}"))
}

View File

@ -131,7 +131,7 @@ class PreloaderForTransaction(moduleName: String) extends ModuleBase(moduleName)
case PreTransBlock(block,prefixOfDbTag) =>
RepLogger.trace(RepLogger.Consensus_Logger, this.getLogMsgPrefix( "entry preload"))
logTime("block preload inner time", System.currentTimeMillis(), true)
//logTime("block preload inner time", System.currentTimeMillis(), true)
if ((block.previousBlockHash.toStringUtf8().equals(pe.getCurrentBlockHash) || block.previousBlockHash == ByteString.EMPTY) &&
block.height == (pe.getCurrentHeight + 1)) {
var preLoadTrans = mutable.HashMap.empty[String, Transaction]
@ -156,7 +156,7 @@ class PreloaderForTransaction(moduleName: String) extends ModuleBase(moduleName)
//全部或者部分交易成功
sender ! PreTransBlockResult(newblock.get,true)
}
logTime("block preload inner time", System.currentTimeMillis(), false)
//logTime("block preload inner time", System.currentTimeMillis(), false)
}
case _ => //ignore
}

View File

@ -87,7 +87,7 @@ class Storager(moduleName: String) extends ModuleBase(moduleName) {
}
}
logTime("create block storeblock time", System.currentTimeMillis(), false)
//logTime("create block storeblock time", System.currentTimeMillis(), false)
RepLogger.trace(RepLogger.Storager_Logger, this.getLogMsgPrefix( s"CurrentHash(After presistence): ${pe.getCurrentBlockHash}" + "~" + selfAddr))
RepLogger.trace(RepLogger.Storager_Logger, this.getLogMsgPrefix( s"save block success,height=${pe.getCurrentHeight},hash=${pe.getCurrentBlockHash}" + "~" + selfAddr))
} else {
@ -103,9 +103,6 @@ class Storager(moduleName: String) extends ModuleBase(moduleName) {
}
private def NoticeVoteModule = {
if(pe.getSysTag == pe.getBlocker.blocker){
RepTimeTracer.setEndTime(pe.getSysTag, "Block", System.currentTimeMillis())
}
if (pe.getBlockCacheMgr.isEmpty ) {
RepLogger.trace(RepLogger.Storager_Logger, this.getLogMsgPrefix(s"presistence is over,this is startup vote" + "~" + selfAddr))
//通知抽签模块开始抽签
@ -193,10 +190,12 @@ class Storager(moduleName: String) extends ModuleBase(moduleName) {
override def receive = {
case blkRestore: BlockRestore =>
RepLogger.trace(RepLogger.Storager_Logger, this.getLogMsgPrefix( s"node number:${pe.getSysTag},restore single block,height:${blkRestore.blk.height}" + "~" + selfAddr))
RepTimeTracer.setStartTime(pe.getSysTag, "storage", System.currentTimeMillis())
RepTimeTracer.setStartTime(pe.getSysTag, "storage", System.currentTimeMillis(),blkRestore.blk.height,blkRestore.blk.transactions.size)
Handler(blkRestore)
RepTimeTracer.setEndTime(pe.getSysTag, "storage", System.currentTimeMillis())
RepTimeTracer.setEndTime(pe.getSysTag, "storage", System.currentTimeMillis(),blkRestore.blk.height,blkRestore.blk.transactions.size)
if(pe.getSysTag == pe.getBlocker.blocker){
RepTimeTracer.setEndTime(pe.getSysTag, "Block", System.currentTimeMillis(),blkRestore.blk.height,blkRestore.blk.transactions.size)
}
case _ => //ignore
}

View File

@ -60,7 +60,7 @@ class SynchResponseInfoAnalyzer(val systemName: String, val lchaininfo: Blockcha
//当前本地高度0没有前序块不需要检查前序块hash可以直接进入同步
this.aresult = AnalysisResult(true, "")
this.saction = SynchAction(lh, maxheight, reslist.filter(_.response.height == maxheight).head.responser)
RepLogger.info(RepLogger.BlockSyncher_Logger, this.getLogMsgPrefix("--------info,大于本地高度,同步完成"))
RepLogger.info(RepLogger.BlockSyncher_Logger, this.getLogMsgPrefix(s"--------info,大于本地高度,同步完成,local height=${lh},maxheight=${maxheight}"))
} else {
//本地高度大于0需要检查前序块的hash是否一致
val leadingAgreementResult = checkHashAgreement(maxheight, reslist, nodes.size, 2)
@ -72,7 +72,7 @@ class SynchResponseInfoAnalyzer(val systemName: String, val lchaininfo: Blockcha
this.saction = SynchAction(lh, maxheight, reslist.filter(_.response.height == maxheight).
filter(_.response.currentBlockHash.toStringUtf8() == AgreementHash).
filter(_.ChainInfoOfSpecifiedHeight.currentBlockHash.toStringUtf8() == leadingAgreementResult._2).head.responser)
RepLogger.info(RepLogger.BlockSyncher_Logger, this.getLogMsgPrefix("--------info,大于本地高度,同步完成"))
RepLogger.info(RepLogger.BlockSyncher_Logger, this.getLogMsgPrefix(s"--------info,大于本地高度,同步完成,local height=${lh},maxheight=${maxheight}"))
} else {
//由于与远端的前序块的hash不一致需要进一步进入回滚当前块的判断
val fls = reslist.filter(_.response.height == maxheight).
@ -89,19 +89,19 @@ class SynchResponseInfoAnalyzer(val systemName: String, val lchaininfo: Blockcha
filter(_.ChainInfoOfSpecifiedHeight.currentBlockHash.toStringUtf8() == leadingAgreementResult._2).head.responser)
} else {
//本地块的前一块的hash与远端前导块的前一块的hash不一致输出错误停止同步
this.aresult = AnalysisResult(false, "大于本地高度本地块的前一块的hash与远端前导块的前一块的hash不一致输出错误停止同步")
RepLogger.error(RepLogger.BlockSyncher_Logger, this.getLogMsgPrefix("--------error,大于本地高度本地块的前一块的hash与远端前导块的前一块的hash不一致输出错误停止同步"))
this.aresult = AnalysisResult(false, s"大于本地高度本地块的前一块的hash与远端前导块的前一块的hash不一致输出错误停止同步,local height=${lh},maxheight=${maxheight}")
RepLogger.error(RepLogger.BlockSyncher_Logger, this.getLogMsgPrefix(s"--------error,大于本地高度本地块的前一块的hash与远端前导块的前一块的hash不一致输出错误停止同步,local height=${lh},maxheight=${maxheight}"))
}
} else {
//找不到正确的响应信息输出错误停止同步
this.aresult = AnalysisResult(false, "大于本地高度,找不到正确的响应信息,输出错误,停止同步")
RepLogger.error(RepLogger.BlockSyncher_Logger, this.getLogMsgPrefix("--------error,大于本地高度,找不到正确的响应信息,输出错误,停止同步"))
this.aresult = AnalysisResult(false, "大于本地高度,找不到正确的响应信息,输出错误,停止同步,local height=${lh},maxheight=${maxheight}")
RepLogger.error(RepLogger.BlockSyncher_Logger, this.getLogMsgPrefix(s"--------error,大于本地高度,找不到正确的响应信息,输出错误,停止同步,local height=${lh},maxheight=${maxheight}"))
}
}
} else {
//远端前序块hash不一致输出错误停止同步
this.aresult = AnalysisResult(false, "大于本地高度远端前序块hash不一致输出错误停止同步")
RepLogger.error(RepLogger.BlockSyncher_Logger, this.getLogMsgPrefix("--------error,大于本地高度远端前序块hash不一致输出错误停止同步"))
this.aresult = AnalysisResult(false, s"大于本地高度远端前序块hash不一致输出错误停止同步,local height=${lh},maxheight=${maxheight}")
RepLogger.error(RepLogger.BlockSyncher_Logger, this.getLogMsgPrefix(s"--------error,大于本地高度远端前序块hash不一致输出错误停止同步,local height=${lh},maxheight=${maxheight}"))
}
}
}
@ -134,11 +134,11 @@ class SynchResponseInfoAnalyzer(val systemName: String, val lchaininfo: Blockcha
if (seedactor != null) {
this.aresult = AnalysisResult(true, "")
this.saction = SynchAction(lh, 1, seedactor)
RepLogger.info(RepLogger.BlockSyncher_Logger, this.getLogMsgPrefix("--------info,等于本地高度,找到创世节点,启动同步创世块"))
RepLogger.info(RepLogger.BlockSyncher_Logger, this.getLogMsgPrefix(s"--------info,等于本地高度,找到创世节点,启动同步创世块,local height=${lh},maxheight=${maxheight}"))
} else {
////没有找到创世节点输出信息停止同步
this.aresult = AnalysisResult(false, "--------error,等于本地高度,//找到创世节点,输出信息,停止同步")
RepLogger.error(RepLogger.BlockSyncher_Logger, this.getLogMsgPrefix("--------error,等于本地高度,//找到创世节点,输出信息,停止同步"))
RepLogger.error(RepLogger.BlockSyncher_Logger, this.getLogMsgPrefix(s"--------error,等于本地高度,//找到创世节点,输出信息,停止同步,local height=${lh},maxheight=${maxheight}"))
}
} else {
//系统非初始状态检查hash一致性
@ -146,7 +146,7 @@ class SynchResponseInfoAnalyzer(val systemName: String, val lchaininfo: Blockcha
if (lhash == AgreementHash) {
//自己同大多数节点hash一致完成同步
this.aresult = AnalysisResult(true, "")
RepLogger.info(RepLogger.BlockSyncher_Logger, this.getLogMsgPrefix("--------error,等于本地高度自己同大多数节点hash一致完成同步"))
RepLogger.info(RepLogger.BlockSyncher_Logger, this.getLogMsgPrefix(s"--------info,等于本地高度自己同大多数节点hash一致完成同步,local height=${lh},maxheight=${maxheight}"))
} else {
//开始检查回滚
val tmpres = reslist.filter(_.response.height == maxheight).
@ -156,11 +156,11 @@ class SynchResponseInfoAnalyzer(val systemName: String, val lchaininfo: Blockcha
this.aresult = AnalysisResult(true, "")
this.raction = RollbackAction(lh - 1)
this.saction = SynchAction(lh - 1, maxheight, tmpres.responser)
RepLogger.info(RepLogger.BlockSyncher_Logger, this.getLogMsgPrefix("--------info,等于本地高度,回滚完成,完成同步"))
RepLogger.info(RepLogger.BlockSyncher_Logger, this.getLogMsgPrefix(s"--------info,等于本地高度,回滚完成,完成同步,local height=${lh},maxheight=${maxheight}"))
} else {
//前一个块的hash不一致输出错误停止同步
this.aresult = AnalysisResult(false, "等于本地高度前一个块的hash不一致输出错误停止同步")
RepLogger.error(RepLogger.BlockSyncher_Logger, this.getLogMsgPrefix("--------error,等于本地高度前一个块的hash不一致输出错误停止同步"))
this.aresult = AnalysisResult(false, s"等于本地高度前一个块的hash不一致输出错误停止同步,local height=${lh},maxheight=${maxheight}")
RepLogger.error(RepLogger.BlockSyncher_Logger, this.getLogMsgPrefix(s"--------error,等于本地高度前一个块的hash不一致输出错误停止同步,local height=${lh},maxheight=${maxheight}"))
}
}
}
@ -175,14 +175,14 @@ class SynchResponseInfoAnalyzer(val systemName: String, val lchaininfo: Blockcha
if (NodeHelp.isSeedNode(this.systemName)) {
//当前系统是种子节点并且是创世块完成同步
this.aresult = AnalysisResult(true, "小于本地高度,当前系统是种子节点,并且是创世块,完成同步")
RepLogger.info(RepLogger.BlockSyncher_Logger, this.getLogMsgPrefix("--------info,小于本地高度,当前系统是种子节点,并且是创世块,完成同步"))
RepLogger.info(RepLogger.BlockSyncher_Logger, this.getLogMsgPrefix(s"--------info,小于本地高度,当前系统是种子节点,并且是创世块,完成同步,local height=${lh},maxheight=${maxheight}"))
} else {
this.aresult = AnalysisResult(true, "小于本地高度,当前系统不是种子节点,只有创世块,完成同步")
RepLogger.info(RepLogger.BlockSyncher_Logger, this.getLogMsgPrefix("--------info,小于本地高度,当前系统不是种子节点,只有创世块,完成同步"))
RepLogger.info(RepLogger.BlockSyncher_Logger, this.getLogMsgPrefix(s"--------info,小于本地高度,当前系统不是种子节点,只有创世块,完成同步,local height=${lh},maxheight=${maxheight}"))
}
} else {
this.aresult = AnalysisResult(false, "小于本地高度当前系统不是种子节点高度大于1系统错误停止同步")
RepLogger.error(RepLogger.BlockSyncher_Logger, this.getLogMsgPrefix("--------error,小于本地高度当前系统不是种子节点高度大于1系统错误停止同步"))
RepLogger.error(RepLogger.BlockSyncher_Logger, this.getLogMsgPrefix(s"--------error,小于本地高度当前系统不是种子节点高度大于1系统错误停止同步,local height=${lh},maxheight=${maxheight}"))
}
} else {
//大多数节点的高度hash相同本地节点高于这些节点需要回滚检查回滚信息
@ -194,7 +194,7 @@ class SynchResponseInfoAnalyzer(val systemName: String, val lchaininfo: Blockcha
this.raction = RollbackAction(maxheight)
} else {
this.aresult = AnalysisResult(false, "小于本地高度本地找不到对应大多数节点的hash的块停止同步")
RepLogger.error(RepLogger.BlockSyncher_Logger, this.getLogMsgPrefix("--------error,小于本地高度本地找不到对应大多数节点的hash的块停止同步"))
RepLogger.error(RepLogger.BlockSyncher_Logger, this.getLogMsgPrefix(s"--------error,小于本地高度本地找不到对应大多数节点的hash的块停止同步,local height=${lh},maxheight=${maxheight}"))
}
}
}

View File

@ -175,6 +175,10 @@ class SynchronizeRequester4Future(moduleName: String) extends ModuleBase(moduleN
sendEvent(EventType.PUBLISH_INFO, mediator,pe.getSysTag, BlockEvent.CHAIN_INFO_SYNC, Event.Action.BLOCK_SYNC)
val res = AsyncGetNodeOfChainInfos(nodes,lh)
//if(pe.getSysTag == "921000006e0012v696.node5"){
// println("921000006e0012v696.node5")
//}
val parser = new SynchResponseInfoAnalyzer(pe.getSysTag, pe.getSystemCurrentChainStatus, pe.getNodeMgr)
parser.Parser(res)
val result = parser.getResult
@ -229,6 +233,9 @@ class SynchronizeRequester4Future(moduleName: String) extends ModuleBase(moduleN
case SyncRequestOfStorager(responser, maxHeight) =>
if (!pe.isSynching) {
pe.setSynching(true)
//if(pe.getSysTag == "921000006e0012v696.node5"){
// println("921000006e0012v696.node5")
// }
getBlockDatas(pe.getCurrentHeight,maxHeight,responser)
pe.setSynching(false)
//pe.getActorRef(ActorType.modulemanager) ! ModuleManager.startup_Consensus

View File

@ -97,6 +97,9 @@ object verify4Storage {
var b = true
RepLogger.info(RepLogger.System_Logger, "系统开始自检区块文件")
var errorInfo = "未知问题"
if(sysName == "921000006e0012v696.node5"){
println("921000006e0012v696.node5")
}
try{
val sr: ImpDataAccess = ImpDataAccess.GetDataAccess(sysName)
val bcinfo = sr.getBlockChainInfo()

View File

@ -22,6 +22,11 @@ import scala.collection.immutable._
import java.nio.ByteBuffer
import rep.storage.util.pathUtil
import scalapb.json4s.JsonFormat
import org.json4s.{DefaultFormats, Formats, jackson}
import org.json4s.jackson.JsonMethods._
import org.json4s.DefaultFormats._
object blockDataCheck extends App {
implicit val serialization = jackson.Serialization
implicit val formats = DefaultFormats
@ -31,8 +36,8 @@ object blockDataCheck extends App {
val da4 = ImpDataAccess.GetDataAccess("921000005k36123789.node4")
val da5 = ImpDataAccess.GetDataAccess("921000006e0012v696.node5")
val ch = 3744l
val ch1 = 3743l //308652l
val ch = 2
val ch1 = 1 //308652l
/*printlnBlock
printlnBlocker
@ -48,6 +53,9 @@ object blockDataCheck extends App {
case class bcinfo(height:Long,hash:String)
case class resInfo (req:bcinfo,reqer:String,last:bcinfo)
def longToByte(number:Long):Array[Byte]={
var buffer = ByteBuffer.allocate(8)
buffer.putLong(0, number)
@ -61,7 +69,7 @@ object blockDataCheck extends App {
buffer.getLong()
}
val start = System.currentTimeMillis()
/*val start = System.currentTimeMillis()
for(i<-0 to 100000){
val mylong : Long = 294723843
val b = longToByte(mylong)
@ -79,7 +87,7 @@ object blockDataCheck extends App {
//println(s"old=${mylong},new=${l}")
}
val end1 = System.currentTimeMillis()
println("spent time="+(end1-start1))
println("spent time="+(end1-start1))*/
/* def longToByte(number:Long) :Array[Byte]={
var param = number
@ -240,8 +248,19 @@ object blockDataCheck extends App {
def readBlockToString(da: ImpDataAccess, h: Long): String = {
val b = da.getBlock4ObjectByHeight(h)
writePretty(b.endorsements)
val r = JsonFormat.toJson(b)
pretty(render(r))
//writePretty(b.endorsements)
}
println(readBlockToString(da4,1))
println(readBlockToString(da4,2))
println(readBlockToString(da4,3))
/*da5.FindByLike("rechain_", 1).foreach(f=>{
println(f._1)
println(new String(f._2))
})*/
def findEndorseTime(da: ImpDataAccess, h: Long): String = {
val b = da.getBlock4ObjectByHeight(h)