程序包 com.cnosdb.impl

类 CnosDBImpl

java.lang.Object
com.cnosdb.impl.CnosDBImpl
所有已实现的接口:
CnosDB, AutoCloseable

public class CnosDBImpl extends Object implements CnosDB
Implementation of a InluxDB API.
作者:
stefan.majer [at] gmail.com
  • 构造器详细资料

    • CnosDBImpl

      public CnosDBImpl(String url, String username, String password, okhttp3.OkHttpClient.Builder okHttpBuilder, CnosDB.ResponseFormat responseFormat)
      Constructs a new CnosDBImpl.
      参数:
      url - The CnosDB server API URL
      username - The CnosDB user name
      password - The CnosDB user password
      okHttpBuilder - The OkHttp Client Builder
      responseFormat - The ResponseFormat to use for response from CnosDB server
    • CnosDBImpl

      public CnosDBImpl(String url, String username, String password, okhttp3.OkHttpClient.Builder okHttpBuilder, retrofit2.Retrofit.Builder retrofitBuilder, CnosDB.ResponseFormat responseFormat)
      Constructs a new CnosDBImpl.
      参数:
      url - The CnosDB server API URL
      username - The CnosDB user name
      password - The CnosDB user password
      okHttpBuilder - The OkHttp Client Builder
      retrofitBuilder - The Retrofit Builder
      responseFormat - The ResponseFormat to use for response from CnosDB server
    • CnosDBImpl

      public CnosDBImpl(String url, String username, String password, okhttp3.OkHttpClient.Builder client)
    • CnosDBImpl

      public CnosDBImpl(String url, String username, String password, okhttp3.OkHttpClient.Builder client, String database, String retentionPolicy, CnosDB.ConsistencyLevel consistency)
  • 方法详细资料

    • setLogLevel

      public CnosDB setLogLevel(CnosDB.LogLevel logLevel)
      从接口复制的说明: CnosDB
      Set the loglevel which is used for REST related actions.
      指定者:
      setLogLevel 在接口中 CnosDB
      参数:
      logLevel - the loglevel to set.
      返回:
      the CnosDB instance to be able to use it in a fluent manner.
    • enableGzip

      public CnosDB enableGzip()
      Enable Gzip compress for http request body.
      指定者:
      enableGzip 在接口中 CnosDB
      返回:
      the CnosDB instance to be able to use it in a fluent manner.
    • disableGzip

      public CnosDB disableGzip()
      Disable Gzip compress for http request body.
      指定者:
      disableGzip 在接口中 CnosDB
      返回:
      the CnosDB instance to be able to use it in a fluent manner.
    • isGzipEnabled

      public boolean isGzipEnabled()
      Returns whether Gzip compress for http request body is enabled.
      指定者:
      isGzipEnabled 在接口中 CnosDB
      返回:
      true if gzip is enabled.
    • enableBatch

      public CnosDB enableBatch()
      从接口复制的说明: CnosDB
      Enable batching of single Point writes to speed up writes significantly. This is the same as calling CnosDB.enableBatch(BatchOptions.DEFAULTS)
      指定者:
      enableBatch 在接口中 CnosDB
      返回:
      the CnosDB instance to be able to use it in a fluent manner.
    • enableBatch

      public CnosDB enableBatch(BatchOptions batchOptions)
      从接口复制的说明: CnosDB
      Enable batching of single Point writes to speed up writes significantly. If either number of points written or flushDuration time limit is reached, a batch write is issued. Note that batch processing needs to be explicitly stopped before the application is shutdown. To do so call disableBatch().
      指定者:
      enableBatch 在接口中 CnosDB
      参数:
      batchOptions - the options to set for batching the writes.
      返回:
      the CnosDB instance to be able to use it in a fluent manner.
    • enableBatch

      public CnosDB enableBatch(int actions, int flushDuration, TimeUnit flushDurationTimeUnit)
      从接口复制的说明: CnosDB
      Enable batching of single Point writes as CnosDB.enableBatch(int, int, TimeUnit, ThreadFactory)} using default thread factory.
      指定者:
      enableBatch 在接口中 CnosDB
      参数:
      actions - the number of actions to collect
      flushDuration - the time to wait at most.
      flushDurationTimeUnit - the TimeUnit for the given flushDuration.
      返回:
      the CnosDB instance to be able to use it in a fluent manner.
      另请参阅:
    • enableBatch

      public CnosDB enableBatch(int actions, int flushDuration, TimeUnit flushDurationTimeUnit, ThreadFactory threadFactory)
      从接口复制的说明: CnosDB
      Enable batching of single Point writes as CnosDB.enableBatch(int, int, TimeUnit, ThreadFactory, BiConsumer) using with a exceptionHandler that does nothing.
      指定者:
      enableBatch 在接口中 CnosDB
      参数:
      actions - the number of actions to collect
      flushDuration - the time to wait at most.
      flushDurationTimeUnit - the TimeUnit for the given flushDuration.
      threadFactory - a ThreadFactory instance to be used.
      返回:
      the CnosDB instance to be able to use it in a fluent manner.
      另请参阅:
    • enableBatch

      public CnosDB enableBatch(int actions, int flushDuration, TimeUnit flushDurationTimeUnit, ThreadFactory threadFactory, BiConsumer<Iterable<Point>,Throwable> exceptionHandler, CnosDB.ConsistencyLevel consistency)
      从接口复制的说明: CnosDB
      Enable batching of single Point writes with consistency set for an entire batch flushDurations is reached first, a batch write is issued. Note that batch processing needs to be explicitly stopped before the application is shutdown. To do so call disableBatch(). Default consistency is ONE.
      指定者:
      enableBatch 在接口中 CnosDB
      参数:
      actions - the number of actions to collect
      flushDuration - the time to wait at most.
      flushDurationTimeUnit - the TimeUnit for the given flushDuration.
      threadFactory - a ThreadFactory instance to be used.
      exceptionHandler - a consumer function to handle asynchronous errors
      consistency - a consistency setting for batch writes.
      返回:
      the CnosDB instance to be able to use it in a fluent manner.
    • enableBatch

      public CnosDB enableBatch(int actions, int flushDuration, TimeUnit flushDurationTimeUnit, ThreadFactory threadFactory, BiConsumer<Iterable<Point>,Throwable> exceptionHandler)
      从接口复制的说明: CnosDB
      Enable batching of single Point writes to speed up writes significant. If either actions or flushDurations is reached first, a batch write is issued. Note that batch processing needs to be explicitly stopped before the application is shutdown. To do so call disableBatch().
      指定者:
      enableBatch 在接口中 CnosDB
      参数:
      actions - the number of actions to collect
      flushDuration - the time to wait at most.
      flushDurationTimeUnit - the TimeUnit for the given flushDuration.
      threadFactory - a ThreadFactory instance to be used.
      exceptionHandler - a consumer function to handle asynchronous errors
      返回:
      the CnosDB instance to be able to use it in a fluent manner.
    • disableBatch

      public void disableBatch()
      从接口复制的说明: CnosDB
      Disable Batching.
      指定者:
      disableBatch 在接口中 CnosDB
    • isBatchEnabled

      public boolean isBatchEnabled()
      从接口复制的说明: CnosDB
      Returns whether Batching is enabled.
      指定者:
      isBatchEnabled 在接口中 CnosDB
      返回:
      true if batch is enabled.
    • ping

      public Pong ping()
      从接口复制的说明: CnosDB
      Ping this cnosDB.
      指定者:
      ping 在接口中 CnosDB
      返回:
      the response of the ping execution.
    • version

      public String version()
      从接口复制的说明: CnosDB
      Return the version of the connected cnosDB Server.
      指定者:
      version 在接口中 CnosDB
      返回:
      the version String, otherwise unknown.
    • write

      public void write(Point point)
      从接口复制的说明: CnosDB
      Write a single Point to the default database.
      指定者:
      write 在接口中 CnosDB
      参数:
      point - The point to write
    • write

      public void write(String records)
      从接口复制的说明: CnosDB
      Write a set of Points to the default database with the string records.
      指定者:
      write 在接口中 CnosDB
      参数:
      records - the points in the correct lineprotocol.
    • write

      public void write(List<String> records)
      从接口复制的说明: CnosDB
      Write a set of Points to the default database with the list of string records.
      指定者:
      write 在接口中 CnosDB
      参数:
      records - the List of points in the correct lineprotocol.
    • write

      public void write(String database, String retentionPolicy, Point point)
      从接口复制的说明: CnosDB
      Write a single Point to the database.
      指定者:
      write 在接口中 CnosDB
      参数:
      database - the database to write to.
      retentionPolicy - the retentionPolicy to use.
      point - The point to write
    • write

      public void write(int udpPort, Point point)
      Write a single Point to the database through UDP.
      指定者:
      write 在接口中 CnosDB
      参数:
      udpPort - the udpPort to write to.
      point - The point to write.
    • write

      public void write(BatchPoints batchPoints)
      从接口复制的说明: CnosDB
      Write a set of Points to the cnosdb database with the new (>= 0.9.0rc32) lineprotocol.
      指定者:
      write 在接口中 CnosDB
      参数:
      batchPoints - the points to write in BatchPoints.
      另请参阅:
    • writeWithRetry

      public void writeWithRetry(BatchPoints batchPoints)
      从接口复制的说明: CnosDB
      Write a set of Points to the cnosdb database with the new (>= 0.9.0rc32) lineprotocol. If batching is enabled with appropriate BatchOptions settings (BatchOptions.bufferLimit greater than BatchOptions.actions) This method will try to retry in case of some recoverable errors. Otherwise it just works as CnosDB.write(BatchPoints)
      指定者:
      writeWithRetry 在接口中 CnosDB
      参数:
      batchPoints - the points to write in BatchPoints.
      另请参阅:
    • write

      public void write(String database, String retentionPolicy, CnosDB.ConsistencyLevel consistency, TimeUnit precision, String records)
      从接口复制的说明: CnosDB
      Write a set of Points to the cnosdb database with the string records.
      指定者:
      write 在接口中 CnosDB
      参数:
      database - the name of the database to write
      retentionPolicy - the retentionPolicy to use
      consistency - the ConsistencyLevel to use
      precision - the time precision to use
      records - the points in the correct lineprotocol.
      另请参阅:
    • write

      public void write(String database, String retentionPolicy, CnosDB.ConsistencyLevel consistency, String records)
      从接口复制的说明: CnosDB
      Write a set of Points to the cnosdb database with the string records.
      指定者:
      write 在接口中 CnosDB
      参数:
      database - the name of the database to write
      retentionPolicy - the retentionPolicy to use
      consistency - the ConsistencyLevel to use
      records - the points in the correct lineprotocol.
      另请参阅:
    • write

      public void write(String database, String retentionPolicy, CnosDB.ConsistencyLevel consistency, List<String> records)
      从接口复制的说明: CnosDB
      Write a set of Points to the cnosdb database with the list of string records.
      指定者:
      write 在接口中 CnosDB
      参数:
      database - the name of the database to write
      retentionPolicy - the retentionPolicy to use
      consistency - the ConsistencyLevel to use
      records - the List of points in the correct lineprotocol.
      另请参阅:
    • write

      public void write(String database, String retentionPolicy, CnosDB.ConsistencyLevel consistency, TimeUnit precision, List<String> records)
      从接口复制的说明: CnosDB
      Write a set of Points to the cnosdb database with the list of string records.
      指定者:
      write 在接口中 CnosDB
      参数:
      database - the name of the database to write
      retentionPolicy - the retentionPolicy to use
      consistency - the ConsistencyLevel to use
      precision - the time precision to use
      records - the List of points in the correct lineprotocol.
      另请参阅:
    • write

      public void write(int udpPort, String records)
      Write a set of Points to the cnosdb database with the string records through UDP.
      指定者:
      write 在接口中 CnosDB
      参数:
      udpPort - the udpPort where cnosdb is listening
      records - the content will be encoded by UTF-8 before sent.
    • write

      public void write(int udpPort, List<String> records)
      Write a set of Points to the cnosdb database with the list of string records through UDP.
      指定者:
      write 在接口中 CnosDB
      参数:
      udpPort - the udpPort where cnosdb is listening
      records - list of record, the content will be encoded by UTF-8 before sent.
    • query

      public QueryResult query(Query query)
      Execute a query against a database.
      指定者:
      query 在接口中 CnosDB
      参数:
      query - the query to execute.
      返回:
      a List of Series which matched the query.
    • query

      public void query(Query query, Consumer<QueryResult> onSuccess, Consumer<Throwable> onFailure)
      Execute a query against a database. One of the consumers will be executed.
      指定者:
      query 在接口中 CnosDB
      参数:
      query - the query to execute.
      onSuccess - the consumer to invoke when result is received
      onFailure - the consumer to invoke when error is thrown
    • query

      public void query(Query query, int chunkSize, Consumer<QueryResult> onNext)
      Execute a streaming query against a database.
      指定者:
      query 在接口中 CnosDB
      参数:
      query - the query to execute.
      chunkSize - the number of QueryResults to process in one chunk.
      onNext - the consumer to invoke for each received QueryResult
    • query

      public void query(Query query, int chunkSize, BiConsumer<CnosDB.Cancellable,QueryResult> onNext)
      Execute a streaming query against a database.
      指定者:
      query 在接口中 CnosDB
      参数:
      query - the query to execute.
      chunkSize - the number of QueryResults to process in one chunk.
      onNext - the consumer to invoke for each received QueryResult; with capability to discontinue a streaming query
    • query

      public void query(Query query, int chunkSize, Consumer<QueryResult> onNext, Runnable onComplete)
      Execute a streaming query against a database.
      指定者:
      query 在接口中 CnosDB
      参数:
      query - the query to execute.
      chunkSize - the number of QueryResults to process in one chunk.
      onNext - the consumer to invoke for each received QueryResult
      onComplete - the onComplete to invoke for successfully end of stream
    • query

      public void query(Query query, int chunkSize, BiConsumer<CnosDB.Cancellable,QueryResult> onNext, Runnable onComplete)
      从接口复制的说明: CnosDB
      Execute a streaming query against a database.
      指定者:
      query 在接口中 CnosDB
      参数:
      query - the query to execute.
      chunkSize - the number of QueryResults to process in one chunk.
      onNext - the consumer to invoke for each received QueryResult; with capability to discontinue a streaming query
      onComplete - the onComplete to invoke for successfully end of stream
    • query

      public void query(Query query, int chunkSize, BiConsumer<CnosDB.Cancellable,QueryResult> onNext, Runnable onComplete, Consumer<Throwable> onFailure)
      Execute a streaming query against a database.
      指定者:
      query 在接口中 CnosDB
      参数:
      query - the query to execute.
      chunkSize - the number of QueryResults to process in one chunk.
      onNext - the consumer to invoke for each received QueryResult; with capability to discontinue a streaming query
      onComplete - the onComplete to invoke for successfully end of stream
      onFailure - the consumer for error handling
    • query

      public QueryResult query(Query query, TimeUnit timeUnit)
      Execute a query against a database.
      指定者:
      query 在接口中 CnosDB
      参数:
      query - the query to execute.
      timeUnit - the time unit of the results.
      返回:
      a List of Series which matched the query.
    • createDatabase

      public void createDatabase(String name)
      Create a new Database.
      指定者:
      createDatabase 在接口中 CnosDB
      参数:
      name - the name of the new database.
    • deleteDatabase

      public void deleteDatabase(String name)
      Delete a database.
      指定者:
      deleteDatabase 在接口中 CnosDB
      参数:
      name - the name of the database to delete.
    • describeDatabases

      public List<String> describeDatabases()
      Describe all available databases.
      指定者:
      describeDatabases 在接口中 CnosDB
      返回:
      a List of all Database names.
    • databaseExists

      public boolean databaseExists(String name)
      Check if a database exists.
      指定者:
      databaseExists 在接口中 CnosDB
      参数:
      name - the name of the database to search.
      返回:
      true if the database exists or false if it doesn't exist
    • flush

      public void flush()
      Send any buffered points to CnosDB. This method is synchronous and will block while all pending points are written.
      指定者:
      flush 在接口中 CnosDB
    • close

      public void close()
      close thread for asynchronous batch write and UDP socket to release resources if need.
      指定者:
      close 在接口中 AutoCloseable
      指定者:
      close 在接口中 CnosDB
    • setConsistency

      public CnosDB setConsistency(CnosDB.ConsistencyLevel consistency)
      从接口复制的说明: CnosDB
      Set the consistency level which is used for writing points.
      指定者:
      setConsistency 在接口中 CnosDB
      参数:
      consistency - the consistency level to set.
      返回:
      the CnosDB instance to be able to use it in a fluent manner.
    • setDatabase

      public CnosDB setDatabase(String database)
      从接口复制的说明: CnosDB
      Set the database which is used for writing points.
      指定者:
      setDatabase 在接口中 CnosDB
      参数:
      database - the database to set.
      返回:
      the CnosDB instance to be able to use it in a fluent manner.
    • setRetentionPolicy

      public CnosDB setRetentionPolicy(String retentionPolicy)
      从接口复制的说明: CnosDB
      Set the retention policy which is used for writing points.
      指定者:
      setRetentionPolicy 在接口中 CnosDB
      参数:
      retentionPolicy - the retention policy to set.
      返回:
      the CnosDB instance to be able to use it in a fluent manner.
    • createRetentionPolicy

      public void createRetentionPolicy(String rpName, String database, String duration, String shardDuration, int replicationFactor, boolean isDefault)
      Creates a retentionPolicy.
      指定者:
      createRetentionPolicy 在接口中 CnosDB
      参数:
      rpName - the name of the retentionPolicy(rp)
      database - the name of the database
      duration - the duration of the rp
      shardDuration - the shardDuration
      replicationFactor - the replicationFactor of the rp
      isDefault - if the rp is the default rp for the database or not
    • createRetentionPolicy

      public void createRetentionPolicy(String rpName, String database, String duration, int replicationFactor, boolean isDefault)
      Creates a retentionPolicy. (optional shardDuration)
      指定者:
      createRetentionPolicy 在接口中 CnosDB
      参数:
      rpName - the name of the retentionPolicy(rp)
      database - the name of the database
      duration - the duration of the rp
      replicationFactor - the replicationFactor of the rp
      isDefault - if the rp is the default rp for the database or not
    • createRetentionPolicy

      public void createRetentionPolicy(String rpName, String database, String duration, String shardDuration, int replicationFactor)
      Creates a retentionPolicy. (optional shardDuration and isDefault)
      指定者:
      createRetentionPolicy 在接口中 CnosDB
      参数:
      rpName - the name of the retentionPolicy(rp)
      database - the name of the database
      duration - the duration of the rp
      shardDuration - the shardDuration
      replicationFactor - the replicationFactor of the rp
    • dropRetentionPolicy

      public void dropRetentionPolicy(String rpName, String database)
      Drops a retentionPolicy in a database.
      指定者:
      dropRetentionPolicy 在接口中 CnosDB
      参数:
      rpName - the name of the retentionPolicy
      database - the name of the database