com.pivotal.gemfirexd.thrift.internal

## Class ClientService

- java.lang.Object
- - java.util.concurrent.locks.ReentrantLock
  - - com.pivotal.gemfirexd.thrift.internal.ClientService

All Implemented Interfaces:
  Serializable, Lock

    public final class ClientService
    extends ReentrantLock

Implementation of client service that wraps a `GFXDService.Client` thrift transport to add exception handling, connection pooling, failover and single-hop.

This class is NOT THREAD-SAFE and only one thread should be using an instance of this class at a time (or use synchronization at higher layers).

Since:
  gfxd 1.1
See Also:
  Serialized Form

### Constructor Summary

Constructors
Constructor and Description
`ClientService(String host, int port, com.pivotal.gemfirexd.thrift.OpenConnectionArgs connArgs)`

### Method Summary

Methods
`void` `beginTransaction(int jdbcIsolationLevel, Map<com.pivotal.gemfirexd.thrift.TransactionAttribute,Boolean> flags)`
`boolean` `bulkClose(HostConnection thisSource, List<com.pivotal.gemfirexd.thrift.EntityId> entities, List<ClientService> closeServices, long lockTimeoutMillis)`
`void` `cancelStatement(HostConnection source, int stmtId)`
`boolean` `closeConnection(long lockTimeoutMillis)`
`boolean` `closeResultSet(HostConnection source, int cursorId, long lockTimeoutMillis)`
`boolean` `closeStatement(HostConnection source, int stmtId, long lockTimeoutMillis)`
`void` `commitTransaction(HostConnection source, boolean startNewTransaction, Map<com.pivotal.gemfirexd.thrift.TransactionAttribute,Boolean> flags)`
`com.pivotal.gemfirexd.thrift.StatementResult` `execute(String sql, Map<Integer,com.pivotal.gemfirexd.thrift.OutputParameter> outputParams, com.pivotal.gemfirexd.thrift.StatementAttrs attrs)`
`void` `executeCursorUpdate(HostConnection source, int cursorId, byte operation, com.pivotal.gemfirexd.thrift.Row changedRow, List<Integer> changedColumns, int changedRowIndex)`
`void` `executeCursorUpdate(HostConnection source, int cursorId, List<Byte> operations, List<com.pivotal.gemfirexd.thrift.Row> changedRows, List<List<Integer>> changedColumnsList, List<Integer> changedRowIndexes)`
`com.pivotal.gemfirexd.thrift.StatementResult` `executePrepared(HostConnection source, int stmtId, com.pivotal.gemfirexd.thrift.Row params, Map<Integer,com.pivotal.gemfirexd.thrift.OutputParameter> outputParams, com.pivotal.gemfirexd.thrift.common.PrepareResultHolder prh)`
`com.pivotal.gemfirexd.thrift.UpdateResult` `executePreparedBatch(HostConnection source, int stmtId, List<com.pivotal.gemfirexd.thrift.Row> paramsBatch, com.pivotal.gemfirexd.thrift.common.PrepareResultHolder prh)`
`com.pivotal.gemfirexd.thrift.RowSet` `executePreparedQuery(HostConnection source, int stmtId, com.pivotal.gemfirexd.thrift.Row params, com.pivotal.gemfirexd.thrift.common.PrepareResultHolder prh)`
`com.pivotal.gemfirexd.thrift.UpdateResult` `executePreparedUpdate(HostConnection source, int stmtId, com.pivotal.gemfirexd.thrift.Row params, com.pivotal.gemfirexd.thrift.common.PrepareResultHolder prh)`
`com.pivotal.gemfirexd.thrift.RowSet` `executeQuery(String sql, com.pivotal.gemfirexd.thrift.StatementAttrs attrs)`
`com.pivotal.gemfirexd.thrift.UpdateResult` `executeUpdate(List<String> sqls, com.pivotal.gemfirexd.thrift.StatementAttrs attrs)`
`List<com.pivotal.gemfirexd.thrift.ConnectionProperties>` `fetchActiveConnections()`
`Map<Integer,String>` `fetchActiveStatements()`
`boolean` `freeLob(HostConnection source, int lobId, long lockTimeoutMillis)`
`com.pivotal.gemfirexd.thrift.RowSet` `getBestRowIdentifier(com.pivotal.gemfirexd.thrift.ServiceMetaDataArgs metadataArgs, int scope, boolean nullable)`
`com.pivotal.gemfirexd.thrift.BlobChunk` `getBlobChunk(HostConnection source, int lobId, long offset, int chunkSize, boolean freeLobAtEnd)`
`com.pivotal.gemfirexd.thrift.ClobChunk` `getClobChunk(HostConnection source, int lobId, long offset, int chunkSize, boolean freeLobAtEnd)`
`com.pivotal.gemfirexd.thrift.RowSet` `getIndexInfo(com.pivotal.gemfirexd.thrift.ServiceMetaDataArgs metadataArgs, boolean unique, boolean approximate)`
`static org.slf4j.Logger` `getLogger()`
`com.pivotal.gemfirexd.thrift.RowSet` `getNextResultSet(HostConnection source, int cursorId, byte otherResultSetBehaviour)`
`com.pivotal.gemfirexd.thrift.RowSet` `getSchemaMetaData(com.pivotal.gemfirexd.thrift.ServiceMetaDataCall schemaCall, com.pivotal.gemfirexd.thrift.ServiceMetaDataArgs metadataArgs)`
`com.pivotal.gemfirexd.thrift.ServiceMetaData` `getServiceMetaData()`
`com.pivotal.gemfirexd.thrift.RowSet` `getUDTs(com.pivotal.gemfirexd.thrift.ServiceMetaDataArgs metadataArgs, List<com.pivotal.gemfirexd.thrift.GFXDType> types)`
`protected Set<com.pivotal.gemfirexd.thrift.HostAddress>` `handleException(Throwable t, Set<com.pivotal.gemfirexd.thrift.HostAddress> failedServers, boolean tryFailover, boolean createNewConnection, String op)`
`com.pivotal.gemfirexd.thrift.StatementResult` `prepareAndExecute(String sql, List<com.pivotal.gemfirexd.thrift.Row> paramsBatch, Map<Integer,com.pivotal.gemfirexd.thrift.OutputParameter> outputParams, com.pivotal.gemfirexd.thrift.StatementAttrs attrs)`
`boolean` `prepareCommitTransaction(HostConnection source, Map<com.pivotal.gemfirexd.thrift.TransactionAttribute,Boolean> flags)`
`com.pivotal.gemfirexd.thrift.PrepareResult` `prepareStatement(String sql, Map<Integer,com.pivotal.gemfirexd.thrift.OutputParameter> outputParams, com.pivotal.gemfirexd.thrift.StatementAttrs attrs)`
`void` `rollbackTransaction(HostConnection source, boolean startNewTransaction, Map<com.pivotal.gemfirexd.thrift.TransactionAttribute,Boolean> flags)`
`com.pivotal.gemfirexd.thrift.RowSet` `scrollCursor(HostConnection source, int cursorId, int offset, boolean offsetIsAbsolute, boolean fetchReverseForAbsolute, int fetchSize)`
`int` `sendBlobChunk(HostConnection source, com.pivotal.gemfirexd.thrift.BlobChunk chunk)`
`int` `sendClobChunk(HostConnection source, com.pivotal.gemfirexd.thrift.ClobChunk chunk)`
`static void` `setLogger(org.slf4j.Logger log)`
`void` `setTransactionAttributes(Map<com.pivotal.gemfirexd.thrift.TransactionAttribute,Boolean> flags)`

