TODO: Have a central warnings/errors structure. Warnings by path for things that are anamolous (spelling), such as resource hash directories with unexpected names. Warnings for things failed to auto-cleanup. Errors by path for csync2 failures, could initialize state from a csync2 -t test. Could background re-test either all csync2 or paths with known synchronization failures. Could integrated into status page (or status.json). Could integrated into AO monitoring.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final char
The separator character to go between the resource or filename and the extension. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionfindOrAdd
(UploadFile uploadFile) Stores a new file in CDN data.fsck()
Performs a non-startup fsck of this CDN data.Gets the resources handler for this CDN.Gets the uploads handler for this CDN.toString()
-
Field Details
-
EXTENSION_SEPARATOR
public static final char EXTENSION_SEPARATORThe separator character to go between the resource or filename and the extension. This is used internally in the filesystem and externally in the URL.- See Also:
-
-
Constructor Details
-
CdnData
Creates a new CDN data accessor. An fsck() is performed immediately in start-up mode. Any issue that is severe or higher will cause the CDN to fail by throwingIOException
.- Parameters:
cdnRoot
- The directory that contains the underlying CDN data. This should not be in the web root directly, but instead should be mapped into Tomcat via the<PreResource>
mechanism. The front-end component will dispatch to the resource after URL rewriting and access control. Back-end components interact with this CDN data directly.csync2Group
- The Csync2 group to be synchronized after each change. Whennull
empty (after trimming), no synchronization is performed.isUploader
- Is this the uploader instance of cdn-data, which is responsible for introducing entirely new resources?- Throws:
IOException
- When CDN start-up fsck() fails.- See Also:
-
-
Method Details
-
toString
-
fsck
Performs a non-startup fsck of this CDN data.- Returns:
- Unmodifiable map of issues
-
getResources
Gets the resources handler for this CDN. -
getUploads
Gets the uploads handler for this CDN.- Throws:
IllegalStateException
- when this CDN data upload is disabled.
-
findOrAdd
Stores a new file in CDN data.First searches all existing resources for a match, including matching derived resources. A full byte-by-byte check is performed.
When a match is found, the existing resource is returned. This means that a higher quality resource may be returned than the one requested.
- Parameters:
uploadFile
- This underlying file should have been returned fromUploads.createUploadFile(com.aoapps.cdn.data.CdnData.ContentType)
. If a different file is used, it may not have correct permissions and also may not be able to be moved into place efficiently.The underlying file must have an extension matching the expected extension for the type.
This underlying file must not be changed after being stored. Doing so may corrupted the underlying CDN data.
- Returns:
- The resource, whether found existing or stored new. This resource will be equivalent to, or higher quality, than the requested resource. Furthermore, the requested resource is guaranteed to be immediately available at its specific resolution without any on-demand scaling.
- Throws:
IllegalArgumentException
- if the upload file is from a different CDN data instance, if the upload file has already been stored, or if the upload file has an incorrect extensionIOException
- See Also:
-