ostore.read
Class ReadResp

java.lang.Object
  |
  +--ostore.read.ReadResp
All Implemented Interfaces:
QueueElementIF, QuickSerializable
Direct Known Subclasses:
BytesReadResp, HandleStoreReadResp, SliceReadResp

public abstract class ReadResp
extends Object
implements QueueElementIF, QuickSerializable

A superclass for events sent from the ReadStage to the ReplicaStage responding to ReadReq events.

TODO: reuse same event for ClientStage->ReplicaStage requests?

Version:
$Id: ReadResp.java,v 1.17 2004/03/23 03:11:05 hweather Exp $
Author:
Dennis Geels

Field Summary
protected  SecureHash digest
          The digest of this ReadResp.
protected  int error_code
          One of the error codes above (or NO_ERROR).
protected  Selection missing
          The portion of the DataObject that was not successfully read, or null.
static int NO_ERROR
          An error code that indicates no error occurred.
protected  Selection read
          The portion of the DataObject that was successfully read, or null.
static int READ_ERROR
          An error code that indicates a request failed because some portion of the requested data could not be read.
protected  SecureHash req_digest
          A digest of the corresponding ReadReq.
 
Constructor Summary
protected ReadResp(InputBuffer buffer)
          Constructs a ReadResp from its serialized form.
protected ReadResp(ReadReq req, Selection read, Selection missing, int error_code)
          Constructs a new ReadResp for the specified ReadReq.
 
Method Summary
 SecureHash get_digest()
          Returns the digest of this ReadResp.
 int get_error_code()
          Returns the error code.
 Selection get_missing()
          Returns the Selection which describes the portion of the DataObject that was not successfuly read.
 Selection get_read()
          Returns the Selection which describes the portion of the DataObject that was read.
 SecureHash get_req_digest()
          Returns the digest over the corresponding ReadReq.
 QSLong get_req_seq_num()
          Returns the sequence number of the request that generated this result.
 int hashCode()
          Returns the hash of the digest of this ReadResp.
 void serialize(OutputBuffer buffer)
          Add the object to the buffer.
 boolean successful()
          Returns true iff error_code() == NO_ERROR.
 String toString()
          Returns a human-readable representation of this ReadResp.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

NO_ERROR

public static final int NO_ERROR
An error code that indicates no error occurred.

See Also:
Constant Field Values

READ_ERROR

public static final int READ_ERROR
An error code that indicates a request failed because some portion of the requested data could not be read. NOTE use this flag only if the original request specified that partial failure was unacceptable.

TODO: be more specific?

See Also:
Constant Field Values

req_digest

protected SecureHash req_digest
A digest of the corresponding ReadReq.


read

protected Selection read
The portion of the DataObject that was successfully read, or null.


missing

protected Selection missing
The portion of the DataObject that was not successfully read, or null.

The union of read and missing should equal the original requested Selection.


error_code

protected int error_code
One of the error codes above (or NO_ERROR).


digest

protected transient SecureHash digest
The digest of this ReadResp. Do NOT include this field in to_bytes.

Constructor Detail

ReadResp

protected ReadResp(ReadReq req,
                   Selection read,
                   Selection missing,
                   int error_code)
Constructs a new ReadResp for the specified ReadReq.


ReadResp

protected ReadResp(InputBuffer buffer)
            throws QSException
Constructs a ReadResp from its serialized form.

Method Detail

successful

public boolean successful()
Returns true iff error_code() == NO_ERROR.


get_error_code

public int get_error_code()
Returns the error code.


get_req_seq_num

public QSLong get_req_seq_num()
Returns the sequence number of the request that generated this result. This allows the applications to corelate requests and responses.

Returns:
the sequence number of the request that generated this result

get_req_digest

public SecureHash get_req_digest()
Returns the digest over the corresponding ReadReq.


get_read

public Selection get_read()
Returns the Selection which describes the portion of the DataObject that was read.


get_missing

public Selection get_missing()
Returns the Selection which describes the portion of the DataObject that was not successfuly read.


get_digest

public SecureHash get_digest()
Returns the digest of this ReadResp.

WARNING: the first invocation of this method may be expensive, because it requires serializing the entire object.

See Also:
get_req_digest()

serialize

public void serialize(OutputBuffer buffer)
Description copied from interface: QuickSerializable
Add the object to the buffer.

Specified by:
serialize in interface QuickSerializable
Parameters:
buffer - the output buffer to add the object to

hashCode

public int hashCode()
Returns the hash of the digest of this ReadResp.

WARNING: the first invocation of this method may be expensive, because it requires serializing the entire object.

Overrides:
hashCode in class Object

toString

public String toString()
Returns a human-readable representation of this ReadResp.

Overrides:
toString in class Object