Package com.attivio.client.streaming
Class StreamedResponseClient
- java.lang.Object
-
- com.attivio.client.streaming.StreamedResponseClient
-
- All Implemented Interfaces:
StreamingQueryResponse,java.io.Closeable,java.lang.AutoCloseable
public class StreamedResponseClient extends java.lang.Object implements StreamingQueryResponse
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceStreamedResponseClient.PingHandlerExpert: PingHandler interface.
-
Field Summary
Fields Modifier and Type Field Description static intDOCUMENT_END_FRAMEstatic intDOCUMENT_START_FRAMEstatic intEXCEPTION_FRAMEstatic intFACET_START_FRAMEstatic intOBJECT_FRAMEstatic intPING_FRAMEstatic intQUERY_RESPONSE_FRAME
-
Constructor Summary
Constructors Constructor Description StreamedResponseClient(StreamRequestInfo config, java.io.InputStream input)Internal Use Only
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description longbytesRead()Get the number of bytes read during streaming request.voidcancel()Force disconnect the client connection.voidclose()Closes the streaming connection.static StreamedResponseClientconnect(StreamRequestInfo request, StreamResponse response)static StreamedResponseClientcreateStreamedResponseClient(java.lang.String clientWorkflow, java.lang.String queryEndpoint, QueryRequest request, StreamRequestInfo streamConfig)Create a new streamed response client.protected voidfinalize()java.lang.Iterable<java.lang.String>getDocumentIds()Get the response document ids.java.lang.Iterable<SearchDocument>getDocuments()Get the response documents.java.lang.Iterable<StreamingFacetResponse>getFacets()Get the facets.StreamedResponseClient.PingHandlergetPingHandler()Expert: Get the ping handler.QueryResponsegetQueryResponse()Get the QueryResponse for the query.StreamRequestInfogetStreamConfig()StreamResponsegetStreamResponse()voidinitStream()protected java.lang.Objectreceive()Read the next element from the response stream.voidsetPingHandler(StreamedResponseClient.PingHandler value)Expert: Set the ping handler.
-
-
-
Field Detail
-
OBJECT_FRAME
public static final int OBJECT_FRAME
- See Also:
- Constant Field Values
-
DOCUMENT_START_FRAME
public static final int DOCUMENT_START_FRAME
- See Also:
- Constant Field Values
-
FACET_START_FRAME
public static final int FACET_START_FRAME
- See Also:
- Constant Field Values
-
QUERY_RESPONSE_FRAME
public static final int QUERY_RESPONSE_FRAME
- See Also:
- Constant Field Values
-
EXCEPTION_FRAME
public static final int EXCEPTION_FRAME
- See Also:
- Constant Field Values
-
PING_FRAME
public static final int PING_FRAME
- See Also:
- Constant Field Values
-
DOCUMENT_END_FRAME
public static final int DOCUMENT_END_FRAME
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
StreamedResponseClient
public StreamedResponseClient(StreamRequestInfo config, java.io.InputStream input)
Internal Use Only
-
-
Method Detail
-
bytesRead
public long bytesRead()
Get the number of bytes read during streaming request.NOTE: Returns -1 if this could not be determined.
-
getPingHandler
public StreamedResponseClient.PingHandler getPingHandler()
Expert: Get the ping handler.
-
setPingHandler
public void setPingHandler(StreamedResponseClient.PingHandler value)
Expert: Set the ping handler.
-
getStreamResponse
public StreamResponse getStreamResponse()
-
getStreamConfig
public StreamRequestInfo getStreamConfig()
-
getDocuments
public java.lang.Iterable<SearchDocument> getDocuments() throws java.io.IOException
Get the response documents.This method will throw an exception if documents are not yet available, or were not requested.
- Specified by:
getDocumentsin interfaceStreamingQueryResponse- Throws:
java.io.IOException
-
getDocumentIds
public java.lang.Iterable<java.lang.String> getDocumentIds() throws java.io.IOExceptionGet the response document ids.This method will throw an exception if document ids are not yet available, or were not requested.
- Specified by:
getDocumentIdsin interfaceStreamingQueryResponse- Throws:
java.io.IOException
-
getFacets
public java.lang.Iterable<StreamingFacetResponse> getFacets() throws java.io.IOException
Get the facets.This method will throw an exception if facets are not yet available, or were not requested.
- Specified by:
getFacetsin interfaceStreamingQueryResponse- Throws:
java.io.IOException
-
getQueryResponse
public QueryResponse getQueryResponse() throws java.io.IOException, AttivioException
Get the QueryResponse for the query.This method will throw an exception if the query response is not yet available, or if the query execution resulted in an exception.
NOTE: this method may return
nullif stream was closed prematurely.- Specified by:
getQueryResponsein interfaceStreamingQueryResponse- Throws:
java.io.IOExceptionAttivioException
-
initStream
public void initStream() throws AttivioException, java.io.IOException- Throws:
AttivioExceptionjava.io.IOException
-
receive
protected java.lang.Object receive()
Read the next element from the response stream.Returns null on boundary.
-
close
public void close() throws java.io.IOExceptionCloses the streaming connection.- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Specified by:
closein interfaceStreamingQueryResponse- Throws:
java.io.IOException
-
finalize
protected void finalize() throws java.lang.Throwable- Overrides:
finalizein classjava.lang.Object- Throws:
java.lang.Throwable
-
cancel
public void cancel() throws java.io.IOExceptionForce disconnect the client connection. Ignores thread guards on purpose.- Specified by:
cancelin interfaceStreamingQueryResponse- Throws:
java.io.IOException
-
createStreamedResponseClient
public static final StreamedResponseClient createStreamedResponseClient(java.lang.String clientWorkflow, java.lang.String queryEndpoint, QueryRequest request, StreamRequestInfo streamConfig) throws AttivioException
Create a new streamed response client.This will move into SearchClient eventually but is left here for better separation during development.
- Throws:
AttivioException
-
connect
public static final StreamedResponseClient connect(StreamRequestInfo request, StreamResponse response) throws AttivioException
- Throws:
AttivioException
-
-