You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by up...@apache.org on 2018/04/17 00:21:17 UTC
[geode] branch feature/transcoding_experiments updated:
Experimenting with buffering the input stream of protobuf
This is an automated email from the ASF dual-hosted git repository.
upthewaterspout pushed a commit to branch feature/transcoding_experiments
in repository https://gitbox.apache.org/repos/asf/geode.git
The following commit(s) were added to refs/heads/feature/transcoding_experiments by this push:
new eb37bb4 Experimenting with buffering the input stream of protobuf
eb37bb4 is described below
commit eb37bb44900285adb173c8594a63399728016125
Author: Dan Smith <up...@apache.org>
AuthorDate: Mon Apr 16 17:18:12 2018 -0700
Experimenting with buffering the input stream of protobuf
If protobuf is reading directly from the socket input stream, it's possible
that will increase the overhead.
---
.../geode/internal/cache/tier/sockets/ProtobufServerConnection.java | 6 ++++--
.../java/org/apache/geode/experimental/driver/ProtobufChannel.java | 6 ++++--
2 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/ProtobufServerConnection.java b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/ProtobufServerConnection.java
index cb1d2fc..d6dc58c 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/ProtobufServerConnection.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/ProtobufServerConnection.java
@@ -15,6 +15,7 @@
package org.apache.geode.internal.cache.tier.sockets;
+import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.EOFException;
import java.io.IOException;
@@ -41,6 +42,7 @@ import org.apache.geode.internal.security.SecurityService;
public class ProtobufServerConnection extends ServerConnection {
// The new protocol lives in a separate module and gets loaded when this class is instantiated.
private final ClientProtocolProcessor protocolProcessor;
+ private final BufferedInputStream input;
private boolean cleanedUp;
private ClientProxyMembershipID clientProxyMembershipID;
private final BufferedOutputStream output;
@@ -58,6 +60,7 @@ public class ProtobufServerConnection extends ServerConnection {
this.protocolProcessor = clientProtocolProcessor;
this.output = new BufferedOutputStream(socket.getOutputStream(), socketBufferSize);
+ this.input = new BufferedInputStream(socket.getInputStream(), socketBufferSize);
setClientProxyMembershipId();
doHandShake(CommunicationMode.ProtobufClientServerProtocol.getModeNumber(), 0);
@@ -67,12 +70,11 @@ public class ProtobufServerConnection extends ServerConnection {
protected void doOneMessage() {
Socket socket = this.getSocket();
try {
- InputStream inputStream = socket.getInputStream();
InternalCache cache = getCache();
cache.setReadSerializedForCurrentThread(true);
try {
- protocolProcessor.processMessage(inputStream, output);
+ protocolProcessor.processMessage(input, output);
output.flush();
} finally {
cache.setReadSerializedForCurrentThread(false);
diff --git a/geode-experimental-driver/src/main/java/org/apache/geode/experimental/driver/ProtobufChannel.java b/geode-experimental-driver/src/main/java/org/apache/geode/experimental/driver/ProtobufChannel.java
index b309053..1e5d239 100644
--- a/geode-experimental-driver/src/main/java/org/apache/geode/experimental/driver/ProtobufChannel.java
+++ b/geode-experimental-driver/src/main/java/org/apache/geode/experimental/driver/ProtobufChannel.java
@@ -14,6 +14,7 @@
*/
package org.apache.geode.experimental.driver;
+import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.IOException;
import java.io.InputStream;
@@ -41,6 +42,7 @@ class ProtobufChannel {
final Socket socket;
final BufferedOutputStream output;
private final ValueSerializer serializer;
+ private final BufferedInputStream input;
public ProtobufChannel(final Set<InetSocketAddress> locators, String username, String password,
String keyStorePath, String trustStorePath, String protocols, String ciphers,
@@ -49,6 +51,7 @@ class ProtobufChannel {
socket = connectToAServer(locators, username, password, keyStorePath, trustStorePath, protocols,
ciphers);
output = new BufferedOutputStream(socket.getOutputStream(), socket.getSendBufferSize());
+ input = new BufferedInputStream(socket.getInputStream(), socket.getReceiveBufferSize());
}
public void close() throws IOException {
@@ -212,8 +215,7 @@ class ProtobufChannel {
}
private Message readResponse() throws IOException {
- final InputStream inputStream = socket.getInputStream();
- Message response = ClientProtocol.Message.parseDelimitedFrom(inputStream);
+ Message response = ClientProtocol.Message.parseDelimitedFrom(input);
if (response == null) {
throw new IOException("Unable to parse a response message due to EOF");
}
--
To stop receiving notification emails like this one, please contact
upthewaterspout@apache.org.