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 interface
StreamedResponseClient.PingHandler
Expert: PingHandler interface.
-
Field Summary
Fields Modifier and Type Field Description static int
DOCUMENT_END_FRAME
static int
DOCUMENT_START_FRAME
static int
EXCEPTION_FRAME
static int
FACET_START_FRAME
static int
OBJECT_FRAME
static int
PING_FRAME
static int
QUERY_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 long
bytesRead()
Get the number of bytes read during streaming request.void
cancel()
Force disconnect the client connection.void
close()
Closes the streaming connection.static StreamedResponseClient
connect(StreamRequestInfo request, StreamResponse response)
static StreamedResponseClient
createStreamedResponseClient(java.lang.String clientWorkflow, java.lang.String queryEndpoint, QueryRequest request, StreamRequestInfo streamConfig)
Create a new streamed response client.protected void
finalize()
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.PingHandler
getPingHandler()
Expert: Get the ping handler.QueryResponse
getQueryResponse()
Get the QueryResponse for the query.StreamRequestInfo
getStreamConfig()
StreamResponse
getStreamResponse()
void
initStream()
protected java.lang.Object
receive()
Read the next element from the response stream.void
setPingHandler(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:
getDocuments
in interfaceStreamingQueryResponse
- Throws:
java.io.IOException
-
getDocumentIds
public java.lang.Iterable<java.lang.String> getDocumentIds() throws java.io.IOException
Get the response document ids.This method will throw an exception if document ids are not yet available, or were not requested.
- Specified by:
getDocumentIds
in 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:
getFacets
in 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
null
if stream was closed prematurely.- Specified by:
getQueryResponse
in interfaceStreamingQueryResponse
- Throws:
java.io.IOException
AttivioException
-
initStream
public void initStream() throws AttivioException, java.io.IOException
- Throws:
AttivioException
java.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.IOException
Closes the streaming connection.- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Specified by:
close
in interfaceStreamingQueryResponse
- Throws:
java.io.IOException
-
finalize
protected void finalize() throws java.lang.Throwable
- Overrides:
finalize
in classjava.lang.Object
- Throws:
java.lang.Throwable
-
cancel
public void cancel() throws java.io.IOException
Force disconnect the client connection. Ignores thread guards on purpose.- Specified by:
cancel
in 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
-
-