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
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ private void recordMetrics(Instant startTime) {
}
final long latency = Duration.between(startTime, Instant.now()).toMillis();
metricsRecorder.recordOperationCount(1);
metricsRecorder.recordOperationLatency(latency);
metricsRecorder.recordOperationLatency((double) latency);
}

private static int readNBytesJava8(InputStream in, byte[] b, int off, int len)
Expand Down Expand Up @@ -352,7 +352,7 @@ private PreparePayloadResult preparePayload(MessageContext ctx) {
case ProtocolConstants.Opcode.BATCH:
return prepareBatchMessage((Batch) decodeFrame(ctx.payload).message, ctx.streamId);
case ProtocolConstants.Opcode.QUERY:
return prepareQueryMessage((Query) decodeFrame(ctx.payload).message, ctx.streamId);
return prepareQueryMessage((Query) decodeFrame(ctx.payload).message);
default:
return new PreparePayloadResult(DEFAULT_CONTEXT);
}
Expand Down Expand Up @@ -394,7 +394,7 @@ private PreparePayloadResult prepareBatchMessage(Batch message, int streamId) {
return new PreparePayloadResult(DEFAULT_CONTEXT_WITH_LAR, attachments, attachmentErrorResponse);
}

private PreparePayloadResult prepareQueryMessage(Query message, int streamId) {
private PreparePayloadResult prepareQueryMessage(Query message) {
ApiCallContext context;
Map<String, String> attachments = Collections.emptyMap();
if (startsWith(message.query, "SELECT")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@
*/
package com.google.cloud.spanner.adapter;

import static java.nio.charset.StandardCharsets.UTF_8;

import com.sun.net.httpserver.HttpExchange;
import com.sun.net.httpserver.HttpHandler;
import com.sun.net.httpserver.HttpServer;
import java.io.IOException;
import java.io.OutputStream;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.nio.charset.StandardCharsets;
import java.util.concurrent.atomic.AtomicBoolean;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -83,7 +84,7 @@ public void handle(HttpExchange exchange) throws IOException {

private void sendResponse(HttpExchange exchange, int statusCode, String response)
throws IOException {
byte[] responseBytes = response.getBytes(StandardCharsets.UTF_8);
byte[] responseBytes = response.getBytes(UTF_8);
exchange.getResponseHeaders().set("Content-Type", "text/plain; charset=utf-8");
exchange.sendResponseHeaders(statusCode, responseBytes.length);
try (OutputStream os = exchange.getResponseBody()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,11 @@ public void close() {
// nothing to do
}

private RetryDecision retryOrRethrow(int retryCount, String error_msg) {
private RetryDecision retryOrRethrow(int retryCount, String errorMsg) {
final RetryDecision decision =
(retryCount < DEFAULT_MAX_RETRY_COUNT) ? RetryDecision.RETRY_SAME : RetryDecision.RETHROW;
if (decision == RetryDecision.RETRY_SAME && LOG.isTraceEnabled()) {
LOG.trace(error_msg, logPrefix, retryCount);
LOG.trace(errorMsg, logPrefix, retryCount);
}
return decision;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import javax.annotation.Nullable;
import org.yaml.snakeyaml.Yaml;

/**
Expand All @@ -35,6 +36,7 @@ public class YamlConfigLoader {
* @param inputStream The input stream containing the YAML data.
* @return A {@link UserConfigs} object representing the parsed configuration.
*/
@Nullable
public static UserConfigs load(InputStream inputStream) {
Yaml yaml = new Yaml();
Map<String, Object> yamlMap = yaml.load(inputStream);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@
import com.datastax.oss.protocol.internal.response.Supported;
import com.datastax.oss.protocol.internal.response.error.Unprepared;
import com.google.api.core.InternalApi;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.protobuf.ByteString;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufAllocator;
import java.util.Collections;

/**
* Utility class for creating specific types of response frames used in the server protocol, encoded
Expand All @@ -53,8 +53,8 @@ public final class MessageUtils {
private static final Supported SUPPORTED_MESSAGE =
new Supported(
ImmutableMap.of(
"CQL_VERSION", Collections.singletonList("3.0.0"),
"COMPRESSION", Collections.emptyList()));
"CQL_VERSION", ImmutableList.of("3.0.0"),
"COMPRESSION", ImmutableList.of()));

private static final FrameCodec<ByteBuf> serverFrameCodec =
FrameCodec.defaultServer(
Expand Down Expand Up @@ -112,7 +112,7 @@ public static ByteString supportedResponse(int streamId) {
public static ByteString messageResponse(int streamId, Message message) {
Frame responseFrame =
Frame.forResponse(
PROTOCOL_VERSION, streamId, null, Frame.NO_PAYLOAD, Collections.emptyList(), message);
PROTOCOL_VERSION, streamId, null, Frame.NO_PAYLOAD, ImmutableList.of(), message);
ByteBuf responseBuf = serverFrameCodec.encode(responseFrame);
ByteString response = ByteString.copyFrom(responseBuf.nioBuffer());
responseBuf.release();
Expand Down
Loading