-
Notifications
You must be signed in to change notification settings - Fork 192
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cos: add read-open-close-seeker; CLI: multi-put with client-side chec…
…ksumming Signed-off-by: Alex Aizman <[email protected]>
- Loading branch information
1 parent
9cf2805
commit de32e6f
Showing
10 changed files
with
118 additions
and
80 deletions.
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
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,63 @@ | ||
// Package cli provides easy-to-use commands to manage, monitor, and utilize AIS clusters. | ||
/* | ||
* Copyright (c) 2025, NVIDIA CORPORATION. All rights reserved. | ||
*/ | ||
package cli | ||
|
||
import ( | ||
"io" | ||
"math" | ||
|
||
"github.com/NVIDIA/aistore/cmn/cos" | ||
"github.com/NVIDIA/aistore/cmn/debug" | ||
) | ||
|
||
type rocCb struct { | ||
roc cos.ROCS | ||
cb func(int, error) | ||
readBytes int // bytes read since last `Open`. | ||
reportedBytes int // vs reopen | ||
} | ||
|
||
// interface guard | ||
var ( | ||
_ cos.ReadOpenCloser = (*rocCb)(nil) | ||
_ io.Seeker = (*rocCb)(nil) | ||
) | ||
|
||
/////////// | ||
// rocCb // | ||
/////////// | ||
|
||
func newRocCb(roc cos.ROCS, readCb func(int, error), reportedBytes int) *rocCb { | ||
return &rocCb{ | ||
roc: roc, | ||
cb: readCb, | ||
reportedBytes: reportedBytes, | ||
} | ||
} | ||
|
||
func (r *rocCb) Read(p []byte) (n int, err error) { | ||
n, err = r.roc.Read(p) | ||
debug.Assert(r.readBytes < math.MaxInt-n) | ||
r.readBytes += n | ||
if delta := r.readBytes - r.reportedBytes; delta > 0 { | ||
r.cb(delta, err) | ||
r.reportedBytes += delta | ||
} | ||
return n, err | ||
} | ||
|
||
func (r *rocCb) Open() (cos.ReadOpenCloser, error) { | ||
roc2, err := r.roc.OpenDup() | ||
if err != nil { | ||
return nil, err | ||
} | ||
return newRocCb(roc2, r.cb, r.reportedBytes), nil | ||
} | ||
|
||
func (r *rocCb) Close() error { return r.roc.Close() } | ||
|
||
func (r *rocCb) Seek(offset int64, whence int) (int64, error) { | ||
return r.roc.Seek(offset, whence) | ||
} |
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
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
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