### Methods inherited from class java.util.concurrent.locks.ReentrantLock

`getHoldCount, getOwner, getQueuedThreads, getQueueLength, getWaitingThreads, getWaitQueueLength, hasQueuedThread, hasQueuedThreads, hasWaiters, isFair, isHeldByCurrentThread, isLocked, lock, lockInterruptibly, newCondition, toString, tryLock, tryLock, unlock`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Constructor Detail

#### ClientService

    public ClientService(String host,
                 int port,
                 com.pivotal.gemfirexd.thrift.OpenConnectionArgs connArgs)
                  throws com.pivotal.gemfirexd.thrift.GFXDException

Throws:
  `com.pivotal.gemfirexd.thrift.GFXDException`

### Method Detail

#### getLogger

    public static org.slf4j.Logger getLogger()

#### setLogger

    public static void setLogger(org.slf4j.Logger log)

#### handleException

    protected Set<com.pivotal.gemfirexd.thrift.HostAddress> handleException(Throwable t,
                                                                Set<com.pivotal.gemfirexd.thrift.HostAddress> failedServers,
                                                                boolean tryFailover,
                                                                boolean createNewConnection,
                                                                String op)
                                                                     throws com.pivotal.gemfirexd.thrift.GFXDException

Throws:
  `com.pivotal.gemfirexd.thrift.GFXDException`

