public class CommonTimeConfig extends Object
Modifier and Type | Class and Description |
---|---|
static interface |
CommonTimeConfig.OnServerDiedListener
The OnServerDiedListener interface defines a method called by the
CommonTimeConfig instance to indicate that the connection to the native
media server has been broken and that the CommonTimeConfig instance will
need to be released and re-created. |
Modifier and Type | Field and Description |
---|---|
static int |
ERROR
Unspecified error.
|
static int |
ERROR_BAD_VALUE
Operation failed due to bad parameter value.
|
static int |
ERROR_DEAD_OBJECT
Operation failed due to dead remote object.
|
static long |
INVALID_GROUP_ID
Sentinel value returned by
getMasterElectionGroupId() when an error occurs trying to
fetch the master election group. |
static String |
SERVICE_NAME
Name of the underlying native binder service
|
static int |
SUCCESS
Successful operation.
|
Constructor and Description |
---|
CommonTimeConfig()
Class constructor.
|
Modifier and Type | Method and Description |
---|---|
static CommonTimeConfig |
create()
Handy class factory method.
|
protected void |
finalize()
Called by the garbage collector on an object when garbage collection
determines that there are no more references to the object.
|
int |
forceNetworklessMasterMode()
At startup, the time service enters the initial state and remains there until it is given a
network interface to bind to.
|
boolean |
getAutoDisable()
Gets the current state of the common time service's auto disable flag.
|
int |
getClientSyncInterval()
Gets the amount of time the common time service will wait between time synchronization
requests when it is the client of another common time service on the network.
|
String |
getInterfaceBinding()
Gets the name of the network interface which the common time service attempts to bind to.
|
int |
getMasterAnnounceInterval()
Gets the amount of time the common time service will wait between master announcements when
it is the timeline master.
|
InetSocketAddress |
getMasterElectionEndpoint()
Gets the IP endpoint used by the time service to participate in the master election protocol.
|
long |
getMasterElectionGroupId()
Gets the current group ID used by the common time service in the master election protocol.
|
byte |
getMasterElectionPriority()
Gets the current priority of the common time service used in the master election protocol.
|
int |
getPanicThreshold()
Gets the panic threshold for the estimated error level of the common time service.
|
void |
release()
Release all native resources held by this
CommonTimeConfig instance. |
int |
setAutoDisable(boolean autoDisable)
Sets the current state of the common time service's auto disable flag.
|
int |
setClientSyncInterval(int interval)
Sets the amount of time the common time service will wait between time synchronization
requests when it is the client of another common time service on the network.
|
int |
setMasterAnnounceInterval(int interval)
Sets the amount of time the common time service will wait between master announcements when
it is the timeline master.
|
int |
setMasterElectionEndpoint(InetSocketAddress ep)
Sets the IP endpoint used by the common time service to participate in the master election
protocol.
|
int |
setMasterElectionGroupId(long id)
Sets the current group ID used by the common time service in the master election protocol.
|
int |
setMasterElectionPriority(byte priority)
Sets the current priority of the common time service used in the master election protocol.
|
int |
setNetworkBinding(String ifaceName)
Sets the name of the network interface which the common time service should attempt to bind
to.
|
int |
setPanicThreshold(int threshold)
Sets the panic threshold for the estimated error level of the common time service.
|
void |
setServerDiedListener(CommonTimeConfig.OnServerDiedListener listener)
Registers an OnServerDiedListener interface.
|
public static final int SUCCESS
public static final int ERROR
public static final int ERROR_BAD_VALUE
public static final int ERROR_DEAD_OBJECT
public static final long INVALID_GROUP_ID
getMasterElectionGroupId()
when an error occurs trying to
fetch the master election group.public static final String SERVICE_NAME
public CommonTimeConfig() throws RemoteException
RemoteException
public static CommonTimeConfig create()
public void release()
CommonTimeConfig
instance. Once
resources have been released, the CommonTimeConfig
instance is
disconnected from the native service and will throw a RemoteException
if
any of its methods are called. Clients should always call release on their client instances
before releasing their last Java reference to the instance. Failure to do this will cause
non-deterministic native resource reclamation and may cause the common time service to remain
active on the network for longer than it should.public byte getMasterElectionPriority() throws RemoteException
RemoteException
public int setMasterElectionPriority(byte priority)
priority
- priority of the common time service used in the master election protocol.
Lower numbers are lower priority.SUCCESS
in case of success,
ERROR
or ERROR_DEAD_OBJECT
in case of failure.public InetSocketAddress getMasterElectionEndpoint() throws RemoteException
RemoteException
public int setMasterElectionEndpoint(InetSocketAddress ep)
ep
- The IP address and UDP port to be used by the common time service to participate in
the master election protocol. The supplied IP address must be either the broadcast or
multicast address, unicast addresses are considered to be illegal values.SUCCESS
in case of success,
ERROR
, ERROR_BAD_VALUE
or ERROR_DEAD_OBJECT
in case of failure.public long getMasterElectionGroupId() throws RemoteException
RemoteException
public int setMasterElectionGroupId(long id)
id
- The 64-bit group ID of the common time service.SUCCESS
in case of success,
ERROR
, ERROR_BAD_VALUE
or ERROR_DEAD_OBJECT
in case of failure.public String getInterfaceBinding() throws RemoteException
RemoteException
public int setNetworkBinding(String ifaceName)
ifaceName
- The name of the network interface ("eth0", "wlan0", etc...) wich the common
time service should attempt to bind to, or null to force the common time service to unbind
from the network and run in networkless mode.SUCCESS
in case of success,
ERROR
, ERROR_BAD_VALUE
or ERROR_DEAD_OBJECT
in case of failure.public int getMasterAnnounceInterval() throws RemoteException
RemoteException
public int setMasterAnnounceInterval(int interval)
interval
- The time (in milliseconds) between master announcements.SUCCESS
in case of success,
ERROR
, ERROR_BAD_VALUE
or ERROR_DEAD_OBJECT
in case of failure.public int getClientSyncInterval() throws RemoteException
RemoteException
public int setClientSyncInterval(int interval)
interval
- The time (in milliseconds) between time sync requests.SUCCESS
in case of success,
ERROR
, ERROR_BAD_VALUE
or ERROR_DEAD_OBJECT
in case of failure.public int getPanicThreshold() throws RemoteException
RemoteException
public int setPanicThreshold(int threshold)
threshold
- The threshold (in microseconds) past which the common time service will
panic.SUCCESS
in case of success,
ERROR
, ERROR_BAD_VALUE
or ERROR_DEAD_OBJECT
in case of failure.public boolean getAutoDisable() throws RemoteException
RemoteException
public int setAutoDisable(boolean autoDisable)
autoDisable
- The desired state of the common time service's auto disable flag.SUCCESS
in case of success,
ERROR
or ERROR_DEAD_OBJECT
in case of failure.public int forceNetworklessMasterMode()
forceNetworklessMasterMode()
method to force a time service in the INITIAL state
with no network configuration to assume MASTER status for a brand new timeline in order to
allow clients of the common time service to operate, even though the device is isolated and
not on any network. When a networkless master does join a network, it will defer to any
masters already on the network, or continue to maintain the timeline it made up during its
networkless state if no other masters are detected. Attempting to force a client into master
mode while it is actively bound to a network will fail with the status code ERROR
SUCCESS
in case of success,
ERROR
or ERROR_DEAD_OBJECT
in case of failure.public void setServerDiedListener(CommonTimeConfig.OnServerDiedListener listener)
Call this method with a null listener to stop receiving server death notifications.
protected void finalize() throws Throwable
Object
finalize
method to dispose of
system resources or to perform other cleanup.
The general contract of finalize
is that it is invoked
if and when the JavaTM virtual
machine has determined that there is no longer any
means by which this object can be accessed by any thread that has
not yet died, except as a result of an action taken by the
finalization of some other object or class which is ready to be
finalized. The finalize
method may take any action, including
making this object available again to other threads; the usual purpose
of finalize
, however, is to perform cleanup actions before
the object is irrevocably discarded. For example, the finalize method
for an object that represents an input/output connection might perform
explicit I/O transactions to break the connection before the object is
permanently discarded.
The finalize
method of class Object
performs no
special action; it simply returns normally. Subclasses of
Object
may override this definition.
The Java programming language does not guarantee which thread will
invoke the finalize
method for any given object. It is
guaranteed, however, that the thread that invokes finalize will not
be holding any user-visible synchronization locks when finalize is
invoked. If an uncaught exception is thrown by the finalize method,
the exception is ignored and finalization of that object terminates.
After the finalize
method has been invoked for an object, no
further action is taken until the Java virtual machine has again
determined that there is no longer any means by which this object can
be accessed by any thread that has not yet died, including possible
actions by other objects or classes which are ready to be finalized,
at which point the object may be discarded.
The finalize
method is never invoked more than once by a Java
virtual machine for any given object.
Any exception thrown by the finalize
method causes
the finalization of this object to be halted, but is otherwise
ignored.