You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by el...@apache.org on 2017/07/07 23:10:40 UTC
[6/6] calcite-avatica git commit: [CALCITE-1879] Log incoming
protobuf requests at TRACE
[CALCITE-1879] Log incoming protobuf requests at TRACE
Project: http://git-wip-us.apache.org/repos/asf/calcite-avatica/repo
Commit: http://git-wip-us.apache.org/repos/asf/calcite-avatica/commit/4d0f397a
Tree: http://git-wip-us.apache.org/repos/asf/calcite-avatica/tree/4d0f397a
Diff: http://git-wip-us.apache.org/repos/asf/calcite-avatica/diff/4d0f397a
Branch: refs/heads/master
Commit: 4d0f397a71b9c43ca5962d3b7e87bcabdd6cc9f5
Parents: bf615c1
Author: Josh Elser <el...@apache.org>
Authored: Fri Jul 7 18:55:56 2017 -0400
Committer: Josh Elser <el...@apache.org>
Committed: Fri Jul 7 19:06:38 2017 -0400
----------------------------------------------------------------------
.../avatica/remote/ProtobufTranslationImpl.java | 50 ++++++++++++++++++++
.../avatica/remote/RequestTranslator.java | 45 ------------------
.../avatica/remote/ResponseTranslator.java | 44 -----------------
3 files changed, 50 insertions(+), 89 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/calcite-avatica/blob/4d0f397a/core/src/main/java/org/apache/calcite/avatica/remote/ProtobufTranslationImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/avatica/remote/ProtobufTranslationImpl.java b/core/src/main/java/org/apache/calcite/avatica/remote/ProtobufTranslationImpl.java
index e1dd06d..b1e92f1 100644
--- a/core/src/main/java/org/apache/calcite/avatica/remote/ProtobufTranslationImpl.java
+++ b/core/src/main/java/org/apache/calcite/avatica/remote/ProtobufTranslationImpl.java
@@ -61,7 +61,9 @@ import org.apache.calcite.avatica.util.UnsynchronizedBuffer;
import com.google.protobuf.ByteString;
import com.google.protobuf.CodedInputStream;
+import com.google.protobuf.InvalidProtocolBufferException;
import com.google.protobuf.Message;
+import com.google.protobuf.Parser;
import com.google.protobuf.TextFormat;
import com.google.protobuf.UnsafeByteOperations;
@@ -85,6 +87,54 @@ import static java.nio.charset.StandardCharsets.UTF_8;
public class ProtobufTranslationImpl implements ProtobufTranslation {
private static final Logger LOG = LoggerFactory.getLogger(ProtobufTranslationImpl.class);
+ /**
+ * Encapsulate the logic of transforming a protobuf Request message into the Avatica POJO request.
+ */
+ static class RequestTranslator {
+
+ private final Parser<? extends Message> parser;
+ private final Service.Request impl;
+
+ public RequestTranslator(Parser<? extends Message> parser, Service.Request impl) {
+ this.parser = parser;
+ this.impl = impl;
+ }
+
+ public Service.Request transform(ByteString serializedMessage) throws
+ InvalidProtocolBufferException {
+ // This should already be an aliased CodedInputStream from the WireMessage parsing.
+ Message msg = parser.parseFrom(serializedMessage.newCodedInput());
+ if (LOG.isTraceEnabled()) {
+ LOG.trace("Deserialized request '{}'", TextFormat.shortDebugString(msg));
+ }
+ return impl.deserialize(msg);
+ }
+ }
+
+ /**
+ * Encapsulate the logic of transforming a protobuf Response message into the Avatica POJO
+ * Response.
+ */
+ static class ResponseTranslator {
+
+ private final Parser<? extends Message> parser;
+ private final Service.Response impl;
+
+ public ResponseTranslator(Parser<? extends Message> parser, Service.Response impl) {
+ this.parser = parser;
+ this.impl = impl;
+ }
+
+ public Service.Response transform(ByteString serializedMessage) throws
+ InvalidProtocolBufferException {
+ Message msg = parser.parseFrom(serializedMessage);
+ if (LOG.isTraceEnabled()) {
+ LOG.trace("Deserialized response '{}'", TextFormat.shortDebugString(msg));
+ }
+ return impl.deserialize(msg);
+ }
+ }
+
// Extremely ugly mapping of PB class name into a means to convert it to the POJO
private static final Map<String, RequestTranslator> REQUEST_PARSERS;
private static final Map<String, ResponseTranslator> RESPONSE_PARSERS;
http://git-wip-us.apache.org/repos/asf/calcite-avatica/blob/4d0f397a/core/src/main/java/org/apache/calcite/avatica/remote/RequestTranslator.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/avatica/remote/RequestTranslator.java b/core/src/main/java/org/apache/calcite/avatica/remote/RequestTranslator.java
deleted file mode 100644
index 417c6ed..0000000
--- a/core/src/main/java/org/apache/calcite/avatica/remote/RequestTranslator.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you 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 org.apache.calcite.avatica.remote;
-
-import com.google.protobuf.ByteString;
-import com.google.protobuf.InvalidProtocolBufferException;
-import com.google.protobuf.Message;
-import com.google.protobuf.Parser;
-
-/**
- * Encapsulate the logic of transforming a protobuf Request message into the Avatica POJO request.
- */
-public class RequestTranslator {
-
- private final Parser<? extends Message> parser;
- private final Service.Request impl;
-
- public RequestTranslator(Parser<? extends Message> parser, Service.Request impl) {
- this.parser = parser;
- this.impl = impl;
- }
-
- public Service.Request transform(ByteString serializedMessage) throws
- InvalidProtocolBufferException {
- // This should already be an aliased CodedInputStream from the WireMessage parsing.
- Message msg = parser.parseFrom(serializedMessage.newCodedInput());
- return impl.deserialize(msg);
- }
-}
-
-// End RequestTranslator.java
http://git-wip-us.apache.org/repos/asf/calcite-avatica/blob/4d0f397a/core/src/main/java/org/apache/calcite/avatica/remote/ResponseTranslator.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/avatica/remote/ResponseTranslator.java b/core/src/main/java/org/apache/calcite/avatica/remote/ResponseTranslator.java
deleted file mode 100644
index 0311e13..0000000
--- a/core/src/main/java/org/apache/calcite/avatica/remote/ResponseTranslator.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you 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 org.apache.calcite.avatica.remote;
-
-import com.google.protobuf.ByteString;
-import com.google.protobuf.InvalidProtocolBufferException;
-import com.google.protobuf.Message;
-import com.google.protobuf.Parser;
-
-/**
- * Encapsulate the logic of transforming a protobuf Response message into the Avatica POJO Response.
- */
-public class ResponseTranslator {
-
- private final Parser<? extends Message> parser;
- private final Service.Response impl;
-
- public ResponseTranslator(Parser<? extends Message> parser, Service.Response impl) {
- this.parser = parser;
- this.impl = impl;
- }
-
- public Service.Response transform(ByteString serializedMessage) throws
- InvalidProtocolBufferException {
- Message msg = parser.parseFrom(serializedMessage);
- return impl.deserialize(msg);
- }
-}
-
-// End ResponseTranslator.java