Skip to content

Rest Xml marshaller/unmarshaller refactor #758

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 25, 2018
Merged

Rest Xml marshaller/unmarshaller refactor #758

merged 2 commits into from
Oct 25, 2018

Conversation

varunnvs92
Copy link
Contributor

@varunnvs92 varunnvs92 commented Oct 15, 2018

  • Refactored xml marshaller/unmarshaller similar to json/query
  • Addressed most of the old comments
  • Perf tests results are similar to json (a bit slower than v1). But it is ~10 micro seconds depending on the file size which is minute compared to other latency like network calls

TODO

  • Will run integ tests

@@ -74,7 +74,7 @@
.memberFieldInfo(
SdkField.<String> builder(MarshallingType.STRING)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
.locationName("member").build()).build()).flattened(false).build()).build();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my branch I only add flattened when it's not false. Helps cut the noise down a bit.


public <T extends AwsRequest> ProtocolMarshaller<Request<T>> createProtocolMarshaller(OperationInfo operationInfo,
T origRequest,
String xmlNameSpaceUri) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be worth having some mechanism to communicate protocol specific metadata in OperationInfo. Like some attribute map similar to the execution attributes. Or allowing protocols to extend OperationInfo to add additional properties.


// TODO Is it required? No shape uses this. Fix casting
// See line 8 in MarshalHeaderMembersMacro.ftl
public static final XmlMarshaller<List> LiST = new SimpleHeaderMarshaller<List>(null) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need to support this and should remove it until we need it. It's not clear how we should marshall lists in headers as it's not yet defined.

return;
}

for (Map.Entry<String, String> entry : ((Map<String, String>) map).entrySet()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to assume it's a string or can we lookup in the marshaller registry and delegate?

@SdkInternalApi
public interface XmlUnmarshaller<T> {

T unmarshall(XmlUnmarshallerContext context,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NP one liner

pom.xml Outdated
@@ -549,7 +549,7 @@
</execution>
</executions>
<configuration>
<failOnWarning>true</failOnWarning>
<failOnWarning>false</failOnWarning>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's this?

@@ -29,4 +29,14 @@
AWS Budgets Service
</description>
<url>https://aws.amazon.com/sdkforjava</url>

<dependencies>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove

@@ -0,0 +1,29 @@

#
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why's this in codegen-resources?

@@ -63,5 +63,9 @@
<version>${awsjavasdk.version}</version>
<scope>test</scope>
</dependency>
<dependency>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove

@varunnvs92 varunnvs92 changed the title Rest Xml marshaller refactor [Not ready for review] Rest Xml marshaller refactor Oct 24, 2018
@varunnvs92 varunnvs92 force-pushed the xmlRefactor branch 5 times, most recently from 5db4222 to fb81b6b Compare October 25, 2018 03:46
@varunnvs92 varunnvs92 changed the title [Not ready for review] Rest Xml marshaller refactor Rest Xml marshaller refactor Oct 25, 2018
@varunnvs92 varunnvs92 changed the title Rest Xml marshaller refactor Rest Xml marshaller/unmarshaller refactor Oct 25, 2018
@Override
public void marshall(SdkBytes val, XmlMarshallerContext context, String paramName, SdkField<SdkBytes> sdkField,
ValueToStringConverter.ValueToString<SdkBytes> converter) {
context.xmlGenerator().xmlWriter().value(val.asByteBuffer());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this base64 encoded?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes (here)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it worth just moving that up to this level? We've got a ValueToString for SDK_BYTES that base64 encodes already.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. I will use it

}

/**
* This value indicates if the root element in the response xml document should be ignored
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this or can we just use the PayloadTrait?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we discussed yesterday, we are setting a customization to enable this value for operation like S3 GetBucketLocationOutput. So we need it

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking that we would use that customization to just apply the payload trait to LocationConstraint. Wouldn't that have the same behavior?

@@ -55,7 +55,8 @@
private static final Region DESTINATION_REGION = Region.of("us-west-2");

private static RdsPresignInterceptor<CopyDbSnapshotRequest> presignInterceptor = new CopyDbSnapshotPresignInterceptor();
private final CopyDbSnapshotRequestMarshaller marshaller = new CopyDbSnapshotRequestMarshaller(new AwsQueryProtocolFactory());
private final CopyDbSnapshotRequestMarshaller marshaller =
new CopyDbSnapshotRequestMarshaller(AwsQueryProtocolFactory.builder().build());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we just have a create method?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to add overload create methods if we add state to this class, so i avoided it. We don't use it in many places, so it should be fine. We can always add it later.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good.

@Override
public SdkHttpFullRequest modifyHttpRequest(Context.ModifyHttpRequest context, ExecutionAttributes executionAttributes) {
SdkHttpFullRequest request = context.httpRequest();
if (request.contentStreamProvider().isPresent() && !request.firstMatchingHeader(CONTENT_MD5).isPresent()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this add MD5 for all operations? what about PutObject?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ignoring PutObject and UploadPart as discussed offline

@varunnvs92 varunnvs92 merged commit 07b72ee into master Oct 25, 2018
@zoewangg zoewangg deleted the xmlRefactor branch November 29, 2018 19:31
aws-sdk-java-automation added a commit that referenced this pull request Mar 17, 2020
…a5323a23

Pull request: release <- staging/194ffc2d-3f15-4f2c-95ce-60e7a5323a23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants