Exemplo n.º 1
0
        public ExecuteRequest(int protocolVersion, byte[] id, RowSetMetadata metadata, bool tracingEnabled, QueryProtocolOptions queryOptions)
        {
            ProtocolVersion = protocolVersion;
            if (metadata != null && queryOptions.Values.Length != metadata.Columns.Length)
            {
                throw new ArgumentException("Number of values does not match with number of prepared statement markers(?).", "values");
            }
            _id = id;
            _metadata = metadata;
            _queryOptions = queryOptions;
            if (tracingEnabled)
            {
                _flags = 0x02;
            }

            if (Consistency.IsSerialConsistencyLevel())
            {
                throw new RequestInvalidException("Serial consistency specified as a non-serial one.");
            }
            if (queryOptions.SerialConsistency != ConsistencyLevel.Any && queryOptions.SerialConsistency.IsSerialConsistencyLevel() == false)
            {
                throw new RequestInvalidException("Non-serial consistency specified as a serial one.");
            }
            if (queryOptions.Timestamp != null && protocolVersion < 3)
            {
                throw new NotSupportedException("Timestamp for query is supported in Cassandra 2.1 or above.");
            }
        }
Exemplo n.º 2
0
 internal PreparedStatement(RowSetMetadata metadata, byte[] id, string cql, RowSetMetadata resultMetadata)
 {
     Metadata = metadata;
     Id = id;
     Cql = cql;
     ResultMetadata = resultMetadata;
 }
        public IAsyncResult BeginExecuteQuery(int _streamId, byte[] Id, string cql, RowSetMetadata Metadata, object[] values,
                                              AsyncCallback callback, object state, object owner,
                                              ConsistencyLevel consistency, bool isTracing)
        {
            var jar = SetupJob(_streamId, callback, state, owner, "EXECUTE");

            BeginJob(jar, SetupKeyspace(jar, SetupPreparedQuery(jar, Id, cql, () =>
               {
                   Evaluate(new ExecuteRequest(jar.StreamId, Id, Metadata, values, consistency, isTracing), jar.StreamId,
                            new Action<ResponseFrame>((frame2) =>
                                {
                                    var response = FrameParser.Parse(frame2);
                                    if (response is ResultResponse)
                                        JobFinished(jar, (response as ResultResponse).Output);
                                    else
                                        _protocolErrorHandlerAction(new ErrorActionParam()
                                            {
                                                AbstractResponse = response,
                                                Jar = jar
                                            });

                                }));
               })));

            return jar;
        }
Exemplo n.º 4
0
 internal OutputRows(FrameReader reader, Guid? traceId)
 {
     _metadata = new RowSetMetadata(reader);
     _rowLength = reader.ReadInt32();
     TraceId = traceId;
     RowSet = new RowSet();
     ProcessRows(RowSet, reader);
 }
Exemplo n.º 5
0
 internal OutputRows(BEBinaryReader reader, bool buffered, Guid? traceID)
 {
     this._buffered = buffered;
     this._reader = reader;
     Metadata = new RowSetMetadata(reader);
     Rows = reader.ReadInt32();
     _disposedEvent = new ManualResetEvent(buffered);
     _traceID = traceID;
 }
Exemplo n.º 6
0
 internal OutputRows(byte protocolVersion, BEBinaryReader reader, bool buffered, Guid? traceId)
 {
     _protocolVersion = protocolVersion;
     _metadata = new RowSetMetadata(reader);
     RowLength = reader.ReadInt32();
     _traceId = traceId;
     RowSet = new RowSet();
     ProcessRows(RowSet, reader);
 }
Exemplo n.º 7
0
 internal OutputRows(byte protocolVersion, FrameReader reader, Guid? traceId)
 {
     _protocolVersion = protocolVersion;
     _metadata = new RowSetMetadata(reader);
     _rowLength = reader.ReadInt32();
     TraceId = traceId;
     RowSet = new RowSet();
     ProcessRows(RowSet, reader);
 }
