Exemplo n.º 1
0
        public ODocument Response(Response response)
        {
            // start from this position since standard fields (status, session ID) has been already parsed
            int offset = 5;
            ODocument document = new ODocument();

            if (response == null)
            {
                return document;
            }

            // operation specific fields
            document.SetField("SessionId", BinarySerializer.ToInt(response.Data.Skip(offset).Take(4).ToArray()));
            offset += 4;
            short clusterCount = BinarySerializer.ToShort(response.Data.Skip(offset).Take(2).ToArray());
            document.SetField("ClusterCount", clusterCount);
            offset += 2;

            if (clusterCount > 0)
            {
                List<OCluster> clusters = new List<OCluster>();

                for (int i = 1; i <= clusterCount; i++)
                {
                    OCluster cluster = new OCluster();

                    int clusterNameLength = BinarySerializer.ToInt(response.Data.Skip(offset).Take(4).ToArray());
                    offset += 4;

                    cluster.Name = BinarySerializer.ToString(response.Data.Skip(offset).Take(clusterNameLength).ToArray());
                    offset += clusterNameLength;

                    cluster.Id = BinarySerializer.ToShort(response.Data.Skip(offset).Take(2).ToArray());
                    offset += 2;

                    int clusterTypeLength = BinarySerializer.ToInt(response.Data.Skip(offset).Take(4).ToArray());
                    offset += 4;

                    string clusterName = BinarySerializer.ToString(response.Data.Skip(offset).Take(clusterTypeLength).ToArray());
                    cluster.Type = (OClusterType)Enum.Parse(typeof(OClusterType), clusterName, true);
                    offset += clusterTypeLength;

                    cluster.DataSegmentID = BinarySerializer.ToShort(response.Data.Skip(offset).Take(2).ToArray());
                    offset += 2;

                    clusters.Add(cluster);
                }

                document.SetField("Clusters", clusters);
            }

            int clusterConfigLength = BinarySerializer.ToInt(response.Data.Skip(offset).Take(4).ToArray());
            offset += 4;

            document.SetField("ClusterConfig", response.Data.Skip(offset).Take(clusterConfigLength).ToArray());
            offset += clusterConfigLength;

            return document;
        }
Exemplo n.º 2
0
        public object Response(Response response)
        {
            // start from this position since standard fields (status, session ID) has been already parsed
            int offset = 5;
            DtoDatabase database = new DtoDatabase();

            if (response == null)
            {
                return database;
            }

            // operation specific fields
            database.SessionID = BinaryParser.ToInt(response.Data.Skip(offset).Take(4).ToArray());
            offset += 4;
            database.ClustersCount = BinaryParser.ToShort(response.Data.Skip(offset).Take(2).ToArray());
            offset += 2;

            if (database.ClustersCount > 0)
            {
                for (int i = 1; i <= database.ClustersCount; i++)
                {
                    OCluster cluster = new OCluster();

                    int clusterNameLength = BinaryParser.ToInt(response.Data.Skip(offset).Take(4).ToArray());
                    offset += 4;

                    cluster.Name = BinaryParser.ToString(response.Data.Skip(offset).Take(clusterNameLength).ToArray());
                    offset += clusterNameLength;

                    cluster.ID = BinaryParser.ToShort(response.Data.Skip(offset).Take(2).ToArray());
                    offset += 2;

                    int clusterTypeLength = BinaryParser.ToInt(response.Data.Skip(offset).Take(4).ToArray());
                    offset += 4;

                    string clusterName = BinaryParser.ToString(response.Data.Skip(offset).Take(clusterTypeLength).ToArray());
                    cluster.Type = (OClusterType)Enum.Parse(typeof(OClusterType), clusterName, true);
                    offset += clusterTypeLength;

                    cluster.DataSegmentID = BinaryParser.ToShort(response.Data.Skip(offset).Take(2).ToArray());
                    offset += 2;

                    database.Clusters.Add(cluster);
                }
            }

            int clusterConfigLength = BinaryParser.ToInt(response.Data.Skip(offset).Take(4).ToArray());
            offset += 4;

            database.ClusterConfig = response.Data.Skip(offset).Take(clusterConfigLength).ToArray();
            offset += clusterConfigLength;

            return database;
        }
