Class TickDBClient

    • Field Detail

      • LOGGER

        public static final deltix.gflog.Log LOGGER
      • enableSSL

        protected final boolean enableSSL
    • Constructor Detail

      • TickDBClient

        protected TickDBClient​(java.lang.String host,
                               int port,
                               boolean enableSSL,
                               UserPrincipal user)
      • TickDBClient

        public TickDBClient​(java.lang.String host,
                            int port,
                            java.lang.String user,
                            java.lang.String pass)
      • TickDBClient

        public TickDBClient​(java.lang.String host,
                            int port,
                            boolean enableSSL,
                            java.lang.String user,
                            java.lang.String pass)
      • TickDBClient

        public TickDBClient​(java.lang.String host,
                            int port)
      • TickDBClient

        public TickDBClient​(java.lang.String host,
                            int port,
                            boolean enableSSL)
    • Method Detail

      • setAccessToken

        public void setAccessToken​(java.lang.String token)
        Sets user access token to login to the Timebase server when OAUTH type of authentication defined on server.
        Parameters:
        token - Access token
      • testConnectLatency

        public long[] testConnectLatency​(int iterations)
                                  throws java.io.IOException
        Throws:
        java.io.IOException
      • getConnectLatency

        public long[] getConnectLatency()
      • connect

        public VSChannel connect()
                          throws java.io.IOException
        Throws:
        java.io.IOException
      • connect

        public VSChannel connect​(ChannelType type,
                                 boolean autoCommit,
                                 boolean noDelay,
                                 ChannelCompression c,
                                 int channelBufferSize)
                          throws java.io.IOException
        Throws:
        java.io.IOException
      • createChannel

        protected VSChannel createChannel​(ChannelType type,
                                          boolean autoCommit,
                                          boolean noDelay,
                                          ChannelCompression c,
                                          int channelBufferSize)
                                   throws java.io.IOException
        Throws:
        java.io.IOException
      • getId

        public java.lang.String getId()
        Specified by:
        getId in interface deltix.util.io.AbstractDataStore
      • getConnectionString

        public java.lang.String getConnectionString()
      • getTimeout

        public int getTimeout()
        Gets timeout value for socket connections.
        Specified by:
        getTimeout in interface RemoteTickDB
        Returns:
        timeout value, in milliseconds.
      • setTimeout

        public void setTimeout​(int timeout)
        Sets timeout for socket connections, in milliseconds. A timeout of zero is interpreted as an infinite timeout. By default - 5 sec for remote connections, 1 sec for local connections.
        Specified by:
        setTimeout in interface RemoteTickDB
        Parameters:
        timeout - the specified timeout, in milliseconds.
        See Also:
        getTimeout()
      • getServerProtocolVersion

        public int getServerProtocolVersion()
      • open

        public void open​(boolean readOnly)
        Specified by:
        open in interface deltix.util.io.AbstractDataStore
      • getQuickExecutor

        public deltix.util.concurrent.QuickExecutor getQuickExecutor()
      • getSizeOnDisk

        public long getSizeOnDisk()
        Description copied from interface: DXTickDB
        Returns the approximate size of the database's footprint.
        Specified by:
        getSizeOnDisk in interface DXTickDB
        Returns:
        Size in bytes.
      • getStream

        public deltix.qsrv.hf.tickdb.comm.client.TickStreamClient getStream​(java.lang.String key)
        Description copied from interface: WritableTickDB
        Looks up an existing stream by key.
        Specified by:
        getStream in interface DXTickDB
        Specified by:
        getStream in interface TickDB
        Specified by:
        getStream in interface WritableTickDB
        Parameters:
        key - Identifies the stream.
        Returns:
        A stream object, or null if the key was not found.
      • getServerAvailableBandwidth

        public long getServerAvailableBandwidth()
      • getServerTime

        public long getServerTime()
        Description copied from interface: DXTickDB
        Returns system time of the timebase server.
        Specified by:
        getServerTime in interface DXTickDB
      • coolDown

        public void coolDown()
        Description copied from interface: DXTickDB
        Removes all memory indexes. The indexes will be rebuilt on demand.
        Specified by:
        coolDown in interface DXTickDB
      • createStream

        public deltix.qsrv.hf.tickdb.comm.client.TickStreamClient createStream​(java.lang.String key,
                                                                               StreamOptions options)
        Description copied from interface: DXTickDB
        Creates a new stream within the database.
        Specified by:
        createStream in interface DXTickDB
        Parameters:
        key - A required key later used to identify the stream.
        options - Options for creating the stream.
      • createFileStream

        public deltix.qsrv.hf.tickdb.comm.client.TickStreamClient createFileStream​(java.lang.String key,
                                                                                   java.lang.String dataFile)
        Description copied from interface: DXTickDB
        Creates a new stream mount to the given data file.
        Specified by:
        createFileStream in interface DXTickDB
        Parameters:
        key - A required key later used to identify the stream.
        dataFile - Path to the data file (on server side).
        Returns:
        A new instance of DXTickStream.
      • createTopic

        public DirectChannel createTopic​(@Nonnull
                                         java.lang.String topicKey,
                                         @Nonnull
                                         RecordClassDescriptor[] types,
                                         @Nullable
                                         TopicSettings settings)
        Description copied from interface: TopicDB
        Creates pub/sub style topic (IPC). You can use this type of topics only when client is local (on same machine with TimeBase).
        Specified by:
        createTopic in interface TopicDB
        Parameters:
        topicKey - topic identifier
        types - list of message types
        settings - custom topic settings
      • deleteTopic

        public void deleteTopic​(@Nonnull
                                java.lang.String topicKey)
        Description copied from interface: TopicDB
        Deletes topic data from registry. Does not check for existing publishers/consumers.
        Specified by:
        deleteTopic in interface TopicDB
      • listTopics

        public java.util.List<java.lang.String> listTopics()
        Specified by:
        listTopics in interface TopicDB
        Returns:
        list of all topic keys
      • getTypes

        public RecordClassDescriptor[] getTypes​(@Nonnull
                                                java.lang.String topicKey)
        Description copied from interface: TopicDB
        Returns list of types that can be written to and read from the specified topic.
        Specified by:
        getTypes in interface TopicDB
        Parameters:
        topicKey - topic key
        Returns:
        types for topic
      • createPublisher

        public deltix.data.stream.MessageChannel<deltix.qsrv.hf.pub.InstrumentMessage> createPublisher​(@Nonnull
                                                                                                       java.lang.String topicKey,
                                                                                                       @Nullable
                                                                                                       PublisherPreferences pref,
                                                                                                       @Nullable
                                                                                                       IdleStrategy idleStrategy)
                                                                                                throws TopicNotFoundException
        Description copied from interface: TopicDB
        Creates channel for message publishing.
        Specified by:
        createPublisher in interface TopicDB
        Parameters:
        topicKey - topic identifier
        pref - configuration for this publisher
        idleStrategy - strategy to be used when publishing is not possible due to back pressure. If null then determined by preferences.
        Throws:
        TopicNotFoundException
      • createConsumerWorker

        public deltix.util.lang.Disposable createConsumerWorker​(@Nonnull
                                                                java.lang.String topicKey,
                                                                @Nullable
                                                                ConsumerPreferences pref,
                                                                @Nullable
                                                                IdleStrategy idleStrategy,
                                                                @Nullable
                                                                java.util.concurrent.ThreadFactory threadFactory,
                                                                @Nonnull
                                                                MessageProcessor processor)
        Description copied from interface: TopicDB
        Creates worker-style message consumer.
        Specified by:
        createConsumerWorker in interface TopicDB
        Parameters:
        topicKey - topic identifier
        pref - configuration for this consumer
        idleStrategy - strategy to be used when there are no messages to consume. If null then determined by preferences.
        threadFactory - thread factory that will be used to run the processor. If null then default thread factory will be used.
        processor - instance to process arrived messages
        Returns:
        returns a Disposable that can be used to stop message processing
      • createPollingConsumer

        public MessagePoller createPollingConsumer​(@Nonnull
                                                   java.lang.String topicKey,
                                                   @Nullable
                                                   ConsumerPreferences pref)
        Description copied from interface: TopicDB
        Creates a non-blocking poll-style message consumer.
        Specified by:
        createPollingConsumer in interface TopicDB
        Parameters:
        topicKey - topic identifier
        pref - configuration for this consumer
        Returns:
        returns MessagePoller that can be used to poll messages from subscription.
      • createConsumer

        public deltix.data.stream.MessageSource<deltix.qsrv.hf.pub.InstrumentMessage> createConsumer​(@Nonnull
                                                                                                     java.lang.String topicKey,
                                                                                                     @Nullable
                                                                                                     ConsumerPreferences pref,
                                                                                                     @Nullable
                                                                                                     IdleStrategy idleStrategy)
        Description copied from interface: TopicDB
        Creates MessageSource-style message consumer (blocking).
        Specified by:
        createConsumer in interface TopicDB
        Parameters:
        topicKey - topic identifier
        pref - configuration for this consumer
        idleStrategy - strategy to be used when there are no messages to consume. If null then determined by preferences.
        Returns:
        MessageSource for topic. Calling AbstractCursor.next() will block.
      • createCursor

        public TickCursor createCursor​(SelectionOptions options,
                                       TickStream... streams)
        Description copied from interface: TickDB

        Opens an initially empty cursor for reading data from multiple streams, according to the specified options. The messages are returned from the cursor strictly ordered by time. Within the same exact time stamp, the order of messages is undefined and may vary from call to call, i.e. it is non-deterministic.

        The cursor is returned initially empty and must be reset. The TickCursor interface provides methods for dynamically re-configuring the subscription, or jumping to a different timestamp.

        Specified by:
        createCursor in interface TickDB
        Parameters:
        options - Selection options.
        streams - Streams from which data will be selected.
        Returns:
        A cursor used to read messages.
      • select

        public TickCursor select​(long time,
                                 SelectionOptions options,
                                 java.lang.String[] types,
                                 deltix.qsrv.hf.pub.InstrumentIdentity[] entities,
                                 TickStream... streams)
        Description copied from interface: TickDB

        Opens a cursor for reading data from multiple streams, according to the specified options. The messages are returned from the cursor strictly ordered by time. Within the same exact time stamp, the order of messages is undefined and may vary from call to call, i.e. it is non-deterministic.

        Note that the arguments of this method only determine the initial configuration of the cursor. The TickCursor interface provides methods for dynamically re-configuring the subscription, or jumping to a different timestamp.

        Specified by:
        select in interface TickDB
        Parameters:
        time - The start timestamp.
        options - Selection options.
        types - Specified message types to be subscribed. If null, then all types will be subscribed.
        entities - Specified entities to be subscribed. If null, then all entities will be subscribed.
        streams - Streams from which data will be selected.
        Returns:
        A cursor used to read messages.
      • setGrowthPolicy

        public void setGrowthPolicy​(deltix.util.lang.GrowthPolicy policy)
        Description copied from interface: DXTickDB
        Sets the file growth policy
        Specified by:
        setGrowthPolicy in interface DXTickDB
        Parameters:
        policy - Growth Policy value
      • trimToSize

        public void trimToSize()
        Description copied from interface: DXTickDB
        Trims all data files to minimum size.
        Specified by:
        trimToSize in interface DXTickDB
      • warmUp

        public void warmUp()
        Description copied from interface: DXTickDB
        Forces the building of all memory indexes. This is useful in performance testing or on server startup.
        Specified by:
        warmUp in interface DXTickDB
      • delete

        public void delete()
        Specified by:
        delete in interface deltix.util.io.AbstractDataStore
      • format

        public void format()
        Specified by:
        format in interface deltix.util.io.AbstractDataStore
      • isOpen

        public boolean isOpen()
        Specified by:
        isOpen in interface deltix.util.io.AbstractDataStore
      • isReadOnly

        public boolean isReadOnly()
        Specified by:
        isReadOnly in interface deltix.util.io.AbstractDataStore
      • close

        public void close()
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Specified by:
        close in interface deltix.util.lang.Disposable
      • getDbDirs

        public java.io.File[] getDbDirs()
        Specified by:
        getDbDirs in interface DXTickDB
      • getMetaDataVersion

        public long getMetaDataVersion()
        Description copied from interface: DXTickDB
        Gets current metadata version.
        Specified by:
        getMetaDataVersion in interface DXTickDB
        Returns:
        current metadata version number.
      • getMetaData

        public MetaData getMetaData()
        Description copied from interface: DXTickDB
        Gets stream metadata contains all class descriptors.
        Specified by:
        getMetaData in interface DXTickDB
        Returns:
        metadata object.
      • tryReconnect

        public boolean tryReconnect​(int numAttempts,
                                    long timeSinceDisconnected,
                                    deltix.qsrv.hf.spi.conn.ReconnectableImpl helper)
                             throws java.lang.Exception
        Specified by:
        tryReconnect in interface deltix.qsrv.hf.spi.conn.ReconnectableImpl.Reconnector
        Throws:
        java.lang.Exception
      • addDisconnectEventListener

        public void addDisconnectEventListener​(deltix.qsrv.hf.spi.conn.DisconnectEventListener listener)
        Specified by:
        addDisconnectEventListener in interface deltix.qsrv.hf.spi.conn.Disconnectable
      • removeDisconnectEventListener

        public void removeDisconnectEventListener​(deltix.qsrv.hf.spi.conn.DisconnectEventListener listener)
        Specified by:
        removeDisconnectEventListener in interface deltix.qsrv.hf.spi.conn.Disconnectable
      • isLoopback

        public boolean isLoopback()
      • isConnected

        public boolean isConnected()
        Specified by:
        isConnected in interface deltix.qsrv.hf.spi.conn.Disconnectable
      • compileQuery

        public void compileQuery​(java.lang.String query,
                                 java.util.List<Token> tokens)
        Compiles QQL/DDL Query. Returns CompilationResult contains parsed tokens information. If query contains errors, throws CompilationException.
        Parameters:
        query - query to compile.
        tokens -
      • describeQuery

        public ClassSet<ClassDescriptor> describeQuery​(java.lang.String qql,
                                                       SelectionOptions options,
                                                       Parameter... params)
                                                throws deltix.util.parsers.CompilationException
        Description copied from interface: DXTickDB
        Returns schema for the given query.
        Specified by:
        describeQuery in interface DXTickDB
        Parameters:
        qql - Query text.
        options - Selection options.
        params - Specified message types to be subscribed. If null, then all types will be subscribed.*
        Returns:
        Schema contains classes definitions.
        Throws:
        deltix.util.parsers.CompilationException - when query has errors
      • executeQuery

        public InstrumentMessageSource executeQuery​(java.lang.String qql,
                                                    Parameter... params)
                                             throws deltix.util.parsers.CompilationException
        Description copied from interface: DXTickDB

        Execute Query and creates a message source for reading data from it, according to the specified options. The messages are returned from the cursor strictly ordered by time. Within the same exact time stamp, the order of messages is undefined and may vary from call to call, i.e. it is non-deterministic.

        select * from bars
        Specified by:
        executeQuery in interface DXTickDB
        Parameters:
        qql - Query text.
        params - The parameter values of the query.
        Returns:
        An iterable message source to read messages.
        Throws:
        deltix.util.parsers.CompilationException
      • executeQuery

        public InstrumentMessageSource executeQuery​(java.lang.String qql,
                                                    SelectionOptions options,
                                                    Parameter... params)
                                             throws deltix.util.parsers.CompilationException
        Description copied from interface: DXTickDB

        Execute Query and creates a message source for reading data from it, according to the specified options. The messages are returned from the cursor strictly ordered by time. Within the same exact time stamp, the order of messages is undefined and may vary from call to call, i.e. it is non-deterministic.

        select * from bars
        Specified by:
        executeQuery in interface DXTickDB
        Parameters:
        qql - Query text.
        options - Selection options.
        params - The parameter values of the query.
        Returns:
        An iterable message source to read messages.
        Throws:
        deltix.util.parsers.CompilationException - when query has errors
      • executeQuery

        public InstrumentMessageSource executeQuery​(java.lang.String qql,
                                                    SelectionOptions options,
                                                    deltix.qsrv.hf.pub.InstrumentIdentity[] ids,
                                                    Parameter... params)
                                             throws deltix.util.parsers.CompilationException
        Description copied from interface: DXTickDB

        Execute Query and creates a message source for reading data from it, according to the specified options. The messages are returned from the cursor strictly ordered by time. Within the same exact time stamp, the order of messages is undefined and may vary from call to call, i.e. it is non-deterministic.

        select * from bars
        Specified by:
        executeQuery in interface DXTickDB
        Parameters:
        qql - Query text.
        options - Selection options.
        ids - Specified entities to be subscribed. If null, then all entities will be subscribed.
        params - The parameter values of the query.
        Returns:
        An iterable message source to read messages.
        Throws:
        deltix.util.parsers.CompilationException
      • executeQuery

        public InstrumentMessageSource executeQuery​(deltix.util.parsers.Element qql,
                                                    SelectionOptions options,
                                                    TickStream[] streams,
                                                    deltix.qsrv.hf.pub.InstrumentIdentity[] ids,
                                                    long time,
                                                    Parameter... params)
                                             throws deltix.util.parsers.CompilationException
        Description copied from interface: DXTickDB

        Execute Query and creates a message source for reading data from it, according to the specified options. The messages are returned from the cursor strictly ordered by time. Within the same exact time stamp, the order of messages is undefined and may vary from call to call, i.e. it is non-deterministic.

        select * from bars
        Specified by:
        executeQuery in interface DXTickDB
        Parameters:
        qql - Query text element.
        options - Selection options.
        streams - Streams from which data will be selected.
        ids - Specified entities to be subscribed. If null, then all entities will be subscribed.
        time - The start timestamp.
        params - The parameter values of the query.
        Returns:
        An iterable message source to read messages.
        Throws:
        deltix.util.parsers.CompilationException - when query has errors.
      • executeQuery

        public InstrumentMessageSource executeQuery​(deltix.util.parsers.Element qql,
                                                    SelectionOptions options,
                                                    TickStream[] streams,
                                                    deltix.qsrv.hf.pub.InstrumentIdentity[] ids,
                                                    long startTimestamp,
                                                    long endTimestamp,
                                                    Parameter... params)
                                             throws deltix.util.parsers.CompilationException
        Description copied from interface: DXTickDB

        Execute Query and creates a message source for reading data from it, according to the specified options. The messages are returned from the cursor strictly ordered by time. Within the same exact time stamp, the order of messages is undefined and may vary from call to call, i.e. it is non-deterministic.

        select * from bars
        Specified by:
        executeQuery in interface DXTickDB
        Parameters:
        qql - Query text element.
        options - Selection options.
        streams - Streams from which data will be selected.
        ids - Specified entities to be subscribed. If null, then all entities will be subscribed.
        startTimestamp - The start timestamp.
        endTimestamp - The end timestamp
        params - The parameter values of the query.
        Returns:
        An iterable message source to read messages.
        Throws:
        deltix.util.parsers.CompilationException - when query has errors.
      • executeQuery

        public InstrumentMessageSource executeQuery​(java.lang.String qql,
                                                    SelectionOptions options,
                                                    TickStream[] streams,
                                                    deltix.qsrv.hf.pub.InstrumentIdentity[] ids,
                                                    long time,
                                                    Parameter... params)
                                             throws deltix.util.parsers.CompilationException
        Description copied from interface: DXTickDB

        Execute Query and creates a message source for reading data from it, according to the specified options. The messages are returned from the cursor strictly ordered by time. Within the same exact time stamp, the order of messages is undefined and may vary from call to call, i.e. it is non-deterministic.

        select * from bars
        Specified by:
        executeQuery in interface DXTickDB
        Parameters:
        qql - Query text.
        options - Selection options.
        streams - Streams from which data will be selected.
        ids - Specified entities to be subscribed. If null, then all entities will be subscribed.
        time - The start timestamp.
        params - The parameter values of the query.
        Returns:
        An iterable message source to read messages.
        Throws:
        deltix.util.parsers.CompilationException - when query has errors.
      • executeQuery

        public InstrumentMessageSource executeQuery​(java.lang.String qql,
                                                    SelectionOptions options,
                                                    TickStream[] streams,
                                                    deltix.qsrv.hf.pub.InstrumentIdentity[] ids,
                                                    long startTimestamp,
                                                    long endTimestamp,
                                                    Parameter... params)
                                             throws deltix.util.parsers.CompilationException
        Description copied from interface: DXTickDB

        Execute Query and creates a message source for reading data from it, according to the specified options. The messages are returned from the cursor strictly ordered by time. Within the same exact time stamp, the order of messages is undefined and may vary from call to call, i.e. it is non-deterministic.

        select * from bars
        Specified by:
        executeQuery in interface DXTickDB
        Parameters:
        qql - Query text.
        options - Selection options.
        streams - Streams from which data will be selected.
        ids - Specified entities to be subscribed. If null, then all entities will be subscribed.
        startTimestamp - The start timestamp.
        endTimestamp - The end timestamp
        params - The parameter values of the query.
        Returns:
        An iterable message source to read messages.
        Throws:
        deltix.util.parsers.CompilationException - when query has errors.
      • getHost

        public java.lang.String getHost()
      • getPort

        public int getPort()
      • setCompression

        public void setCompression​(boolean useCompression)
      • setApplicationId

        public void setApplicationId​(java.lang.String id)
      • getApplicationId

        public java.lang.String getApplicationId()
      • setAffinityConfig

        public void setAffinityConfig​(deltix.thread.affinity.AffinityConfig affinityConfig)
      • isSSLEnabled

        public boolean isSSLEnabled()
      • getSSLPort

        public int getSSLPort()
      • fireRenamed

        public void fireRenamed​(java.lang.String fromKey,
                                java.lang.String toKey)
        Specified by:
        fireRenamed in interface DBStateNotifier
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • getServerVersion

        public java.lang.String getServerVersion()
      • isTopicDBSupported

        public boolean isTopicDBSupported()
        Specified by:
        isTopicDBSupported in interface DXTickDB
        Returns:
        true if this DB instance supports topics. If this methods returns false then DXTickDB.getTopicDB() is unavailable.