Class IndexCopier
java.lang.Object
org.apache.jackrabbit.oak.plugins.index.lucene.IndexCopier
- All Implemented Interfaces:
Closeable,AutoCloseable,CopyOnReadStatsMBean
Copies index files to/from the local disk and the datastore.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsFields inherited from interface org.apache.jackrabbit.oak.plugins.index.lucene.CopyOnReadStatsMBean
TYPE -
Constructor Summary
ConstructorsConstructorDescriptionIndexCopier(Executor executor, File indexRootDir) IndexCopier(Executor executor, File indexRootDir, boolean prefetchEnabled) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()voidcopyDone()booleandeleteFile(Directory dir, String fileName, boolean copiedFromRemote) voiddoneCopy(org.apache.jackrabbit.oak.plugins.index.lucene.directory.LocalIndexFile file, long start) voidintString[]intintlongString[]getIndexDir(org.apache.jackrabbit.oak.plugins.index.search.IndexDefinition definition, String indexPath, String dirName) intlongintintstatic longgetNewestLocalFSTimestampFor(Set<String> names, Directory localDir) This method would return the latest modification timestamp from the set of filenameson the file system.intintintintlongintintbooleanisClosed()booleanisCopyInProgress(org.apache.jackrabbit.oak.plugins.index.lucene.directory.LocalIndexFile file) static booleanisFileModifiedBefore(String name, Directory localDir, long millis) booleanvoidreadFromLocal(boolean reader) voidreadFromRemote(boolean reader) voidvoidskippedUpload(long skippedFilesSize) longstartCopy(org.apache.jackrabbit.oak.plugins.index.lucene.directory.LocalIndexFile file) voidwaitForCopyCompletion(org.apache.jackrabbit.oak.plugins.index.lucene.directory.LocalIndexFile file, long timeoutMillis) Waits for maximum oftimeoutMilliswhile checking iffileisn't being copied already.wrapForRead(String indexPath, LuceneIndexDefinition definition, Directory remote, String dirName) wrapForWrite(LuceneIndexDefinition definition, Directory remote, boolean reindexMode, String dirName, IndexCopier.COWDirectoryTracker cowDirectoryTracker)
-
Field Details
-
REMOTE_ONLY
-
-
Constructor Details
-
IndexCopier
- Throws:
IOException
-
IndexCopier
public IndexCopier(Executor executor, File indexRootDir, boolean prefetchEnabled) throws IOException - Throws:
IOException
-
-
Method Details
-
wrapForRead
public Directory wrapForRead(String indexPath, LuceneIndexDefinition definition, Directory remote, String dirName) throws IOException - Throws:
IOException
-
wrapForWrite
public Directory wrapForWrite(LuceneIndexDefinition definition, Directory remote, boolean reindexMode, String dirName, IndexCopier.COWDirectoryTracker cowDirectoryTracker) throws IOException - Throws:
IOException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
isClosed
public boolean isClosed() -
getIndexDir
public File getIndexDir(org.apache.jackrabbit.oak.plugins.index.search.IndexDefinition definition, String indexPath, String dirName) throws IOException - Throws:
IOException
-
deleteFile
-
getNewestLocalFSTimestampFor
This method would return the latest modification timestamp from the set of filenameson the file system. The parameterlocalDiris expected to be an instance ofFSDirectory(or wrapped one inFilterDirectory. If this assumption doesn't hold, the method would return -1. Each of file names are expected to be existing inlocalDir. If this fails the method shall return -1. In case of any error while computing modified timestamps on the file system, the method shall return -1.- Parameters:
names- file names to evaluate on local FSlocalDir-Directoryimplementation to be used to get the files- Returns:
- latest timestamp or -1 (with logs) in case of any doubt
-
isFileModifiedBefore
- Parameters:
name- file name to evaluate on local FSlocalDir-Directoryimplementation to be used to get the filemillis- timestamp to compare file's modified timestamp against- Returns:
trueif file referred to benameis modified beforemillis; false otherwise
-
startCopy
public long startCopy(org.apache.jackrabbit.oak.plugins.index.lucene.directory.LocalIndexFile file) -
isCopyInProgress
public boolean isCopyInProgress(org.apache.jackrabbit.oak.plugins.index.lucene.directory.LocalIndexFile file) -
waitForCopyCompletion
public void waitForCopyCompletion(org.apache.jackrabbit.oak.plugins.index.lucene.directory.LocalIndexFile file, long timeoutMillis) Waits for maximum oftimeoutMilliswhile checking iffileisn't being copied already. The method can return beforetimeoutMillisif it got interrupted. So, if required then the caller should check usingisCopyInProgressand wait again.- Parameters:
file-timeoutMillis-
-
doneCopy
public void doneCopy(org.apache.jackrabbit.oak.plugins.index.lucene.directory.LocalIndexFile file, long start) -
skippedUpload
public void skippedUpload(long skippedFilesSize) -
scheduledForCopy
public void scheduledForCopy() -
copyDone
public void copyDone() -
readFromRemote
public void readFromRemote(boolean reader) -
readFromLocal
public void readFromLocal(boolean reader) -
foundInvalidFile
public void foundInvalidFile() -
getIndexPathMapping
- Specified by:
getIndexPathMappingin interfaceCopyOnReadStatsMBean
-
isPrefetchEnabled
public boolean isPrefetchEnabled()- Specified by:
isPrefetchEnabledin interfaceCopyOnReadStatsMBean
-
getReaderLocalReadCount
public int getReaderLocalReadCount()- Specified by:
getReaderLocalReadCountin interfaceCopyOnReadStatsMBean
-
getReaderRemoteReadCount
public int getReaderRemoteReadCount()- Specified by:
getReaderRemoteReadCountin interfaceCopyOnReadStatsMBean
-
getWriterLocalReadCount
public int getWriterLocalReadCount()- Specified by:
getWriterLocalReadCountin interfaceCopyOnReadStatsMBean
-
getWriterRemoteReadCount
public int getWriterRemoteReadCount()- Specified by:
getWriterRemoteReadCountin interfaceCopyOnReadStatsMBean
-
getInvalidFileCount
public int getInvalidFileCount() -
getDownloadSize
- Specified by:
getDownloadSizein interfaceCopyOnReadStatsMBean
-
getDownloadTime
public long getDownloadTime()- Specified by:
getDownloadTimein interfaceCopyOnReadStatsMBean
-
getDownloadCount
public int getDownloadCount()- Specified by:
getDownloadCountin interfaceCopyOnReadStatsMBean
-
getUploadCount
public int getUploadCount()- Specified by:
getUploadCountin interfaceCopyOnReadStatsMBean
-
getUploadSize
- Specified by:
getUploadSizein interfaceCopyOnReadStatsMBean
-
getUploadTime
public long getUploadTime()- Specified by:
getUploadTimein interfaceCopyOnReadStatsMBean
-
getLocalIndexSize
- Specified by:
getLocalIndexSizein interfaceCopyOnReadStatsMBean
-
getLocalIndexDirSize
public long getLocalIndexDirSize()- Specified by:
getLocalIndexDirSizein interfaceCopyOnReadStatsMBean
-
getGarbageDetails
- Specified by:
getGarbageDetailsin interfaceCopyOnReadStatsMBean
-
getGarbageSize
- Specified by:
getGarbageSizein interfaceCopyOnReadStatsMBean
-
getScheduledForCopyCount
public int getScheduledForCopyCount()- Specified by:
getScheduledForCopyCountin interfaceCopyOnReadStatsMBean
-
getCopyInProgressCount
public int getCopyInProgressCount()- Specified by:
getCopyInProgressCountin interfaceCopyOnReadStatsMBean
-
getCopyInProgressSize
- Specified by:
getCopyInProgressSizein interfaceCopyOnReadStatsMBean
-
getMaxCopyInProgressCount
public int getMaxCopyInProgressCount()- Specified by:
getMaxCopyInProgressCountin interfaceCopyOnReadStatsMBean
-
getMaxScheduledForCopyCount
public int getMaxScheduledForCopyCount()- Specified by:
getMaxScheduledForCopyCountin interfaceCopyOnReadStatsMBean
-
getSkippedFromUploadSize
- Specified by:
getSkippedFromUploadSizein interfaceCopyOnReadStatsMBean
-
getCopyInProgressDetails
- Specified by:
getCopyInProgressDetailsin interfaceCopyOnReadStatsMBean
-
getDeletedFilesCount
public int getDeletedFilesCount()- Specified by:
getDeletedFilesCountin interfaceCopyOnReadStatsMBean
-
getGarbageCollectedSize
- Specified by:
getGarbageCollectedSizein interfaceCopyOnReadStatsMBean
-