Exemplo n.º 3
0
        public override ODocument Response(Response response)
        {
            ODocument document = new ODocument();

            if (response == null)
            {
                return document;
            }

            var reader = response.Reader;
            if (response.Connection.ProtocolVersion > 26 && response.Connection.UseTokenBasedSession)
                ReadToken(reader);

            short clusterCount = reader.ReadInt16EndianAware();
            document.SetField("ClusterCount", clusterCount);

            if (clusterCount > 0)
            {
                List<OCluster> clusters = new List<OCluster>();

                for (int i = 1; i <= clusterCount; i++)
                {
                    OCluster cluster = new OCluster();

                    int clusterNameLength = reader.ReadInt32EndianAware();

                    cluster.Name = System.Text.Encoding.Default.GetString(reader.ReadBytes(clusterNameLength));

                    cluster.Id = reader.ReadInt16EndianAware();

                    if (OClient.ProtocolVersion < 24)
                    {
                        int clusterTypeLength = reader.ReadInt32EndianAware();

                        string clusterType = System.Text.Encoding.Default.GetString(reader.ReadBytes(clusterTypeLength));
                        //cluster.Type = (OClusterType)Enum.Parse(typeof(OClusterType), clusterType, true);
                        if (OClient.ProtocolVersion >= 12)
                            cluster.DataSegmentID = reader.ReadInt16EndianAware();
                        else
                            cluster.DataSegmentID = 0;
                    }

                    clusters.Add(cluster);
                }

                document.SetField("Clusters", clusters);
            }

            return document;
        }
Exemplo n.º 4
0
        public ODocument Response(Response response)
        {
            ODocument document = new ODocument();

            if (response == null)
            {
                return document;
            }

            var reader = response.Reader;

            // operation specific fields
            document.SetField("SessionId", reader.ReadInt32EndianAware());
            short clusterCount = reader.ReadInt16EndianAware();
            document.SetField("ClusterCount", clusterCount);

            if (clusterCount > 0)
            {
                List<OCluster> clusters = new List<OCluster>();

                for (int i = 1; i <= clusterCount; i++)
                {
                    OCluster cluster = new OCluster();

                    int clusterNameLength = reader.ReadInt32EndianAware();

                    cluster.Name = System.Text.Encoding.Default.GetString(reader.ReadBytes(clusterNameLength));

                    cluster.Id = reader.ReadInt16EndianAware();

                    if (OClient.ProtocolVersion < 24)
                    {
                        int clusterTypeLength = reader.ReadInt32EndianAware();

                        string clusterType = System.Text.Encoding.Default.GetString(reader.ReadBytes(clusterTypeLength));
                        cluster.Type = (OClusterType)Enum.Parse(typeof(OClusterType), clusterType, true);

                        cluster.DataSegmentID = reader.ReadInt16EndianAware();
                    }

                    clusters.Add(cluster);
                }

                document.SetField("Clusters", clusters);
            }

            int clusterConfigLength = reader.ReadInt32EndianAware();

            byte[] clusterConfig = null;

            if (clusterConfigLength > 0)
            {
                 clusterConfig = reader.ReadBytes(clusterConfigLength);
            }
            
            document.SetField("ClusterConfig", clusterConfig);

            string release = reader.ReadInt32PrefixedString();
            document.SetField("OrientdbRelease", release);

            return document;
        }
