-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Case 3 and case 4 #1198
Merged
Merged
Case 3 and case 4 #1198
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
c8de907
Send WM commit status to conductor
lpoli 8e99dbf
Rename file
lpoli 5348065
Merge branch 'staging' into add/conductor-tests-for-blobber-and-valid…
lpoli 71aaa87
Modify log type
lpoli 8e765d0
Add state for stopping blobber from committing WM
lpoli bce9c45
Send file meta root to rpc server
lpoli c5a3058
Export function to use it in conductor client
lpoli 8a6aeed
Modify field type
lpoli 7dd0419
Add code to get file meta root
lpoli efc4535
Modify file meta root retrieval
lpoli 5eb0285
Add field
lpoli 416965a
Apply rename for conductor test based on conductor state
lpoli 66319cf
Add comment
lpoli 73ded20
Merge branch 'sprint-july-4' into add/case-2-and-case-4
lpoli 3c2357f
Log error
lpoli 0dfac0f
Merge branch 'sprint-july-4' into case-3-and-case-4
lpoli 2fc8c37
Merge branch 'sprint-july-4' into case-3-and-case-4
devyetii 58d406f
Merge branch 'sprint-july-4' into case-3-and-case-4
devyetii 50cb16f
Merge branch 'sprint-july-4' into case-3-and-case-4
devyetii 61d8176
Merge branch 'sprint-1.11' into case-3-and-case-4
devyetii 65f072b
Merge branch 'sprint-1.11' into case-3-and-case-4
devyetii 97b9af5
Merge branch 'sprint-1.11' into case-3-and-case-4
devyetii File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
code/go/0chain.net/blobbercore/allocation/renamefilechange_integration.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 (rf *RenameFileChange) ApplyChange(ctx context.Context, rootRef *reference.Ref, change *AllocationChange, | ||
allocationRoot string, ts common.Timestamp, _ map[string]string) (*reference.Ref, error) { | ||
|
||
state := conductrpc.Client().State() | ||
if state.FailRenameCommit != nil { | ||
for _, nodeId := range state.FailRenameCommit { | ||
if nodeId == node.Self.ID { | ||
return nil, errors.New("error directed by conductor") | ||
} | ||
} | ||
} | ||
return rf.applyChange(ctx, rootRef, change, allocationRoot, ts, nil) | ||
} |
17 changes: 17 additions & 0 deletions
17
code/go/0chain.net/blobbercore/allocation/renamefilechange_main.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
//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 (rf *RenameFileChange) ApplyChange(ctx context.Context, rootRef *reference.Ref, change *AllocationChange, | ||
allocationRoot string, ts common.Timestamp, _ map[string]string) (*reference.Ref, error) { | ||
|
||
return rf.applyChange(ctx, rootRef, change, allocationRoot, ts, nil) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package conductrpc | ||
|
||
import ( | ||
"context" | ||
|
||
"log" | ||
|
||
"github.com/0chain/blobber/code/go/0chain.net/blobbercore/datastore" | ||
|
||
"github.com/0chain/blobber/code/go/0chain.net/core/node" | ||
) | ||
|
||
// alreadyRunning is simple indicator that given function is running | ||
// no need to acquire mutex lock. It does not matter if at a time it | ||
// somehow runs the given function multiple times. Since it takes some | ||
// time to acquire state from rpc server there is no concurrent running | ||
var alreadyRunning bool | ||
|
||
func SendFileMetaRoot() { | ||
if alreadyRunning { | ||
return | ||
} | ||
alreadyRunning = true | ||
defer func() { | ||
alreadyRunning = false | ||
}() | ||
|
||
ctx, ctxCncl := context.WithCancel(context.TODO()) | ||
defer ctxCncl() | ||
|
||
for { | ||
select { | ||
case <-ctx.Done(): | ||
return | ||
default: | ||
} | ||
|
||
s := global.State() | ||
if s.GetFileMetaRoot { | ||
fmr, err := getFileMetaRoot() | ||
if err != nil { | ||
log.Printf("Error: %v", err) | ||
continue | ||
} | ||
|
||
global.SendFileMetaRoot(node.Self.ID, fmr, ctxCncl) | ||
} | ||
} | ||
} | ||
|
||
func getFileMetaRoot() (string, error) { | ||
db := datastore.GetStore().GetDB() | ||
var fmr string | ||
|
||
// It will work fine because this blobber will have only single allocation | ||
// created by conductor | ||
err := db.Raw("SELECT file_meta_root FROM allocations LIMIT 1").Scan(&fmr).Error | ||
|
||
if err != nil { | ||
return "", err | ||
} | ||
|
||
return fmr, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this change required?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're trying not to re-write the code for conductor tests, that's why we lower-cased the fn. that applies the main logic and kept the upper-case named fn. to be a switch between main flow and conductor testing flow. Is this contradicting with any other code?