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 ofResource
for 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 long
contentLength()
org.springframework.core.io.Resource
createRelative(java.lang.String relativePath)
boolean
exists()
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.static AgentFileResourceImpl
forNonExistingResource()
Factory method to create a placeholder resource for a remote file that does not exist.java.lang.String
getDescription()
java.io.File
getFile()
java.lang.String
getFilename()
java.io.InputStream
getInputStream()
java.net.URI
getURI()
java.net.URL
getURL()
boolean
isOpen()
long
lastModified()
-
-
-
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:
exists
in interfaceorg.springframework.core.io.Resource
-
isOpen
public boolean isOpen()
- Specified by:
isOpen
in interfaceorg.springframework.core.io.Resource
-
getURL
public java.net.URL getURL() throws java.io.IOException
- Specified by:
getURL
in interfaceorg.springframework.core.io.Resource
- Throws:
java.io.IOException
-
getURI
public java.net.URI getURI() throws java.io.IOException
- Specified by:
getURI
in interfaceorg.springframework.core.io.Resource
- Throws:
java.io.IOException
-
getFile
public java.io.File getFile() throws java.io.IOException
- Specified by:
getFile
in interfaceorg.springframework.core.io.Resource
- Throws:
java.io.IOException
-
contentLength
public long contentLength() throws java.io.IOException
- Specified by:
contentLength
in interfaceorg.springframework.core.io.Resource
- Throws:
java.io.IOException
-
lastModified
public long lastModified() throws java.io.IOException
- Specified by:
lastModified
in 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:
createRelative
in interfaceorg.springframework.core.io.Resource
- Throws:
java.io.IOException
-
getFilename
public java.lang.String getFilename()
- Specified by:
getFilename
in interfaceorg.springframework.core.io.Resource
-
getDescription
public java.lang.String getDescription()
- Specified by:
getDescription
in interfaceorg.springframework.core.io.Resource
-
getInputStream
public java.io.InputStream getInputStream() throws java.io.IOException
- Specified by:
getInputStream
in interfaceorg.springframework.core.io.InputStreamSource
- Throws:
java.io.IOException
-
-