@@ -88,38 +88,13 @@ namespace hazelcast {
8888 if (!clientContext.getLifecycleService ().isRunning ()) {
8989 break ;
9090 }
91- runRefresher ();
91+ refreshPartitions ();
9292 } catch (exception::IException& e) {
9393 util::ILogger::getLogger ().warning (std::string (" PartitionService::runListener" ) + e.what ());
9494 }
9595 }
9696 }
9797
98- void PartitionService::runRefresher () {
99-
100- if (updating.compareAndSet (false , true )) {
101- try {
102- std::auto_ptr<protocol::ClientMessage> partitionResponse;
103- std::auto_ptr<Address> ptr = clientContext.getClusterService ().getMasterAddress ();
104- if (ptr.get () == NULL ) {
105- partitionResponse = getPartitionsFrom ();
106- } else {
107- partitionResponse = getPartitionsFrom (*ptr.get ());
108- }
109- if (partitionResponse.get () != NULL ) {
110- processPartitionResponse (*partitionResponse);
111- }
112- } catch (hazelcast::client::exception::IException& e) {
113- util::ILogger::getLogger ().finest (std::string (" Exception partitionService::runRefresher " ) + e.what ());
114- } catch (...) {
115- util::ILogger::getLogger ().finest (std::string (" Unkown exception partitionService::runRefresher " ));
116- throw ;
117- }
118- updating = false ;
119- }
120-
121- }
122-
12398 std::auto_ptr<protocol::ClientMessage> PartitionService::getPartitionsFrom (const Address& address) {
12499 std::auto_ptr<protocol::ClientMessage> responseMessage;
125100 try {
@@ -165,7 +140,7 @@ namespace hazelcast {
165140 }
166141 }
167142
168- int newPartionCount = newPartitions->size ();
143+ int newPartionCount = ( int ) newPartitions->size ();
169144 if (newPartionCount > 0 ) {
170145 util::LockGuard lg (lock);
171146
@@ -204,19 +179,28 @@ namespace hazelcast {
204179 return result;
205180 }
206181
207-
208- int PartitionService::getPartitionCount () {
209- return partitionCount;
210- }
211-
212- // TODO: Implement using executor as done in java
182+ // TODO: Implement using executor as done in java (especially when the separate owner connection implementation is changed)
213183 void PartitionService::refreshPartitions () {
214- util::Thread t (refreshTask, this );
215- }
216-
217- void PartitionService::refreshTask (util::ThreadArgs &args) {
218- PartitionService *partitionSrv = (PartitionService *)args.arg0 ;
219- partitionSrv->runRefresher ();
184+ if (updating.compareAndSet (false , true )) {
185+ try {
186+ std::auto_ptr<protocol::ClientMessage> partitionResponse;
187+ std::auto_ptr<Address> ptr = clientContext.getClusterService ().getMasterAddress ();
188+ if (ptr.get () == NULL ) {
189+ partitionResponse = getPartitionsFrom ();
190+ } else {
191+ partitionResponse = getPartitionsFrom (*ptr.get ());
192+ }
193+ if (partitionResponse.get () != NULL ) {
194+ processPartitionResponse (*partitionResponse);
195+ }
196+ } catch (hazelcast::client::exception::IException& e) {
197+ util::ILogger::getLogger ().finest (std::string (" Exception in partitionService::refreshPartitions " ) + e.what ());
198+ } catch (...) {
199+ util::ILogger::getLogger ().finest (std::string (" Unkown exception in partitionService::refreshPartitions " ));
200+ throw ;
201+ }
202+ updating = false ;
203+ }
220204 }
221205 }
222206 }
0 commit comments