Skip to content

Commit

Permalink
feat: 增加ddc服务批量操作接口 #2776
Browse files Browse the repository at this point in the history
  • Loading branch information
cnlkl committed Dec 3, 2024
1 parent 6f6a02e commit f746413
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ class DdcLocalRepository(
} else {
artifactFile.getInputStream().use { it.readBytes() }
}
val ref = referenceService.create(Reference.from(artifactInfo, payload))
val ref = referenceService.create(Reference.from(artifactInfo, payload), operator)
if (ref.inlineBlob == null) {
// inlineBlob为null时表示inlineBlob过大,需要存到文件中
val nodeCreateRequest = buildRefNodeCreateRequest(repositoryDetail, artifactInfo, artifactFile, operator)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ class ReferenceArtifactService(
val userId = SecurityUtils.getUserId()
for (op in ops.ops) {
results[op.opId] = when (op.op) {
Operation.GET.name -> executor.submit<Pair<CbObject, Int>> { getRef(projectId, repoName, op) }
Operation.HEAD.name -> executor.submit<Pair<CbObject, Int>> { headRef(projectId, repoName, op) }
Operation.GET.name -> executor.submit<Pair<CbObject, Int>> { getRef(projectId, repoName, op, userId) }
Operation.HEAD.name -> executor.submit<Pair<CbObject, Int>> { headRef(projectId, repoName, op, userId) }
Operation.PUT.name -> executor.submit<Pair<CbObject, Int>> { putRef(repo, op, userId) }
else -> throw UnsupportedOperationException("unsupported op: ${op.op}")
}
Expand All @@ -142,8 +142,7 @@ class ReferenceArtifactService(
return BatchOpsResponse(opResponse)
}

private fun getRef(projectId: String, repoName: String, op: BatchOp): Pair<CbObject, Int> {
val user = SecurityUtils.getUserId()
private fun getRef(projectId: String, repoName: String, op: BatchOp, user: String): Pair<CbObject, Int> {
val refFullKey = "$projectId/$repoName/${op.bucket}/${op.key}"
return try {
ddcMeterBinder.incCacheCount(projectId, repoName)
Expand All @@ -162,8 +161,7 @@ class ReferenceArtifactService(
}
}

private fun headRef(projectId: String, repoName: String, op: BatchOp): Pair<CbObject, Int> {
val user = SecurityUtils.getUserId()
private fun headRef(projectId: String, repoName: String, op: BatchOp, user: String): Pair<CbObject, Int> {
val refFullKey = "$projectId/$repoName/${op.bucket}/${op.key}"
return try {
val ref = referenceService.getReference(projectId, repoName, op.bucket, op.key)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,13 @@ class ReferenceService(
private val nodeService: NodeService,
private val storageManager: StorageManager,
) {
fun create(ref: Reference): Reference {
fun create(ref: Reference, userId: String): Reference {
val inlineBlob = if (ref.inlineBlob!!.size > ddcProperties.inlineBlobMaxSize.toBytes()) {
null
} else {
ref.inlineBlob
}

val userId = SecurityUtils.getUserId()
val now = LocalDateTime.now()
val tRef = TDdcRef(
createdBy = userId,
Expand Down

0 comments on commit f746413

Please sign in to comment.