diff --git a/hazelcast/include/hazelcast/client/spi/PartitionService.h b/hazelcast/include/hazelcast/client/spi/PartitionService.h index 4fdcb04cb0..b15e5d0a2e 100644 --- a/hazelcast/include/hazelcast/client/spi/PartitionService.h +++ b/hazelcast/include/hazelcast/client/spi/PartitionService.h @@ -48,8 +48,6 @@ namespace hazelcast { namespace serialization { namespace pimpl { - class SerializationService; - class Data; } } @@ -72,11 +70,6 @@ namespace hazelcast { int getPartitionId(const serialization::pimpl::Data &key); - /** - * @return The total number of partitions in the cluster. - */ - int getPartitionCount(); - /** * Refreshes the partition */ @@ -100,8 +93,6 @@ namespace hazelcast { void runListener(util::Thread* currentThread); - void runRefresher(); - std::auto_ptr getPartitionsFrom(const Address &address); std::auto_ptr getPartitionsFrom(); @@ -109,8 +100,6 @@ namespace hazelcast { bool processPartitionResponse(protocol::ClientMessage &response); bool getInitialPartitions(); - - static void refreshTask(util::ThreadArgs &args); }; } } diff --git a/hazelcast/src/hazelcast/client/spi/PartitionService.cpp b/hazelcast/src/hazelcast/client/spi/PartitionService.cpp index 7278dc0bb7..e37b4e0088 100644 --- a/hazelcast/src/hazelcast/client/spi/PartitionService.cpp +++ b/hazelcast/src/hazelcast/client/spi/PartitionService.cpp @@ -88,38 +88,13 @@ namespace hazelcast { if (!clientContext.getLifecycleService().isRunning()) { break; } - runRefresher(); + refreshPartitions(); } catch (exception::IException& e) { util::ILogger::getLogger().warning(std::string("PartitionService::runListener") + e.what()); } } } - void PartitionService::runRefresher() { - - if (updating.compareAndSet(false, true)) { - try { - std::auto_ptr partitionResponse; - std::auto_ptr
ptr = clientContext.getClusterService().getMasterAddress(); - if (ptr.get() == NULL) { - partitionResponse = getPartitionsFrom(); - } else { - partitionResponse = getPartitionsFrom(*ptr.get()); - } - if (partitionResponse.get() != NULL) { - processPartitionResponse(*partitionResponse); - } - } catch (hazelcast::client::exception::IException& e) { - util::ILogger::getLogger().finest(std::string("Exception partitionService::runRefresher ") + e.what()); - } catch (...) { - util::ILogger::getLogger().finest(std::string("Unkown exception partitionService::runRefresher ")); - throw; - } - updating = false; - } - - } - std::auto_ptr PartitionService::getPartitionsFrom(const Address& address) { std::auto_ptr responseMessage; try { @@ -165,7 +140,7 @@ namespace hazelcast { } } - int newPartionCount = newPartitions->size(); + int newPartionCount = (int)newPartitions->size(); if (newPartionCount > 0) { util::LockGuard lg(lock); @@ -204,19 +179,28 @@ namespace hazelcast { return result; } - - int PartitionService::getPartitionCount() { - return partitionCount; - } - - // TODO: Implement using executor as done in java + // TODO: Implement using executor as done in java (especially when the separate owner connection implementation is changed) void PartitionService::refreshPartitions() { - util::Thread t(refreshTask, this); - } - - void PartitionService::refreshTask(util::ThreadArgs &args) { - PartitionService *partitionSrv = (PartitionService *)args.arg0; - partitionSrv->runRefresher(); + if (updating.compareAndSet(false, true)) { + try { + std::auto_ptr partitionResponse; + std::auto_ptr
ptr = clientContext.getClusterService().getMasterAddress(); + if (ptr.get() == NULL) { + partitionResponse = getPartitionsFrom(); + } else { + partitionResponse = getPartitionsFrom(*ptr.get()); + } + if (partitionResponse.get() != NULL) { + processPartitionResponse(*partitionResponse); + } + } catch (hazelcast::client::exception::IException& e) { + util::ILogger::getLogger().finest(std::string("Exception in partitionService::refreshPartitions ") + e.what()); + } catch (...) { + util::ILogger::getLogger().finest(std::string("Unkown exception in partitionService::refreshPartitions ")); + throw; + } + updating = false; + } } } } diff --git a/java/src/main/resources/hazelcast.xml b/java/src/main/resources/hazelcast.xml index 4520c4e78e..d60d0a64bb 100644 --- a/java/src/main/resources/hazelcast.xml +++ b/java/src/main/resources/hazelcast.xml @@ -46,7 +46,11 @@ 54327 - 127.0.0.1 + 127.0.0.1:5701 + 127.0.0.1:5702 + 127.0.0.1:5703 + 127.0.0.1:5704 + 127.0.0.1:5705 my-access-key