Пример #1
0
        internal ResultResponse(ResponseFrame frame) : base(frame)
        {
            Kind = (ResultResponseKind)BeBinaryReader.ReadInt32();
            switch (Kind)
            {
            case ResultResponseKind.Void:
                Output = new OutputVoid(TraceId);
                break;

            case ResultResponseKind.Rows:
                Output = new OutputRows(frame.Header.Version, BeBinaryReader, true, TraceId);
                break;

            case ResultResponseKind.SetKeyspace:
                Output = new OutputSetKeyspace(BeBinaryReader.ReadString());
                break;

            case ResultResponseKind.Prepared:
                Output = new OutputPrepared(BeBinaryReader, frame.Header.Version > 1);
                break;

            case ResultResponseKind.SchemaChange:
                Output = new OutputSchemaChange(BeBinaryReader, TraceId);
                break;

            default:
                throw new DriverInternalError("Unknown ResultResponseKind Type");
            }
        }
Пример #2
0
        internal ResultResponse(ResponseFrame frame) : base(frame)
        {
            Kind = (ResultResponseKind)BeBinaryReader.ReadInt32();
            switch (Kind)
            {
            case ResultResponseKind.Void:
                Output = new OutputVoid(TraceId);
                break;

            case ResultResponseKind.Rows:
                Output = new OutputRows(BeBinaryReader, frame.RawStream is BufferedProtoBuf, TraceId);
                break;

            case ResultResponseKind.SetKeyspace:
                Output = new OutputSetKeyspace(BeBinaryReader.ReadString());
                break;

            case ResultResponseKind.Prepared:
                Output = new OutputPrepared(BeBinaryReader, frame.FrameHeader.Version == ResponseFrame.ProtocolV2ResponseVersionByte);
                break;

            case ResultResponseKind.SchemaChange:
                Output = new OutputSchemaChange(BeBinaryReader, TraceId);
                break;

            default:
                throw new DriverInternalError("Unknown ResultResponseKind Type");
            }
        }
Пример #3
0
        internal ErrorResponse(ResponseFrame frame)
            : base(frame)
        {
            int    errorCode = BeBinaryReader.ReadInt32();
            string message   = BeBinaryReader.ReadString();

            Output = OutputError.CreateOutputError(errorCode, message, BeBinaryReader);
        }
Пример #4
0
        public void HandleSchemaChange(ResponseFrame frame)
        {
            var ce = new SchemaChangeEventArgs();

            CassandraEventArgs = ce;
            var changeTypeText = BeBinaryReader.ReadString();

            SchemaChangeEventArgs.Reason changeType;
            switch (changeTypeText)
            {
            case "UPDATED":
                changeType = SchemaChangeEventArgs.Reason.Updated;
                break;

            case "DROPPED":
                changeType = SchemaChangeEventArgs.Reason.Dropped;
                break;

            default:
                changeType = SchemaChangeEventArgs.Reason.Created;
                break;
            }
            ce.What = changeType;
            if (frame.Header.Version < 3)
            {
                //protocol v1 and v2: <change_type><keyspace><table>
                ce.Keyspace = BeBinaryReader.ReadString();
                ce.Table    = BeBinaryReader.ReadString();
                return;
            }
            //protocol v3+: <change_type><target><options>
            var target = BeBinaryReader.ReadString();

            ce.Keyspace = BeBinaryReader.ReadString();
            switch (target)
            {
            case "TABLE":
                ce.Table = BeBinaryReader.ReadString();
                break;

            case "TYPE":
                ce.Type = BeBinaryReader.ReadString();
                break;

            case "FUNCTION":
                ce.FunctionName = BeBinaryReader.ReadString();
                ce.Signature    = BeBinaryReader.ReadStringList();
                break;

            case "AGGREGATE":
                ce.AggregateName = BeBinaryReader.ReadString();
                ce.Signature     = BeBinaryReader.ReadStringList();
                break;
            }
        }
Пример #5
0
 public static void Load(BeBinaryReader br, Save save)
 {
     save.Team        = new Team(br);
     save.Team.Emblem = br.ReadInt16();
     save.Team.Name   = br.ReadString();
     for (int i = 0; i < 16; i++)
     {
         var player = new Player();
         player.MoveList = new MoveList(br);
         player.Stats    = new Stats(br);
         var teamPlayer = save.Team.Players[i];
         var id         = teamPlayer.Id;
         save.Players[id] = player;
     }
 }
Пример #6
0
        internal EventResponse(ResponseFrame frame)
            : base(frame)
        {
            string eventTypeString = BeBinaryReader.ReadString();

            if (eventTypeString == "TOPOLOGY_CHANGE")
            {
                var ce = new TopologyChangeEventArgs();
                ce.What = BeBinaryReader.ReadString() == "NEW_NODE"
                              ? TopologyChangeEventArgs.Reason.NewNode
                              : TopologyChangeEventArgs.Reason.RemovedNode;
                ce.Address         = BeBinaryReader.ReadInet().Address;
                CassandraEventArgs = ce;
                return;
            }
            if (eventTypeString == "STATUS_CHANGE")
            {
                var ce = new StatusChangeEventArgs();
                ce.What = BeBinaryReader.ReadString() == "UP"
                              ? StatusChangeEventArgs.Reason.Up
                              : StatusChangeEventArgs.Reason.Down;
                ce.Address         = BeBinaryReader.ReadInet().Address;
                CassandraEventArgs = ce;
                return;
            }
            if (eventTypeString == "SCHEMA_CHANGE")
            {
                var    ce = new SchemaChangeEventArgs();
                string m  = BeBinaryReader.ReadString();
                ce.What = m == "CREATED"
                              ? SchemaChangeEventArgs.Reason.Created
                              : (m == "UPDATED"
                                     ? SchemaChangeEventArgs.Reason.Updated
                                     : SchemaChangeEventArgs.Reason.Dropped);
                ce.Keyspace        = BeBinaryReader.ReadString();
                ce.Table           = BeBinaryReader.ReadString();
                CassandraEventArgs = ce;
                return;
            }

            var ex = new DriverInternalError("Unknown Event Type");

            _logger.Error(ex);
            throw ex;
        }
