Ejemplo n.º 1
0
        protected override void WriteFrame(IFrameWriter fw)
        {
            Stream stream = fw.WriteOnlyStream;

            stream.WriteLongString(CQL);
            fw.SetMessageType(MessageOpcodes.Prepare);
        }
Ejemplo n.º 2
0
        protected override void WriteFrame(IFrameWriter fw)
        {
            Stream stream = fw.WriteOnlyStream;

            stream.WriteLongString(CQL);
            stream.WriteUShort((ushort)ConsistencyLevel);
            fw.SetMessageType(MessageOpcodes.Query);
        }
Ejemplo n.º 3
0
        protected override void WriteFrame(IFrameWriter fw)
        {
            var    cql    = "USE " + _keyspace;
            Stream stream = fw.WriteOnlyStream;

            stream.WriteLongString(cql);
            stream.WriteUShort((ushort)ConsistencyLevel);
            stream.WriteByte(0);
            fw.SetMessageType(MessageOpcodes.Query);
        }
Ejemplo n.º 4
0
        protected override void WriteFrame(IFrameWriter fw)
        {
            Dictionary <string, string> options = new Dictionary <string, string>
            {
                { "CQL_VERSION", _cqlVersion }
            };

            fw.WriteOnlyStream.WriteStringMap(options);
            fw.SetMessageType(MessageOpcodes.Startup);
        }
Ejemplo n.º 5
0
        protected override void WriteFrame(IFrameWriter fw)
        {
            Stream stream = fw.WriteOnlyStream;
            Dictionary <string, string> authParams = new Dictionary <string, string>
            {
                { "username", _user },
                { "password", _password }
            };

            stream.WriteStringMap(authParams);
            fw.SetMessageType(MessageOpcodes.Credentials);
        }
Ejemplo n.º 6
0
        protected override void WriteFrame(IFrameWriter fw)
        {
            Stream stream = fw.WriteOnlyStream;

            stream.WriteShortByteArray(_id);
            stream.WriteUShort((ushort)_columnSpecs.Length);

            foreach (var columnData in _mapperIn.MapToColumns(_dataSource, _columnSpecs))
            {
                stream.WriteByteArray(columnData.RawData);
            }

            stream.WriteUShort((ushort)ConsistencyLevel);
            fw.SetMessageType(MessageOpcodes.Batch);
        }
Ejemplo n.º 7
0
        protected override void WriteFrame(IFrameWriter fw)
        {
            StringBuilder sb = new StringBuilder("CREATE KEYSPACE ");

            sb.Append(_name);
            sb.Append(" WITH replication = {");
            sb.Append(string.Join(",", _replicationOptions.Select(x => string.Format("'{0}': '{1}'", x.Key, x.Value))));
            sb.Append("} AND durable_writes = ");
            sb.Append(_durableWrites);

            Stream stream = fw.WriteOnlyStream;

            stream.WriteLongString(sb.ToString());
            stream.WriteUShort((ushort)ConsistencyLevel);
            fw.SetMessageType(MessageOpcodes.Query);
        }
Ejemplo n.º 8
0
        private void WriteExecuteRequest(IFrameWriter frameWriter, ConsistencyLevel cl, IDataMapperFactory factory)
        {
            frameWriter.WriteShortByteArray(_id);
            frameWriter.WriteShort((short) _columnSpecs.Length);

            IDataSource dataSource = factory.DataSource;
            foreach (IColumnSpec columnSpec in _columnSpecs)
            {
                object data = dataSource.Get(columnSpec);
                byte[] rawData = columnSpec.Serialize(data);
                frameWriter.WriteByteArray(rawData);
            }

            frameWriter.WriteShort((short) cl);
            frameWriter.Send(MessageOpcodes.Execute);
        }
Ejemplo n.º 9
0
        protected sealed override async ValueTask WriteFrameAsync(
            IFrameWriter frameWriter,
            CancellationToken cancellationToken = default)
        {
            await frameWriter.WriteUShortAsync(
                Version ^ 0x8000, cancellationToken)
            .ConfigureAwait(false);

            await frameWriter.WriteUShortAsync(_type, cancellationToken)
            .ConfigureAwait(false);

            await frameWriter.WriteByteAsync(Flags, cancellationToken)
            .ConfigureAwait(false);

            await WriteControlFrameAsync(frameWriter, cancellationToken)
            .ConfigureAwait(false);
        }
