Skip to content

Commit

Permalink
Uncommented the mistakenly commented out test code and a minor correc…
Browse files Browse the repository at this point in the history
…tion on a new test. Eliminated the warning during the invocation resend operations by fixing the promise future into correct state before making the reinvocation of the request.
  • Loading branch information
ihsandemir committed Dec 10, 2015
1 parent b9e0f96 commit 9806575
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ namespace hazelcast {

int incrementAndGetResendCount();

void resetFuture();
private:
util::Future<std::auto_ptr<protocol::ClientMessage> > future;
std::auto_ptr<protocol::ClientMessage> request;
Expand Down
8 changes: 6 additions & 2 deletions hazelcast/include/hazelcast/util/Future.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions hazelcast/src/hazelcast/client/connection/CallPromise.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ namespace hazelcast {
int CallPromise::incrementAndGetResendCount() {
return ++resendCount;
}

void CallPromise::resetFuture() {
future.reset();
}
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions hazelcast/src/hazelcast/client/spi/InvocationService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,8 @@ namespace hazelcast {
" to connection " +
util::IOUtil::to_string<Address>(connection->getRemoteEndpoint()));

promise->resetFuture();

return registerAndEnqueue(connection, promise, -1);
}

Expand Down
6 changes: 4 additions & 2 deletions hazelcast/test/cluster/ClusterTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}

Expand Down Expand Up @@ -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() {
Expand Down
6 changes: 2 additions & 4 deletions hazelcast/test/map/ClientMapTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ namespace hazelcast {
}

void ClientMapTest::addTests() {
/*
addTest(&ClientMapTest::testContains, "testContains");
addTest(&ClientMapTest::testGet, "testGet");
addTest(&ClientMapTest::testRemoveAndDelete, "testRemoveAndDelete");
Expand All @@ -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");
}
Expand Down Expand Up @@ -695,7 +693,7 @@ namespace hazelcast {
};

void ClientMapTest::testExecuteOnKey() {
IMap<int, Employee> employees = client->getMap<int, Employee>("employees");
IMap<int, Employee> employees = client->getMap<int, Employee>("executeOnKey");

Employee empl1("ahmet", 35);
Employee empl2("mehmet", 21);
Expand All @@ -712,7 +710,7 @@ namespace hazelcast {
}

void ClientMapTest::testExecuteOnEntries() {
IMap<int, Employee> employees = client->getMap<int, Employee>("employees");
IMap<int, Employee> employees = client->getMap<int, Employee>("testExecuteOnEntries");

Employee empl1("ahmet", 35);
Employee empl2("mehmet", 21);
Expand Down

0 comments on commit 9806575

Please sign in to comment.