use of org.apache.asterix.common.replication.Replica in project asterixdb by apache.
the class ReplicationManager method checkReplicaState.
/**
* Checks the state of a remote replica by trying to ping it.
*
* @param replicaId
* The replica to check the state for.
* @param async
* a flag indicating whether to wait for the result or not.
* @param suspendReplication
* a flag indicating whether to suspend replication on replica state change or not.
*/
private void checkReplicaState(String replicaId, boolean async, boolean suspendReplication) {
Replica replica = replicas.get(replicaId);
ReplicaStateChecker connector = new ReplicaStateChecker(replica, replicationProperties.getReplicationTimeOut(), this, replicationProperties, suspendReplication);
Future<? extends Object> ft = asterixAppRuntimeContextProvider.getThreadExecutor().submit(connector);
if (!async) {
//wait until task is done
while (!ft.isDone()) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
}
}
}
use of org.apache.asterix.common.replication.Replica in project asterixdb by apache.
the class ReplicationManager method updateReplicaInfo.
@Override
public synchronized void updateReplicaInfo(Replica replicaNode) {
Replica replica = replicas.get(replicaNode.getNode().getId());
//should not update the info of an active replica
if (replica.getState() == ReplicaState.ACTIVE) {
return;
}
replica.getNode().setClusterIp(replicaNode.getNode().getClusterIp());
}
use of org.apache.asterix.common.replication.Replica in project asterixdb by apache.
the class ReplicationManager method sendShutdownNotifiction.
/**
* Sends a shutdown event to remote replicas notifying them
* no more logs/files will be sent from this local replica.
*
* @throws IOException
*/
private void sendShutdownNotifiction() throws IOException {
Node node = new Node();
node.setId(nodeId);
node.setClusterIp(NetworkingUtil.getHostAddress(hostIPAddressFirstOctet));
Replica replica = new Replica(node);
ReplicaEvent event = new ReplicaEvent(replica, ClusterEventType.NODE_SHUTTING_DOWN);
ByteBuffer buffer = ReplicationProtocol.writeReplicaEventRequest(event);
Map<String, SocketChannel> replicaSockets = getActiveRemoteReplicasSockets();
sendRequest(replicaSockets, buffer);
closeReplicaSockets(replicaSockets);
}
use of org.apache.asterix.common.replication.Replica in project asterixdb by apache.
the class ReplicaEventMessage method handle.
@Override
public void handle(INcApplicationContext appContext) throws HyracksDataException, InterruptedException {
Node node = new Node();
node.setId(nodeId);
node.setClusterIp(nodeIPAddress);
Replica replica = new Replica(node);
appContext.getReplicationManager().reportReplicaEvent(new ReplicaEvent(replica, event));
}
Aggregations