Exemple #1
0
        /// <summary>
        /// Refresh projection nodes.
        /// </summary>
        /// <returns>Nodes.</returns>
        private IList <IClusterNode> RefreshNodes()
        {
            long oldTopVer = Interlocked.Read(ref _topVer);

            List <IClusterNode> newNodes = null;

            DoOutInOp(OpNodes, writer =>
            {
                writer.WriteLong(oldTopVer);
            }, input =>
            {
                BinaryReader reader = Marshaller.StartUnmarshal(input);

                if (reader.ReadBoolean())
                {
                    // Topology has been updated.
                    long newTopVer = reader.ReadLong();

                    newNodes = IgniteUtils.ReadNodes(reader, _pred);

                    UpdateTopology(newTopVer, newNodes);
                }
            });

            if (newNodes != null)
            {
                return(newNodes);
            }

            // No topology changes.
            Debug.Assert(_nodes != null, "At least one topology update should have occurred.");

            return(_nodes);
        }
Exemple #2
0
        /// <summary>
        /// Refresh projection nodes.
        /// </summary>
        /// <returns>Nodes.</returns>
        private IList <IClusterNode> RefreshNodes()
        {
            long oldTopVer = Interlocked.Read(ref _topVer);

            var res = Target.InStreamOutStream(OpNodes, writer =>
            {
                writer.WriteLong(oldTopVer);
            }, reader =>
            {
                if (reader.ReadBoolean())
                {
                    // Topology has been updated.
                    long newTopVer = reader.ReadLong();
                    var newNodes   = IgniteUtils.ReadNodes((BinaryReader)reader, _pred);

                    return(Tuple.Create(newTopVer, newNodes));
                }

                return(null);
            });

            if (res != null)
            {
                UpdateTopology(res.Item1, res.Item2);

                return(res.Item2);
            }

            // No topology changes.
            Debug.Assert(_nodes != null, "At least one topology update should have occurred.");

            return(_nodes);
        }
Exemple #3
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="r">The reader to read data from.</param>
        internal DiscoveryEvent(BinaryReader r) : base(r)
        {
            _eventNode       = ReadNode(r);
            _topologyVersion = r.ReadLong();

            var nodes = IgniteUtils.ReadNodes(r);

            _topologyNodes = nodes == null ? null : new ReadOnlyCollection <IClusterNode>(nodes);
        }
        /// <summary>
        /// Reads the partitions assignment from a stream.
        /// </summary>
        /// <param name="stream">The stream.</param>
        /// <param name="marsh">The marshaller.</param>
        /// <returns>Partitions assignment.</returns>
        internal static IEnumerable <IEnumerable <IClusterNode> > ReadPartitions(IBinaryStream stream, Marshaller marsh)
        {
            Debug.Assert(stream != null);
            Debug.Assert(marsh != null);

            var reader = marsh.StartUnmarshal(stream);

            var partCnt = reader.ReadInt();

            var res = new List <IEnumerable <IClusterNode> >(partCnt);

            for (var i = 0; i < partCnt; i++)
            {
                res.Add(IgniteUtils.ReadNodes(reader));
            }

            return(res);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="AffinityFunctionContext"/> class.
        /// </summary>
        /// <param name="reader">The reader.</param>
        internal AffinityFunctionContext(IBinaryRawReader reader)
        {
            var cnt = reader.ReadInt();

            if (cnt > 0)
            {
                _previousAssignment = new List <List <IClusterNode> >(cnt);

                for (var i = 0; i < cnt; i++)
                {
                    _previousAssignment.Add(IgniteUtils.ReadNodes(reader));
                }
            }

            _backups = reader.ReadInt();
            _currentTopologySnapshot = IgniteUtils.ReadNodes(reader);
            _currentTopologyVersion  = new AffinityTopologyVersion(reader.ReadLong(), reader.ReadInt());
            _discoveryEvent          = EventReader.Read <DiscoveryEvent>(reader);
        }
Exemple #6
0
 /// <summary>
 /// Reads nodes from stream.
 /// </summary>
 private IList <IClusterNode> ReadNodes(IBinaryStream reader)
 {
     return(IgniteUtils.ReadNodes(Marshaller.StartUnmarshal(reader, _keepBinary)));
 }
Exemple #7
0
 /// <summary>
 /// Gets a topology by version. Returns null if topology history storage doesn't contain
 /// specified topology version (history currently keeps the last 1000 snapshots).
 /// </summary>
 /// <param name="version">Topology version.</param>
 /// <returns>Collection of Ignite nodes which represented by specified topology version,
 /// if it is present in history storage, {@code null} otherwise.</returns>
 /// <exception cref="IgniteException">If underlying SPI implementation does not support
 /// topology history. Currently only {@link org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi}
 /// supports topology history.</exception>
 internal ICollection <IClusterNode> Topology(long version)
 {
     return(DoOutInOp(OpTopology, writer => writer.WriteLong(version),
                      input => IgniteUtils.ReadNodes(Marshaller.StartUnmarshal(input))));
 }
 /// <summary>
 /// Reads nodes from stream.
 /// </summary>
 private IList <IClusterNode> ReadNodes(IPortableStream reader)
 {
     return(IgniteUtils.ReadNodes(Marshaller.StartUnmarshal(reader, _keepPortable)));
 }