From 678b07b31492c6cdb805d7436edac06a3582a9d0 Mon Sep 17 00:00:00 2001 From: Ivan Fraixedes Date: Fri, 15 Jan 2021 16:34:41 +0100 Subject: [PATCH] satellite: Fix typos & code formatting Fix some typos in the doc comments and readdress some code formatting applied automatically. Change-Id: I605b4eff2e7c6c58227ecf16be4c1d26f5322eb6 --- satellite/gracefulexit/db.go | 2 +- satellite/gracefulexit/endpoint.go | 1 - satellite/satellitedb/database.go | 7 ++----- satellite/satellitedb/gracefulexit.go | 19 +++++++++---------- 4 files changed, 12 insertions(+), 17 deletions(-) diff --git a/satellite/gracefulexit/db.go b/satellite/gracefulexit/db.go index 0f65dc83e..a83937a63 100644 --- a/satellite/gracefulexit/db.go +++ b/satellite/gracefulexit/db.go @@ -53,7 +53,7 @@ type DB interface { DeleteTransferQueueItem(ctx context.Context, nodeID storj.NodeID, key metabase.SegmentKey, pieceNum int32) error // DeleteTransferQueueItem deletes a graceful exit transfer queue entries by nodeID. DeleteTransferQueueItems(ctx context.Context, nodeID storj.NodeID) error - // DeleteFinishedTransferQueueItem deletes finiahed graceful exit transfer queue entries. + // DeleteFinishedTransferQueueItem deletes finished graceful exit transfer queue entries. DeleteFinishedTransferQueueItems(ctx context.Context, nodeID storj.NodeID) error // GetTransferQueueItem gets a graceful exit transfer queue entry. GetTransferQueueItem(ctx context.Context, nodeID storj.NodeID, key metabase.SegmentKey, pieceNum int32) (*TransferQueueItem, error) diff --git a/satellite/gracefulexit/endpoint.go b/satellite/gracefulexit/endpoint.go index e9bfa9d0c..3add5c335 100644 --- a/satellite/gracefulexit/endpoint.go +++ b/satellite/gracefulexit/endpoint.go @@ -844,7 +844,6 @@ func (endpoint *Endpoint) generateExitStatusRequest(ctx context.Context, nodeID } return exitStatusRequest, exitFailedReason, nil - } func (endpoint *Endpoint) calculatePieceSize(ctx context.Context, pointer *pb.Pointer, incomplete *TransferQueueItem, nodePiece *pb.RemotePiece) (int64, error) { diff --git a/satellite/satellitedb/database.go b/satellite/satellitedb/database.go index ab9502857..8c7cf06fb 100644 --- a/satellite/satellitedb/database.go +++ b/satellite/satellitedb/database.go @@ -36,10 +36,8 @@ import ( "storj.io/storj/satellite/snopayout" ) -var ( - // Error is the default satellitedb errs class. - Error = errs.Class("satellitedb") -) +// Error is the default satellitedb errs class. +var Error = errs.Class("satellitedb") type satelliteDBCollection struct { dbs map[string]*satelliteDB @@ -173,7 +171,6 @@ func (db *satelliteDB) AsOfSystemTimeClause(interval time.Duration) (asOf string } return asOf - } // TestDBAccess for raw database access, diff --git a/satellite/satellitedb/gracefulexit.go b/satellite/satellitedb/gracefulexit.go index b845fad62..73fda518c 100644 --- a/satellite/satellitedb/gracefulexit.go +++ b/satellite/satellitedb/gracefulexit.go @@ -32,7 +32,7 @@ func (db *gracefulexitDB) IncrementProgress(ctx context.Context, nodeID storj.No statement := db.db.Rebind( `INSERT INTO graceful_exit_progress (node_id, bytes_transferred, pieces_transferred, pieces_failed, updated_at) VALUES (?, ?, ?, ?, ?) ON CONFLICT(node_id) - DO UPDATE SET bytes_transferred = graceful_exit_progress.bytes_transferred + excluded.bytes_transferred, + DO UPDATE SET bytes_transferred = graceful_exit_progress.bytes_transferred + excluded.bytes_transferred, pieces_transferred = graceful_exit_progress.pieces_transferred + excluded.pieces_transferred, pieces_failed = graceful_exit_progress.pieces_failed + excluded.pieces_failed, updated_at = excluded.updated_at;`, @@ -52,7 +52,6 @@ func (db *gracefulexitDB) GetProgress(ctx context.Context, nodeID storj.NodeID) dbxProgress, err := db.db.Get_GracefulExitProgress_By_NodeId(ctx, dbx.GracefulExitProgress_NodeId(nodeID.Bytes())) if errors.Is(err, sql.ErrNoRows) { return nil, gracefulexit.ErrNodeNotFound.Wrap(err) - } else if err != nil { return nil, Error.Wrap(err) } @@ -147,7 +146,7 @@ func (db *gracefulexitDB) DeleteTransferQueueItems(ctx context.Context, nodeID s return Error.Wrap(err) } -// DeleteFinishedTransferQueueItem deletes finiahed graceful exit transfer queue entries by nodeID. +// DeleteFinishedTransferQueueItem deletes finished graceful exit transfer queue entries by nodeID. func (db *gracefulexitDB) DeleteFinishedTransferQueueItems(ctx context.Context, nodeID storj.NodeID) (err error) { defer mon.Task()(&ctx)(&err) _, err = db.db.Delete_GracefulExitTransferQueue_By_NodeId_And_FinishedAt_IsNot_Null(ctx, dbx.GracefulExitTransferQueue_NodeId(nodeID.Bytes())) @@ -177,9 +176,9 @@ func (db *gracefulexitDB) GetTransferQueueItem(ctx context.Context, nodeID storj func (db *gracefulexitDB) GetIncomplete(ctx context.Context, nodeID storj.NodeID, limit int, offset int64) (_ []*gracefulexit.TransferQueueItem, err error) { defer mon.Task()(&ctx)(&err) sql := `SELECT node_id, path, piece_num, root_piece_id, durability_ratio, queued_at, requested_at, last_failed_at, last_failed_code, failed_count, finished_at, order_limit_send_count - FROM graceful_exit_transfer_queue - WHERE node_id = ? - AND finished_at is NULL + FROM graceful_exit_transfer_queue + WHERE node_id = ? + AND finished_at is NULL ORDER BY durability_ratio asc, queued_at asc LIMIT ? OFFSET ?` rows, err := db.db.Query(ctx, db.db.Rebind(sql), nodeID.Bytes(), limit, offset) if err != nil { @@ -199,8 +198,8 @@ func (db *gracefulexitDB) GetIncomplete(ctx context.Context, nodeID storj.NodeID func (db *gracefulexitDB) GetIncompleteNotFailed(ctx context.Context, nodeID storj.NodeID, limit int, offset int64) (_ []*gracefulexit.TransferQueueItem, err error) { defer mon.Task()(&ctx)(&err) sql := `SELECT node_id, path, piece_num, root_piece_id, durability_ratio, queued_at, requested_at, last_failed_at, last_failed_code, failed_count, finished_at, order_limit_send_count - FROM graceful_exit_transfer_queue - WHERE node_id = ? + FROM graceful_exit_transfer_queue + WHERE node_id = ? AND finished_at is NULL AND last_failed_at is NULL ORDER BY durability_ratio asc, queued_at asc LIMIT ? OFFSET ?` @@ -222,8 +221,8 @@ func (db *gracefulexitDB) GetIncompleteNotFailed(ctx context.Context, nodeID sto func (db *gracefulexitDB) GetIncompleteFailed(ctx context.Context, nodeID storj.NodeID, maxFailures int, limit int, offset int64) (_ []*gracefulexit.TransferQueueItem, err error) { defer mon.Task()(&ctx)(&err) sql := `SELECT node_id, path, piece_num, root_piece_id, durability_ratio, queued_at, requested_at, last_failed_at, last_failed_code, failed_count, finished_at, order_limit_send_count - FROM graceful_exit_transfer_queue - WHERE node_id = ? + FROM graceful_exit_transfer_queue + WHERE node_id = ? AND finished_at is NULL AND last_failed_at is not NULL AND failed_count < ?