Пример #7
0
        public void HandleSchemaChange(ResponseFrame frame)
        {
            var    ce = new SchemaChangeEventArgs();
            string m  = BeBinaryReader.ReadString();

            ce.What = m == "CREATED"
                          ? SchemaChangeEventArgs.Reason.Created
                          : (m == "UPDATED"
                                 ? SchemaChangeEventArgs.Reason.Updated
                                 : SchemaChangeEventArgs.Reason.Dropped);
            if (frame.Header.Version < 3)
            {
                //protocol v1 and v2: <change_type><keyspace><table>
                ce.Keyspace = BeBinaryReader.ReadString();
                ce.Table    = BeBinaryReader.ReadString();
            }
            else
            {
                //protocol v3: <change_type><target><options>
                var target = BeBinaryReader.ReadString();
                switch (target)
                {
                case "KEYSPACE":
                    ce.Keyspace = BeBinaryReader.ReadString();
                    break;

                case "TABLE":
                    ce.Keyspace = BeBinaryReader.ReadString();
                    ce.Table    = BeBinaryReader.ReadString();
                    break;

                case "TYPE":
                    ce.Keyspace = BeBinaryReader.ReadString();
                    ce.Type     = BeBinaryReader.ReadString();
                    break;
                }
            }
            CassandraEventArgs = ce;
        }
Пример #8
0
        internal ResultResponse(ResponseFrame frame) : base(frame)
        {
            //Handle result flags
            if ((frame.Header.Flags & FrameHeader.HeaderFlag.Warning) != 0)
            {
                Warnings = BeBinaryReader.ReadStringList();
            }
            if ((frame.Header.Flags & FrameHeader.HeaderFlag.CustomPayload) != 0)
            {
                CustomPayload = BeBinaryReader.ReadBytesMap();
            }

            Kind = (ResultResponseKind)BeBinaryReader.ReadInt32();
            switch (Kind)
            {
            case ResultResponseKind.Void:
                Output = new OutputVoid(TraceId);
                break;

            case ResultResponseKind.Rows:
                Output = new OutputRows(frame.Header.Version, BeBinaryReader, TraceId);
                break;

            case ResultResponseKind.SetKeyspace:
                Output = new OutputSetKeyspace(BeBinaryReader.ReadString());
                break;

            case ResultResponseKind.Prepared:
                Output = new OutputPrepared(frame.Header.Version, BeBinaryReader);
                break;

            case ResultResponseKind.SchemaChange:
                Output = new OutputSchemaChange(BeBinaryReader, TraceId);
                break;

            default:
                throw new DriverInternalError("Unknown ResultResponseKind Type");
            }
        }
Пример #9
0
        public static void packBARC(string dir, string barcname)
        {
            var barcstm   = File.OpenWrite(barcname);
            var barcwrite = new BeBinaryWriter(barcstm);

            barcwrite.Write(0x424152432D2D2D2DL); // BARC----
            barcwrite.Write((uint)0xDEADBEEF);    // skip

            var schema   = File.OpenRead(dir + "\\schema.bin");
            var schemard = new BeBinaryReader(schema);

            var total_off = 0;

            var end_size   = schemard.ReadInt32();
            var count      = schemard.ReadInt32();
            var seqArcFile = schemard.ReadString();


            barcwrite.Write(count);
            var sqarc_out = File.OpenWrite(dir + "\\" + seqArcFile);

            util.writeBARCString(barcwrite, seqArcFile);
            seq_map    = new int[0xFFFFF];
            TrackSizes = new int[0xFFFFF];
            for (int i = 0; i < count; i++)
            {
                var  inname = string.Format("{0:D6}.bms", i);
                var  e      = File.ReadAllBytes(dir + "\\" + inname);
                var  wx     = File.OpenRead(dir + "\\" + inname);
                var  wxr    = new BeBinaryReader(wx);
                var  alias  = wxr.ReadUInt32();
                bool doAli  = false;
                int  sIdx   = 0;
                if (alias == 0xAFBFCFDF)
                {
                    sIdx  = wxr.ReadInt32();
                    doAli = true;
                    Console.WriteLine("Aliased {0}", sIdx);
                }
                wx.Close();


                util.writeBARCString(barcwrite, inname);
                barcwrite.Write((int)2);
                barcwrite.Write((int)3);
                if (doAli)
                {
                    Console.WriteLine("Alias map to {0:X}, {1}", seq_map[sIdx], sIdx);
                    barcwrite.Write(seq_map[sIdx]);
                    barcwrite.Write(TrackSizes[sIdx]);

                    continue;
                }
                else
                {
                    barcwrite.Write(total_off);
                }


                Console.WriteLine("Sequence {0} at {1:X}", i, total_off);


                seq_map[i]    = total_off;
                TrackSizes[i] = e.Length;
                barcwrite.Write(e.Length);
                if (doAli)
                {
                    continue;
                }
                sqarc_out.Position = total_off;
                sqarc_out.Write(e, 0, e.Length);



                var Pad = new byte[0x20];
                sqarc_out.Write(Pad, 0, Pad.Length);


                total_off += e.Length + Pad.Length;
            }
            barcwrite.Flush();
            sqarc_out.Flush();
        }
Пример #10
0
 internal AuthenticateResponse(ResponseFrame frame) : base(frame)
 {
     Authenticator = BeBinaryReader.ReadString();
 }