Exemplo n.º 5
0
        public override ODocument Response(Response response)
        {
            ODocument document = new ODocument();

            if (response == null)
            {
                return document;
            }

            var reader = response.Reader;

            var sessionId = reader.ReadInt32EndianAware();
            document.SetField("SessionId", sessionId);

            if (response.Connection.ProtocolVersion > 26)
            {
                var size = reader.ReadInt32EndianAware();
                var token = reader.ReadBytesRequired(size);
                var t = OToken.Parse(token);
                document.SetField("Token", token);
            }

            int clusterCount = -1;

            if (OClient.ProtocolVersion >= 7)
                clusterCount = (int)reader.ReadInt16EndianAware();
            else
                clusterCount = reader.ReadInt32EndianAware();

            document.SetField("ClusterCount", clusterCount);

            if (clusterCount > 0)
            {
                List<OCluster> clusters = new List<OCluster>();

                for (int i = 1; i <= clusterCount; i++)
                {
                    OCluster cluster = new OCluster();

                    int clusterNameLength = reader.ReadInt32EndianAware();

                    cluster.Name = System.Text.Encoding.UTF8.GetString(reader.ReadBytes(clusterNameLength));

                    cluster.Id = reader.ReadInt16EndianAware();

                    if (OClient.ProtocolVersion < 24)
                    {
                        int clusterTypeLength = reader.ReadInt32EndianAware();

                        string clusterType = System.Text.Encoding.UTF8.GetString(reader.ReadBytes(clusterTypeLength));
                        //cluster.Type = (OClusterType)Enum.Parse(typeof(OClusterType), clusterType, true);
                    }
                    clusters.Add(cluster);
                }

                document.SetField("Clusters", clusters);
            }

            int clusterConfigLength = reader.ReadInt32EndianAware();

            byte[] clusterConfig = null;

            if (clusterConfigLength > 0)
            {
                clusterConfig = reader.ReadBytes(clusterConfigLength);
            }

            document.SetField("ClusterConfig", clusterConfig);

            string release = reader.ReadInt32PrefixedString();
            document.SetField("OrientdbRelease", release);

            return document;
        }
Exemplo n.º 6
0
        public override ODocument Response(Response response)
        {
            ODocument document = new ODocument();

            if (response == null)
            {
                return(document);
            }

            var reader = response.Reader;

            var sessionId = reader.ReadInt32EndianAware();

            document.SetField("SessionId", sessionId);

            if (response.Connection.ProtocolVersion > 26)
            {
                var size  = reader.ReadInt32EndianAware();
                var token = reader.ReadBytesRequired(size);
                var t     = OToken.Parse(token);
                document.SetField("Token", token);
            }

            int clusterCount = -1;

            if (OClient.ProtocolVersion >= 7)
            {
                clusterCount = (int)reader.ReadInt16EndianAware();
            }
            else
            {
                clusterCount = reader.ReadInt32EndianAware();
            }

            document.SetField("ClusterCount", clusterCount);

            if (clusterCount > 0)
            {
                List <OCluster> clusters = new List <OCluster>();

                for (int i = 1; i <= clusterCount; i++)
                {
                    OCluster cluster = new OCluster();

                    int clusterNameLength = reader.ReadInt32EndianAware();

                    cluster.Name = System.Text.Encoding.UTF8.GetString(reader.ReadBytes(clusterNameLength));

                    cluster.Id = reader.ReadInt16EndianAware();

                    if (OClient.ProtocolVersion < 24)
                    {
                        int clusterTypeLength = reader.ReadInt32EndianAware();

                        string clusterType = System.Text.Encoding.UTF8.GetString(reader.ReadBytes(clusterTypeLength));
                        //cluster.Type = (OClusterType)Enum.Parse(typeof(OClusterType), clusterType, true);
                    }
                    clusters.Add(cluster);
                }

                document.SetField("Clusters", clusters);
            }

            int clusterConfigLength = reader.ReadInt32EndianAware();

            byte[] clusterConfig = null;

            if (clusterConfigLength > 0)
            {
                clusterConfig = reader.ReadBytes(clusterConfigLength);
            }

            document.SetField("ClusterConfig", clusterConfig);

            string release = reader.ReadInt32PrefixedString();

            document.SetField("OrientdbRelease", release);

            return(document);
        }
Exemplo n.º 7
0
 internal void AddClusterId(OCluster cluster)
 {
     if (!_clusterIds.Contains(cluster))
         _clusterIds.Add(cluster);
 }