#### execute

    public com.pivotal.gemfirexd.thrift.StatementResult execute(String sql,
                                                       Map<Integer,com.pivotal.gemfirexd.thrift.OutputParameter> outputParams,
                                                       com.pivotal.gemfirexd.thrift.StatementAttrs attrs)
                                                         throws com.pivotal.gemfirexd.thrift.GFXDException

Throws:
  `com.pivotal.gemfirexd.thrift.GFXDException`

#### executeUpdate

    public com.pivotal.gemfirexd.thrift.UpdateResult executeUpdate(List<String> sqls,
                                                          com.pivotal.gemfirexd.thrift.StatementAttrs attrs)
                                                            throws com.pivotal.gemfirexd.thrift.GFXDException

Throws:
  `com.pivotal.gemfirexd.thrift.GFXDException`

#### executeQuery

    public com.pivotal.gemfirexd.thrift.RowSet executeQuery(String sql,
                                                   com.pivotal.gemfirexd.thrift.StatementAttrs attrs)
                                                     throws com.pivotal.gemfirexd.thrift.GFXDException

Throws:
  `com.pivotal.gemfirexd.thrift.GFXDException`

#### prepareStatement

    public com.pivotal.gemfirexd.thrift.PrepareResult prepareStatement(String sql,
                                                              Map<Integer,com.pivotal.gemfirexd.thrift.OutputParameter> outputParams,
                                                              com.pivotal.gemfirexd.thrift.StatementAttrs attrs)
                                                                throws com.pivotal.gemfirexd.thrift.GFXDException

Throws:
  `com.pivotal.gemfirexd.thrift.GFXDException`

#### executePrepared

    public com.pivotal.gemfirexd.thrift.StatementResult executePrepared(HostConnection source,
                                                               int stmtId,
                                                               com.pivotal.gemfirexd.thrift.Row params,
                                                               Map<Integer,com.pivotal.gemfirexd.thrift.OutputParameter> outputParams,
                                                               com.pivotal.gemfirexd.thrift.common.PrepareResultHolder prh)
                                                                 throws com.pivotal.gemfirexd.thrift.GFXDException

Throws:
  `com.pivotal.gemfirexd.thrift.GFXDException`

#### executePreparedUpdate

    public com.pivotal.gemfirexd.thrift.UpdateResult executePreparedUpdate(HostConnection source,
                                                                  int stmtId,
                                                                  com.pivotal.gemfirexd.thrift.Row params,
                                                                  com.pivotal.gemfirexd.thrift.common.PrepareResultHolder prh)
                                                                    throws com.pivotal.gemfirexd.thrift.GFXDException

Throws:
  `com.pivotal.gemfirexd.thrift.GFXDException`

#### executePreparedQuery

    public com.pivotal.gemfirexd.thrift.RowSet executePreparedQuery(HostConnection source,
                                                           int stmtId,
                                                           com.pivotal.gemfirexd.thrift.Row params,
                                                           com.pivotal.gemfirexd.thrift.common.PrepareResultHolder prh)
                                                             throws com.pivotal.gemfirexd.thrift.GFXDException

Throws:
  `com.pivotal.gemfirexd.thrift.GFXDException`

#### executePreparedBatch

    public com.pivotal.gemfirexd.thrift.UpdateResult executePreparedBatch(HostConnection source,
                                                                 int stmtId,
                                                                 List<com.pivotal.gemfirexd.thrift.Row> paramsBatch,
                                                                 com.pivotal.gemfirexd.thrift.common.PrepareResultHolder prh)
                                                                   throws com.pivotal.gemfirexd.thrift.GFXDException

Throws:
  `com.pivotal.gemfirexd.thrift.GFXDException`

#### prepareAndExecute

    public com.pivotal.gemfirexd.thrift.StatementResult prepareAndExecute(String sql,
                                                                 List<com.pivotal.gemfirexd.thrift.Row> paramsBatch,
                                                                 Map<Integer,com.pivotal.gemfirexd.thrift.OutputParameter> outputParams,
                                                                 com.pivotal.gemfirexd.thrift.StatementAttrs attrs)
                                                                   throws com.pivotal.gemfirexd.thrift.GFXDException

Throws:
  `com.pivotal.gemfirexd.thrift.GFXDException`

#### beginTransaction

    public void beginTransaction(int jdbcIsolationLevel,
                        Map<com.pivotal.gemfirexd.thrift.TransactionAttribute,Boolean> flags)
                          throws com.pivotal.gemfirexd.thrift.GFXDException

