ch.ethz.iks.r_osgi.messages
Class TimeOffsetMessage

java.lang.Object
  extended by ch.ethz.iks.r_osgi.messages.RemoteOSGiMessage
      extended by ch.ethz.iks.r_osgi.messages.TimeOffsetMessage

public final class TimeOffsetMessage
extends RemoteOSGiMessage

TimeOffsetMessages measures the time offset between two peers.

Since:
0.2
Author:
Jan S. Rellermeyer, ETH Zurich

Field Summary
 
Fields inherited from class ch.ethz.iks.r_osgi.messages.RemoteOSGiMessage
DELIVER_BUNDLE, DELIVER_BUNDLES, DELIVER_SERVICE, LEASE, LEASE_UPDATE, REMOTE_CALL, REMOTE_CALL_RESULT, REMOTE_EVENT, REQUEST_BUNDLE, REQUEST_DEPENDENCIES, REQUEST_SERVICE, STREAM_REQUEST, STREAM_RESULT, TIME_OFFSET, xid
 
Constructor Summary
TimeOffsetMessage()
          creates a new empty TimeSyncMessage.
TimeOffsetMessage(java.io.ObjectInputStream input)
          creates a new TimeSyncMessage from network packet: 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 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | R-OSGi header (function = TimeOffset = 7) | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Marshalled Long[] \ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ .
 
Method Summary
 long[] getTimeSeries()
          returns the time series.
 void restamp(int newXID)
          for retransmissions: replace the last timestamp with the current one.
 void setTimeSeries(long[] series)
          set the time series.
 void timestamp()
          add the current time to the time series.
 java.lang.String toString()
          String representation for debug outputs.
 void writeBody(java.io.ObjectOutputStream out)
          write the body of the message to a stream.
 
Methods inherited from class ch.ethz.iks.r_osgi.messages.RemoteOSGiMessage
getFuncID, getXID, parse, readBytes, readStringArray, send, setXID, writeBytes, writeStringArray
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TimeOffsetMessage

public TimeOffsetMessage()
creates a new empty TimeSyncMessage.


TimeOffsetMessage

public TimeOffsetMessage(java.io.ObjectInputStream input)
                  throws java.io.IOException
creates a new TimeSyncMessage from network packet:
        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
       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       |       R-OSGi header (function = TimeOffset = 7)               |
       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       |                   Marshalled Long[]                           \
       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 
.

Parameters:
input - an ObjectInputStream that provides the body of a R-OSGi network packet.
Throws:
java.io.IOException - in case of IO failures.
Method Detail

writeBody

public void writeBody(java.io.ObjectOutputStream out)
               throws java.io.IOException
write the body of the message to a stream.

Specified by:
writeBody in class RemoteOSGiMessage
Parameters:
out - the ObjectOutputStream.
Throws:
java.io.IOException - in case of IO failures.
See Also:
ch.ethz.iks.r_osgi.messages.RemoteOSGiMessage#getBody()

timestamp

public void timestamp()
add the current time to the time series.


restamp

public void restamp(int newXID)
for retransmissions: replace the last timestamp with the current one. The sending method must increase the XID to signal that this is a "new" message rather than a strict retransmission.


getTimeSeries

public final long[] getTimeSeries()
returns the time series.

Returns:
the time series as long array.

setTimeSeries

public final void setTimeSeries(long[] series)
set the time series.

Parameters:
series - the time series.

toString

public java.lang.String toString()
String representation for debug outputs.

Overrides:
toString in class java.lang.Object
Returns:
a string representation.
See Also:
Object.toString()


Copyright © 2009 IKS, ETH Zurich. All Rights Reserved.