Exemplo n.º 8
0
 internal PreparedStatement(RowSetMetadata metadata, byte[] id, string cql, string keyspace, RowSetMetadata resultMetadata, int protocolVersion)
 {
     Metadata = metadata;
     Id = id;
     Cql = cql;
     ResultMetadata = resultMetadata;
     Keyspace = keyspace;
     _protocolVersion = protocolVersion;
 }
        public IAsyncResult BeginExecuteQuery(byte[] Id, RowSetMetadata Metadata, object[] values,
                                              AsyncCallback callback, object state, object owner,
                                              ConsistencyLevel consistency, bool isTracing)
        {
            return BeginJob(callback, state, owner, "EXECUTE", new Action<int>((streamId) =>
                {
                    Evaluate(new ExecuteRequest(streamId, Id, Metadata, values, consistency, isTracing), streamId,
                             new Action<ResponseFrame>((frame2) =>
                                 {
                                     var response = FrameParser.Parse(frame2);
                                     if (response is ResultResponse)
                                         JobFinished(streamId, (response as ResultResponse).Output);
                                     else
                                         _protocolErrorHandlerAction(new ErrorActionParam()
                                             {
                                                 AbstractResponse = response,
                                                 StreamId = streamId
                                             });

                                 }));
                }));
        }
Exemplo n.º 10
0
 internal RowSet ExecuteQuery(byte[] id, RowSetMetadata metadata, object[] values, ConsistencyLevel consistency = ConsistencyLevel.Default, Query query = null, bool isTracing=false)
 {
     var ar = BeginExecuteQuery(id,metadata,values, null, null, consistency, query, isTracing);
     return EndExecuteQuery(ar);
 }
Exemplo n.º 11
0
        internal IAsyncResult BeginExecuteQuery(byte[] id, RowSetMetadata metadata, object[] values, AsyncCallback callback, object state, ConsistencyLevel consistency = ConsistencyLevel.Default, Query query = null, object sender = null, object tag = null, bool isTracing=false)
        {
            var longActionAc = new AsyncResult<RowSet>(-1, callback, state, this, "SessionExecuteQuery", sender, tag);
            var token = new LongExecuteQueryToken() { Consistency = consistency, Id = id, cql= _preparedQueries[id], Metadata = metadata, Values = values, Query = query, LongActionAc = longActionAc, IsTracinig = isTracing};

            ExecConn(token, false);

            return longActionAc;
        }
 public IOutput ExecuteQuery(byte[] Id, RowSetMetadata Metadata, object[] values, ConsistencyLevel consistency,
                             bool isTracing)
 {
     return EndExecuteQuery(BeginExecuteQuery(Id, Metadata, values, null, null, this, consistency, isTracing),
                            this);
 }
Exemplo n.º 13
0
 internal PreparedStatement(RowSetMetadata metadata, byte[] id, string cql, string keyspace, Serializer serializer)
 {
     Metadata = metadata;
     Id = id;
     Cql = cql;
     Keyspace = keyspace;
     _serializer = serializer;
 }
Exemplo n.º 14
0
 internal byte[] EndPrepareQuery(IAsyncResult ar, out RowSetMetadata metadata)
 {
     var longActionAc = ar as AsyncResult<KeyValuePair<RowSetMetadata, byte[]>>;
     var ret = AsyncResult<KeyValuePair<RowSetMetadata, byte[]>>.End(ar, this, "SessionPrepareQuery");
     metadata = ret.Key;
     return ret.Value;
 }
 public IOutput ExecuteQuery(int streamId, byte[] Id, string cql, RowSetMetadata Metadata, object[] values, ConsistencyLevel consistency,
                             bool isTracing)
 {
     return EndExecuteQuery(BeginExecuteQuery(streamId, Id, cql, Metadata, values, null, null, this, consistency, isTracing),
                            this);
 }
Exemplo n.º 16
0
 private void ProcessPrepareQuery(IOutput outp, out RowSetMetadata metadata, out byte[] queryId)
 {
     using (outp)
     {
         if (outp is OutputError)
         {
             var ex = (outp as OutputError).CreateException();
             _logger.Error(ex);
             throw ex;
         }
         else if (outp is OutputPrepared)
         {
             queryId = (outp as OutputPrepared).QueryID;
             metadata = (outp as OutputPrepared).Metadata;
             _logger.Info("Prepared Query has been successfully processed.");
             return; //ok
         }
         else
         {
             var ex = new DriverInternalError("Unexpected output kind");
             _logger.Error("Prepared Query has returned an unexpected output kind.", ex);
             throw ex;
         }
     }
 }
Exemplo n.º 17
0
 internal byte[] PrepareQuery(string cqlQuery, out RowSetMetadata metadata)
 {
     var ar = BeginPrepareQuery(cqlQuery, null, null, null);
     return EndPrepareQuery(ar, out metadata);
 }