Skip to content

Commit

Permalink
Refactoring: sdk When creating a datapartition, select the datapartit…
Browse files Browse the repository at this point in the history
…ion retry strategy

and go fmt project

Signed-off-by: awzhgw <[email protected]>
  • Loading branch information
awzhgw committed Aug 16, 2019
1 parent b0d82fb commit 2265785
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 24 deletions.
28 changes: 14 additions & 14 deletions datanode/disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ func (d *Disk) incWriteErrCnt() {
func (d *Disk) startScheduleToUpdateSpaceInfo() {
go func() {
updateSpaceInfoTicker := time.NewTicker(5 * time.Second)
checkStatusTickser :=time.NewTicker(time.Minute*2)
checkStatusTickser := time.NewTicker(time.Minute * 2)
defer func() {
updateSpaceInfoTicker.Stop()
checkStatusTickser.Stop()
Expand All @@ -159,38 +159,38 @@ func (d *Disk) startScheduleToUpdateSpaceInfo() {
}

const (
DiskStatusFile=".diskStatus"
DiskStatusFile = ".diskStatus"
)

func (d *Disk)checkDiskStatus(){
path:=path.Join(d.Path,DiskStatusFile)
fp,err:=os.OpenFile(path,os.O_CREATE|os.O_TRUNC|os.O_RDWR,0755)
if err!=nil {
func (d *Disk) checkDiskStatus() {
path := path.Join(d.Path, DiskStatusFile)
fp, err := os.OpenFile(path, os.O_CREATE|os.O_TRUNC|os.O_RDWR, 0755)
if err != nil {
d.triggerDiskError(err)
return
}
defer fp.Close()
data:=[]byte(DiskStatusFile)
_,err=fp.WriteAt(data,0)
if err!=nil {
data := []byte(DiskStatusFile)
_, err = fp.WriteAt(data, 0)
if err != nil {
d.triggerDiskError(err)
return
}
if err=fp.Sync();err!=nil {
if err = fp.Sync(); err != nil {
d.triggerDiskError(err)
return
}
if _,err=fp.ReadAt(data,0);err!=nil {
if _, err = fp.ReadAt(data, 0); err != nil {
d.triggerDiskError(err)
return
}
}

func (d *Disk)triggerDiskError(err error){
if err==nil {
func (d *Disk) triggerDiskError(err error) {
if err == nil {
return
}
if IsDiskErr(err.Error()){
if IsDiskErr(err.Error()) {
mesg := fmt.Sprintf("disk path %v error on %v", d.Path, LocalIP)
exporter.Warning(mesg)
log.LogErrorf(mesg)
Expand Down
6 changes: 3 additions & 3 deletions datanode/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,9 +329,9 @@ func (s *DataNode) checkLocalPartitionMatchWithMaster() (err error) {
}
break
}
dinfo:=new(DataNodeInfo)
if err = json.Unmarshal(data.([]byte),dinfo);err!=nil {
err=fmt.Errorf("checkLocalPartitionMatchWithMaster jsonUnmarsh failed %v",err)
dinfo := new(DataNodeInfo)
if err = json.Unmarshal(data.([]byte), dinfo); err != nil {
err = fmt.Errorf("checkLocalPartitionMatchWithMaster jsonUnmarsh failed %v", err)
log.LogErrorf(err.Error())
return
}
Expand Down
8 changes: 4 additions & 4 deletions metanode/metanode.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,13 @@ func (m *MetaNode) checkLocalPartitionMatchWithMaster() (err error) {
break
}

minfo:=new(MetaNodeInfo)
if err = json.Unmarshal(data.([]byte),minfo);err!=nil {
err=fmt.Errorf("checkLocalPartitionMatchWithMaster jsonUnmarsh failed %v",err)
minfo := new(MetaNodeInfo)
if err = json.Unmarshal(data.([]byte), minfo); err != nil {
err = fmt.Errorf("checkLocalPartitionMatchWithMaster jsonUnmarsh failed %v", err)
log.LogErrorf(err.Error())
return
}

if len(minfo.PersistenceMetaPartitions) == 0 {
return
}
Expand Down
4 changes: 2 additions & 2 deletions storage/extent_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -626,8 +626,8 @@ func (s *ExtentStore) RecordTinyDelete(extentID uint64, offset, size, tinyDelete

func (s *ExtentStore) ReadTinyDeleteRecords(offset, size int64, data []byte) (crc uint32, err error) {
_, err = s.tinyExtentDeleteFp.ReadAt(data[:size], offset)
if err ==nil || err==io.EOF{
err=nil
if err == nil || err == io.EOF {
err = nil
crc = crc32.ChecksumIEEE(data[:size])
}
return
Expand Down
2 changes: 1 addition & 1 deletion vendor/github.com/tiglabs/raft/raft_fsm.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2265785

Please sign in to comment.