Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2015 Real Logic Ltd.
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   * http://www.apache.org/licenses/LICENSE-2.0
   *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 package uk.co.real_logic.aeron.command;
 
 
Control message flyweight for any errors sent from driver to clients

0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Offending Command Correlation ID | | | +---------------------------------------------------------------+ | Error Code | +---------------------------------------------------------------+ | Error Message Length | +---------------------------------------------------------------+ | Error Message ... ... | +---------------------------------------------------------------+

 
 public class ErrorResponseFlyweight extends Flyweight
 {
     private static final int OFFENDING_COMMAND_CORRELATION_ID_OFFSET = 0;
     private static final int ERROR_MESSAGE_OFFSET =  + .;

    
Return correlation ID of the offending command.

Returns:
correlation ID of the offending command
 
     public long offendingCommandCorrelationId()
     {
         return buffer().getLong(offset() + OFFENDING_COMMAND_CORRELATION_ID_OFFSET, ByteOrder.LITTLE_ENDIAN);
     }

    
Set correlation ID of the offending command.

Parameters:
correlationId of the offending command
Returns:
flyweight
 
     public ErrorResponseFlyweight offendingCommandCorrelationId(final long correlationId)
     {
         buffer().putLong(offset() + OFFENDING_COMMAND_CORRELATION_ID_OFFSET, correlationId, ByteOrder.LITTLE_ENDIAN);
         return this;
     }

    
Error code for the command.

Returns:
error code for the command
 
     public ErrorCode errorCode()
     {
         return ErrorCode.get(buffer().getInt(offset() + ERROR_CODE_OFFSET, ByteOrder.LITTLE_ENDIAN));
     }

    
Set the error code for the command.

Parameters:
code for the error
Returns:
flyweight
 
     public ErrorResponseFlyweight errorCode(final ErrorCode code)
     {
         buffer().putInt(offset() + ERROR_CODE_OFFSET, code.value(), ByteOrder.LITTLE_ENDIAN);
         return this;
     }

    
Error message associated with the error.

Returns:
error message
 
     public String errorMessage()
     {
         return buffer().getStringUtf8(offset() + ERROR_MESSAGE_OFFSET, ByteOrder.LITTLE_ENDIAN);
    }

    
Set the error message

Parameters:
message to associate with the error
Returns:
flyweight
    public ErrorResponseFlyweight errorMessage(final String message)
    {
        buffer().putStringUtf8(offset() + ERROR_MESSAGE_OFFSET, message, ByteOrder.LITTLE_ENDIAN);
        return this;
    }

    
Length of the error response in bytes.

Returns:
length of the error response
    public int length()
    {
        return buffer().getInt(offset() + ERROR_MESSAGE_OFFSET, ByteOrder.LITTLE_ENDIAN) +
            ERROR_MESSAGE_OFFSET + BitUtil.SIZE_OF_INT;
    }
New to GrepCode? Check out our FAQ X