org.apache.lucene.replicator.nrt

## Class CopyJob

- java.lang.Object
- - org.apache.lucene.replicator.nrt.CopyJob

- All Implemented Interfaces:
    Comparable<CopyJob>

      public abstract class CopyJob
      extends Object
      implements Comparable<CopyJob>

  Handles copying one set of files, e.g. all files for a new NRT point, or files for pre-copying a merged segment. This notifies the caller via OnceDone when the job finishes or failed.
  WARNING: This API is experimental and might change in incompatible ways in the next release.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static interface` | `CopyJob.OnceDone` Callback invoked by CopyJob once all files have (finally) finished copying

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected String` | `cancelReason`
    `protected Map<String,String>` | `copiedFiles`
    `protected CopyOneFile` | `current`
    `protected ReplicaNode` | `dest`
    `protected Throwable` | `exc`
    `protected Map<String,FileMetaData>` | `files`
    `boolean` | `highPriority` True for an NRT sync, false for pre-copying a newly merged segment
    `CopyJob.OnceDone` | `onceDone`
    `long` | `ord`
    `String` | `reason`
    `long` | `startNS`
    `protected List<Map.Entry<String,FileMetaData>>` | `toCopy`
    `protected long` | `totBytes`
    `protected long` | `totBytesCopied`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `CopyJob(String reason, Map<String,FileMetaData> files, ReplicaNode dest, boolean highPriority, CopyJob.OnceDone onceDone)`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `cancel(String reason, Throwable exc)`
    `abstract boolean` | `conflicts(CopyJob other)` Return true if this job is trying to copy any of the same files as the other job
    `abstract void` | `finish()` Renames all copied (tmp) files to their true file names
    `abstract CopyState` | `getCopyState()`
    `abstract boolean` | `getFailed()`
    `abstract Set<String>` | `getFileNames()` Returns all file names referenced in this copy job
    `abstract Set<String>` | `getFileNamesToCopy()` Returns only those file names (a subset of `getFileNames()`) that need to be copied
    `abstract long` | `getTotalBytesCopied()`
    `protected abstract CopyOneFile` | `newCopyOneFile(CopyOneFile current)`
    `abstract void` | `runBlocking()` Use current thread (blocking) to do all copying and then return once done, or throw exception on failure
    `abstract void` | `start()` Begin copying files
    `void` | `transferAndCancel(CopyJob prevJob)` Transfers whatever tmp files were already copied in this previous job and cancels the previous job

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

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

    - ### Methods inherited from interface java.lang.Comparable

      `compareTo`

- - ### Field Detail

    - #### dest

          protected final ReplicaNode dest

    - #### files

          protected final Map<String,FileMetaData> files

    - #### ord

          public final long ord

    - #### highPriority

          public final boolean highPriority

      True for an NRT sync, false for pre-copying a newly merged segment

    - #### onceDone

          public final CopyJob.OnceDone onceDone

    - #### startNS

          public final long startNS

    - #### reason

          public final String reason

    - #### toCopy

          protected final List<Map.Entry<String,FileMetaData>> toCopy

    - #### totBytes

          protected long totBytes

    - #### totBytesCopied

          protected long totBytesCopied

    - #### current

          protected CopyOneFile current

    - #### exc

          protected volatile Throwable exc

    - #### cancelReason

          protected volatile String cancelReason

    - #### copiedFiles

          protected final Map<String,String> copiedFiles

  - ### Constructor Detail

    - #### CopyJob

          protected CopyJob(String reason,
                            Map<String,FileMetaData> files,
                            ReplicaNode dest,
                            boolean highPriority,
                            CopyJob.OnceDone onceDone)
                     throws IOException

      Throws:
        `IOException`

  - ### Method Detail

    - #### transferAndCancel

          public void transferAndCancel(CopyJob prevJob)
                                 throws IOException

      Transfers whatever tmp files were already copied in this previous job and cancels the previous job
      Throws:
        `IOException`

    - #### newCopyOneFile

          protected abstract CopyOneFile newCopyOneFile(CopyOneFile current)

    - #### start

          public abstract void start()
                              throws IOException

      Begin copying files
      Throws:
        `IOException`

    - #### runBlocking

          public abstract void runBlocking()
                                    throws Exception

      Use current thread (blocking) to do all copying and then return once done, or throw exception on failure
      Throws:
        `Exception`

    - #### cancel

          public void cancel(String reason,
                             Throwable exc)
                      throws IOException

      Throws:
        `IOException`

    - #### conflicts

          public abstract boolean conflicts(CopyJob other)

      Return true if this job is trying to copy any of the same files as the other job

    - #### finish

          public abstract void finish()
                               throws IOException

      Renames all copied (tmp) files to their true file names
      Throws:
        `IOException`

    - #### getFailed

          public abstract boolean getFailed()

    - #### getFileNamesToCopy

          public abstract Set<String> getFileNamesToCopy()

      Returns only those file names (a subset of `getFileNames()`) that need to be copied

    - #### getFileNames

          public abstract Set<String> getFileNames()

      Returns all file names referenced in this copy job

    - #### getCopyState

          public abstract CopyState getCopyState()

    - #### getTotalBytesCopied

          public abstract long getTotalBytesCopied()

Copyright © 2000-2024 Apache Software Foundation. All Rights Reserved.