Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions hazelcast/include/hazelcast/client/spi/PartitionService.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ namespace hazelcast {

namespace serialization {
namespace pimpl {
class SerializationService;

class Data;
}
}
Expand All @@ -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
*/
Expand All @@ -100,17 +93,13 @@ namespace hazelcast {

void runListener(util::Thread* currentThread);

void runRefresher();

std::auto_ptr<protocol::ClientMessage> getPartitionsFrom(const Address &address);

std::auto_ptr<protocol::ClientMessage> getPartitionsFrom();

bool processPartitionResponse(protocol::ClientMessage &response);

bool getInitialPartitions();

static void refreshTask(util::ThreadArgs &args);
};
}
}
Expand Down
62 changes: 23 additions & 39 deletions hazelcast/src/hazelcast/client/spi/PartitionService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<protocol::ClientMessage> partitionResponse;
std::auto_ptr<Address> 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<protocol::ClientMessage> PartitionService::getPartitionsFrom(const Address& address) {
std::auto_ptr<protocol::ClientMessage> responseMessage;
try {
Expand Down Expand Up @@ -165,7 +140,7 @@ namespace hazelcast {
}
}

int newPartionCount = newPartitions->size();
int newPartionCount = (int)newPartitions->size();
if (newPartionCount > 0) {
util::LockGuard lg(lock);

Expand Down Expand Up @@ -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<protocol::ClientMessage> partitionResponse;
std::auto_ptr<Address> 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;
}
}
}
}
Expand Down
6 changes: 5 additions & 1 deletion java/src/main/resources/hazelcast.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@
<multicast-port>54327</multicast-port>
</multicast>
<tcp-ip enabled="true">
<interface>127.0.0.1</interface>
<interface>127.0.0.1:5701</interface>
<interface>127.0.0.1:5702</interface>
<interface>127.0.0.1:5703</interface>
<interface>127.0.0.1:5704</interface>
<interface>127.0.0.1:5705</interface>
</tcp-ip>
<aws enabled="false">
<access-key>my-access-key</access-key>
Expand Down