3#ifndef STREAMBASE_CLIENT_H
4#define STREAMBASE_CLIENT_H
6#include "StreamBase.hpp"
7#include "StreamBaseVersion.hpp"
8#include "Exceptions.hpp"
11#include "StreamProperties.hpp"
12#include "StreamBaseEntityType.hpp"
13#include "StreamBaseURI.hpp"
14#include "TupleList.hpp"
15#include "DequeueResult.hpp"
16#include "ClientSettings.hpp"
18SB_INTERNAL_FWD(StreamBaseClientImpl)
30 static const unsigned int DEFAULT_FLUSH_INTERVAL = 250;
35 static bool useRawTuples;
45 int flush_interval=DEFAULT_FLUSH_INTERVAL);
49 int flush_interval=DEFAULT_FLUSH_INTERVAL);
53 int flush_interval=DEFAULT_FLUSH_INTERVAL);
58 int flush_interval=DEFAULT_FLUSH_INTERVAL);
70 FULLY_QUALIFIED_NAMES = 1,
76 ALL_CONTAINERS = 4 | FULLY_QUALIFIED_NAMES
83 void listEntities(
const std::string &type,
int flags, std::vector<std::string>& names);
98 std::string
describe(
const std::string &entity);
102 bool checkLicense(
const std::string &featureName);
132 std::map<std::string, Schema>& streams,
330 void operatorStatus(
const std::string &containerName, std::vector<std::string> &aStatus);
333 void status(std::vector<std::string> &aStatus,
bool verbose =
false);
338 const std::vector<StreamBaseURI>& getURIs()
const;
381 void enableConnectionlessEnqueue(
bool enable);
388 bool getIsConnectionlessEnqueue();
460 void internalCommand(
const std::vector<std::string>& arguments, std::vector<std::string> &result);
476 return std::string(StreamBaseVersion::INFO_LINE);
483 return _clientSettings;
498 typedef std::map<std::string, StreamProperties> StreamMap;
500 std::shared_ptr<sb_internal::StreamBaseClientImpl> _impl;
511 StreamMap _streamMap;
This class loads all the environment variables used by the C++ client API.
Definition: ClientSettings.hpp:20
A callback interface that can be implemented by an object that is associated with a StreamBaseClient ...
Definition: DequeueResult.hpp:30
Encapsulates the data returned from a dequeue() operation.
Definition: DequeueResult.hpp:23
A type of tuple, containing zero or more fields (each encapsulated as a Schema::Field object).
Definition: Schema.hpp:62
The StreamBase client API.
Definition: StreamBaseClient.hpp:28
std::string getVersion()
Returns the client version as a string.
Definition: StreamBaseClient.hpp:475
DequeueResult dequeue(int timeout_ms)
Dequeue tuples from any subscribed stream.
void enqueue(const StreamProperties &props, TupleList &tuples)
Enqueue tuples to a stream.
bool isStreamSubscribed(const std::string &entity)
Returns true if this stream has been subscribed to.
Schema getSchemaForStream(const std::string &entity, StreamProperties::CaptureTransformStrategy strategy=StreamProperties::FLATTEN)
Returns the schema of a stream, throwing an exception if the stream does not exist.
long long getTupleEnqueueCount() const
Returns the number of tuples this client has actually enqueued to the server.
void enqueue(const std::string &stream_name, Tuple &tuple)
Enqueue tuples to a stream.
long long getTupleDequeueCount() const
Returns the number of tuples this client has dequeued from the server.
DequeueResult::Interceptor * getDequeueResultsInterceptor()
Get the current dequeue results interceptor, or null if there is no current processor.
void setDynamicVariable(const std::string &dynamicVariablePath, const std::string &value)
Set the dynamic variable at the given path to the given value, expressed as a string in CSV style.
TupleList dequeue(std::string &stream_name)
Dequeue tuples from any subscribed stream.
TupleList readTable(const std::string &tablePath, int limit, const std::string &predicate="")
Read rows out of the table at this path.
StreamProperties subscribe(const std::string &stream_name, const std::string &logical_stream, const std::string &predicate)
Subscribes to a stream with a predicate to apply to output tuples.
void typecheck(const std::string &sbapp, std::map< std::string, Schema > &streams, bool full=false)
Typechecks a potential modification to the application, outputting properties of all streams in the a...
bool getIsBuffering() const
Return whether buffering is turned on or off.
bool isClosed()
Return true if the client connection is closed.
void enqueue(const StreamProperties &props, Tuple &tuple)
Enqueue tuples to a stream.
void operatorStatus(const std::string &containerName, std::vector< std::string > &aStatus)
status of java operators and adapters
void flushBuffer(const std::string &stream_name)
Flush any pending enqueue buffer for the stream name provided.
void enableBuffering(int buffer_size, int flush_interval=DEFAULT_FLUSH_INTERVAL)
Turn on buffering. The WakeAndFlushBuffer thread is only started if flush_interval > 0.
void flushBuffer(const StreamProperties &props)
Flush any pending enqueue buffer for the StreamProperties provided.
void close()
Terminate the client.
StreamProperties resubscribe(const StreamProperties &props, const std::string &logical_stream, const std::string &predicate)
Resubscribes to an already subscribed stream.
StreamProperties subscribe(const std::string &stream_name)
Subscribes to a stream.
Schema getSchemaByHash(const std::string &hash)
Returns a schema with a particular hash.
StreamProperties subscribe(const StreamProperties &props)
Subscribes to a stream.
std::string describe(const std::string &entity)
Returns an XML description of an entity, or an empty string if the method does not exist.
void listEntities(StreamBaseEntityType::Type type, int flags, std::vector< std::string > &names)
Lists all entities of a particular type.
TupleList dequeue(StreamProperties &streamProperties)
Dequeue tuples from any subscribed stream.
bool canDequeue()
Return true if we can call dequeue without blocking.
StreamProperties getStreamProperties(const std::string &entity, StreamProperties::CaptureTransformStrategy strategy=StreamProperties::FLATTEN)
Returns a description of a stream, throwing an exception if the stream does not exist.
int setQuiescentLimit(int timeoutMS)
Sets how many milliseconds a dequeueing client will tolerate not receiving a client heart beat from t...
const StreamBaseURI & getURI() const
Return the URI we're talking to.
std::string getConnectionID() const
Return the Connection ID for this Client Connection.
StreamProperties resubscribe(const std::string &stream_name, const std::string &logical_stream, const std::string &predicate)
Resubscribes to an already subscribed stream.
void enableHeartbeating()
Enable heartbeating for this client. Generally this is only for enqueue-only clients.
StreamProperties subscribe(const StreamProperties &props, const std::string &logical_stream, const std::string &predicate)
Subscribes to a stream with a predicate to apply to output tuples.
bool isConnected()
Returns true if this TupleConnections has any live connections to a server.
StreamBaseClient(const StreamBaseURI &uri=StreamBaseURI::fromEnvironment(), int buffer_size=0, int flush_interval=DEFAULT_FLUSH_INTERVAL)
Creates an StreamBase client and establishes a connection to a remote server.
std::string getConnectionIdAsHexString() const
Return the Connection ID for this Client Connection.
StreamProperties getStreamPropertiesByHash(const std::string &hex)
Returns a description of a stream, throwing an exception if the stream does not exist.
void setDequeueResultInterceptor(DequeueResult::Interceptor *dri)
Set the dequeue results interceptor for this client connection.
int getBufferSize() const
Return buffer size (in tuples)
void unsubscribe(const std::string &stream_name)
UnSubscribes to a stream.
sb::ClientSettings & getSettings()
Get the settings for the client.
Definition: StreamBaseClient.hpp:482
Tuple getDynamicVariables(const std::string &modulePath)
Get all the dynamic variables in the given module, and return them as a Tuple where the field names a...
void unsubscribe(const StreamProperties &props)
UnSubscribes to a stream.
void listEntities(StreamBaseEntityType::Type type, std::vector< std::string > &names)
Lists all entities of a particular type.
Schema getSchemaByName(const std::string &name)
Returns a schema by name.
void enqueue(const std::string &stream_name, TupleList &tuples)
Enqueue tuples to a stream.
DequeueResult dequeue()
Dequeue tuples from any subscribed stream.
void flushAllBuffers()
Flush any pending enqueue buffers.
void listEntities(const std::string &type, int flags, std::vector< std::string > &names)
Lists all entities of a particular type.
void status(std::vector< std::string > &aStatus, bool verbose=false)
status the streambase daemons
~StreamBaseClient()
Destroys a session.
ListEntitiesFlags
Flags for the listEntities call This must be consistent with what is found on the Java side of the ho...
Definition: StreamBaseClient.hpp:66
Type
An enumeration of the types of entities stored in a catalog.
Definition: StreamBaseEntityType.hpp:20
A URI for a StreamBase client connection.
Definition: StreamBaseURI.hpp:36
Properties of a single stream.
Definition: StreamProperties.hpp:17
CaptureTransformStrategy
Determines the method StreamBase will use to expose capture fields to client dequeuers.
Definition: StreamProperties.hpp:21
TupleLists are value types that can be copied and modified seperately thus.
Definition: TupleList.hpp:17
Tuples are value types that can be copied and modified separately thus.
Definition: Tuple.hpp:47