You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by bb...@apache.org on 2020/12/09 23:20:14 UTC
[geode-native] branch develop updated: GEODE-8773: Ensure that PING
and CLOSE_CONNECTION are not transactional. (#706)
This is an automated email from the ASF dual-hosted git repository.
bbender pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode-native.git
The following commit(s) were added to refs/heads/develop by this push:
new a8eb1a0 GEODE-8773: Ensure that PING and CLOSE_CONNECTION are not transactional. (#706)
a8eb1a0 is described below
commit a8eb1a04897ad239564e91fb0f7c7000d0949cfe
Author: Matthew Reddington <mr...@pivotal.io>
AuthorDate: Wed Dec 9 15:20:08 2020 -0800
GEODE-8773: Ensure that PING and CLOSE_CONNECTION are not transactional. (#706)
* Test that PING and CLOSE_CONNECTION are not implicitly transactional.
* Always send TxId -1 (NOTX in Java) for PING and CLOSE_CONNECTION
- These should never be part of a transaction
Co-authored-by: Blake Bender <bb...@vmware.com>
---
cppcache/src/TcrMessage.cpp | 22 ++++------------------
cppcache/test/TcrMessageTest.cpp | 27 +++++++++++++++++++++++++++
2 files changed, 31 insertions(+), 18 deletions(-)
diff --git a/cppcache/src/TcrMessage.cpp b/cppcache/src/TcrMessage.cpp
index 4fc08db..fcf621a 100644
--- a/cppcache/src/TcrMessage.cpp
+++ b/cppcache/src/TcrMessage.cpp
@@ -2092,18 +2092,8 @@ TcrMessagePing::TcrMessagePing(DataOutput* dataOutput, bool decodeAll) {
m_msgType = TcrMessage::PING;
m_decodeAll = decodeAll;
m_request.reset(dataOutput);
- m_request->writeInt(m_msgType);
- m_request->writeInt(static_cast<int32_t>(
- 0)); // 17 is fixed message len ... PING only has a header.
- m_request->writeInt(static_cast<int32_t>(0)); // Number of parts.
- // int32_t txId = TcrMessage::m_transactionId++;
- // Setting the txId to 0 for all ping message as it is not being used on the
- // SERVER side or the
- // client side.
- m_request->writeInt(static_cast<int32_t>(0));
- m_request->write(static_cast<int8_t>(0)); // Early ack is '0'.
- m_msgLength = g_headerLen;
- m_txId = 0;
+ writeHeader(m_msgType, 0);
+ writeMessageLength();
}
TcrMessageCloseConnection::TcrMessageCloseConnection(DataOutput* dataOutput,
@@ -2111,18 +2101,14 @@ TcrMessageCloseConnection::TcrMessageCloseConnection(DataOutput* dataOutput,
m_msgType = TcrMessage::CLOSE_CONNECTION;
m_decodeAll = decodeAll;
m_request.reset(dataOutput);
- m_request->writeInt(m_msgType);
- m_request->writeInt(static_cast<int32_t>(6));
- m_request->writeInt(static_cast<int32_t>(1)); // Number of parts.
- // int32_t txId = TcrMessage::m_transactionId++;
- m_request->writeInt(static_cast<int32_t>(0));
- m_request->write(static_cast<int8_t>(0)); // Early ack is '0'.
+ writeHeader(m_msgType, 1);
// last two parts are not used ... setting zero in both the parts.
m_request->writeInt(static_cast<int32_t>(1)); // len is 1
m_request->write(static_cast<int8_t>(0)); // is obj is '0'.
// cast away constness here since we want to modify this
TcrMessage::m_keepAlive = const_cast<uint8_t*>(m_request->getCursor());
m_request->write(static_cast<int8_t>(0)); // keepalive is '0'.
+ writeMessageLength();
}
TcrMessageClientMarker::TcrMessageClientMarker(DataOutput* dataOutput,
diff --git a/cppcache/test/TcrMessageTest.cpp b/cppcache/test/TcrMessageTest.cpp
index 93d26a9..cfe2004 100644
--- a/cppcache/test/TcrMessageTest.cpp
+++ b/cppcache/test/TcrMessageTest.cpp
@@ -798,4 +798,31 @@ TEST_F(TcrMessageTest, testConstructorEXECUTECQ_WITH_IR_MSG_TYPE) {
testMessage);
}
+TEST_F(TcrMessageTest, testConstructorPING) {
+ using apache::geode::client::TcrMessagePing;
+
+ std::shared_ptr<Cacheable> myCacheablePtr(
+ CacheableString::createDeserializable());
+
+ TcrMessagePing testMessage(new DataOutputUnderTest(), false);
+
+ EXPECT_EQ(TcrMessage::PING, testMessage.getMessageType());
+
+ EXPECT_MESSAGE_EQ("000000050000000000000000FFFFFFFF00", testMessage);
+}
+
+TEST_F(TcrMessageTest, testConstructorCLOSE_CONNECTION) {
+ using apache::geode::client::TcrMessageCloseConnection;
+
+ std::shared_ptr<Cacheable> myCacheablePtr(
+ CacheableString::createDeserializable());
+
+ TcrMessageCloseConnection testMessage(new DataOutputUnderTest(), false);
+
+ EXPECT_EQ(TcrMessage::CLOSE_CONNECTION, testMessage.getMessageType());
+
+ EXPECT_MESSAGE_EQ("000000120000000600000001FFFFFFFF00000000010000",
+ testMessage);
+}
+
} // namespace