net.i2p.router.networkdb.kademlia

## Class StoreJob

- java.lang.Object
- - net.i2p.router.JobImpl
  - - net.i2p.router.networkdb.kademlia.StoreJob

- All Implemented Interfaces:
    Job
  Direct Known Subclasses:
    FloodfillStoreJob

      abstract class StoreJob
      extends JobImpl

  Abstract base class for network database store operations.

  Handles the process of storing database entries (RouterInfo or LeaseSet) to floodfill peers with configurable parallelization, redundancy, and timeout handling. Supports both direct and tunnel-based delivery with garlic encryption for client data.

  All store operations through this class request a reply to confirm successful delivery. Unused directly - see FloodfillStoreJob for the concrete implementation.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected Log` | `_log` Logger for this class
    `protected StoreState` | `_state` Current state of the store operation
    `static String` | `MIN_STORE_ENCLS2_VERSION` Was supported in 38, but they're now sigtype 11 which wasn't added until 39
    `static String` | `MIN_STORE_LS2_VERSION`
    `static String` | `MIN_STORE_VERSION` Short ECIES tunnel build messages (1.5.0)

    - ### Fields inherited from class net.i2p.router.JobImpl

      `_id`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `StoreJob(RouterContext context, KademliaNetworkDatabaseFacade facade, Hash key, DatabaseEntry data, Job onSuccess, Job onFailure, long timeoutMs)` Send a data structure to the floodfills
    `StoreJob(RouterContext context, KademliaNetworkDatabaseFacade facade, Hash key, DatabaseEntry data, Job onSuccess, Job onFailure, long timeoutMs, Set<Hash> toSkip)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `fail()` Handle failed completion of the store operation.
    `String` | `getName()` Get the name of this job for logging and debugging.
    `protected int` | `getParallelization()` Get the maximum number of parallel store operations.
    `protected int` | `getRedundancy()` Get the required redundancy level for successful store.
    `void` | `runJob()` Execute the job to start sending to the next batch of peers.
    `(package private) static boolean` | `shouldStoreEncLS2To(RouterInfo ri)` Is it new enough?
    `(package private) static boolean` | `shouldStoreLS2To(RouterInfo ri)` Is it new enough?
    `(package private) static boolean` | `shouldStoreTo(RouterInfo ri)` Is it new enough?
    `protected void` | `succeed()` Handle successful completion of the store operation.

    - ### Methods inherited from class net.i2p.router.JobImpl

      `dropped, getContext, getJobId, getMadeReadyOn, getTiming, madeReady, requeue, toString`

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

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

- - ### Field Detail

    - #### _log

          protected final Log _log

      Logger for this class

    - #### _state

          protected final StoreState _state

      Current state of the store operation

    - #### MIN_STORE_ENCLS2_VERSION

          public static final String MIN_STORE_ENCLS2_VERSION

      Was supported in 38, but they're now sigtype 11 which wasn't added until 39
      See Also:
        Constant Field Values

    - #### MIN_STORE_LS2_VERSION

          public static final String MIN_STORE_LS2_VERSION

      See Also:
        Constant Field Values

    - #### MIN_STORE_VERSION

          public static final String MIN_STORE_VERSION

      Short ECIES tunnel build messages (1.5.0)
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### StoreJob

          public StoreJob(RouterContext context,
                          KademliaNetworkDatabaseFacade facade,
                          Hash key,
                          DatabaseEntry data,
                          Job onSuccess,
                          Job onFailure,
                          long timeoutMs)

      Send a data structure to the floodfills

    - #### StoreJob

          public StoreJob(RouterContext context,
                          KademliaNetworkDatabaseFacade facade,
                          Hash key,
                          DatabaseEntry data,
                          Job onSuccess,
                          Job onFailure,
                          long timeoutMs,
                          Set<Hash> toSkip)

      Parameters:
        `toSkip` - set of peer hashes of people we don't want to send the data to (e.g. we already know they have it). This can be null.

  - ### Method Detail

    - #### fail

          protected void fail()

      Handle failed completion of the store operation. Called when the store operation has exhausted all options.

    - #### getName

          public String getName()

      Get the name of this job for logging and debugging.
      Returns:
        job name

    - #### getParallelization

          protected int getParallelization()

      Get the maximum number of parallel store operations. Note: Overridden in Floodfill Search Job.
      Returns:
        number of messages to send simultaneously

    - #### getRedundancy

          protected int getRedundancy()

      Get the required redundancy level for successful store. Note: Overridden in Floodfill Search Job.
      Returns:
        number of peers that must receive the data

    - #### runJob

          public void runJob()

      Execute the job to start sending to the next batch of peers.

    - #### shouldStoreEncLS2To

          static boolean shouldStoreEncLS2To(RouterInfo ri)

      Is it new enough?

    - #### shouldStoreLS2To

          static boolean shouldStoreLS2To(RouterInfo ri)

      Is it new enough?

    - #### shouldStoreTo

          static boolean shouldStoreTo(RouterInfo ri)

      Is it new enough?

    - #### succeed

          protected void succeed()

      Handle successful completion of the store operation. Called when the required redundancy level is reached.