Exemplo n.º 8
0
        public ODocument Response(Response response)
        {
            ODocument document = new ODocument();

            if (response == null)
            {
                return(document);
            }

            var reader = response.Reader;

            // operation specific fields
            document.SetField("SessionId", reader.ReadInt32EndianAware());
            short clusterCount = reader.ReadInt16EndianAware();

            document.SetField("ClusterCount", clusterCount);

            if (clusterCount > 0)
            {
                List <OCluster> clusters = new List <OCluster>();

                for (int i = 1; i <= clusterCount; i++)
                {
                    OCluster cluster = new OCluster();

                    int clusterNameLength = reader.ReadInt32EndianAware();

                    cluster.Name = System.Text.Encoding.Default.GetString(reader.ReadBytes(clusterNameLength));

                    cluster.Id = reader.ReadInt16EndianAware();

                    int clusterTypeLength = reader.ReadInt32EndianAware();

                    string clusterType = System.Text.Encoding.Default.GetString(reader.ReadBytes(clusterTypeLength));
                    cluster.Type = (OClusterType)Enum.Parse(typeof(OClusterType), clusterType, true);

                    cluster.DataSegmentID = reader.ReadInt16EndianAware();

                    clusters.Add(cluster);
                }

                document.SetField("Clusters", clusters);
            }

            int clusterConfigLength = reader.ReadInt32EndianAware();

            byte[] clusterConfig = null;

            if (clusterConfigLength > 0)
            {
                clusterConfig = reader.ReadBytes(clusterConfigLength);
            }

            document.SetField("ClusterConfig", clusterConfig);

            string release = reader.ReadInt32PrefixedString();

            document.SetField("OrientdbRelease", release);

            return(document);
        }
Exemplo n.º 9
0
        public ODocument Response(Response response)
        {
            // start from this position since standard fields (status, session ID) has been already parsed
            int       offset   = 5;
            ODocument document = new ODocument();

            if (response == null)
            {
                return(document);
            }

            // operation specific fields
            document.SetField("SessionId", BinarySerializer.ToInt(response.Data.Skip(offset).Take(4).ToArray()));
            offset += 4;
            short clusterCount = BinarySerializer.ToShort(response.Data.Skip(offset).Take(2).ToArray());

            document.SetField("ClusterCount", clusterCount);
            offset += 2;

            if (clusterCount > 0)
            {
                List <OCluster> clusters = new List <OCluster>();

                for (int i = 1; i <= clusterCount; i++)
                {
                    OCluster cluster = new OCluster();

                    int clusterNameLength = BinarySerializer.ToInt(response.Data.Skip(offset).Take(4).ToArray());
                    offset += 4;

                    cluster.Name = BinarySerializer.ToString(response.Data.Skip(offset).Take(clusterNameLength).ToArray());
                    offset      += clusterNameLength;

                    cluster.Id = BinarySerializer.ToShort(response.Data.Skip(offset).Take(2).ToArray());
                    offset    += 2;

                    int clusterTypeLength = BinarySerializer.ToInt(response.Data.Skip(offset).Take(4).ToArray());
                    offset += 4;

                    string clusterName = BinarySerializer.ToString(response.Data.Skip(offset).Take(clusterTypeLength).ToArray());
                    cluster.Type = (OClusterType)Enum.Parse(typeof(OClusterType), clusterName, true);
                    offset      += clusterTypeLength;

                    cluster.DataSegmentID = BinarySerializer.ToShort(response.Data.Skip(offset).Take(2).ToArray());
                    offset += 2;

                    clusters.Add(cluster);
                }

                document.SetField("Clusters", clusters);
            }

            int clusterConfigLength = BinarySerializer.ToInt(response.Data.Skip(offset).Take(4).ToArray());

            offset += 4;

            document.SetField("ClusterConfig", response.Data.Skip(offset).Take(clusterConfigLength).ToArray());
            offset += clusterConfigLength;

            return(document);
        }