Class AgentFileResourceImpl
- java.lang.Object
-
- com.netflix.genie.web.agent.resources.AgentFileResourceImpl
-
- All Implemented Interfaces:
AgentFileStreamService.AgentFileResource,org.springframework.core.io.InputStreamSource,org.springframework.core.io.Resource
public final class AgentFileResourceImpl extends java.lang.Object implements AgentFileStreamService.AgentFileResource
Implementation ofResourcefor files local to an agent running a job that can be requested and streamed to the server (so they can be served via API).- Since:
- 4.0.0
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description longcontentLength()org.springframework.core.io.ResourcecreateRelative(java.lang.String relativePath)booleanexists()static AgentFileStreamService.AgentFileResourceforAgentFile(java.net.URI uri, long size, java.time.Instant lastModifiedTime, java.nio.file.Path relativePath, java.lang.String jobId, java.io.InputStream inputStream)Factory method to create a resource for a remote file.static AgentFileResourceImplforNonExistingResource()Factory method to create a placeholder resource for a remote file that does not exist.java.lang.StringgetDescription()java.io.FilegetFile()java.lang.StringgetFilename()java.io.InputStreamgetInputStream()java.net.URIgetURI()java.net.URLgetURL()booleanisOpen()longlastModified()
-
-
-
Method Detail
-
forNonExistingResource
public static AgentFileResourceImpl forNonExistingResource()
Factory method to create a placeholder resource for a remote file that does not exist.- Returns:
- a
AgentFileStreamService.AgentFileResource
-
forAgentFile
public static AgentFileStreamService.AgentFileResource forAgentFile(java.net.URI uri, long size, java.time.Instant lastModifiedTime, java.nio.file.Path relativePath, java.lang.String jobId, java.io.InputStream inputStream)
Factory method to create a resource for a remote file.- Parameters:
uri- the resource URIsize- the size of the file, as per latest manifestlastModifiedTime- the last modification time, as per latest manifestrelativePath- the path of the file relative to the root of the job directoryjobId- the id of the job this file belongs toinputStream- the input stream to read this file content- Returns:
- a
AgentFileStreamService.AgentFileResource
-
exists
public boolean exists()
- Specified by:
existsin interfaceorg.springframework.core.io.Resource
-
isOpen
public boolean isOpen()
- Specified by:
isOpenin interfaceorg.springframework.core.io.Resource
-
getURL
public java.net.URL getURL() throws java.io.IOException- Specified by:
getURLin interfaceorg.springframework.core.io.Resource- Throws:
java.io.IOException
-
getURI
public java.net.URI getURI() throws java.io.IOException- Specified by:
getURIin interfaceorg.springframework.core.io.Resource- Throws:
java.io.IOException
-
getFile
public java.io.File getFile() throws java.io.IOException- Specified by:
getFilein interfaceorg.springframework.core.io.Resource- Throws:
java.io.IOException
-
contentLength
public long contentLength() throws java.io.IOException- Specified by:
contentLengthin interfaceorg.springframework.core.io.Resource- Throws:
java.io.IOException
-
lastModified
public long lastModified() throws java.io.IOException- Specified by:
lastModifiedin interfaceorg.springframework.core.io.Resource- Throws:
java.io.IOException
-
createRelative
public org.springframework.core.io.Resource createRelative(java.lang.String relativePath) throws java.io.IOException- Specified by:
createRelativein interfaceorg.springframework.core.io.Resource- Throws:
java.io.IOException
-
getFilename
public java.lang.String getFilename()
- Specified by:
getFilenamein interfaceorg.springframework.core.io.Resource
-
getDescription
public java.lang.String getDescription()
- Specified by:
getDescriptionin interfaceorg.springframework.core.io.Resource
-
getInputStream
public java.io.InputStream getInputStream() throws java.io.IOException- Specified by:
getInputStreamin interfaceorg.springframework.core.io.InputStreamSource- Throws:
java.io.IOException
-
-