Search in sources :

Example 1 with BackupAckResponse

use of com.hazelcast.spi.impl.operationservice.impl.responses.BackupAckResponse in project hazelcast by hazelcast.

the class InboundResponseHandler method handle.

@Override
public void handle(Packet packet) throws Exception {
    Response response = serializationService.toObject(packet);
    Address sender = packet.getConn().getEndPoint();
    try {
        if (response instanceof NormalResponse) {
            NormalResponse normalResponse = (NormalResponse) response;
            notifyNormalResponse(normalResponse.getCallId(), normalResponse.getValue(), normalResponse.getBackupAcks(), sender);
        } else if (response instanceof BackupAckResponse) {
            notifyBackupComplete(response.getCallId());
        } else if (response instanceof CallTimeoutResponse) {
            notifyCallTimeout(response.getCallId(), sender);
        } else if (response instanceof ErrorResponse) {
            ErrorResponse errorResponse = (ErrorResponse) response;
            notifyErrorResponse(errorResponse.getCallId(), errorResponse.getCause(), sender);
        } else {
            logger.severe("Unrecognized response: " + response);
        }
    } catch (Throwable e) {
        logger.severe("While processing response...", e);
    }
}
Also used : CallTimeoutResponse(com.hazelcast.spi.impl.operationservice.impl.responses.CallTimeoutResponse) Response(com.hazelcast.spi.impl.operationservice.impl.responses.Response) BackupAckResponse(com.hazelcast.spi.impl.operationservice.impl.responses.BackupAckResponse) NormalResponse(com.hazelcast.spi.impl.operationservice.impl.responses.NormalResponse) ErrorResponse(com.hazelcast.spi.impl.operationservice.impl.responses.ErrorResponse) CallTimeoutResponse(com.hazelcast.spi.impl.operationservice.impl.responses.CallTimeoutResponse) BackupAckResponse(com.hazelcast.spi.impl.operationservice.impl.responses.BackupAckResponse) Address(com.hazelcast.nio.Address) NormalResponse(com.hazelcast.spi.impl.operationservice.impl.responses.NormalResponse) ErrorResponse(com.hazelcast.spi.impl.operationservice.impl.responses.ErrorResponse)

Example 2 with BackupAckResponse

use of com.hazelcast.spi.impl.operationservice.impl.responses.BackupAckResponse in project hazelcast by hazelcast.

the class Backup method afterRun.

@Override
public void afterRun() throws Exception {
    if (!valid || !sync || getCallId() == 0 || originalCaller == null) {
        return;
    }
    NodeEngineImpl nodeEngine = (NodeEngineImpl) getNodeEngine();
    long callId = getCallId();
    OperationServiceImpl operationService = (OperationServiceImpl) nodeEngine.getOperationService();
    if (nodeEngine.getThisAddress().equals(originalCaller)) {
        operationService.getInboundResponseHandler().notifyBackupComplete(callId);
    } else {
        BackupAckResponse backupAckResponse = new BackupAckResponse(callId, backupOp.isUrgent());
        operationService.getOutboundResponseHandler().send(backupAckResponse, originalCaller);
    }
}
Also used : NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) BackupAckResponse(com.hazelcast.spi.impl.operationservice.impl.responses.BackupAckResponse) OperationServiceImpl(com.hazelcast.spi.impl.operationservice.impl.OperationServiceImpl)

Aggregations

BackupAckResponse (com.hazelcast.spi.impl.operationservice.impl.responses.BackupAckResponse)2 Address (com.hazelcast.nio.Address)1 NodeEngineImpl (com.hazelcast.spi.impl.NodeEngineImpl)1 OperationServiceImpl (com.hazelcast.spi.impl.operationservice.impl.OperationServiceImpl)1 CallTimeoutResponse (com.hazelcast.spi.impl.operationservice.impl.responses.CallTimeoutResponse)1 ErrorResponse (com.hazelcast.spi.impl.operationservice.impl.responses.ErrorResponse)1 NormalResponse (com.hazelcast.spi.impl.operationservice.impl.responses.NormalResponse)1 Response (com.hazelcast.spi.impl.operationservice.impl.responses.Response)1