Skip to content
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

Import evenstream library #5908

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .brazil.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"http-auth-aws-eventstream": { "packageName": "AwsJavaSdk-Core-HttpAuthAwsEventStream" },
"retries-spi": { "packageName": "AwsJavaSdk-Core-RetriesSpi" },
"retries": { "packageName": "AwsJavaSdk-Core-Retries" },
"eventstream": { "packageName": "AwsJavaSdk-Core-EventStream" },

"dynamodb": { "packageName": "AwsJavaSdk-DynamoDb" },
"waf": { "packageName": "AwsJavaSdk-Waf" },
Expand Down
5 changes: 5 additions & 0 deletions bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,11 @@
<artifactId>endpoints-spi</artifactId>
<version>${awsjavasdk.version}</version>
</dependency>
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>eventstream</artifactId>
<version>${awsjavasdk.version}</version>
</dependency>
<!-- Services -->
<dependency>
<groupId>software.amazon.awssdk</groupId>
Expand Down
57 changes: 57 additions & 0 deletions core/eventstream/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ 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.
-->

<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>core</artifactId>
<groupId>software.amazon.awssdk</groupId>
<version>2.30.30-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>eventstream</artifactId>
<name>AWS Java SDK :: EventStream</name>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifestEntries>
<Automatic-Module-Name>software.amazon.awssdk.eventstream</Automatic-Module-Name>
</manifestEntries>
</archive>
</configuration>
</plugin>
</plugins>
</build>

<dependencies>
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>annotations</artifactId>
<version>${awsjavasdk.version}</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* 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.eventstream;

import java.nio.ByteBuffer;
import java.util.zip.Checksum;
import software.amazon.awssdk.annotations.SdkInternalApi;

@SdkInternalApi
final class Checksums {

private Checksums() {
}

static void update(Checksum checksum, ByteBuffer buffer) {
if (buffer.hasArray()) {
int pos = buffer.position();
int off = buffer.arrayOffset();
int limit = buffer.limit();
int rem = limit - pos;
checksum.update(buffer.array(), pos + off, rem);
buffer.position(limit);
} else {
int length = buffer.remaining();
byte[] b = new byte[length];
buffer.get(b, 0, length);
checksum.update(b, 0, length);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
/*
* 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.eventstream;

import static java.util.Objects.requireNonNull;

import java.io.DataOutputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.Map;
import software.amazon.awssdk.annotations.SdkInternalApi;

@SdkInternalApi
class Header {
private final String name;
private final HeaderValue value;

Header(String name, HeaderValue value) {
this.name = requireNonNull(name);
this.value = requireNonNull(value);
}

Header(String name, String value) {
this(name, HeaderValue.fromString(value));
}

public String getName() {
return name;
}

public HeaderValue getValue() {
return value;
}

static Header decode(ByteBuffer buf) {
String name = Utils.readShortString(buf);
return new Header(name, HeaderValue.decode(buf));
}

static void encode(Map.Entry<String, HeaderValue> header, DataOutputStream dos) throws IOException {
new Header(header.getKey(), header.getValue()).encode(dos);
}

void encode(DataOutputStream dos) throws IOException {
Utils.writeShortString(dos, name);
value.encode(dos);
}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}

if (o == null || getClass() != o.getClass()) {
return false;
}

Header header = (Header) o;

if (!name.equals(header.name)) {
return false;
}

return value.equals(header.value);
}

@Override
public int hashCode() {
int result = name.hashCode();
result = 31 * result + value.hashCode();
return result;
}

@Override
public String toString() {
return "Header{"
+ "name='" + name + '\''
+ ", value=" + value
+ '}';
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* 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.eventstream;

import software.amazon.awssdk.annotations.SdkInternalApi;

@SdkInternalApi
enum HeaderType {
TRUE(0),
FALSE(1),
BYTE(2),
SHORT(3),
INTEGER(4),
LONG(5),
BYTE_ARRAY(6),
STRING(7),
TIMESTAMP(8),
UUID(9);

final byte headerTypeId;

HeaderType(int headerTypeId) {
this.headerTypeId = (byte) headerTypeId;
}

static HeaderType fromTypeId(byte headerTypeId) {
switch (headerTypeId) {
case 0: return TRUE;
case 1: return FALSE;
case 2: return BYTE;
case 3: return SHORT;
case 4: return INTEGER;
case 5: return LONG;
case 6: return BYTE_ARRAY;
case 7: return STRING;
case 8: return TIMESTAMP;
case 9: return UUID;
default:
throw new IllegalArgumentException("Got unknown headerTypeId " + headerTypeId);
}
}
}
Loading
Loading