use of com.hazelcast.internal.partition.impl.InternalPartitionServiceImpl in project hazelcast by hazelcast.
the class ClientPartitionLostListenerTest method test_partitionLostListener_invoked_fromOtherNode.
@Test
public void test_partitionLostListener_invoked_fromOtherNode() {
final HazelcastInstance instance1 = hazelcastFactory.newHazelcastInstance();
final HazelcastInstance instance2 = hazelcastFactory.newHazelcastInstance();
final ClientConfig clientConfig = new ClientConfig();
clientConfig.getNetworkConfig().setSmartRouting(false);
final HazelcastInstance client = hazelcastFactory.newHazelcastClient(clientConfig);
warmUpPartitions(instance1, instance2, client);
final HazelcastClientInstanceImpl clientInstanceImpl = getHazelcastClientInstanceImpl(client);
final Address clientOwnerAddress = clientInstanceImpl.getClientClusterService().getOwnerConnectionAddress();
final HazelcastInstance other = getAddress(instance1).equals(clientOwnerAddress) ? instance2 : instance1;
final EventCollectingPartitionLostListener listener = new EventCollectingPartitionLostListener();
client.getPartitionService().addPartitionLostListener(listener);
assertRegistrationsSizeEventually(instance1, 1);
assertRegistrationsSizeEventually(instance2, 1);
final InternalPartitionServiceImpl partitionService = getNode(other).getNodeEngine().getService(SERVICE_NAME);
final int partitionId = 5;
partitionService.onPartitionLost(new IPartitionLostEvent(partitionId, 0, null));
assertPartitionLostEventEventually(listener, partitionId);
}
use of com.hazelcast.internal.partition.impl.InternalPartitionServiceImpl in project hazelcast by hazelcast.
the class ClusterServiceImpl method repairPartitionTableIfReturningMember.
private void repairPartitionTableIfReturningMember(MemberImpl member) {
if (!isMaster()) {
return;
}
if (getClusterState() == ClusterState.ACTIVE) {
return;
}
if (!node.getNodeExtension().isStartCompleted()) {
return;
}
Address address = member.getAddress();
MemberImpl memberRemovedWhileClusterIsNotActive = getMemberRemovedWhileClusterIsNotActive(member.getUuid());
if (memberRemovedWhileClusterIsNotActive != null) {
Address oldAddress = memberRemovedWhileClusterIsNotActive.getAddress();
if (!oldAddress.equals(address)) {
assert !isMemberRemovedWhileClusterIsNotActive(address);
logger.warning(member + " is returning with a new address. Old one was: " + oldAddress + ". Will update partition table with the new address.");
InternalPartitionServiceImpl partitionService = node.partitionService;
partitionService.replaceAddress(oldAddress, address);
}
}
}
use of com.hazelcast.internal.partition.impl.InternalPartitionServiceImpl in project hazelcast by hazelcast.
the class ReplicaSyncResponse method run.
@Override
public void run() throws Exception {
NodeEngine nodeEngine = getNodeEngine();
InternalPartitionServiceImpl partitionService = getService();
int partitionId = getPartitionId();
int replicaIndex = getReplicaIndex();
PartitionStateManager partitionStateManager = partitionService.getPartitionStateManager();
InternalPartitionImpl partition = partitionStateManager.getPartitionImpl(partitionId);
Address thisAddress = nodeEngine.getThisAddress();
int currentReplicaIndex = partition.getReplicaIndex(thisAddress);
try {
if (replicaIndex == currentReplicaIndex) {
executeTasks();
} else {
nodeNotOwnsBackup(partition);
}
if (tasks != null) {
tasks.clear();
}
} finally {
postProcessReplicaSync(partitionService, currentReplicaIndex);
}
}
use of com.hazelcast.internal.partition.impl.InternalPartitionServiceImpl in project hazelcast by hazelcast.
the class ReplicaSyncRetryResponse method run.
@Override
public void run() throws Exception {
final InternalPartitionServiceImpl partitionService = getService();
final int partitionId = getPartitionId();
final int replicaIndex = getReplicaIndex();
partitionService.getReplicaManager().clearReplicaSyncRequest(partitionId, replicaIndex);
PartitionStateManager partitionStateManager = partitionService.getPartitionStateManager();
InternalPartitionImpl partition = partitionStateManager.getPartitionImpl(partitionId);
Address thisAddress = getNodeEngine().getThisAddress();
ILogger logger = getLogger();
int currentReplicaIndex = partition.getReplicaIndex(thisAddress);
if (currentReplicaIndex > 0) {
if (logger.isFinestEnabled()) {
logger.finest("Retrying replica sync request for partitionId=" + partitionId + ", initial-replicaIndex=" + replicaIndex + ", current-replicaIndex=" + currentReplicaIndex);
}
partitionService.getReplicaManager().triggerPartitionReplicaSync(partitionId, currentReplicaIndex, InternalPartitionService.REPLICA_SYNC_RETRY_DELAY);
} else if (logger.isFinestEnabled()) {
logger.finest("No need to retry replica sync request for partitionId=" + partitionId + ", initial-replicaIndex=" + replicaIndex + ", current-replicaIndex=" + currentReplicaIndex);
}
}
use of com.hazelcast.internal.partition.impl.InternalPartitionServiceImpl in project hazelcast by hazelcast.
the class PromotionCommitOperation method beforePromotion.
private void beforePromotion() {
NodeEngineImpl nodeEngine = (NodeEngineImpl) getNodeEngine();
InternalOperationService operationService = nodeEngine.getOperationService();
InternalPartitionServiceImpl partitionService = getService();
ILogger logger = getLogger();
if (logger.isFineEnabled()) {
logger.fine("Submitting BeforePromotionOperations for " + promotions.size() + " promotions.");
}
Runnable beforePromotionsCallback = new BeforePromotionOperationCallback(this, new AtomicInteger(promotions.size()));
for (MigrationInfo promotion : promotions) {
if (logger.isFinestEnabled()) {
logger.finest("Submitting BeforePromotionOperation for promotion: " + promotion);
}
int currentReplicaIndex = promotion.getDestinationCurrentReplicaIndex();
BeforePromotionOperation op = new BeforePromotionOperation(currentReplicaIndex, beforePromotionsCallback);
op.setPartitionId(promotion.getPartitionId()).setNodeEngine(nodeEngine).setService(partitionService);
operationService.execute(op);
}
}
Aggregations