forked from linkedin/ambry
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce PutBlobOptions in router API (linkedin#983)
This will allow request options to be passed into the Router::putBlob method. In contrast to the BlobProperties, which are persisted with the blob in storage, PutBlobOptions only influence the router logic. For now, the options object is empty, but will soon include some options required for data chunk upload.
- Loading branch information
Showing
34 changed files
with
817 additions
and
121 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
52 changes: 52 additions & 0 deletions
52
ambry-api/src/main/java/com.github.ambry/frontend/IdSigningService.java
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,52 @@ | ||
/* | ||
* Copyright 2018 LinkedIn Corp. All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
*/ | ||
|
||
package com.github.ambry.frontend; | ||
|
||
import com.github.ambry.rest.RestServiceException; | ||
import com.github.ambry.utils.Pair; | ||
import java.util.Map; | ||
|
||
|
||
/** | ||
* Responsible for providing and verifying blob IDs that are signed with some additional metadata. The implementation | ||
* should include a secure signature field that prevents other parties from tampering with the ID. The implementation | ||
* can also choose to encrypt/decrypt the signed ID. The generated signed ID must be URL-safe. | ||
*/ | ||
public interface IdSigningService { | ||
|
||
/** | ||
* Get a signed ID based on the input blob ID and provided metadata. May not do any checking to ensure that the | ||
* request is authorized to generate a signed ID. | ||
* @param blobId the blob ID to include in the signed ID. | ||
* @param metadata additional parameters to include in the signed ID. | ||
* @return a URL-safe signed ID. | ||
* @throws RestServiceException if the signed ID could not be generated. | ||
*/ | ||
String getSignedId(String blobId, Map<String, String> metadata) throws RestServiceException; | ||
|
||
/** | ||
* @param id the input ID to check. | ||
* @return {@code true} if the ID is signed. {@code false} otherwise | ||
*/ | ||
boolean isIdSigned(String id); | ||
|
||
/** | ||
* Verify that the signed ID has not been tampered with and extract the blob ID and additional metadata from the | ||
* signed ID. | ||
* @return a {@link Pair} that contains the blob ID and additional metadata parsed from the signed ID. | ||
* @throws RestServiceException if there are problems verifying or parsing the ID. | ||
*/ | ||
Pair<String, Map<String, String>> parseSignedId(String signedId) throws RestServiceException; | ||
} |
30 changes: 30 additions & 0 deletions
30
ambry-api/src/main/java/com.github.ambry/frontend/IdSigningServiceFactory.java
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,30 @@ | ||
/* | ||
* Copyright 2018 LinkedIn Corp. All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
*/ | ||
|
||
package com.github.ambry.frontend; | ||
|
||
/** | ||
* IdSigningServiceFactory is a factory to generate all the supporting cast required to instantiate a | ||
* {@link IdSigningService}. | ||
* <p/> | ||
* Usually called with the canonical class name and as such might have to support appropriate (multiple) constructors. | ||
*/ | ||
public interface IdSigningServiceFactory { | ||
|
||
/** | ||
* Returns an instance of the {@link IdSigningService} that the factory generates. | ||
* @return an instance of {@link IdSigningService} generated by this factory. | ||
*/ | ||
IdSigningService getIdSigningService(); | ||
} |
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
42 changes: 42 additions & 0 deletions
42
ambry-api/src/main/java/com.github.ambry/router/FutureCallback.java
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,42 @@ | ||
/* | ||
* Copyright 2018 LinkedIn Corp. All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
*/ | ||
package com.github.ambry.router; | ||
|
||
import java.util.concurrent.CompletableFuture; | ||
|
||
|
||
public class FutureCallback<T> implements Callback<T> { | ||
private final CompletableFuture<T> future = new CompletableFuture<>(); | ||
|
||
/** | ||
* Complete the {@link CompletableFuture} that is returned by {@link #getFuture}. | ||
* @param result The result of the request. This would be non null when the request executed successfully | ||
* @param exception The exception that was reported on execution of the request | ||
*/ | ||
@Override | ||
public void onCompletion(T result, Exception exception) { | ||
if (exception != null) { | ||
future.completeExceptionally(exception); | ||
} else { | ||
future.complete(result); | ||
} | ||
} | ||
|
||
/** | ||
* @return the {@link CompletableFuture} that will be completed by {@link #onCompletion}. | ||
*/ | ||
public CompletableFuture<T> getFuture() { | ||
return future; | ||
} | ||
} |
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
Oops, something went wrong.