Ejemplo n.º 10
0
Archivo: Data.cs Proyecto: lulzzz/Port
        protected override async ValueTask WriteFrameAsync(
            IFrameWriter frameWriter,
            CancellationToken cancellationToken = default)
        {
            var data = StreamId
                       .SetBit(31, false);
            await frameWriter.WriteUInt32Async(data, cancellationToken)
            .ConfigureAwait(false);

            await frameWriter.WriteByteAsync((byte)Flags, cancellationToken)
            .ConfigureAwait(false);

            await frameWriter.WriteUInt24Async(
                UInt24.From((uint)Payload.Length), cancellationToken)
            .ConfigureAwait(false);

            await frameWriter.WriteBytesAsync(Payload, cancellationToken)
            .ConfigureAwait(false);
        }
Ejemplo n.º 11
0
        internal static async ValueTask WriteNameValuePairs(
            this IFrameWriter frameWriter,
            IReadOnlyDictionary <string, string[]> nameValuePairs,
            CancellationToken cancellationToken)
        {
            await frameWriter.WriteInt32Async(
                nameValuePairs.Count, cancellationToken)
            .ConfigureAwait(false);

            foreach (var(name, values) in nameValuePairs)
            {
                await frameWriter
                .WriteStringAsync(name, Encoding.ASCII, cancellationToken)
                .ConfigureAwait(false);

                await frameWriter
                .WriteStringAsync(
                    string.Join(SpdyConstants.Nul, values),
                    Encoding.ASCII, cancellationToken)
                .ConfigureAwait(false);
            }
        }
Ejemplo n.º 12
0
 protected abstract ValueTask WriteControlFrameAsync(
     IFrameWriter frameWriter,
     CancellationToken cancellationToken = default);
Ejemplo n.º 13
0
 protected abstract void WriteFrame(IFrameWriter frameWriter);
 private static void WriteOptions(IFrameWriter frameWriter)
 {
     frameWriter.SetMessageType(MessageOpcodes.Options);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="BinFrameWriterTest"/> class.
 /// </summary>
 public BinFrameWriterTest()
 {
     binFrameWriter = new BinFrameWriter();
 }
Ejemplo n.º 16
0
 /// <summary>
 /// You must use <see cref="Reset"/> before using the Encode methods.
 /// </summary>
 /// <param name="frameWriter"></param>
 public FrameEncoder(IFrameWriter <TFrame> frameWriter) => _frameWriter = frameWriter;
 private static void WriteAuthenticate(IFrameWriter frameWriter, string user, string password)
 {
     Stream stream = frameWriter.WriteOnlyStream;
     Dictionary<string, string> authParams = new Dictionary<string, string>
         {
                 {"username", user},
                 {"password", password}
         };
     stream.WriteStringMap(authParams);
     frameWriter.SetMessageType(MessageOpcodes.Credentials);
 }
 private static void WritePrepareRequest(IFrameWriter frameWriter, string cql)
 {
     Stream stream = frameWriter.WriteOnlyStream;
     stream.WriteLongString(cql);
     frameWriter.SetMessageType(MessageOpcodes.Prepare);
 }
Ejemplo n.º 19
0
 public abstract void Write(IFrameWriter frameWriter);
 private static void WriteQueryRequest(IFrameWriter frameWriter, string cql, ConsistencyLevel cl, MessageOpcodes opcode)
 {
     Stream stream = frameWriter.WriteOnlyStream;
     stream.WriteLongString(cql);
     stream.WriteShort((short) cl);
     frameWriter.SetMessageType(opcode);
 }
Ejemplo n.º 21
0
 protected override void WriteFrame(IFrameWriter fw)
 {
     fw.SetMessageType(MessageOpcodes.Options);
 }
        private static void WriteExecuteRequest(IFrameWriter frameWriter, byte[] id, IColumnSpec[] columnSpecs, ConsistencyLevel cl, IDataMapperFactory factory)
        {
            Stream stream = frameWriter.WriteOnlyStream;
            stream.WriteShortByteArray(id);
            stream.WriteShort((short) columnSpecs.Length);

            IDataSource dataSource = factory.DataSource;
            foreach (IColumnSpec columnSpec in columnSpecs)
            {
                object data = dataSource.Get(columnSpec);
                byte[] rawData = columnSpec.Serialize(data);
                stream.WriteByteArray(rawData);
            }

            stream.WriteShort((short) cl);
            frameWriter.SetMessageType(MessageOpcodes.Execute);
        }
 private static void WriteReady(IFrameWriter frameWriter, string cqlVersion)
 {
     Dictionary<string, string> options = new Dictionary<string, string>
         {
                 {"CQL_VERSION", cqlVersion}
         };
     frameWriter.WriteOnlyStream.WriteStringMap(options);
     frameWriter.SetMessageType(MessageOpcodes.Startup);
 }