-
Notifications
You must be signed in to change notification settings - Fork 853
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add RPCv2 module * Add RPCv2 module (#5445) * Comment out empty rpcv2 dependency * Sync version to 2.26.31-SNAPSHOT * Sugmanue/add byte support (#5477) * Add support to serialize byte values * Add tests for byte support * Address PR comments * Add rpcv2 protocol core (#5496) * Add support to serialize byte values * Add RPCv2 protocol core marshalling/unmarshalling * Address PR comments * Address PR comments 2 * Address PR comments 3 * Support for operation without input defined (#5512) * Support for operation without input defined * Fix a checkstyle issue * Code clean up * Code clean up 2 * Rewrite the condition to conjunctive normal form * Add codgen tests (#5517) * Add codgen tests * Address PR comments * Address PR comments 2 * Add missing class rename * Add missing AWS_JSON protocol facts * Account for null protocol case * Add RPCv2 benchmark tests (#5526) * Add RPCv2 benchmark tests * Give the constants name a meaningful name * Avoid parsing numbers when using RPCv2 protocol (#5539) * Avoid parsing numbers when using RPCv2 protocol * Refactor to avoid impacting JSON with RPCv2 logic (#5544) * Refactor to avoid impacting JSON with RPCv2 logic * Avoid making the unmarshallers depend on timestamp formats * Avoid streams while unmarshalling * Fix build failures * Fix build failures 2 * Avoid growing copies of collections of known size (#5551) * Add the new Smithy RPCv2 package * Sugmanue/rpcv2 improve cbor performance 04 (#5564) * Improve lookup by marshalling type * Improve trait lookup using TraitType * Add support for Smithy RPCv2 to the new service scripts (#5613) * Add changelog for the release * Fix typo in changelog * Update to next SNAPSHOT version
- Loading branch information
Showing
176 changed files
with
10,940 additions
and
1,487 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"category": "AWS SDK for Java v2", | ||
"contributor": "sugmanue", | ||
"type": "feature", | ||
"description": "Added support for the Smithy RPCv2 CBOR protocol, a new RPC protocol with better performance characteristics than AWS Json." | ||
} |
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
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
53 changes: 53 additions & 0 deletions
53
...ware/amazon/awssdk/codegen/customization/processors/SmithyRpcV2CborProtocolProcessor.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,53 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. 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. | ||
* A copy of the License is located at | ||
* | ||
* http://aws.amazon.com/apache2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file is distributed | ||
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
*/ | ||
|
||
package software.amazon.awssdk.codegen.customization.processors; | ||
|
||
import software.amazon.awssdk.codegen.customization.CodegenCustomizationProcessor; | ||
import software.amazon.awssdk.codegen.model.intermediate.IntermediateModel; | ||
import software.amazon.awssdk.codegen.model.service.Http; | ||
import software.amazon.awssdk.codegen.model.service.Operation; | ||
import software.amazon.awssdk.codegen.model.service.ServiceModel; | ||
import software.amazon.awssdk.utils.StringUtils; | ||
|
||
/** | ||
* This processor only runs for services using the <code>smithy-rpc-v2-cbor</code> protocol. | ||
* | ||
* Adds a request URI that conform to the Smithy RPCv2 protocol to each operation in the model, if there's no URI already | ||
* defined. | ||
*/ | ||
public class SmithyRpcV2CborProtocolProcessor implements CodegenCustomizationProcessor { | ||
@Override | ||
public void preprocess(ServiceModel serviceModel) { | ||
if (!"smithy-rpc-v2-cbor".equals(serviceModel.getMetadata().getProtocol())) { | ||
return; | ||
} | ||
serviceModel.getOperations().forEach((name, op) -> setRequestUri(serviceModel, name, op)); | ||
} | ||
|
||
private void setRequestUri(ServiceModel service, String name, Operation op) { | ||
Http http = op.getHttp(); | ||
String requestUri = http.getRequestUri(); | ||
if (StringUtils.isNotBlank(requestUri) && !"/".equals(requestUri)) { | ||
return; | ||
} | ||
String uri = String.format("/service/%s/operation/%s", service.getMetadata().getTargetPrefix(), op.getName()); | ||
op.getHttp().setRequestUri(uri); | ||
} | ||
|
||
@Override | ||
public void postprocess(IntermediateModel intermediateModel) { | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
...c/main/java/software/amazon/awssdk/codegen/internal/DefaultProtocolMetadataConstants.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,51 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. 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. | ||
* A copy of the License is located at | ||
* | ||
* http://aws.amazon.com/apache2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file is distributed | ||
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
*/ | ||
|
||
package software.amazon.awssdk.codegen.internal; | ||
|
||
import java.util.AbstractMap; | ||
import java.util.LinkedHashSet; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Set; | ||
import java.util.stream.Collectors; | ||
import software.amazon.awssdk.protocols.core.OperationMetadataAttribute; | ||
import software.amazon.awssdk.utils.AttributeMap; | ||
|
||
/** | ||
* Default implementation of {@link ProtocolMetadataConstants}. | ||
*/ | ||
public final class DefaultProtocolMetadataConstants implements ProtocolMetadataConstants { | ||
private final Set<Map.Entry<Class<?>, OperationMetadataAttribute<?>>> knownKeys = new LinkedHashSet<>(); | ||
private final AttributeMap.Builder map = AttributeMap.builder(); | ||
|
||
@Override | ||
public List<Map.Entry<Class<?>, OperationMetadataAttribute<?>>> keys() { | ||
return knownKeys.stream().filter(x -> map.get(x.getValue()) != null).collect(Collectors.toList()); | ||
} | ||
|
||
@Override | ||
public <T> T put(Class<?> containingClass, OperationMetadataAttribute<T> key, T value) { | ||
knownKeys.add(new AbstractMap.SimpleEntry<>(containingClass, key)); | ||
T oldValue = map.get(key); | ||
map.put(key, value); | ||
return oldValue; | ||
} | ||
|
||
@Override | ||
public <T> T get(OperationMetadataAttribute<T> key) { | ||
return map.get(key); | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
codegen/src/main/java/software/amazon/awssdk/codegen/internal/ProtocolMetadataConstants.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,51 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. 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. | ||
* A copy of the License is located at | ||
* | ||
* http://aws.amazon.com/apache2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file is distributed | ||
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
*/ | ||
|
||
package software.amazon.awssdk.codegen.internal; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
import software.amazon.awssdk.protocols.core.OperationMetadataAttribute; | ||
|
||
/** | ||
* Keeps the set of {@link OperationMetadataAttribute} constants attributes per operation/protocol. This is used to codegen | ||
* those constant values. | ||
*/ | ||
public interface ProtocolMetadataConstants { | ||
|
||
/** | ||
* Returns the list of keys sets. The {@link Map.Entry} contains as key the class containing the key field and the value | ||
* contains the key constant itself. The class is needed to properly codegen a reference to the key. | ||
* @return | ||
*/ | ||
List<Map.Entry<Class<?>, OperationMetadataAttribute<?>>> keys(); | ||
|
||
/** | ||
* Adds an operation metadata to the set of constants. | ||
*/ | ||
<T> T put(Class<?> containingClass, OperationMetadataAttribute<T> key, T value); | ||
|
||
/** | ||
* Adds an operation metadata to the set of constants. | ||
*/ | ||
default <T> T put(OperationMetadataAttribute<T> key, T value) { | ||
return put(key.getClass(), key, value); | ||
} | ||
|
||
/** | ||
* Gets the constant value for the operation metadata key. | ||
*/ | ||
<T> T get(OperationMetadataAttribute<T> key); | ||
} |
68 changes: 68 additions & 0 deletions
68
codegen/src/main/java/software/amazon/awssdk/codegen/internal/ProtocolMetadataDefault.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,68 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. 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. | ||
* A copy of the License is located at | ||
* | ||
* http://aws.amazon.com/apache2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file is distributed | ||
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
*/ | ||
|
||
package software.amazon.awssdk.codegen.internal; | ||
|
||
import software.amazon.awssdk.codegen.model.intermediate.Protocol; | ||
import software.amazon.awssdk.codegen.model.intermediate.ShapeMarshaller; | ||
import software.amazon.awssdk.protocols.json.BaseAwsJsonProtocolFactory; | ||
|
||
/** | ||
* Enum that maps protocol to metadata attribute constants for a given operation. | ||
*/ | ||
public enum ProtocolMetadataDefault { | ||
|
||
SMITHY_RPC_V2_CBOR(Protocol.SMITHY_RPC_V2_CBOR) { | ||
public ProtocolMetadataConstants protocolMetadata(ShapeMarshaller shapeMarshaller) { | ||
ProtocolMetadataConstants attributes = new DefaultProtocolMetadataConstants(); | ||
|
||
// If the shape is synthetic that means that no-input was defined in the model. For this | ||
// case the protocol requires to send an empty body with no content-type. See | ||
// https://smithy.io/2.0/additional-specs/protocols/smithy-rpc-v2.html#requests. | ||
// To accomplish this we use a no-op JSON generator. Otherwise, we serialize the input | ||
// even when no members are defined. | ||
Boolean isSynthetic = shapeMarshaller.getIsSynthetic(); | ||
if (Boolean.TRUE.equals(isSynthetic)) { | ||
attributes.put(BaseAwsJsonProtocolFactory.class, | ||
BaseAwsJsonProtocolFactory.GENERATES_BODY, | ||
Boolean.FALSE); | ||
} | ||
return attributes; | ||
} | ||
}, | ||
DEFAULT(null); | ||
|
||
private final Protocol protocol; | ||
|
||
ProtocolMetadataDefault(Protocol protocol) { | ||
this.protocol = protocol; | ||
} | ||
|
||
/** | ||
* Returns a function that maps from a {@link ShapeMarshaller} to a set of protocol metadata constants that we codegen. | ||
*/ | ||
public ProtocolMetadataConstants protocolMetadata(ShapeMarshaller shapeMarshaller) { | ||
return new DefaultProtocolMetadataConstants(); | ||
} | ||
|
||
public static ProtocolMetadataDefault from(Protocol protocol) { | ||
for (ProtocolMetadataDefault value : values()) { | ||
if (value.protocol == protocol) { | ||
return value; | ||
} | ||
} | ||
return DEFAULT; | ||
} | ||
} |
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
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.