Class ConcurrentFileEndpoint
java.lang.Object
org.aksw.jena_sparql_api.io.endpoint.ConcurrentFileEndpoint
- All Implemented Interfaces:
Closeable,AutoCloseable,Channel,WritableByteChannel
Class for allowing an arbitrary number of concurrent reads to a file
while it is being written to. Readers reaching the end of their respective channel
will block and wait for more data as long as the write channel remains open.
An endpoint combines sink and source capabilities.
The ConcurrentFileEndpoint is a WritableByteChannel that
supports creating new InputStreams over the data.
At present, these InputStreams are not seekable.
- Author:
- raven
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanprotected CompletableFuture<Path>protected Pathprotected SeekableByteChannel -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidabandon()Only for the creating thread! Indicate that the writing to the endpoint has been abandoned.voidclose()static ConcurrentFileEndpointcreate(Path path, OpenOption... options) getPath()booleanbooleanisOpen()static voidtoString()intwrite(ByteBuffer src)
-
Field Details
-
path
-
writeChannel
-
isAbandoned
protected boolean isAbandoned -
isDone
-
-
Constructor Details
-
ConcurrentFileEndpoint
-
-
Method Details
-
create
- Throws:
IOException
-
getPath
-
isAbandoned
public boolean isAbandoned() -
abandon
public void abandon()Only for the creating thread! Indicate that the writing to the endpoint has been abandoned. Must be indicated before closing the endpoint, as any readers will also check the isOpen state upon reaching the end of data, and if there is no abandon state they will assume successful completion. -
getIsDone
-
isOpen
public boolean isOpen() -
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceChannel- Specified by:
closein interfaceCloseable- Throws:
IOException
-
write
- Specified by:
writein interfaceWritableByteChannel- Throws:
IOException
-
newReadChannel
- Throws:
IOException
-
toString
-
main
- Throws:
IOExceptionInterruptedException
-