Throws:
  `com.pivotal.gemfirexd.thrift.GFXDException`

#### setTransactionAttributes

    public void setTransactionAttributes(Map<com.pivotal.gemfirexd.thrift.TransactionAttribute,Boolean> flags)
                                  throws com.pivotal.gemfirexd.thrift.GFXDException

Throws:
  `com.pivotal.gemfirexd.thrift.GFXDException`

#### commitTransaction

    public void commitTransaction(HostConnection source,
                         boolean startNewTransaction,
                         Map<com.pivotal.gemfirexd.thrift.TransactionAttribute,Boolean> flags)
                           throws com.pivotal.gemfirexd.thrift.GFXDException

Throws:
  `com.pivotal.gemfirexd.thrift.GFXDException`

#### rollbackTransaction

    public void rollbackTransaction(HostConnection source,
                           boolean startNewTransaction,
                           Map<com.pivotal.gemfirexd.thrift.TransactionAttribute,Boolean> flags)
                             throws com.pivotal.gemfirexd.thrift.GFXDException

Throws:
  `com.pivotal.gemfirexd.thrift.GFXDException`

#### prepareCommitTransaction

    public boolean prepareCommitTransaction(HostConnection source,
                                   Map<com.pivotal.gemfirexd.thrift.TransactionAttribute,Boolean> flags)
                                     throws com.pivotal.gemfirexd.thrift.GFXDException

Throws:
  `com.pivotal.gemfirexd.thrift.GFXDException`

#### getNextResultSet

    public com.pivotal.gemfirexd.thrift.RowSet getNextResultSet(HostConnection source,
                                                       int cursorId,
                                                       byte otherResultSetBehaviour)
                                                         throws com.pivotal.gemfirexd.thrift.GFXDException

Throws:
  `com.pivotal.gemfirexd.thrift.GFXDException`

#### getBlobChunk

    public com.pivotal.gemfirexd.thrift.BlobChunk getBlobChunk(HostConnection source,
                                                      int lobId,
                                                      long offset,
                                                      int chunkSize,
                                                      boolean freeLobAtEnd)
                                                        throws com.pivotal.gemfirexd.thrift.GFXDException

Throws:
  `com.pivotal.gemfirexd.thrift.GFXDException`

#### getClobChunk

    public com.pivotal.gemfirexd.thrift.ClobChunk getClobChunk(HostConnection source,
                                                      int lobId,
                                                      long offset,
                                                      int chunkSize,
                                                      boolean freeLobAtEnd)
                                                        throws com.pivotal.gemfirexd.thrift.GFXDException

Throws:
  `com.pivotal.gemfirexd.thrift.GFXDException`

#### sendBlobChunk

    public int sendBlobChunk(HostConnection source,
                    com.pivotal.gemfirexd.thrift.BlobChunk chunk)
                      throws com.pivotal.gemfirexd.thrift.GFXDException

Throws:
  `com.pivotal.gemfirexd.thrift.GFXDException`

#### sendClobChunk

    public int sendClobChunk(HostConnection source,
                    com.pivotal.gemfirexd.thrift.ClobChunk chunk)
                      throws com.pivotal.gemfirexd.thrift.GFXDException

Throws:
  `com.pivotal.gemfirexd.thrift.GFXDException`

#### freeLob

    public boolean freeLob(HostConnection source,
                  int lobId,
                  long lockTimeoutMillis)
                    throws com.pivotal.gemfirexd.thrift.GFXDException

Throws:
  `com.pivotal.gemfirexd.thrift.GFXDException`

#### scrollCursor

    public com.pivotal.gemfirexd.thrift.RowSet scrollCursor(HostConnection source,
                                                   int cursorId,
                                                   int offset,
                                                   boolean offsetIsAbsolute,
                                                   boolean fetchReverseForAbsolute,
                                                   int fetchSize)
                                                     throws com.pivotal.gemfirexd.thrift.GFXDException

Throws:
  `com.pivotal.gemfirexd.thrift.GFXDException`

#### executeCursorUpdate

    public void executeCursorUpdate(HostConnection source,
                           int cursorId,
                           List<Byte> operations,
                           List<com.pivotal.gemfirexd.thrift.Row> changedRows,
                           List<List<Integer>> changedColumnsList,
                           List<Integer> changedRowIndexes)
                             throws com.pivotal.gemfirexd.thrift.GFXDException

