IT. Expert System.

Android Reference

CommonClock


android.os

Class CommonClock



  • public class CommonClock
    extends Object
    Used for accessing the android common time service's common clock and receiving notifications about common time synchronization status changes.
    • Nested Class Summary

      Nested Classes
      Modifier and Type Class and Description
      static interface CommonClock.OnServerDiedListener
      The OnServerDiedListener interface defines a method called by the CommonClock instance to indicate that the connection to the native media server has been broken and that the CommonClock instance will need to be released and re-created.
      static interface CommonClock.OnTimelineChangedListener
      The OnTimelineChangedListener interface defines a method called by the CommonClock instance to indicate that the time synchronization service has either synchronized with a new timeline, or is no longer a member of any timeline.
    • Field Summary

      Fields
      Modifier and Type Field and Description
      static int ERROR_ESTIMATE_UNKNOWN
      Sentinel value returned by getEstimatedError() when the common time service is not currently synced to any timeline.
      static long INVALID_TIMELINE_ID
      Sentinel value returned by getTimelineId() when the common time service is not currently synced to any timeline.
      static String SERVICE_NAME
      Name of the underlying native binder service
      static int STATE_CLIENT
      Value used by getState() to indicate that the common time service is in its client state and is synchronizing its time to a different timeline master on the network.
      static int STATE_INITIAL
      Value used by getState() to indicate that the common time service is in its initial state and attempting to find the current timeline master, if any.
      static int STATE_INVALID
      Value used by getState() to indicate that there was an internal error while attempting to determine the state of the common time service.
      static int STATE_MASTER
      Value used by getState() to indicate that the common time service is in its master state and is serving as the timeline master for other common time service clients on the network.
      static int STATE_RONIN
      Value used by getState() to indicate that the common time service is in its Ronin state.
      static int STATE_WAIT_FOR_ELECTION
      Value used by getState() to indicate that the common time service is waiting for a master election to conclude and for the new master to announce itself before transitioning to the STATE_CLIENT state.
      static long TIME_NOT_SYNCED
      Sentinel value returned by getTime() and getEstimatedError() when the common time service is not able to determine the current common time due to a lack of synchronization.
    • Constructor Summary

      Constructors
      Constructor and Description
      CommonClock()
      Class constructor.
    • Field Detail

      • TIME_NOT_SYNCED

        public static final long TIME_NOT_SYNCED
        Sentinel value returned by getTime() and getEstimatedError() when the common time service is not able to determine the current common time due to a lack of synchronization.
        See Also:
        Constant Field Values
      • INVALID_TIMELINE_ID

        public static final long INVALID_TIMELINE_ID
        Sentinel value returned by getTimelineId() when the common time service is not currently synced to any timeline.
        See Also:
        Constant Field Values
      • ERROR_ESTIMATE_UNKNOWN

        public static final int ERROR_ESTIMATE_UNKNOWN
        Sentinel value returned by getEstimatedError() when the common time service is not currently synced to any timeline.
        See Also:
        Constant Field Values
      • STATE_INVALID

        public static final int STATE_INVALID
        Value used by getState() to indicate that there was an internal error while attempting to determine the state of the common time service.
        See Also:
        Constant Field Values
      • STATE_INITIAL

        public static final int STATE_INITIAL
        Value used by getState() to indicate that the common time service is in its initial state and attempting to find the current timeline master, if any. The service will transition to either STATE_CLIENT if it finds an active master, or to STATE_MASTER if no active master is found and this client becomes the master of a new timeline.
        See Also:
        Constant Field Values
      • STATE_CLIENT

        public static final int STATE_CLIENT
        Value used by getState() to indicate that the common time service is in its client state and is synchronizing its time to a different timeline master on the network.
        See Also:
        Constant Field Values
      • STATE_MASTER

        public static final int STATE_MASTER
        Value used by getState() to indicate that the common time service is in its master state and is serving as the timeline master for other common time service clients on the network.
        See Also:
        Constant Field Values
      • STATE_RONIN

        public static final int STATE_RONIN
        Value used by getState() to indicate that the common time service is in its Ronin state. Common time service instances in the client state enter the Ronin state after their timeline master becomes unreachable on the network. Common time services who enter the Ronin state will begin a new master election for the timeline they were recently clients of. As clients detect they are not the winner and drop out of the election, they will transition to the STATE_WAIT_FOR_ELECTION state. When there is only one client remaining in the election, it will assume ownership of the timeline and transition to the STATE_MASTER state. During the election, all clients will allow their timeline to drift without applying correction.
        See Also:
        Constant Field Values
      • STATE_WAIT_FOR_ELECTION

        public static final int STATE_WAIT_FOR_ELECTION
        Value used by getState() to indicate that the common time service is waiting for a master election to conclude and for the new master to announce itself before transitioning to the STATE_CLIENT state. If no new master announces itself within the timeout threshold, the time service will transition back to the STATE_RONIN state in order to restart the election.
        See Also:
        Constant Field Values
    • Method Detail

      • create

        public static CommonClock create()
        Handy class factory method.
      • release

        public void release()
        Release all native resources held by this CommonClock instance. Once resources have been released, the CommonClock 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.
      • getTime

        public long getTime()
                     throws RemoteException
        Gets the common clock's current time.
        Returns:
        a signed 64-bit value representing the current common time in microseconds, or the special value TIME_NOT_SYNCED if the common time service is currently not synchronized.
        Throws:
        RemoteException
      • getEstimatedError

        public int getEstimatedError()
                              throws RemoteException
        Gets the current estimation of common clock's synchronization accuracy from the common time service.
        Returns:
        a signed 32-bit value representing the common time service's estimation of synchronization accuracy in microseconds, or the special value ERROR_ESTIMATE_UNKNOWN if the common time service is currently not synchronized. Negative values indicate that the local server estimates that the nominal common time is behind the local server's time (in other words, the local clock is running fast) Positive values indicate that the local server estimates that the nominal common time is ahead of the local server's time (in other words, the local clock is running slow)
        Throws:
        RemoteException
      • getTimelineId

        public long getTimelineId()
                           throws RemoteException
        Gets the ID of the timeline the common time service is currently synchronizing its clock to.
        Returns:
        a long representing the unique ID of the timeline the common time service is currently synchronizing with, or INVALID_TIMELINE_ID if the common time service is currently not synchronized.
        Throws:
        RemoteException
      • getState

        public int getState()
                     throws RemoteException
        Gets the current state of this clock's common time service in the the master election algorithm.
        Returns:
        a integer indicating the current state of the this clock's common time service in the master election algorithm or STATE_INVALID if there is an internal error.
        Throws:
        RemoteException
      • getMasterAddr

        public InetSocketAddress getMasterAddr()
                                        throws RemoteException
        Gets the IP address and UDP port of the current timeline master.
        Returns:
        an InetSocketAddress containing the IP address and UDP port of the current timeline master, or null if there is no current master.
        Throws:
        RemoteException
      • setTimelineChangedListener

        public void setTimelineChangedListener(CommonClock.OnTimelineChangedListener listener)
        Registers an OnTimelineChangedListener interface.

        Call this method with a null listener to stop receiving server death notifications.

      • setServerDiedListener

        public void setServerDiedListener(CommonClock.OnServerDiedListener listener)
        Registers an OnServerDiedListener interface.

        Call this method with a null listener to stop receiving server death notifications.

      • finalize

        protected void finalize()
                         throws Throwable
        Description copied from class: Object
        Invoked when the garbage collector has detected that this instance is no longer reachable. The default implementation does nothing, but this method can be overridden to free resources.

        Note that objects that override finalize are significantly more expensive than objects that don't. Finalizers may be run a long time after the object is no longer reachable, depending on memory pressure, so it's a bad idea to rely on them for cleanup. Note also that finalizers are run on a single VM-wide finalizer thread, so doing blocking work in a finalizer is a bad idea. A finalizer is usually only necessary for a class that has a native peer and needs to call a native method to destroy that peer. Even then, it's better to provide an explicit close method (and implement Closeable), and insist that callers manually dispose of instances. This works well for something like files, but less well for something like a BigInteger where typical calling code would have to deal with lots of temporaries. Unfortunately, code that creates lots of temporaries is the worst kind of code from the point of view of the single finalizer thread.

        If you must use finalizers, consider at least providing your own ReferenceQueue and having your own thread process that queue.

        Unlike constructors, finalizers are not automatically chained. You are responsible for calling super.finalize() yourself.

        Uncaught exceptions thrown by finalizers are ignored and do not terminate the finalizer thread. See Effective Java Item 7, "Avoid finalizers" for more.

        Overrides:
        finalize in class Object
        Throws:
        Throwable


Content

Android Reference

Java basics

Java Enterprise Edition (EE)

Java Standard Edition (SE)

SQL

HTML

PHP

CSS

Java Script

MYSQL

JQUERY

VBS

REGEX

C

C++

C#

Design patterns

RFC (standard status)

RFC (proposed standard status)

RFC (draft standard status)

RFC (informational status)

RFC (experimental status)

RFC (best current practice status)

RFC (historic status)

RFC (unknown status)

IT dictionary

License.
All information of this service is derived from the free sources and is provided solely in the form of quotations. This service provides information and interfaces solely for the familiarization (not ownership) and under the "as is" condition.
Copyright 2016 © ELTASK.COM. All rights reserved.
Site is optimized for mobile devices.
Downloads: 2893 / . Delta: 0.06274 с