org.hd.d.pg2k.svrCore
Class Stratum

java.lang.Object
  extended by org.hd.d.pg2k.svrCore.Stratum
All Implemented Interfaces:
java.io.Serializable

public final class Stratum
extends java.lang.Object
implements java.io.Serializable

Immutable stratum and other details of this instance/server and upstream.

See Also:
Serialized Form

Field Summary
static short MAX_ROOT_DELAY
          Maximum root delay; strictly positive (and no higher than Short.MAX_VALUE).
static byte MAX_STRATUM
          Maximum permissible stratum; strictly positive (and much less than Byte.MAX_VALUE).
static int MAX_UPSTREAM_NAME
          Maximum length of upstream short (unique) name; strictly positive.
static Stratum ROOT
          Value for use at the root (master) node; non-null.
private  short rootDelay
          Root delay in ms capped to Short.MAX_VALUE; non-negative.
private static long serialVersionUID
          Unique serialisation ID.
private  byte stratum
          Our stratum, in range [0,MAX_STRATUM] with 0 indicating master/root, or -1 for unknown.
static Stratum UNKNOWN
          Value for use when upstream node is knot known; non-null.
private  boolean upstreamConserving
          True if upstream is in a power-conserving state or unknown (as fail-safe).
private  java.lang.String upstreamName
          Upstream server short, unique, printable-ASCII name, "" for root/master/unknown else mirror tag like "cc-xxx"; never null.
 
Constructor Summary
Stratum(byte stratum, short rootDelay, java.lang.String upstreamName, boolean upstreamConserving)
          Construct an instance.
Stratum(int stratum, int rootDelay, java.lang.String upstreamName, boolean upstreamConserving)
          Construct an instance with int-valued numeric arguments for convenience.
 
Method Summary
 short getRootDelay()
          Root delay in ms capped to Short.MAX_VALUE; non-negative.
 byte getStratum()
          Our stratum, in range [0,MAX_STRATUM] with 0 indicating master/root, -1 unknown.
 java.lang.String getUpstreamName()
          Upstream server short name, "" for root/master/unknown else like "cc-xxx"; never null.
 boolean isUnknownStratum()
          True if stratum is unknown.
 boolean isUpstreamConserving()
          True if upstream is in a power-conserving state.
protected  java.lang.Object readResolve()
          Deserialise: use constructor for validation, defensive copying, etc.
 void validateObject()
          Validate fields/state.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_UPSTREAM_NAME

public static final int MAX_UPSTREAM_NAME
Maximum length of upstream short (unique) name; strictly positive.

See Also:
Constant Field Values

MAX_ROOT_DELAY

public static final short MAX_ROOT_DELAY
Maximum root delay; strictly positive (and no higher than Short.MAX_VALUE). Forced to this for an unknown stratum.

See Also:
Constant Field Values

MAX_STRATUM

public static final byte MAX_STRATUM
Maximum permissible stratum; strictly positive (and much less than Byte.MAX_VALUE). This determines the maximum distance that any (leaf) node can be from the root; 1 would indicate that all nodes must connect to the root/master directly and higher values (2 or more) allow more decentralised structures.

See Also:
Constant Field Values

stratum

private final byte stratum
Our stratum, in range [0,MAX_STRATUM] with 0 indicating master/root, or -1 for unknown.


rootDelay

private final short rootDelay
Root delay in ms capped to Short.MAX_VALUE; non-negative. Is forced to the MAX_ROOT_DELAY for an unknown stratum.


upstreamName

private final java.lang.String upstreamName
Upstream server short, unique, printable-ASCII name, "" for root/master/unknown else mirror tag like "cc-xxx"; never null.


upstreamConserving

private final boolean upstreamConserving
True if upstream is in a power-conserving state or unknown (as fail-safe).


serialVersionUID

private static final long serialVersionUID
Unique serialisation ID.

See Also:
Constant Field Values

ROOT

public static final Stratum ROOT
Value for use at the root (master) node; non-null. The root is at stratum zero with a delay of zero.

It has no upstream node so the upstream name is "" and the conserving flag is false.


UNKNOWN

public static final Stratum UNKNOWN
Value for use when upstream node is knot known; non-null. The root is at stratum zero with a delay of zero.

The upstream node is not known so the upstream name is "" and the conserving flag is false.

Constructor Detail

Stratum

public Stratum(int stratum,
               int rootDelay,
               java.lang.String upstreamName,
               boolean upstreamConserving)
Construct an instance with int-valued numeric arguments for convenience. In passing this silently caps the rootDelay to the maximum permitted value.


Stratum

public Stratum(byte stratum,
               short rootDelay,
               java.lang.String upstreamName,
               boolean upstreamConserving)
Construct an instance.

Method Detail

readResolve

protected java.lang.Object readResolve()
Deserialise: use constructor for validation, defensive copying, etc.


validateObject

public void validateObject()
                    throws java.io.InvalidObjectException
Validate fields/state. Called in the constructor and possibly after de-serialising.

Barf if something bad is found. (Maybe allow some extra info in debug version.)

Throws:
java.io.InvalidObjectException

getStratum

public byte getStratum()
Our stratum, in range [0,MAX_STRATUM] with 0 indicating master/root, -1 unknown.


isUnknownStratum

public boolean isUnknownStratum()
True if stratum is unknown.


getRootDelay

public short getRootDelay()
Root delay in ms capped to Short.MAX_VALUE; non-negative.


getUpstreamName

public java.lang.String getUpstreamName()
Upstream server short name, "" for root/master/unknown else like "cc-xxx"; never null.


isUpstreamConserving

public boolean isUpstreamConserving()
True if upstream is in a power-conserving state.


DHD Multimedia Gallery V1.60.69

Copyright (c) 1996-2012, Damon Hart-Davis. All rights reserved.