Commands |
public class Commands (Code) |
| Protocol commands between Sequoia driver (client) and controller (server).
All communications follow a classic RPC scheme: the driver sends a Command
code, followed by argument(s) for some of the commands, and expects some
answer(s), at the very least an error code or an exception. The server is
event-driven; communications are inited by the client which is the one
sending Protocol commands, so the verbs send and receive
must be understood as from driver point of view. Almost all these commands
are put on the wire by client class
org.continuent.sequoia.driver.Connection and read (and answered) by
class
org.continuent.sequoia.controller.virtualdatabase.VirtualDatabaseWorkerThread.run .
The only exceptions are the following commands: - ProtocolVersion
read only by
org.continuent.sequoia.controller.core.ControllerWorkerThread.run , which
then constructs the connection and pass it to VirtualDatabaseWorkerThread for
the rest of the execution of this command. - Close
in addition to Connection, also sent by
org.continuent.sequoia.driver.ConnectionClosingThread.closeConnection(org.continuent.sequoia.driver.Connection) - Ping
no more used, was sent on a dedicated connection and silently received only
by (again)
org.continuent.sequoia.controller.core.ControllerWorkerThread.run Protocol Data Types
optUTF is a custom type defined like this:
(boolean false) | (boolean true; UTF somestring)
Sent types
Several commands send a SQL query. All SQL queries sent on the wire use the
same starting pattern, a requestStub defined below and in
org.continuent.sequoia.controller.requests.AbstractRequest.AbstractRequest(StringbooleanintStringint)
requestStub
UTF request : SQL query
boolean EscapeProcessing
UTF LINE_SEPARATOR
Int timeout
boolean autoCommit
boolean isDriverProcessed
Queries that expect a result set (read commands mostly) send immediately
after the requestStub a subsetLengths parameter, of type:
subsetLengths. See
org.continuent.sequoia.controller.requests.AbstractRequest.receiveResultSetParams(org.continuent.sequoia.common.stream.DriverBufferedInputStream)
Int maxRows
Int fetchSize
Depending on some configuration flag/state (shared by driver and controller),
most query commands add an optional skeleton parameter of type
optUTF.
Received types
Several commands receive a ResultSet of type:
ResultSet
org.continuent.sequoia.driver.DriverResultSet.DriverResultSet(org.continuent.sequoia.driver.Connection)
org.continuent.sequoia.common.protocol.Field Field [] fields
org.continuent.sequoia.common.protocol.TypeTag [] java column types
ArrayList data
optUTF hasMoreData: cursor name
- fields is the description of the ResultSet columns. -
data is the actual data of the ResultSet. Each element of this
list is an Object array holding one row of the ResultSet. The whole arraylist
is serialized using standard Java serialization/readUnshared().
Exceptions
For almost every command sent, the driver checks if the reply is an exception
serialized by the controller instead of the regular reply type. Most
exceptions are put on the wire by
org.continuent.sequoia.controller.virtualdatabase.VirtualDatabaseWorkerThread.run TODO: finish the classification below.
Exception reply recognized by the driver in:
FetchNextResultSetRows, closeRemoteResultSet, RestoreConnectionState,
setAutoCommit, getCatalog, getCatalogs, setCatalog,
getControllerVersionNumber, DatabaseMetaDataGetTables,
DatabaseMetaDataGetColumns, DatabaseMetaDataGetPrimaryKeys,
DatabaseMetaDataGetProcedureColumns, DatabaseMetaDataGetTableTypes,
DatabaseMetaDataGetTablePrivileges, DatabaseMetaDataGetSchemas,
DatabaseMetaDataGetDatabaseProductName, DatabaseStaticMetadata
Exception reply ignored by the driver in: Close, Reset
Exceptions catched by instanceof(catch-all) default clause in:
setAutoCommit,
Commands not implemented at all by the driver:
GetVirtualDatabaseName,
TODO: - exceptions and the server side (VirtualDatabaseWorkerThread)
- double-check arguments and replies - better topic ordering
author: Emmanuel Cecchet author: Nicolas Modrzyk author: Marc Herbert author: Jean-Bernard van Zuylen author: version: 1.0 |