Skip to content

Commit

Permalink
Allow to use either logical_file_name or this_logical_file_name in bu…
Browse files Browse the repository at this point in the history
…lkblocks API input. The former can be used by clients (CRABPublisher), while latter is used by blockdump DBS API used within DBSMigration python server
  • Loading branch information
vkuznet committed Apr 6, 2022
1 parent 5151cef commit 583ca0d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
5 changes: 4 additions & 1 deletion dbs/blockdump.go
Original file line number Diff line number Diff line change
Expand Up @@ -405,8 +405,11 @@ func getFileParentList(blk string, wg *sync.WaitGroup, fileParentList *FileParen
fileParent := FileParentRecord{}
var pid sql.NullInt64
var pfn sql.NullString
// blockdump DBS API should yield this_logical_file_name
// therefore, here we use it
err = rows.Scan(
&fileParent.LogicalFileName,
// &fileParent.LogicalFileName,
&fileParent.ThisLogicalFileName,
&pid,
&pfn,
)
Expand Down
14 changes: 12 additions & 2 deletions dbs/fileparents.go
Original file line number Diff line number Diff line change
Expand Up @@ -365,9 +365,15 @@ func (a *API) InsertFileParentsBlockTxt(tx *sql.Tx) error {
}

// FileParentRecord represents file parent DBS record
// used by bulkblock API
// used by bulkblocks API
// NOTE: bulkblocks API should return this_logical_file_name as it is used by DBS migrate
// while users, e.g. CRAB, can construct by themselves the bulkblock structure where
// they may use logical_file_name name
// Therefore, we should keep both this_logical_file_name and logical_file_name
// together for backward compatibility
type FileParentRecord struct {
LogicalFileName string `json:"this_logical_file_name"`
ThisLogicalFileName string `json:"this_logical_file_name, omitempty"`
LogicalFileName string `json:"logical_file_name, omitempty"`
ParentFileId int64 `json:"parent_file_id"`
ParentLogicalFileName string `json:"parent_logical_file_name"`
}
Expand Down Expand Up @@ -408,6 +414,10 @@ func (a *API) InsertFileParentsTxt(tx *sql.Tx) error {
log.Printf("Insert FileParents record %+v", rec)
}
lfn := rec.LogicalFileName
// for backward compatibility
if lfn == "" {
lfn = rec.ThisLogicalFileName
}
pfn := rec.ParentLogicalFileName
// get file id for given lfn
fid, err := GetID(tx, "FILES", "file_id", "logical_file_name", lfn)
Expand Down

0 comments on commit 583ca0d

Please sign in to comment.