Class S3FileAccessV1
java.lang.Object
dev.jcputney.elearning.parser.impl.S3FileAccessV1
- All Implemented Interfaces:
FileAccess
Optimized implementation of FileAccess using AWS S3 SDK v1 with batch operations, streaming
support, and intelligent caching.
-
Constructor Summary
ConstructorsConstructorDescriptionS3FileAccessV1(com.amazonaws.services.s3.AmazonS3 s3Client, String bucketName, String rootPath) Constructs an optimized S3FileAccessV1 instance with the specified S3 client and bucket name. -
Method Summary
Modifier and TypeMethodDescriptionvoidClear all caches - useful for testing or when bucket contents change.fileExistsBatch(List<String> paths) Batch check if multiple files exist - much more efficient for module parsing.booleanfileExistsInternal(String path) Checks if a file exists at the specified path with caching.Retrieves statistics about various internal caches used in the class.Gets the contents of a file as an InputStream with intelligent streaming/caching.Determines the internal root directory within the S3 bucket with lazy initialization.listFilesInternal(String directoryPath) Lists the files in the specified directory path with caching and pagination support.voidPrefetch common module files in parallel for faster subsequent access.voidshutdown()Shutdown the executor service when the instance is no longer needed.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface dev.jcputney.elearning.parser.api.FileAccess
fileExists, fullPath, getFileContents, getRootPath, listFiles
-
Constructor Details
-
S3FileAccessV1
public S3FileAccessV1(com.amazonaws.services.s3.AmazonS3 s3Client, String bucketName, String rootPath) Constructs an optimized S3FileAccessV1 instance with the specified S3 client and bucket name.- Parameters:
s3Client- The S3 client to use for accessing files.bucketName- The name of the S3 bucket to access.rootPath- The root path of the S3 bucket to access.
-
-
Method Details
-
fileExistsInternal
Checks if a file exists at the specified path with caching.- Specified by:
fileExistsInternalin interfaceFileAccess- Parameters:
path- The path of the file to check (guaranteed to be non-null).- Returns:
- True if the file exists, false otherwise.
-
fileExistsBatch
Batch check if multiple files exist - much more efficient for module parsing.- Parameters:
paths- List of file paths to check- Returns:
- Map of path to existence boolean
-
prefetchCommonFiles
public void prefetchCommonFiles()Prefetch common module files in parallel for faster subsequent access. -
listFilesInternal
Lists the files in the specified directory path with caching and pagination support.- Specified by:
listFilesInternalin interfaceFileAccess- Parameters:
directoryPath- The path of the directory to list files from (guaranteed to be non-null).- Returns:
- A list of file paths in the specified directory.
- Throws:
IOException- if there's an error accessing the directory or listing its contents.
-
getFileContentsInternal
Gets the contents of a file as an InputStream with intelligent streaming/caching.- Specified by:
getFileContentsInternalin interfaceFileAccess- Parameters:
path- The path of the file to get contents from (guaranteed to be non-null).- Returns:
- An InputStream containing the file contents.
- Throws:
IOException- if the file can't be read.
-
getInternalRootDirectory
Determines the internal root directory within the S3 bucket with lazy initialization.- Returns:
- The detected internal root directory or the original path if none is detected.
-
clearCaches
public void clearCaches()Clear all caches - useful for testing or when bucket contents change. -
getCacheStats
Retrieves statistics about various internal caches used in the class.- Returns:
- A map where the keys are the cache names (e.g., "fileExistsCache", "directoryListCache", etc.) and the values are the respective sizes of these caches.
-
shutdown
public void shutdown()Shutdown the executor service when the instance is no longer needed.
-