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/07/08 19:42:45 UTC
[geode-native] branch develop updated: GEODE-8307: Enforce No
Shadow Field in Constructor as Error (#624)
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 d062be1 GEODE-8307: Enforce No Shadow Field in Constructor as Error (#624)
d062be1 is described below
commit d062be10b55d27e0a5437ff892ef6e0d230db59a
Author: M. Oleske <mo...@users.noreply.github.com>
AuthorDate: Wed Jul 8 12:42:34 2020 -0700
GEODE-8307: Enforce No Shadow Field in Constructor as Error (#624)
---
CMakeLists.txt | 1 -
cppcache/src/ClientProxyMembershipIDFactory.cpp | 14 +-
cppcache/src/ClientProxyMembershipIDFactory.hpp | 4 +-
cppcache/src/PdxTypeRegistry.cpp | 115 ++++++++-------
cppcache/src/PdxTypeRegistry.hpp | 36 ++---
cppcache/src/statistics/StatArchiveWriter.cpp | 182 ++++++++++++------------
cppcache/src/statistics/StatArchiveWriter.hpp | 23 ++-
cppcache/test/ConnectionQueueTest.cpp | 10 +-
8 files changed, 189 insertions(+), 196 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7711923..e18aa29 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -256,7 +256,6 @@ elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
-Wno-header-hygiene #TODO fix
-Wno-shorten-64-to-32 #TODO fix
-Wno-conversion #TODO fix
- -Wno-shadow-field-in-constructor #TODO fix
-Wno-missing-variable-declarations #TODO fix
-Wno-switch-enum #TODO fix
-Wno-reserved-id-macro #TODO fix
diff --git a/cppcache/src/ClientProxyMembershipIDFactory.cpp b/cppcache/src/ClientProxyMembershipIDFactory.cpp
index 021ffb9..b4d653f 100644
--- a/cppcache/src/ClientProxyMembershipIDFactory.cpp
+++ b/cppcache/src/ClientProxyMembershipIDFactory.cpp
@@ -32,7 +32,7 @@ namespace client {
ClientProxyMembershipIDFactory::ClientProxyMembershipIDFactory(
std::string dsName)
- : dsName(std::move(dsName)) {
+ : dsName_(std::move(dsName)) {
static const auto alphabet =
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_";
static const auto numChars = (sizeof(alphabet) / sizeof(char)) - 2;
@@ -41,16 +41,16 @@ ClientProxyMembershipIDFactory::ClientProxyMembershipIDFactory(
std::default_random_engine rng(rd());
std::uniform_int_distribution<> dist(0, numChars);
- randString.reserve(7 + 10 + 15);
- randString.append("Native_");
- std::generate_n(std::back_inserter(randString), 10,
+ randString_.reserve(7 + 10 + 15);
+ randString_.append("Native_");
+ std::generate_n(std::back_inserter(randString_), 10,
[&]() { return alphabet[dist(rng)]; });
auto pid = boost::this_process::get_id();
- randString.append(std::to_string(pid));
+ randString_.append(std::to_string(pid));
LOGINFO("Using %s as random data for ClientProxyMembershipID",
- randString.c_str());
+ randString_.c_str());
}
std::unique_ptr<ClientProxyMembershipID> ClientProxyMembershipIDFactory::create(
@@ -59,7 +59,7 @@ std::unique_ptr<ClientProxyMembershipID> ClientProxyMembershipIDFactory::create(
const auto hostname = boost::asio::ip::host_name();
const ACE_INET_Addr address("", hostname.c_str(), "tcp");
return std::unique_ptr<ClientProxyMembershipID>(
- new ClientProxyMembershipID(dsName, randString, hostname, address, 0,
+ new ClientProxyMembershipID(dsName_, randString_, hostname, address, 0,
durableClientId, durableClntTimeOut));
}
diff --git a/cppcache/src/ClientProxyMembershipIDFactory.hpp b/cppcache/src/ClientProxyMembershipIDFactory.hpp
index 21d0edb..e97251d 100644
--- a/cppcache/src/ClientProxyMembershipIDFactory.hpp
+++ b/cppcache/src/ClientProxyMembershipIDFactory.hpp
@@ -38,8 +38,8 @@ class ClientProxyMembershipIDFactory {
std::chrono::seconds::zero());
private:
- std::string dsName;
- std::string randString;
+ std::string dsName_;
+ std::string randString_;
};
} // namespace client
diff --git a/cppcache/src/PdxTypeRegistry.cpp b/cppcache/src/PdxTypeRegistry.cpp
index 7fc17a6..01cd5f4 100644
--- a/cppcache/src/PdxTypeRegistry.cpp
+++ b/cppcache/src/PdxTypeRegistry.cpp
@@ -28,24 +28,23 @@ namespace geode {
namespace client {
PdxTypeRegistry::PdxTypeRegistry(CacheImpl* cache)
- : cache(cache),
- typeIdToPdxType(),
- remoteTypeIdToMergedPdxType(),
- localTypeToPdxType(),
- pdxTypeToTypeIdMap(),
- enumToInt(CacheableHashMap::create()),
- intToEnum(CacheableHashMap::create()) {}
+ : cache_(cache),
+ typeIdToPdxType_(),
+ remoteTypeIdToMergedPdxType_(),
+ localTypeToPdxType_(),
+ pdxTypeToTypeIdMap_(),
+ enumToInt_(CacheableHashMap::create()),
+ intToEnum_(CacheableHashMap::create()) {}
PdxTypeRegistry::~PdxTypeRegistry() {}
size_t PdxTypeRegistry::testNumberOfPreservedData() const {
- return preserveData.size();
+ return preserveData_.size();
}
int32_t PdxTypeRegistry::getPDXIdForType(const std::string& type, Pool* pool,
std::shared_ptr<PdxType> nType,
bool checkIfThere) {
- // WriteGuard guard(g_readerWriterLock);
if (checkIfThere) {
auto lpdx = getLocalPdxType(type);
if (lpdx != nullptr) {
@@ -56,7 +55,7 @@ int32_t PdxTypeRegistry::getPDXIdForType(const std::string& type, Pool* pool,
}
}
- int typeId = cache->getSerializationRegistry()->GetPDXIdForType(pool, nType);
+ int typeId = cache_->getSerializationRegistry()->GetPDXIdForType(pool, nType);
nType->setTypeId(typeId);
addPdxType(typeId, nType);
@@ -67,9 +66,9 @@ int32_t PdxTypeRegistry::getPDXIdForType(std::shared_ptr<PdxType> nType,
Pool* pool) {
int32_t typeId = 0;
{
- ReadGuard read(g_readerWriterLock);
- auto&& iter = pdxTypeToTypeIdMap.find(nType);
- if (iter != pdxTypeToTypeIdMap.end()) {
+ ReadGuard read(g_readerWriterLock_);
+ auto&& iter = pdxTypeToTypeIdMap_.find(nType);
+ if (iter != pdxTypeToTypeIdMap_.end()) {
typeId = iter->second;
if (typeId != 0) {
return typeId;
@@ -78,18 +77,18 @@ int32_t PdxTypeRegistry::getPDXIdForType(std::shared_ptr<PdxType> nType,
}
{
- WriteGuard write(g_readerWriterLock);
- auto&& iter = pdxTypeToTypeIdMap.find(nType);
- if (iter != pdxTypeToTypeIdMap.end()) {
+ WriteGuard write(g_readerWriterLock_);
+ auto&& iter = pdxTypeToTypeIdMap_.find(nType);
+ if (iter != pdxTypeToTypeIdMap_.end()) {
typeId = iter->second;
if (typeId != 0) {
return typeId;
}
}
- typeId = cache->getSerializationRegistry()->GetPDXIdForType(pool, nType);
+ typeId = cache_->getSerializationRegistry()->GetPDXIdForType(pool, nType);
nType->setTypeId(typeId);
- pdxTypeToTypeIdMap.insert(std::make_pair(nType, typeId));
+ pdxTypeToTypeIdMap_.insert(std::make_pair(nType, typeId));
}
addPdxType(typeId, nType);
return typeId;
@@ -97,36 +96,36 @@ int32_t PdxTypeRegistry::getPDXIdForType(std::shared_ptr<PdxType> nType,
void PdxTypeRegistry::clear() {
{
- WriteGuard guard(g_readerWriterLock);
- typeIdToPdxType.clear();
+ WriteGuard guard(g_readerWriterLock_);
+ typeIdToPdxType_.clear();
- remoteTypeIdToMergedPdxType.clear();
+ remoteTypeIdToMergedPdxType_.clear();
- localTypeToPdxType.clear();
+ localTypeToPdxType_.clear();
- if (intToEnum) intToEnum->clear();
+ if (intToEnum_) intToEnum_->clear();
- if (enumToInt) enumToInt->clear();
+ if (enumToInt_) enumToInt_->clear();
- pdxTypeToTypeIdMap.clear();
+ pdxTypeToTypeIdMap_.clear();
}
{
WriteGuard guard(getPreservedDataLock());
- preserveData.clear();
+ preserveData_.clear();
}
}
void PdxTypeRegistry::addPdxType(int32_t typeId,
std::shared_ptr<PdxType> pdxType) {
- WriteGuard guard(g_readerWriterLock);
+ WriteGuard guard(g_readerWriterLock_);
std::pair<int32_t, std::shared_ptr<PdxType>> pc(typeId, pdxType);
- typeIdToPdxType.insert(pc);
+ typeIdToPdxType_.insert(pc);
}
std::shared_ptr<PdxType> PdxTypeRegistry::getPdxType(int32_t typeId) const {
- ReadGuard guard(g_readerWriterLock);
- auto&& iter = typeIdToPdxType.find(typeId);
- if (iter != typeIdToPdxType.end()) {
+ ReadGuard guard(g_readerWriterLock_);
+ auto&& iter = typeIdToPdxType_.find(typeId);
+ if (iter != typeIdToPdxType_.end()) {
return iter->second;
}
return nullptr;
@@ -134,15 +133,15 @@ std::shared_ptr<PdxType> PdxTypeRegistry::getPdxType(int32_t typeId) const {
void PdxTypeRegistry::addLocalPdxType(const std::string& localType,
std::shared_ptr<PdxType> pdxType) {
- WriteGuard guard(g_readerWriterLock);
- localTypeToPdxType.emplace(localType, pdxType);
+ WriteGuard guard(g_readerWriterLock_);
+ localTypeToPdxType_.emplace(localType, pdxType);
}
std::shared_ptr<PdxType> PdxTypeRegistry::getLocalPdxType(
const std::string& localType) const {
- ReadGuard guard(g_readerWriterLock);
- auto&& it = localTypeToPdxType.find(localType);
- if (it != localTypeToPdxType.end()) {
+ ReadGuard guard(g_readerWriterLock_);
+ auto&& it = localTypeToPdxType_.find(localType);
+ if (it != localTypeToPdxType_.end()) {
return it->second;
}
return nullptr;
@@ -150,14 +149,14 @@ std::shared_ptr<PdxType> PdxTypeRegistry::getLocalPdxType(
void PdxTypeRegistry::setMergedType(int32_t remoteTypeId,
std::shared_ptr<PdxType> mergedType) {
- WriteGuard guard(g_readerWriterLock);
- remoteTypeIdToMergedPdxType.emplace(remoteTypeId, mergedType);
+ WriteGuard guard(g_readerWriterLock_);
+ remoteTypeIdToMergedPdxType_.emplace(remoteTypeId, mergedType);
}
std::shared_ptr<PdxType> PdxTypeRegistry::getMergedType(
int32_t remoteTypeId) const {
- auto&& it = remoteTypeIdToMergedPdxType.find(remoteTypeId);
- if (it != remoteTypeIdToMergedPdxType.end()) {
+ auto&& it = remoteTypeIdToMergedPdxType_.find(remoteTypeId);
+ if (it != remoteTypeIdToMergedPdxType_.end()) {
return it->second;
}
return nullptr;
@@ -169,14 +168,14 @@ void PdxTypeRegistry::setPreserveData(
ExpiryTaskManager& expiryTaskManager) {
WriteGuard guard(getPreservedDataLock());
pData->setOwner(obj);
- if (preserveData.find(obj) != preserveData.end()) {
+ if (preserveData_.find(obj) != preserveData_.end()) {
// reset expiry task
// TODO: check value for nullptr
- auto expTaskId = preserveData[obj]->getPreservedDataExpiryTaskId();
+ auto expTaskId = preserveData_[obj]->getPreservedDataExpiryTaskId();
expiryTaskManager.resetTask(expTaskId, 5);
LOGDEBUG("PdxTypeRegistry::setPreserveData Reset expiry task Done");
pData->setPreservedDataExpiryTaskId(expTaskId);
- preserveData[obj] = pData;
+ preserveData_[obj] = pData;
} else {
// schedule new expiry task
auto handler = new PreservedDataExpiryHandler(shared_from_this(), obj);
@@ -186,7 +185,7 @@ void PdxTypeRegistry::setPreserveData(
LOGDEBUG(
"PdxTypeRegistry::setPreserveData Schedule new expirt task with id=%ld",
id);
- preserveData.emplace(obj, pData);
+ preserveData_.emplace(obj, pData);
}
LOGDEBUG(
@@ -196,8 +195,8 @@ void PdxTypeRegistry::setPreserveData(
std::shared_ptr<PdxRemotePreservedData> PdxTypeRegistry::getPreserveData(
std::shared_ptr<PdxSerializable> pdxobj) const {
ReadGuard guard(getPreservedDataLock());
- const auto& iter = preserveData.find((pdxobj));
- if (iter != preserveData.end()) {
+ const auto& iter = preserveData_.find((pdxobj));
+ if (iter != preserveData_.end()) {
return iter->second;
}
return nullptr;
@@ -206,15 +205,15 @@ std::shared_ptr<PdxRemotePreservedData> PdxTypeRegistry::getPreserveData(
int32_t PdxTypeRegistry::getEnumValue(std::shared_ptr<EnumInfo> ei) {
// TODO locking - naive concurrent optimization?
std::shared_ptr<CacheableHashMap> tmp;
- tmp = enumToInt;
+ tmp = enumToInt_;
const auto& entry = tmp->find(ei);
if (entry != tmp->end()) {
const auto val = std::dynamic_pointer_cast<CacheableInt32>(entry->second);
return val->value();
}
- WriteGuard guard(g_readerWriterLock);
- tmp = enumToInt;
+ WriteGuard guard(g_readerWriterLock_);
+ tmp = enumToInt_;
const auto& entry2 = tmp->find(ei);
if (entry2 != tmp->end()) {
const auto val2 = std::dynamic_pointer_cast<CacheableInt32>(entry2->second);
@@ -222,12 +221,12 @@ int32_t PdxTypeRegistry::getEnumValue(std::shared_ptr<EnumInfo> ei) {
}
int val = static_cast<ThinClientPoolDM*>(
- cache->getPoolManager().getAll().begin()->second.get())
+ cache_->getPoolManager().getAll().begin()->second.get())
->GetEnumValue(ei);
- tmp = enumToInt;
+ tmp = enumToInt_;
tmp->emplace(ei, CacheableInt32::create(val));
- enumToInt = tmp;
+ enumToInt_ = tmp;
return val;
}
@@ -235,7 +234,7 @@ std::shared_ptr<EnumInfo> PdxTypeRegistry::getEnum(int32_t enumVal) {
// TODO locking - naive concurrent optimization?
auto enumValPtr = CacheableInt32::create(enumVal);
- auto&& tmp = intToEnum;
+ auto&& tmp = intToEnum_;
{
auto&& entry = tmp->find(enumValPtr);
if (entry != tmp->end()) {
@@ -246,8 +245,8 @@ std::shared_ptr<EnumInfo> PdxTypeRegistry::getEnum(int32_t enumVal) {
}
}
- WriteGuard guard(g_readerWriterLock);
- tmp = intToEnum;
+ WriteGuard guard(g_readerWriterLock_);
+ tmp = intToEnum_;
{
auto&& entry = tmp->find(enumValPtr);
if (entry != tmp->end()) {
@@ -260,11 +259,11 @@ std::shared_ptr<EnumInfo> PdxTypeRegistry::getEnum(int32_t enumVal) {
auto&& ret = std::dynamic_pointer_cast<EnumInfo>(
std::static_pointer_cast<ThinClientPoolDM>(
- cache->getPoolManager().getAll().begin()->second)
+ cache_->getPoolManager().getAll().begin()->second)
->GetEnum(enumVal));
- tmp = intToEnum;
+ tmp = intToEnum_;
(*tmp)[enumValPtr] = ret;
- intToEnum = tmp;
+ intToEnum_ = tmp;
return std::move(ret);
}
} // namespace client
diff --git a/cppcache/src/PdxTypeRegistry.hpp b/cppcache/src/PdxTypeRegistry.hpp
index 70f4cdd..af69575 100644
--- a/cppcache/src/PdxTypeRegistry.hpp
+++ b/cppcache/src/PdxTypeRegistry.hpp
@@ -54,30 +54,30 @@ typedef std::unordered_map<std::shared_ptr<PdxType>, int32_t,
class APACHE_GEODE_EXPORT PdxTypeRegistry
: public std::enable_shared_from_this<PdxTypeRegistry> {
private:
- CacheImpl* cache;
+ CacheImpl* cache_;
- TypeIdVsPdxType typeIdToPdxType;
+ TypeIdVsPdxType typeIdToPdxType_;
- TypeIdVsPdxType remoteTypeIdToMergedPdxType;
+ TypeIdVsPdxType remoteTypeIdToMergedPdxType_;
- TypeNameVsPdxType localTypeToPdxType;
+ TypeNameVsPdxType localTypeToPdxType_;
- PdxTypeToTypeIdMap pdxTypeToTypeIdMap;
+ PdxTypeToTypeIdMap pdxTypeToTypeIdMap_;
// TODO:: preserveData need to be of type WeakHashMap
- PreservedHashMap preserveData;
+ PreservedHashMap preserveData_;
- mutable ACE_RW_Thread_Mutex g_readerWriterLock;
+ mutable ACE_RW_Thread_Mutex g_readerWriterLock_;
- mutable ACE_RW_Thread_Mutex g_preservedDataLock;
+ mutable ACE_RW_Thread_Mutex g_preservedDataLock_;
- bool pdxIgnoreUnreadFields;
+ bool pdxIgnoreUnreadFields_;
- bool pdxReadSerialized;
+ bool pdxReadSerialized_;
- std::shared_ptr<CacheableHashMap> enumToInt;
+ std::shared_ptr<CacheableHashMap> enumToInt_;
- std::shared_ptr<CacheableHashMap> intToEnum;
+ std::shared_ptr<CacheableHashMap> intToEnum_;
public:
explicit PdxTypeRegistry(CacheImpl* cache);
@@ -114,16 +114,16 @@ class APACHE_GEODE_EXPORT PdxTypeRegistry
int32_t getPDXIdForType(const std::string& type, Pool* pool,
std::shared_ptr<PdxType> nType, bool checkIfThere);
- bool getPdxIgnoreUnreadFields() const { return pdxIgnoreUnreadFields; }
+ bool getPdxIgnoreUnreadFields() const { return pdxIgnoreUnreadFields_; }
- void setPdxIgnoreUnreadFields(bool value) { pdxIgnoreUnreadFields = value; }
+ void setPdxIgnoreUnreadFields(bool value) { pdxIgnoreUnreadFields_ = value; }
- void setPdxReadSerialized(bool value) { pdxReadSerialized = value; }
+ void setPdxReadSerialized(bool value) { pdxReadSerialized_ = value; }
- bool getPdxReadSerialized() const { return pdxReadSerialized; }
+ bool getPdxReadSerialized() const { return pdxReadSerialized_; }
inline const PreservedHashMap& getPreserveDataMap() const {
- return preserveData;
+ return preserveData_;
}
int32_t getEnumValue(std::shared_ptr<EnumInfo> ei);
@@ -133,7 +133,7 @@ class APACHE_GEODE_EXPORT PdxTypeRegistry
int32_t getPDXIdForType(std::shared_ptr<PdxType> nType, Pool* pool);
ACE_RW_Thread_Mutex& getPreservedDataLock() const {
- return g_preservedDataLock;
+ return g_preservedDataLock_;
}
};
diff --git a/cppcache/src/statistics/StatArchiveWriter.cpp b/cppcache/src/statistics/StatArchiveWriter.cpp
index 29d0707..39cc773 100644
--- a/cppcache/src/statistics/StatArchiveWriter.cpp
+++ b/cppcache/src/statistics/StatArchiveWriter.cpp
@@ -317,38 +317,37 @@ void ResourceInst::writeResourceInst(StatDataOutput *dataOutArg,
StatArchiveWriter::StatArchiveWriter(std::string outfile,
HostStatSampler *samplerArg,
CacheImpl *cache)
- : cache(cache) {
- resourceTypeId = 0;
- resourceInstId = 0;
- statResourcesModCount = 0;
- archiveFile = outfile;
- bytesWrittenToFile = 0;
+ : cache_(cache) {
+ resourceTypeId_ = 0;
+ resourceInstId_ = 0;
+ archiveFile_ = outfile;
+ bytesWrittenToFile_ = 0;
- m_samplesize = 0;
+ sampleSize_ = 0;
- dataBuffer = new StatDataOutput(archiveFile, cache);
- this->sampler = samplerArg;
+ dataBuffer_ = new StatDataOutput(archiveFile_, cache);
+ this->sampler_ = samplerArg;
// write the time, system property etc.
- this->previousTimeStamp = steady_clock::now();
+ this->previousTimeStamp_ = steady_clock::now();
- this->dataBuffer->writeByte(HEADER_TOKEN);
- this->dataBuffer->writeByte(ARCHIVE_VERSION);
- this->dataBuffer->writeLong(
+ this->dataBuffer_->writeByte(HEADER_TOKEN);
+ this->dataBuffer_->writeByte(ARCHIVE_VERSION);
+ this->dataBuffer_->writeLong(
duration_cast<milliseconds>(system_clock::now().time_since_epoch())
.count());
- int64_t sysId = sampler->getSystemId();
- this->dataBuffer->writeLong(sysId);
- this->dataBuffer->writeLong(
+ int64_t sysId = sampler_->getSystemId();
+ this->dataBuffer_->writeLong(sysId);
+ this->dataBuffer_->writeLong(
duration_cast<milliseconds>(
- sampler->getSystemStartTime().time_since_epoch())
+ sampler_->getSystemStartTime().time_since_epoch())
.count());
// C++20: Use std::chrono::time_zone
boost::posix_time::time_duration timeZoneOffset(
boost::posix_time::second_clock::local_time() -
boost::posix_time::second_clock::universal_time());
- this->dataBuffer->writeInt(
+ this->dataBuffer_->writeInt(
static_cast<int32_t>(timeZoneOffset.total_milliseconds()));
// C++20: Use std::chrono::time_zone
@@ -356,71 +355,69 @@ StatArchiveWriter::StatArchiveWriter(std::string outfile,
auto localTime = apache::geode::util::chrono::localtime(now);
std::ostringstream timeZoneId;
timeZoneId << std::put_time(&localTime, "%Z");
- this->dataBuffer->writeUTF(timeZoneId.str());
+ this->dataBuffer_->writeUTF(timeZoneId.str());
- this->dataBuffer->writeUTF(sampler->getSystemDirectoryPath());
- this->dataBuffer->writeUTF(sampler->getProductDescription());
- this->dataBuffer->writeUTF(GEODE_SYSTEM_NAME);
- this->dataBuffer->writeUTF(std::string(GEODE_SYSTEM_PROCESSOR) + " " +
- boost::asio::ip::host_name());
+ this->dataBuffer_->writeUTF(sampler_->getSystemDirectoryPath());
+ this->dataBuffer_->writeUTF(sampler_->getProductDescription());
+ this->dataBuffer_->writeUTF(GEODE_SYSTEM_NAME);
+ this->dataBuffer_->writeUTF(std::string(GEODE_SYSTEM_PROCESSOR) + " " +
+ boost::asio::ip::host_name());
resampleResources();
}
StatArchiveWriter::~StatArchiveWriter() {
- if (dataBuffer != nullptr) {
- delete dataBuffer;
- dataBuffer = nullptr;
+ if (dataBuffer_ != nullptr) {
+ delete dataBuffer_;
+ dataBuffer_ = nullptr;
}
- for (const auto &p : resourceTypeMap) {
+ for (const auto &p : resourceTypeMap_) {
auto rt = p.second;
_GEODE_SAFE_DELETE(rt);
}
}
-size_t StatArchiveWriter::bytesWritten() { return bytesWrittenToFile; }
+size_t StatArchiveWriter::bytesWritten() { return bytesWrittenToFile_; }
-size_t StatArchiveWriter::getSampleSize() { return m_samplesize; }
+size_t StatArchiveWriter::getSampleSize() { return sampleSize_; }
void StatArchiveWriter::sample(const steady_clock::time_point &timeStamp) {
- std::lock_guard<decltype(sampler->getStatListMutex())> guard(
- sampler->getStatListMutex());
- m_samplesize = dataBuffer->getBytesWritten();
+ std::lock_guard<decltype(sampler_->getStatListMutex())> guard(
+ sampler_->getStatListMutex());
+ sampleSize_ = dataBuffer_->getBytesWritten();
sampleResources();
- this->dataBuffer->writeByte(SAMPLE_TOKEN);
+ this->dataBuffer_->writeByte(SAMPLE_TOKEN);
writeTimeStamp(timeStamp);
- for (auto p = resourceInstMap.begin(); p != resourceInstMap.end(); p++) {
+ for (auto p = resourceInstMap_.begin(); p != resourceInstMap_.end(); p++) {
auto ri = (*p).second;
if (!!ri && (*p).first != nullptr) {
ri->writeSample();
}
}
- writeResourceInst(this->dataBuffer,
+ writeResourceInst(this->dataBuffer_,
static_cast<int32_t>(ILLEGAL_RESOURCE_INST_ID));
- m_samplesize = dataBuffer->getBytesWritten() - m_samplesize;
+ sampleSize_ = dataBuffer_->getBytesWritten() - sampleSize_;
}
void StatArchiveWriter::sample() { sample(steady_clock::now()); }
void StatArchiveWriter::close() {
sample();
- this->dataBuffer->flush();
- this->dataBuffer->close();
+ this->dataBuffer_->flush();
+ this->dataBuffer_->close();
}
-void StatArchiveWriter::closeFile() { this->dataBuffer->close(); }
+void StatArchiveWriter::closeFile() { this->dataBuffer_->close(); }
void StatArchiveWriter::openFile(std::string filename) {
- // this->dataBuffer->openFile(filename, m_samplesize);
-
- StatDataOutput *p_dataBuffer = new StatDataOutput(filename, cache);
+ StatDataOutput *p_dataBuffer = new StatDataOutput(filename, cache_);
- const uint8_t *buffBegin = dataBuffer->dataBuffer->getBuffer();
+ const uint8_t *buffBegin = dataBuffer_->dataBuffer->getBuffer();
if (buffBegin == nullptr) {
throw NullPointerException("undefined stat data buffer beginning");
}
- const uint8_t *buffEnd = dataBuffer->dataBuffer->getCursor();
+ const uint8_t *buffEnd = dataBuffer_->dataBuffer->getCursor();
if (buffEnd == nullptr) {
throw NullPointerException("undefined stat data buffer end");
}
@@ -430,16 +427,14 @@ void StatArchiveWriter::openFile(std::string filename) {
p_dataBuffer->writeByte(buffBegin[pos]);
}
- delete dataBuffer;
- dataBuffer = p_dataBuffer;
-
- // sample();
+ delete dataBuffer_;
+ dataBuffer_ = p_dataBuffer;
}
void StatArchiveWriter::flush() {
- this->dataBuffer->flush();
- bytesWrittenToFile += dataBuffer->getBytesWritten();
- this->dataBuffer->resetBuffer();
+ this->dataBuffer_->flush();
+ bytesWrittenToFile_ += dataBuffer_->getBytesWritten();
+ this->dataBuffer_->resetBuffer();
/*
// have to figure out the problem with this code.
delete dataBuffer;
@@ -451,7 +446,7 @@ void StatArchiveWriter::flush() {
void StatArchiveWriter::sampleResources() {
// Allocate ResourceInst for newly added stats ( Locked lists already )
- std::vector<Statistics *> &newStatsList = sampler->getNewStatistics();
+ std::vector<Statistics *> &newStatsList = sampler_->getNewStatistics();
std::vector<Statistics *>::iterator newlistIter;
for (newlistIter = newStatsList.begin(); newlistIter != newStatsList.end();
++newlistIter) {
@@ -464,18 +459,18 @@ void StatArchiveWriter::sampleResources() {
// for closed stats, write token and then delete from statlist and
// resourceInstMap.
std::map<Statistics *, std::shared_ptr<ResourceInst>>::iterator mapIter;
- std::vector<Statistics *> &statsList = sampler->getStatistics();
+ std::vector<Statistics *> &statsList = sampler_->getStatistics();
std::vector<Statistics *>::iterator statlistIter = statsList.begin();
while (statlistIter != statsList.end()) {
if ((*statlistIter)->isClosed()) {
- mapIter = resourceInstMap.find(*statlistIter);
- if (mapIter != resourceInstMap.end()) {
+ mapIter = resourceInstMap_.find(*statlistIter);
+ if (mapIter != resourceInstMap_.end()) {
// Write delete token to file and delete from map
auto rinst = (*mapIter).second;
int32_t id = rinst->getId();
- this->dataBuffer->writeByte(RESOURCE_INSTANCE_DELETE_TOKEN);
- this->dataBuffer->writeInt(id);
- resourceInstMap.erase(mapIter);
+ this->dataBuffer_->writeByte(RESOURCE_INSTANCE_DELETE_TOKEN);
+ this->dataBuffer_->writeInt(id);
+ resourceInstMap_.erase(mapIter);
}
// Delete stats object stat list
StatisticsManager::deleteStatistics(*statlistIter);
@@ -488,9 +483,9 @@ void StatArchiveWriter::sampleResources() {
}
void StatArchiveWriter::resampleResources() {
- std::lock_guard<decltype(sampler->getStatListMutex())> guard(
- sampler->getStatListMutex());
- std::vector<Statistics *> &statsList = sampler->getStatistics();
+ std::lock_guard<decltype(sampler_->getStatListMutex())> guard(
+ sampler_->getStatListMutex());
+ std::vector<Statistics *> &statsList = sampler_->getStatistics();
std::vector<Statistics *>::iterator statlistIter = statsList.begin();
while (statlistIter != statsList.end()) {
if (!(*statlistIter)->isClosed()) {
@@ -503,19 +498,20 @@ void StatArchiveWriter::resampleResources() {
void StatArchiveWriter::writeTimeStamp(
const steady_clock::time_point &timeStamp) {
auto delta = static_cast<int32_t>(
- duration_cast<milliseconds>(timeStamp - this->previousTimeStamp).count());
+ duration_cast<milliseconds>(timeStamp - this->previousTimeStamp_)
+ .count());
if (delta > MAX_SHORT_TIMESTAMP) {
- dataBuffer->writeShort(static_cast<uint16_t>(INT_TIMESTAMP_TOKEN));
- dataBuffer->writeInt(delta);
+ dataBuffer_->writeShort(static_cast<uint16_t>(INT_TIMESTAMP_TOKEN));
+ dataBuffer_->writeInt(delta);
} else {
- dataBuffer->writeShort(static_cast<uint16_t>(delta));
+ dataBuffer_->writeShort(static_cast<uint16_t>(delta));
}
- this->previousTimeStamp = timeStamp;
+ this->previousTimeStamp_ = timeStamp;
}
bool StatArchiveWriter::resourceInstMapHas(Statistics *sp) {
- auto p = resourceInstMap.find(sp);
- if (p != resourceInstMap.end()) {
+ auto p = resourceInstMap_.find(sp);
+ if (p != resourceInstMap_.end()) {
return true;
} else {
return false;
@@ -527,16 +523,16 @@ void StatArchiveWriter::allocateResourceInst(Statistics *s) {
const auto type = getResourceType(s);
auto ri = std::shared_ptr<ResourceInst>(
- new ResourceInst(resourceInstId, s, type, dataBuffer));
- resourceInstMap.insert(
+ new ResourceInst(resourceInstId_, s, type, dataBuffer_));
+ resourceInstMap_.insert(
std::pair<Statistics *, std::shared_ptr<ResourceInst>>(s, ri));
- this->dataBuffer->writeByte(RESOURCE_INSTANCE_CREATE_TOKEN);
- this->dataBuffer->writeInt(resourceInstId);
- this->dataBuffer->writeUTF(s->getTextId());
- this->dataBuffer->writeLong(s->getNumericId());
- this->dataBuffer->writeInt(type->getId());
+ this->dataBuffer_->writeByte(RESOURCE_INSTANCE_CREATE_TOKEN);
+ this->dataBuffer_->writeInt(resourceInstId_);
+ this->dataBuffer_->writeUTF(s->getTextId());
+ this->dataBuffer_->writeLong(s->getNumericId());
+ this->dataBuffer_->writeInt(type->getId());
- resourceInstId++;
+ resourceInstId_++;
}
const ResourceType *StatArchiveWriter::getResourceType(const Statistics *s) {
@@ -546,40 +542,40 @@ const ResourceType *StatArchiveWriter::getResourceType(const Statistics *s) {
"could not know the type of the statistics object");
}
const ResourceType *rt = nullptr;
- const auto p = resourceTypeMap.find(type);
- if (p != resourceTypeMap.end()) {
+ const auto p = resourceTypeMap_.find(type);
+ if (p != resourceTypeMap_.end()) {
rt = p->second;
} else {
- rt = new ResourceType(resourceTypeId, type);
+ rt = new ResourceType(resourceTypeId_, type);
if (type == nullptr) {
throw NullPointerException(
"could not allocate memory for a new resourcetype");
}
- resourceTypeMap.emplace(type, rt);
+ resourceTypeMap_.emplace(type, rt);
// write the type to the archive
- this->dataBuffer->writeByte(RESOURCE_TYPE_TOKEN);
- this->dataBuffer->writeInt(resourceTypeId);
- this->dataBuffer->writeUTF(type->getName());
- this->dataBuffer->writeUTF(type->getDescription());
+ this->dataBuffer_->writeByte(RESOURCE_TYPE_TOKEN);
+ this->dataBuffer_->writeInt(resourceTypeId_);
+ this->dataBuffer_->writeUTF(type->getName());
+ this->dataBuffer_->writeUTF(type->getDescription());
auto stats = rt->getStats();
auto descCnt = rt->getNumOfDescriptors();
- this->dataBuffer->writeShort(static_cast<int16_t>(descCnt));
+ this->dataBuffer_->writeShort(static_cast<int16_t>(descCnt));
for (decltype(descCnt) i = 0; i < descCnt; i++) {
std::string statsName = stats[i]->getName();
- this->dataBuffer->writeUTF(statsName);
+ this->dataBuffer_->writeUTF(statsName);
auto sdImpl = std::static_pointer_cast<StatisticDescriptorImpl>(stats[i]);
if (sdImpl == nullptr) {
throw NullPointerException(
"could not down cast to StatisticDescriptorImpl");
}
- this->dataBuffer->writeByte(static_cast<int8_t>(sdImpl->getTypeCode()));
- this->dataBuffer->writeBoolean(stats[i]->isCounter());
- this->dataBuffer->writeBoolean(stats[i]->isLargerBetter());
- this->dataBuffer->writeUTF(stats[i]->getUnit());
- this->dataBuffer->writeUTF(stats[i]->getDescription());
+ this->dataBuffer_->writeByte(static_cast<int8_t>(sdImpl->getTypeCode()));
+ this->dataBuffer_->writeBoolean(stats[i]->isCounter());
+ this->dataBuffer_->writeBoolean(stats[i]->isLargerBetter());
+ this->dataBuffer_->writeUTF(stats[i]->getUnit());
+ this->dataBuffer_->writeUTF(stats[i]->getDescription());
}
// increment resourceTypeId
- resourceTypeId++;
+ resourceTypeId_++;
}
return rt;
}
diff --git a/cppcache/src/statistics/StatArchiveWriter.hpp b/cppcache/src/statistics/StatArchiveWriter.hpp
index a343647..0a0b2d9 100644
--- a/cppcache/src/statistics/StatArchiveWriter.hpp
+++ b/cppcache/src/statistics/StatArchiveWriter.hpp
@@ -179,18 +179,17 @@ class APACHE_GEODE_EXPORT ResourceInst {
class HostStatSampler;
class APACHE_GEODE_EXPORT StatArchiveWriter {
- HostStatSampler *sampler;
- StatDataOutput *dataBuffer;
- CacheImpl *cache;
- steady_clock::time_point previousTimeStamp;
- int32_t resourceTypeId;
- int32_t resourceInstId;
- int32_t statResourcesModCount;
- size_t bytesWrittenToFile;
- size_t m_samplesize;
- std::string archiveFile;
- std::map<Statistics *, std::shared_ptr<ResourceInst>> resourceInstMap;
- std::map<const StatisticsType *, const ResourceType *> resourceTypeMap;
+ HostStatSampler *sampler_;
+ StatDataOutput *dataBuffer_;
+ CacheImpl *cache_;
+ steady_clock::time_point previousTimeStamp_;
+ int32_t resourceTypeId_;
+ int32_t resourceInstId_;
+ size_t bytesWrittenToFile_;
+ size_t sampleSize_;
+ std::string archiveFile_;
+ std::map<Statistics *, std::shared_ptr<ResourceInst>> resourceInstMap_;
+ std::map<const StatisticsType *, const ResourceType *> resourceTypeMap_;
void allocateResourceInst(Statistics *r);
void sampleResources();
diff --git a/cppcache/test/ConnectionQueueTest.cpp b/cppcache/test/ConnectionQueueTest.cpp
index dd1e6ed..cae1da2 100644
--- a/cppcache/test/ConnectionQueueTest.cpp
+++ b/cppcache/test/ConnectionQueueTest.cpp
@@ -44,16 +44,16 @@ struct TestObjectState {
class TestObject {
private:
- TestObjectState* const state;
+ TestObjectState* const state_;
public:
- TestObject() : state(nullptr) {}
- explicit TestObject(TestObjectState* state) : state(state) {}
+ TestObject() : state_(nullptr) {}
+ explicit TestObject(TestObjectState* state) : state_(state) {}
~TestObject() {
- if (state) state->destructed = true;
+ if (state_) state_->destructed = true;
}
void close() {
- if (state) state->closed = true;
+ if (state_) state_->closed = true;
}
};