Throws:
  `com.pivotal.gemfirexd.thrift.GFXDException`

#### executeCursorUpdate

    public void executeCursorUpdate(HostConnection source,
                           int cursorId,
                           byte operation,
                           com.pivotal.gemfirexd.thrift.Row changedRow,
                           List<Integer> changedColumns,
                           int changedRowIndex)
                             throws com.pivotal.gemfirexd.thrift.GFXDException

Throws:
  `com.pivotal.gemfirexd.thrift.GFXDException`

#### getServiceMetaData

    public com.pivotal.gemfirexd.thrift.ServiceMetaData getServiceMetaData()
                                                                    throws com.pivotal.gemfirexd.thrift.GFXDException

Throws:
  `com.pivotal.gemfirexd.thrift.GFXDException`

#### getSchemaMetaData

    public com.pivotal.gemfirexd.thrift.RowSet getSchemaMetaData(com.pivotal.gemfirexd.thrift.ServiceMetaDataCall schemaCall,
                                                        com.pivotal.gemfirexd.thrift.ServiceMetaDataArgs metadataArgs)
                                                          throws com.pivotal.gemfirexd.thrift.GFXDException

Throws:
  `com.pivotal.gemfirexd.thrift.GFXDException`

#### getIndexInfo

    public com.pivotal.gemfirexd.thrift.RowSet getIndexInfo(com.pivotal.gemfirexd.thrift.ServiceMetaDataArgs metadataArgs,
                                                   boolean unique,
                                                   boolean approximate)
                                                     throws com.pivotal.gemfirexd.thrift.GFXDException

Throws:
  `com.pivotal.gemfirexd.thrift.GFXDException`

#### getUDTs

    public com.pivotal.gemfirexd.thrift.RowSet getUDTs(com.pivotal.gemfirexd.thrift.ServiceMetaDataArgs metadataArgs,
                                              List<com.pivotal.gemfirexd.thrift.GFXDType> types)
                                                throws com.pivotal.gemfirexd.thrift.GFXDException

Throws:
  `com.pivotal.gemfirexd.thrift.GFXDException`

#### getBestRowIdentifier

    public com.pivotal.gemfirexd.thrift.RowSet getBestRowIdentifier(com.pivotal.gemfirexd.thrift.ServiceMetaDataArgs metadataArgs,
                                                           int scope,
                                                           boolean nullable)
                                                             throws com.pivotal.gemfirexd.thrift.GFXDException

Throws:
  `com.pivotal.gemfirexd.thrift.GFXDException`

#### fetchActiveConnections

    public List<com.pivotal.gemfirexd.thrift.ConnectionProperties> fetchActiveConnections()
                                                                                   throws com.pivotal.gemfirexd.thrift.GFXDException

Throws:
  `com.pivotal.gemfirexd.thrift.GFXDException`

#### fetchActiveStatements

    public Map<Integer,String> fetchActiveStatements()
                                              throws com.pivotal.gemfirexd.thrift.GFXDException

Throws:
  `com.pivotal.gemfirexd.thrift.GFXDException`

#### cancelStatement

    public void cancelStatement(HostConnection source,
                       int stmtId)
                         throws com.pivotal.gemfirexd.thrift.GFXDException

Throws:
  `com.pivotal.gemfirexd.thrift.GFXDException`

#### closeResultSet

    public boolean closeResultSet(HostConnection source,
                         int cursorId,
                         long lockTimeoutMillis)
                           throws com.pivotal.gemfirexd.thrift.GFXDException

Throws:
  `com.pivotal.gemfirexd.thrift.GFXDException`

#### closeStatement

    public boolean closeStatement(HostConnection source,
                         int stmtId,
                         long lockTimeoutMillis)
                           throws com.pivotal.gemfirexd.thrift.GFXDException

Throws:
  `com.pivotal.gemfirexd.thrift.GFXDException`

#### closeConnection

    public boolean closeConnection(long lockTimeoutMillis)
                            throws com.pivotal.gemfirexd.thrift.GFXDException

Throws:
  `com.pivotal.gemfirexd.thrift.GFXDException`

#### bulkClose

    public boolean bulkClose(HostConnection thisSource,
                    List<com.pivotal.gemfirexd.thrift.EntityId> entities,
                    List<ClientService> closeServices,
                    long lockTimeoutMillis)
                      throws com.pivotal.gemfirexd.thrift.GFXDException

Throws:
  `com.pivotal.gemfirexd.thrift.GFXDException`