Search in sources :

Example 1 with Response

use of com.hazelcast.spi.impl.operationservice.impl.responses.Response 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 Response

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

the class OutboundResponseHandler method sendResponse.

@Override
public void sendResponse(Operation operation, Object obj) {
    Response response = toResponse(operation, obj);
    if (!send(response, operation.getCallerAddress())) {
        Connection conn = operation.getConnection();
        logger.warning("Cannot send response: " + obj + " to " + conn.getEndPoint() + ". " + operation);
    }
}
Also used : Response(com.hazelcast.spi.impl.operationservice.impl.responses.Response) NormalResponse(com.hazelcast.spi.impl.operationservice.impl.responses.NormalResponse) ErrorResponse(com.hazelcast.spi.impl.operationservice.impl.responses.ErrorResponse) Connection(com.hazelcast.nio.Connection)

Aggregations

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