Skip to content
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
20 changes: 20 additions & 0 deletions client-it/src/test/java/io/oxia/client/it/OxiaClientIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@

import static io.oxia.client.api.options.PutOption.IfRecordDoesNotExist;
import static io.oxia.client.api.options.PutOption.IfVersionIdEquals;
import static io.oxia.client.constants.Constants.MAXIMUM_FRAME_SIZE;
import static java.nio.charset.StandardCharsets.UTF_8;
import static java.util.concurrent.CompletableFuture.allOf;
import static java.util.function.Function.identity;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.awaitility.Awaitility.await;

import io.grpc.StatusRuntimeException;
import io.opentelemetry.api.OpenTelemetry;
import io.opentelemetry.api.common.Attributes;
import io.opentelemetry.sdk.OpenTelemetrySdk;
Expand Down Expand Up @@ -869,4 +871,22 @@ void testGetSequenceUpdates() throws Exception {
assertThat(updates2.poll(1, TimeUnit.SECONDS)).isEqualTo(pr4.key());
assertThat(updates2.poll(1, TimeUnit.SECONDS)).isNull();
}

@Test
@SneakyThrows
void testMaximumSize() {
@Cleanup
SyncOxiaClient client = OxiaClientBuilder.create(oxia.getServiceAddress()).syncClient();
String key = "key-" + UUID.randomUUID();
byte[] payload = new byte[50 * 1024 * 1024];
client.put(key, payload);
client.get(key);

key = "key-" + UUID.randomUUID();
payload = new byte[MAXIMUM_FRAME_SIZE];
final String finalKey = key;
final byte[] finalPayload = payload;
assertThatThrownBy(() -> client.put(finalKey, finalPayload))
.isInstanceOf(StatusRuntimeException.class);
}
}
21 changes: 21 additions & 0 deletions client/src/main/java/io/oxia/client/constants/Constants.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* Copyright © 2022-2025 The Oxia Authors
*
* 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.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.oxia.client.constants;

public final class Constants {
// As same as oxia server configuration
public static final int MAXIMUM_FRAME_SIZE = 256 * 1024 * 1024;
}
7 changes: 6 additions & 1 deletion client/src/main/java/io/oxia/client/grpc/OxiaStub.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package io.oxia.client.grpc;

import static io.oxia.client.constants.Constants.MAXIMUM_FRAME_SIZE;
import static java.util.concurrent.TimeUnit.MILLISECONDS;

import com.google.common.base.Throwables;
Expand Down Expand Up @@ -89,6 +90,8 @@ public OxiaStub(ManagedChannel channel, @Nullable final Authentication authentic
if (authentication != null) {
this.asyncStub =
OxiaClientGrpc.newStub(channel)
.withMaxInboundMessageSize(MAXIMUM_FRAME_SIZE)
.withMaxOutboundMessageSize(MAXIMUM_FRAME_SIZE)
.withCallCredentials(
new CallCredentials() {

Expand All @@ -112,7 +115,9 @@ public void thisUsesUnstableApi() {
}
});
} else {
this.asyncStub = OxiaClientGrpc.newStub(channel);
this.asyncStub = OxiaClientGrpc.newStub(channel)
.withMaxInboundMessageSize(MAXIMUM_FRAME_SIZE)
.withMaxOutboundMessageSize(MAXIMUM_FRAME_SIZE);
}
}

Expand Down
Loading