diff --git a/hazelcast/include/hazelcast/client/connection/CallPromise.h b/hazelcast/include/hazelcast/client/connection/CallPromise.h index 54419eb983..a99338bf53 100644 --- a/hazelcast/include/hazelcast/client/connection/CallPromise.h +++ b/hazelcast/include/hazelcast/client/connection/CallPromise.h @@ -60,6 +60,7 @@ namespace hazelcast { int incrementAndGetResendCount(); + void resetFuture(); private: util::Future > future; std::auto_ptr request; diff --git a/hazelcast/include/hazelcast/util/Future.h b/hazelcast/include/hazelcast/util/Future.h index 5e9d95d6d3..62b26278a7 100644 --- a/hazelcast/include/hazelcast/util/Future.h +++ b/hazelcast/include/hazelcast/util/Future.h @@ -48,7 +48,6 @@ namespace hazelcast { LockGuard guard(mutex); if (exceptionReady || resultReady) { util::ILogger::getLogger().warning(std::string("Future.set_value should not be called twice")); - return; } sharedObject = value; resultReady = true; @@ -59,7 +58,6 @@ namespace hazelcast { LockGuard guard(mutex); if (exceptionReady || resultReady) { util::ILogger::getLogger().warning(std::string("Future.set_exception should not be called twice : details ") + exceptionDetails); - return; } this->exceptionName = exceptionName; this->exceptionDetails = exceptionDetails; @@ -108,6 +106,12 @@ namespace hazelcast { throw client::exception::TimeoutException("Future::get(timeInSeconds)", "Wait is timed out"); }; + void reset() { + LockGuard guard(mutex); + + resultReady = false; + exceptionReady = false; + } private: bool resultReady; bool exceptionReady; diff --git a/hazelcast/src/hazelcast/client/connection/CallPromise.cpp b/hazelcast/src/hazelcast/client/connection/CallPromise.cpp index dde5538373..3a8d833a25 100644 --- a/hazelcast/src/hazelcast/client/connection/CallPromise.cpp +++ b/hazelcast/src/hazelcast/client/connection/CallPromise.cpp @@ -61,6 +61,10 @@ namespace hazelcast { int CallPromise::incrementAndGetResendCount() { return ++resendCount; } + + void CallPromise::resetFuture() { + future.reset(); + } } } } diff --git a/hazelcast/src/hazelcast/client/spi/InvocationService.cpp b/hazelcast/src/hazelcast/client/spi/InvocationService.cpp index 3b4c2e7f80..5c9f930912 100644 --- a/hazelcast/src/hazelcast/client/spi/InvocationService.cpp +++ b/hazelcast/src/hazelcast/client/spi/InvocationService.cpp @@ -211,6 +211,8 @@ namespace hazelcast { " to connection " + util::IOUtil::to_string
(connection->getRemoteEndpoint())); + promise->resetFuture(); + return registerAndEnqueue(connection, promise, -1); } diff --git a/hazelcast/test/cluster/ClusterTest.cpp b/hazelcast/test/cluster/ClusterTest.cpp index 6941146cb7..4b1050ed23 100644 --- a/hazelcast/test/cluster/ClusterTest.cpp +++ b/hazelcast/test/cluster/ClusterTest.cpp @@ -47,7 +47,7 @@ namespace hazelcast { void ClusterTest::addTests() { addTest(&ClusterTest::testClusterListeners, "testClusterListeners"); addTest(&ClusterTest::testClusterListenersFromConfig, "testClusterListenersFromConfig"); -// addTest(&ClusterTest::testListenersWhenClusterDown, "testListenersWhenClusterDown"); + addTest(&ClusterTest::testListenersWhenClusterDown, "testListenersWhenClusterDown"); addTest(&ClusterTest::testBehaviourWhenClusterNotFound, "testBehaviourWhenClusterNotFound"); } @@ -244,9 +244,11 @@ namespace hazelcast { HazelcastServer instance2(hazelcastInstanceFactory); assertTrue(lifecycleLatch.await(120), "Lifecycle latch await timed out!"); + // Let enough time for the client to re-register the failed listeners + util::sleep(1); m.put("sample", "entry"); assertTrue(countDownLatch.await(60), "Await timed out !"); - assertTrue(hazelcastClient.removeLifecycleListener(&lifecycleListener), "Listener could not removed"); + assertTrue(hazelcastClient.removeLifecycleListener(&lifecycleListener), "Listener could not be removed"); } void ClusterTest::testBehaviourWhenClusterNotFound() { diff --git a/hazelcast/test/map/ClientMapTest.cpp b/hazelcast/test/map/ClientMapTest.cpp index a8fb78daf4..c7071da199 100644 --- a/hazelcast/test/map/ClientMapTest.cpp +++ b/hazelcast/test/map/ClientMapTest.cpp @@ -45,7 +45,6 @@ namespace hazelcast { } void ClientMapTest::addTests() { -/* addTest(&ClientMapTest::testContains, "testContains"); addTest(&ClientMapTest::testGet, "testGet"); addTest(&ClientMapTest::testRemoveAndDelete, "testRemoveAndDelete"); @@ -72,7 +71,6 @@ namespace hazelcast { addTest(&ClientMapTest::testMapWithPortable, "testMapWithPortable"); addTest(&ClientMapTest::testMapStoreRelatedRequests, "testMapStoreRelatedRequests"); addTest(&ClientMapTest::testKeySetAndValuesWithPredicates, "testKeySetAndValuesWithPredicates"); -*/ addTest(&ClientMapTest::testExecuteOnKey, "testExecuteOnKey"); addTest(&ClientMapTest::testExecuteOnEntries, "testExecuteOnEntries"); } @@ -695,7 +693,7 @@ namespace hazelcast { }; void ClientMapTest::testExecuteOnKey() { - IMap employees = client->getMap("employees"); + IMap employees = client->getMap("executeOnKey"); Employee empl1("ahmet", 35); Employee empl2("mehmet", 21); @@ -712,7 +710,7 @@ namespace hazelcast { } void ClientMapTest::testExecuteOnEntries() { - IMap employees = client->getMap("employees"); + IMap employees = client->getMap("testExecuteOnEntries"); Employee empl1("ahmet", 35); Employee empl2("mehmet", 21);