Skip to content

Commit

Permalink
Added changes for fail upload commit (#1318)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jayashsatolia403 committed Nov 8, 2023
1 parent 4edd89d commit 259c0cd
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 1 deletion.
Expand Up @@ -21,7 +21,7 @@ type UploadFileChanger struct {
}

// ApplyChange update references, and create a new FileRef
func (nf *UploadFileChanger) ApplyChange(ctx context.Context, rootRef *reference.Ref, change *AllocationChange,
func (nf *UploadFileChanger) applyChange(ctx context.Context, rootRef *reference.Ref, change *AllocationChange,
allocationRoot string, ts common.Timestamp, fileIDMeta map[string]string) (*reference.Ref, error) {

totalRefs, err := reference.CountRefs(ctx, nf.AllocationID)
Expand Down
@@ -0,0 +1,28 @@
//go:build integration_tests
// +build integration_tests

package allocation

import (
"context"
"errors"

"github.com/0chain/blobber/code/go/0chain.net/blobbercore/reference"
"github.com/0chain/blobber/code/go/0chain.net/conductor/conductrpc"
"github.com/0chain/blobber/code/go/0chain.net/core/common"
"github.com/0chain/blobber/code/go/0chain.net/core/node"
)

func (nf *UploadFileChanger) ApplyChange(ctx context.Context, rootRef *reference.Ref, change *AllocationChange,
allocationRoot string, ts common.Timestamp, fileIDMeta map[string]string) (*reference.Ref, error) {

state := conductrpc.Client().State()
if state.FailUploadCommit != nil {
for _, nodeId := range state.FailUploadCommit {
if nodeId == node.Self.ID {
return nil, errors.New("error directed by conductor")
}
}
}
return nf.applyChange(ctx, rootRef, change, allocationRoot, ts, fileIDMeta)
}
@@ -0,0 +1,15 @@
//go:build !integration_tests
// +build !integration_tests

package allocation

import (
"context"
"github.com/0chain/blobber/code/go/0chain.net/blobbercore/reference"
"github.com/0chain/blobber/code/go/0chain.net/core/common"
)

func (nf *UploadFileChanger) ApplyChange(ctx context.Context, rootRef *reference.Ref, change *AllocationChange,
allocationRoot string, ts common.Timestamp, fileIDMeta map[string]string) (*reference.Ref, error) {
return nf.applyChange(ctx, rootRef, change, allocationRoot, ts, fileIDMeta)
}
1 change: 1 addition & 0 deletions code/go/0chain.net/conductor/conductrpc/state.go
Expand Up @@ -65,6 +65,7 @@ type State struct {
NotifyOnValidationTicketGeneration bool
StopWMCommit *bool
FailRenameCommit []string
FailUploadCommit []string
GetFileMetaRoot bool
}

Expand Down

0 comments on commit 259c0cd

Please sign in to comment.