Search in sources :

Example 1 with ReplicaEvent

use of org.apache.asterix.common.replication.ReplicaEvent in project asterixdb by apache.

the class ReplicationManager method reportFailedReplica.

/**
     * Suspends replications and sends a remote replica failure event to ReplicasEventsMonitor.
     *
     * @param replicaId
     *            the failed replica id.
     */
public void reportFailedReplica(String replicaId) {
    Replica replica = replicas.get(replicaId);
    if (replica == null) {
        return;
    }
    if (replica.getState() == ReplicaState.DEAD) {
        return;
    }
    //need to stop processing any new logs or jobs
    terminateJobsReplication.set(true);
    ReplicaEvent event = new ReplicaEvent(replica, ClusterEventType.NODE_FAILURE);
    reportReplicaEvent(event);
}
Also used : Replica(org.apache.asterix.common.replication.Replica) ReplicaEvent(org.apache.asterix.common.replication.ReplicaEvent)

Example 2 with ReplicaEvent

use of org.apache.asterix.common.replication.ReplicaEvent 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);
}
Also used : SocketChannel(java.nio.channels.SocketChannel) Node(org.apache.asterix.event.schema.cluster.Node) Replica(org.apache.asterix.common.replication.Replica) ReplicaEvent(org.apache.asterix.common.replication.ReplicaEvent) ByteBuffer(java.nio.ByteBuffer)

Example 3 with ReplicaEvent

use of org.apache.asterix.common.replication.ReplicaEvent 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));
}
Also used : Node(org.apache.asterix.event.schema.cluster.Node) Replica(org.apache.asterix.common.replication.Replica) ReplicaEvent(org.apache.asterix.common.replication.ReplicaEvent)

Aggregations

Replica (org.apache.asterix.common.replication.Replica)3 ReplicaEvent (org.apache.asterix.common.replication.ReplicaEvent)3 Node (org.apache.asterix.event.schema.cluster.Node)2 ByteBuffer (java.nio.ByteBuffer)1 SocketChannel (java.nio.channels.SocketChannel)1