Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
YottaChain
YTFS
提交
fb2cbd87
Y
YTFS
项目概览
YottaChain
/
YTFS
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Y
YTFS
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
fb2cbd87
编写于
4月 13, 2020
作者:
X
xiaojianming
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
delete restoreIndex log
上级
c645e712
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
2 addition
and
34 deletion
+2
-34
storage/indexfile.go
storage/indexfile.go
+0
-5
ytfs.go
ytfs.go
+2
-29
未找到文件。
storage/indexfile.go
浏览文件 @
fb2cbd87
...
...
@@ -176,7 +176,6 @@ func (indexFile *YTFSIndexFile) loadTableFromStorage(tbIndex uint32) (map[ydcomm
func
(
indexFile
*
YTFSIndexFile
)
ClearItemFromTable
(
tbidx
uint32
,
hashKey
ydcommon
.
IndexTableKey
,
btCnt
uint32
,
tbItemMap
map
[
uint32
]
uint32
)
error
{
var
err
error
fmt
.
Printf
(
"[ClearItemFromTable] tableindex=%v, btCnt=%v, hash=%v
\n
"
,
tbidx
,
btCnt
,
base58
.
Encode
(
hashKey
[
:
]))
writer
,
err
:=
indexFile
.
store
.
Writer
()
if
err
!=
nil
{
fmt
.
Println
(
"[ClearItemFromTable] get writer error!"
)
...
...
@@ -201,10 +200,8 @@ func (indexFile *YTFSIndexFile) ClearItemFromTable( tbidx uint32, hashKey ydcomm
tableSize
:=
binary
.
LittleEndian
.
Uint32
(
sizeBuf
)
itemBuf
:=
make
([]
byte
,
itemSize
)
zeroBuf
:=
make
([]
byte
,
itemSize
)
fmt
.
Printf
(
"[ClearItemFromTable] tableindex=%v, tablesize=%v, btCnt=%v
\n
"
,
tbidx
,
tableSize
,
btCnt
)
for
i
:=
tableSize
;
0
<=
i
;
i
--
{
fmt
.
Printf
(
"[ClearItemFromTable] tableindex=%v, tablesize=%v, btCnt=%v, i=%v
\n
"
,
tbidx
,
tableSize
,
btCnt
,
i
)
itemOffset
:=
tableOffset
+
4
+
int64
(
i
*
itemSize
)
reader
.
Seek
(
itemOffset
,
io
.
SeekStart
)
reader
.
Read
(
itemBuf
)
...
...
@@ -229,12 +226,10 @@ func (indexFile *YTFSIndexFile)ResetTableSize(tbItemMap map[uint32]uint32) error
tableAllocationSize
:=
indexFile
.
meta
.
RangeCoverage
*
itemSize
+
4
sizeBuf
:=
make
([]
byte
,
4
)
for
tbidx
,
value
:=
range
tbItemMap
{
fmt
.
Printf
(
"[resettablesize] tbidx=%v, value=%v
\n
"
,
tbidx
,
value
)
tableOffset
:=
int64
(
indexFile
.
meta
.
HashOffset
)
+
int64
(
tbidx
)
*
int64
(
tableAllocationSize
)
reader
.
Seek
(
tableOffset
,
io
.
SeekStart
)
reader
.
Read
(
sizeBuf
)
tableSize
:=
binary
.
LittleEndian
.
Uint32
(
sizeBuf
)
fmt
.
Printf
(
"[resettablesize] before reset, tbidx=%v, tablesize=%v
\n
"
,
tbidx
,
tableSize
)
tableSize
=
tableSize
-
value
writer
.
Seek
(
tableOffset
,
io
.
SeekStart
)
binary
.
LittleEndian
.
PutUint32
(
sizeBuf
,
tableSize
)
...
...
ytfs.go
浏览文件 @
fb2cbd87
...
...
@@ -3,12 +3,10 @@ package ytfs
import
(
"encoding/json"
"fmt"
"time"
// "github.com/linux-go/go1.13.5.linux-amd64/go/src/time"
"github.com/mr-tron/base58/base58"
"github.com/yottachain/YTDataNode/util"
ydcommon
"github.com/yottachain/YTFS/common"
"github.com/yottachain/YTFS/errors"
"github.com/yottachain/YTFS/opt"
_
"net/http/pprof"
"os"
...
...
@@ -208,17 +206,14 @@ func (ytfs *YTFS) restoreYTFS() {
func
(
ytfs
*
YTFS
)
restoreIndex
(
conflict
map
[
ydcommon
.
IndexTableKey
]
byte
,
batchindex
[]
ydcommon
.
IndexItem
,
btCnt
uint32
)
error
{
var
err
error
fmt
.
Println
(
"[restoreIndex] start"
)
tbItemMap
:=
make
(
map
[
uint32
]
uint32
,
btCnt
)
for
_
,
kvPairs
:=
range
batchindex
{
hashkey
:=
kvPairs
.
Hash
fmt
.
Println
(
"[restoreIndex] restore hashkey:"
,
base58
.
Encode
(
hashkey
[
:
]))
if
_
,
ok
:=
conflict
[
hashkey
];
ok
{
fmt
.
Println
(
"[restoreIndex] hashkey conflict:"
,
base58
.
Encode
(
hashkey
[
:
]))
continue
}
idx
:=
ytfs
.
db
.
indexFile
.
GetTableEntryIndex
(
hashkey
)
fmt
.
Printf
(
"[restoreIndex] tableindex=%v
\n
"
,
idx
)
err
=
ytfs
.
db
.
indexFile
.
ClearItemFromTable
(
idx
,
hashkey
,
btCnt
,
tbItemMap
)
if
err
!=
nil
{
fmt
.
Printf
(
"[restoreIndex] reset tableidx %v hashkey %v
\n
"
,
idx
,
hashkey
)
...
...
@@ -229,7 +224,6 @@ func (ytfs *YTFS) restoreIndex(conflict map[ydcommon.IndexTableKey]byte, batchin
if
err
!=
nil
{
fmt
.
Println
(
"[restoreIndex] ResetTableSize error"
)
}
fmt
.
Println
(
"[restoreIndex] end"
)
return
err
}
...
...
@@ -271,7 +265,7 @@ func (ytfs *YTFS)checkConflicts(conflicts map[ydcommon.IndexTableKey]byte, batch
}
}
var
mutexindex
uint64
=
0
//
var mutexindex uint64 = 0
// BatchPut sets the value array for the given key array.
// It panics if there exists any previous value for that key as YottaDisk is not a multi-map.
// It is safe to modify the contents of the arguments after Put returns but not
...
...
@@ -280,7 +274,6 @@ func (ytfs *YTFS) BatchPut(batch map[ydcommon.IndexTableKey][]byte) (map[ydcommo
ytfs
.
mutex
.
Lock
()
defer
ytfs
.
mutex
.
Unlock
()
fmt
.
Printf
(
"[mutexlocked] ytfs batchput lock %v
\n
"
,
mutexindex
)
if
len
(
batch
)
>
1000
{
return
nil
,
fmt
.
Errorf
(
"Batch Size is too big"
)
}
...
...
@@ -314,30 +307,10 @@ func (ytfs *YTFS) BatchPut(batch map[ydcommon.IndexTableKey][]byte) (map[ydcommo
conflicts
,
err
:=
ytfs
.
db
.
BatchPut
(
batchIndexes
)
defer
ytfs
.
checkConflicts
(
conflicts
,
batch
)
//todo xiaojm
if
err
!=
nil
{
ytfs
.
restoreYTFS
()
ytfs
.
restoreIndex
(
conflicts
,
batchIndexes
,
uint32
(
bufCnt
))
fmt
.
Printf
(
"[mutexunlocked] ytfs batchput unlock %v
\n
"
,
mutexindex
)
mutexindex
++
if
mutexindex
%
1000
==
0
{
time
.
Sleep
(
time
.
Second
*
15
)
}
return
conflicts
,
err
}
fmt
.
Printf
(
"[mutexunlocked] ytfs batchput unlock %v
\n
"
,
mutexindex
)
mutexindex
++
if
mutexindex
%
1000
==
0
{
time
.
Sleep
(
time
.
Second
*
15
)
}
if
mutexindex
%
2099
==
0
{
ytfs
.
restoreYTFS
()
ytfs
.
restoreIndex
(
conflicts
,
batchIndexes
,
uint32
(
bufCnt
))
fmt
.
Printf
(
"[error_injection] %v
\n
"
,
mutexindex
)
return
conflicts
,
errors
.
ErrRangeFull
return
conflicts
,
err
}
return
nil
,
nil
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录