Repository: geode-native Updated Branches: refs/heads/develop d898e629b -> ce35534e6
GEODE-2741: Fixed quickstarts impacted by shared_ptr Project: http://git-wip-us.apache.org/repos/asf/geode-native/repo Commit: http://git-wip-us.apache.org/repos/asf/geode-native/commit/ce35534e Tree: http://git-wip-us.apache.org/repos/asf/geode-native/tree/ce35534e Diff: http://git-wip-us.apache.org/repos/asf/geode-native/diff/ce35534e Branch: refs/heads/develop Commit: ce35534e61469857682f55edc476e7e72a602f6d Parents: d898e62 Author: Ernest Burghardt <eburgha...@pivotal.io> Authored: Thu Jul 20 17:18:21 2017 -0600 Committer: Ernest Burghardt <eburgha...@pivotal.io> Committed: Thu Jul 20 17:19:03 2017 -0600 ---------------------------------------------------------------------- src/quickstart/cpp/DataExpiration.cpp | 7 ++++--- src/quickstart/cpp/DurableClient.cpp | 2 ++ src/quickstart/cpp/HACache.cpp | 4 +++- src/quickstart/cpp/PdxInstance.cpp | 2 +- src/quickstart/cpp/PdxSerializer.cpp | 2 +- src/quickstart/cpp/PutAllGetAllOperations.cpp | 3 +-- src/quickstart/cpp/TransactionsXA.cpp | 2 +- src/quickstart/cpp/queryobjects/Portfolio.cpp | 8 ++++---- src/quickstart/cpp/queryobjects/PortfolioPdx.cpp | 9 ++++----- 9 files changed, 21 insertions(+), 18 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/geode-native/blob/ce35534e/src/quickstart/cpp/DataExpiration.cpp ---------------------------------------------------------------------- diff --git a/src/quickstart/cpp/DataExpiration.cpp b/src/quickstart/cpp/DataExpiration.cpp index 004213d..130fc1a 100644 --- a/src/quickstart/cpp/DataExpiration.cpp +++ b/src/quickstart/cpp/DataExpiration.cpp @@ -36,6 +36,8 @@ // Include the Geode library. #include <geode/GeodeCppCache.hpp> +#include <chrono> +#include <thread> // Include the SimpleCacheListener plugin. #include "plugins/SimpleCacheListener.hpp" @@ -85,8 +87,7 @@ int main(int argc, char** argv) { LOGINFO("Got Entry Idle Timeout as %d seconds", entryIdleTimeout); // Wait for half the Entry Idle Timeout duration, using - // apache::geode::client::millisleep(). - millisleep(entryIdleTimeout * 1000 / 2); + std::this_thread::sleep_for(std::chrono::milliseconds(entryIdleTimeout * 1000 / 2)); // Get the number of Keys remaining in the Region, should be all 3. VectorOfCacheableKey keys; @@ -103,7 +104,7 @@ int main(int argc, char** argv) { // Wait for the entire Entry Idle Timeout duration, using // apache::geode::client::millisleep(). - apache::geode::client::millisleep(entryIdleTimeout * 1000); + std::this_thread::sleep_for(std::chrono::milliseconds(entryIdleTimeout * 1000)); // Get the number of Keys remaining in the Region, should be 0 now. regionPtr->keys(keys); http://git-wip-us.apache.org/repos/asf/geode-native/blob/ce35534e/src/quickstart/cpp/DurableClient.cpp ---------------------------------------------------------------------- diff --git a/src/quickstart/cpp/DurableClient.cpp b/src/quickstart/cpp/DurableClient.cpp index b406237..3d82abb 100644 --- a/src/quickstart/cpp/DurableClient.cpp +++ b/src/quickstart/cpp/DurableClient.cpp @@ -31,6 +31,8 @@ // Include the Geode library. #include <geode/GeodeCppCache.hpp> +#include <chrono> +#include <thread> // Include cachelistener #include "plugins/DurableCacheListener.hpp" http://git-wip-us.apache.org/repos/asf/geode-native/blob/ce35534e/src/quickstart/cpp/HACache.cpp ---------------------------------------------------------------------- diff --git a/src/quickstart/cpp/HACache.cpp b/src/quickstart/cpp/HACache.cpp index bef557d..73a1bac 100644 --- a/src/quickstart/cpp/HACache.cpp +++ b/src/quickstart/cpp/HACache.cpp @@ -32,6 +32,8 @@ // Include the Geode library. #include <geode/GeodeCppCache.hpp> +#include <chrono> +#include <thread> // Use the "geode" namespace. using namespace apache::geode::client; @@ -77,7 +79,7 @@ int main(int argc, char** argv) { LOGINFO("Called put() on Region"); LOGINFO("Waiting for updates on keys"); - millisleep(10000); + std::this_thread::sleep_for(std::chrono::milliseconds(10000)); int count = 0; http://git-wip-us.apache.org/repos/asf/geode-native/blob/ce35534e/src/quickstart/cpp/PdxInstance.cpp ---------------------------------------------------------------------- diff --git a/src/quickstart/cpp/PdxInstance.cpp b/src/quickstart/cpp/PdxInstance.cpp index d5277a1..64ea59a 100644 --- a/src/quickstart/cpp/PdxInstance.cpp +++ b/src/quickstart/cpp/PdxInstance.cpp @@ -93,7 +93,7 @@ int main(int argc, char** argv) { LOGINFO("Populated PdxInstance Object"); - PdxInstancePtr retPdxInstance = regionPtr->get("Key1"); + PdxInstancePtr retPdxInstance = std::dynamic_pointer_cast<apache::geode::client::PdxInstance>(regionPtr->get("Key1")); LOGINFO("Got PdxInstance Object"); http://git-wip-us.apache.org/repos/asf/geode-native/blob/ce35534e/src/quickstart/cpp/PdxSerializer.cpp ---------------------------------------------------------------------- diff --git a/src/quickstart/cpp/PdxSerializer.cpp b/src/quickstart/cpp/PdxSerializer.cpp index 1d76ad3..b394c28 100644 --- a/src/quickstart/cpp/PdxSerializer.cpp +++ b/src/quickstart/cpp/PdxSerializer.cpp @@ -218,7 +218,7 @@ int main(int argc, char** argv) { LOGINFO("Region Query returned %d rows", resultsPtr->size()); // Execute the Region selectValue() API. - PdxWrapperPtr pdxWrapperPtr = regionPtr->selectValue("m_id = 3"); + PdxWrapperPtr pdxWrapperPtr = std::dynamic_pointer_cast<apache::geode::client::PdxWrapper>(regionPtr->selectValue("m_id = 3")); Person* per = reinterpret_cast<Person*>(pdxWrapperPtr->getObject()); LOGINFO( http://git-wip-us.apache.org/repos/asf/geode-native/blob/ce35534e/src/quickstart/cpp/PutAllGetAllOperations.cpp ---------------------------------------------------------------------- diff --git a/src/quickstart/cpp/PutAllGetAllOperations.cpp b/src/quickstart/cpp/PutAllGetAllOperations.cpp index f79ed0b..5750fc4 100644 --- a/src/quickstart/cpp/PutAllGetAllOperations.cpp +++ b/src/quickstart/cpp/PutAllGetAllOperations.cpp @@ -60,8 +60,7 @@ int main(int argc, char** argv) { for (int32_t item = 0; item < 100; item++) { sprintf(key, "key-%d", item); sprintf(value, "%d", item); - entryMap.insert(CacheableKey::create(key), - CacheableString::create(value)); + entryMap[CacheableKey::create(key)] = CacheableString::create(value); } regionPtr->putAll(entryMap); http://git-wip-us.apache.org/repos/asf/geode-native/blob/ce35534e/src/quickstart/cpp/TransactionsXA.cpp ---------------------------------------------------------------------- diff --git a/src/quickstart/cpp/TransactionsXA.cpp b/src/quickstart/cpp/TransactionsXA.cpp index 61dfc5a..745f83f 100644 --- a/src/quickstart/cpp/TransactionsXA.cpp +++ b/src/quickstart/cpp/TransactionsXA.cpp @@ -65,7 +65,7 @@ int main(int argc, char** argv) { LOGINFO("Created the Region Programmatically."); InternalCacheTransactionManager2PCPtr txManager = - static_cast<InternalCacheTransactionManager2PCPtr>( + std::dynamic_pointer_cast<apache::geode::client::InternalCacheTransactionManager2PC>( cachePtr->getCacheTransactionManager()); // start a transaction http://git-wip-us.apache.org/repos/asf/geode-native/blob/ce35534e/src/quickstart/cpp/queryobjects/Portfolio.cpp ---------------------------------------------------------------------- diff --git a/src/quickstart/cpp/queryobjects/Portfolio.cpp b/src/quickstart/cpp/queryobjects/Portfolio.cpp index f9828eb..351c714 100644 --- a/src/quickstart/cpp/queryobjects/Portfolio.cpp +++ b/src/quickstart/cpp/queryobjects/Portfolio.cpp @@ -16,6 +16,7 @@ */ #include "Portfolio.hpp" +#include <memory> using namespace apache::geode::client; using namespace testobject; @@ -38,16 +39,15 @@ Portfolio::Portfolio(int32_t i, uint32_t size, CacheableStringArrayPtr nm) type = CacheableString::create(buf); int numSecIds = sizeof(secIds) / sizeof(char*); position1 = - new Position(secIds[Position::cnt % numSecIds], Position::cnt * 1000); + std::make_shared<Position>(secIds[Position::cnt % numSecIds], Position::cnt * 1000); if (i % 2 != 0) { position2 = - new Position(secIds[Position::cnt % numSecIds], Position::cnt * 1000); + std::make_shared<Position>(secIds[Position::cnt % numSecIds], Position::cnt * 1000); } else { position2 = nullptr; } positions = CacheableHashMap::create(); - positions->insert(CacheableString::create(secIds[Position::cnt % numSecIds]), - position1); + (*positions)[CacheableString::create(secIds[Position::cnt % numSecIds])] = position1; newVal = new uint8_t[size + 1]; memset(newVal, 'B', size); newVal[size] = '\0'; http://git-wip-us.apache.org/repos/asf/geode-native/blob/ce35534e/src/quickstart/cpp/queryobjects/PortfolioPdx.cpp ---------------------------------------------------------------------- diff --git a/src/quickstart/cpp/queryobjects/PortfolioPdx.cpp b/src/quickstart/cpp/queryobjects/PortfolioPdx.cpp index c505514..516921b 100644 --- a/src/quickstart/cpp/queryobjects/PortfolioPdx.cpp +++ b/src/quickstart/cpp/queryobjects/PortfolioPdx.cpp @@ -44,17 +44,16 @@ PortfolioPdx::PortfolioPdx(int32_t i, int32_t size, char** nm) : names(nm) { memcpy(type, buf, strSize2); int numSecIds = sizeof(secIds) / sizeof(char*); - position1 = new PositionPdx(secIds[PositionPdx::cnt % numSecIds], + position1 = std::make_shared<PositionPdx>(secIds[PositionPdx::cnt % numSecIds], PositionPdx::cnt * 1000); if (i % 2 != 0) { - position2 = new PositionPdx(secIds[PositionPdx::cnt % numSecIds], - PositionPdx::cnt * 1000); + position2 = std::make_shared<PositionPdx>(secIds[PositionPdx::cnt % numSecIds], + PositionPdx::cnt * 1000); } else { position2 = nullptr; } positions = CacheableHashMap::create(); - positions->insert( - CacheableString::create(secIds[PositionPdx::cnt % numSecIds]), position1); + (*positions)[CacheableString::create(secIds[PositionPdx::cnt % numSecIds])] = position1; if (size > 0) { newVal = new int8_t[size];