From bbdfd5cce3c63a20ca277cb8378f2853c1562409 Mon Sep 17 00:00:00 2001 From: sopguo Date: Tue, 17 Sep 2024 16:02:18 -0700 Subject: [PATCH] Move idConverter inside of router phase1 (#2894) Co-authored-by: Sophie Guo --- .../src/test/java/com/github/ambry/account/MockRouter.java | 3 ++- ambry-api/src/main/java/com/github/ambry/router/Router.java | 5 +++-- .../java/com/github/ambry/frontend/NamedBlobPutHandler.java | 2 +- .../ambry/frontend/FrontendRestRequestServiceTest.java | 2 +- .../main/java/com/github/ambry/router/NonBlockingRouter.java | 5 +++-- .../main/java/com/github/ambry/router/InMemoryRouter.java | 3 ++- .../java/com/github/ambry/tools/perf/rest/PerfRouter.java | 5 +++-- 7 files changed, 15 insertions(+), 10 deletions(-) diff --git a/ambry-account/src/test/java/com/github/ambry/account/MockRouter.java b/ambry-account/src/test/java/com/github/ambry/account/MockRouter.java index 450edbfac3..c6e2d2ad5e 100644 --- a/ambry-account/src/test/java/com/github/ambry/account/MockRouter.java +++ b/ambry-account/src/test/java/com/github/ambry/account/MockRouter.java @@ -20,6 +20,7 @@ import com.github.ambry.messageformat.BlobProperties; import com.github.ambry.commons.Callback; import com.github.ambry.quota.QuotaChargeCallback; +import com.github.ambry.rest.RestRequest; import com.github.ambry.router.ChunkInfo; import com.github.ambry.router.FutureResult; import com.github.ambry.router.GetBlobOptions; @@ -100,7 +101,7 @@ public Future getBlob(String blobId, GetBlobOptions options, Call @Override public Future putBlob(BlobProperties blobProperties, byte[] userMetadata, ReadableStreamChannel channel, - PutBlobOptions options, Callback callback, QuotaChargeCallback quotaChargeCallback, String blobPath) { + PutBlobOptions options, Callback callback, QuotaChargeCallback quotaChargeCallback, RestRequest restRequest) { lock.lock(); try { FutureResult future = new FutureResult<>(); diff --git a/ambry-api/src/main/java/com/github/ambry/router/Router.java b/ambry-api/src/main/java/com/github/ambry/router/Router.java index d7d141f392..58febb9de2 100644 --- a/ambry-api/src/main/java/com/github/ambry/router/Router.java +++ b/ambry-api/src/main/java/com/github/ambry/router/Router.java @@ -19,6 +19,7 @@ import com.github.ambry.messageformat.BlobInfo; import com.github.ambry.messageformat.BlobProperties; import com.github.ambry.quota.QuotaChargeCallback; +import com.github.ambry.rest.RestRequest; import com.github.ambry.utils.Utils; import java.io.Closeable; import java.io.IOException; @@ -56,11 +57,11 @@ Future getBlob(String blobId, GetBlobOptions options, Callback putBlob(BlobProperties blobProperties, byte[] userMetadata, ReadableStreamChannel channel, - PutBlobOptions options, Callback callback, QuotaChargeCallback quotaChargeCallback, String blobPath); + PutBlobOptions options, Callback callback, QuotaChargeCallback quotaChargeCallback, RestRequest restRequest); /** * Requests for a new metadata blob to be put asynchronously and invokes the {@link Callback} when the request diff --git a/ambry-frontend/src/main/java/com/github/ambry/frontend/NamedBlobPutHandler.java b/ambry-frontend/src/main/java/com/github/ambry/frontend/NamedBlobPutHandler.java index c3704ecd2b..2ab6aa85ec 100644 --- a/ambry-frontend/src/main/java/com/github/ambry/frontend/NamedBlobPutHandler.java +++ b/ambry-frontend/src/main/java/com/github/ambry/frontend/NamedBlobPutHandler.java @@ -236,7 +236,7 @@ private Callback securityPostProcessRequestCallback(BlobInfo blobInfo) { PutBlobOptions options = getPutBlobOptionsFromRequest(); router.putBlob(getPropertiesForRouterUpload(blobInfo), blobInfo.getUserMetadata(), restRequest, options, routerPutBlobCallback(blobInfo), QuotaUtils.buildQuotaChargeCallback(restRequest, quotaManager, true), - RestUtils.getRequestPath(restRequest).getOperationOrBlobId(false)); + restRequest); } }, uri, LOGGER, deleteDatasetCallback); } diff --git a/ambry-frontend/src/test/java/com/github/ambry/frontend/FrontendRestRequestServiceTest.java b/ambry-frontend/src/test/java/com/github/ambry/frontend/FrontendRestRequestServiceTest.java index 2914eb8787..940b2aa821 100644 --- a/ambry-frontend/src/test/java/com/github/ambry/frontend/FrontendRestRequestServiceTest.java +++ b/ambry-frontend/src/test/java/com/github/ambry/frontend/FrontendRestRequestServiceTest.java @@ -4411,7 +4411,7 @@ public Future getBlob(String blobId, GetBlobOptions options, Call @Override public Future putBlob(BlobProperties blobProperties, byte[] usermetadata, ReadableStreamChannel channel, - PutBlobOptions options, Callback callback, QuotaChargeCallback quotaChargeCallback, String blobPath) { + PutBlobOptions options, Callback callback, QuotaChargeCallback quotaChargeCallback, RestRequest restRequest) { return completeOperation(TestUtils.getRandomString(10), callback, OpType.PutBlob); } diff --git a/ambry-router/src/main/java/com/github/ambry/router/NonBlockingRouter.java b/ambry-router/src/main/java/com/github/ambry/router/NonBlockingRouter.java index 7cf2cc1e3a..1a684a7384 100644 --- a/ambry-router/src/main/java/com/github/ambry/router/NonBlockingRouter.java +++ b/ambry-router/src/main/java/com/github/ambry/router/NonBlockingRouter.java @@ -33,6 +33,7 @@ import com.github.ambry.quota.QuotaChargeCallback; import com.github.ambry.repair.RepairRequestsDb; import com.github.ambry.repair.RepairRequestsDbFactory; +import com.github.ambry.rest.RestRequest; import com.github.ambry.store.StoreKey; import com.github.ambry.utils.Time; import com.github.ambry.utils.Utils; @@ -354,12 +355,12 @@ public Future getBlob(String blobIdStr, GetBlobOptions options, f * @param channel The {@link ReadableStreamChannel} that contains the content of the blob. * @param options The {@link PutBlobOptions} associated with the request. This cannot be null. * @param callback The {@link Callback} which will be invoked on the completion of the request . - * @param blobPath The name of the blob path for named blob based upload. + * @param restRequest The {@link RestRequest} to put the blob. * @return A future that would contain the BlobId eventually. */ @Override public Future putBlob(BlobProperties blobProperties, byte[] userMetadata, ReadableStreamChannel channel, - PutBlobOptions options, Callback callback, QuotaChargeCallback quotaChargeCallback, String blobPath) { + PutBlobOptions options, Callback callback, QuotaChargeCallback quotaChargeCallback, RestRequest restRequest) { if (blobProperties == null || channel == null || options == null) { throw new IllegalArgumentException("blobProperties, channel, or options must not be null"); } diff --git a/ambry-test-utils/src/main/java/com/github/ambry/router/InMemoryRouter.java b/ambry-test-utils/src/main/java/com/github/ambry/router/InMemoryRouter.java index d91c578cfd..d7389c239d 100644 --- a/ambry-test-utils/src/main/java/com/github/ambry/router/InMemoryRouter.java +++ b/ambry-test-utils/src/main/java/com/github/ambry/router/InMemoryRouter.java @@ -27,6 +27,7 @@ import com.github.ambry.notification.NotificationSystem; import com.github.ambry.protocol.GetOption; import com.github.ambry.quota.QuotaChargeCallback; +import com.github.ambry.rest.RestRequest; import com.github.ambry.store.StoreKey; import com.github.ambry.utils.Pair; import com.github.ambry.utils.SystemTime; @@ -259,7 +260,7 @@ public Future getBlob(String blobId, GetBlobOptions options, Call @Override public Future putBlob(BlobProperties blobProperties, byte[] usermetadata, ReadableStreamChannel channel, - PutBlobOptions options, Callback callback, QuotaChargeCallback quotaChargeCallback, String blobPath) { + PutBlobOptions options, Callback callback, QuotaChargeCallback quotaChargeCallback, RestRequest restRequest) { FutureResult futureResult = new FutureResult<>(); if (!handlePrechecks(futureResult, callback)) { return futureResult; diff --git a/ambry-tools/src/main/java/com/github/ambry/tools/perf/rest/PerfRouter.java b/ambry-tools/src/main/java/com/github/ambry/tools/perf/rest/PerfRouter.java index 80d1c9c559..4efb4cbd22 100644 --- a/ambry-tools/src/main/java/com/github/ambry/tools/perf/rest/PerfRouter.java +++ b/ambry-tools/src/main/java/com/github/ambry/tools/perf/rest/PerfRouter.java @@ -20,6 +20,7 @@ import com.github.ambry.messageformat.BlobInfo; import com.github.ambry.messageformat.BlobProperties; import com.github.ambry.quota.QuotaChargeCallback; +import com.github.ambry.rest.RestRequest; import com.github.ambry.router.ChunkInfo; import com.github.ambry.router.FutureResult; import com.github.ambry.router.GetBlobOptions; @@ -108,12 +109,12 @@ public Future getBlob(String blobId, GetBlobOptions options, Call * @param channel The {@link ReadableStreamChannel} that contains the content of the blob. * @param options the {@link PutBlobOptions} for the blob. * @param callback the {@link Callback} to invoke on operation completion. - * @param blobPath The name of the blob path for named blob based upload. + * @param restRequest The name of the blob path for named blob based upload. * @return a {@link Future} that will contain a (dummy) blob id. */ @Override public Future putBlob(BlobProperties blobProperties, byte[] usermetadata, final ReadableStreamChannel channel, - PutBlobOptions options, final Callback callback, QuotaChargeCallback quotaChargeCallback, String blobPath) { + PutBlobOptions options, final Callback callback, QuotaChargeCallback quotaChargeCallback, RestRequest restRequest) { logger.trace("Received putBlob call"); final FutureResult futureResult = new FutureResult(); if (!routerOpen) {