net.i2p.router.tasks

## Class MarkLiveliness

- java.lang.Object
- - net.i2p.router.tasks.MarkLiveliness

- All Implemented Interfaces:
    SimpleTimer.TimedEvent

      public class MarkLiveliness
      extends Object
      implements SimpleTimer.TimedEvent

  Router instance liveliness marker for multi-instance detection. This class periodically writes a timestamp to a "ping file" to indicate that this router instance is alive and running. Other router instances attempting to use the same configuration directory can check this file to detect if another instance is already active. Purpose:
  - Prevent multiple router instances using same config
  - Allow detection of active router instances
  - Provide timestamp-based liveliness indication
  - Support automatic cleanup on router shutdown
  Behavior:
  - Updates timestamp periodically while router is alive
  - Deletes ping file when router shuts down
  - Logs errors only once to prevent log spam
  - Uses secure file writing for atomic updates
  The ping file contains only the current timestamp in milliseconds since epoch. Other instances can check the file age to determine if the router is recently active or abandoned.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `MarkLiveliness(Router router, File pingFile)` Create a new liveliness marker.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `timeReached()` Update the ping file with current timestamp if router is alive.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### MarkLiveliness

          public MarkLiveliness(Router router,
                                File pingFile)

      Create a new liveliness marker.
      Parameters:
        `router` - the router instance to monitor for liveliness
        `pingFile` - the file to write timestamps to

  - ### Method Detail

    - #### timeReached

          public void timeReached()

      Update the ping file with current timestamp if router is alive. If the router is alive, writes the current timestamp to the ping file. If the router is not alive, deletes the ping file to indicate that this router instance is no longer running. The ping file allows other router instances using the same configuration to detect if another instance is already running.
      Specified by:
        `timeReached` in interface `SimpleTimer.TimedEvent`