예제 #1
0
        /**
         * <summary>
         * Updates topology if cache enabled. If cache is disabled, returns original node.</summary>
         *
         * <param name="node">Converted rest server response.</param>
         * <returns>Node in topology.</returns>
         */
        public N UpdateNode(N node)
        {
            A.NotNull(node, "node");

            busyLock.AcquireWriterLock(Timeout.Infinite);

            try {
                bool nodeAdded = !_nodes.ContainsKey(node.Id);

                // We update the whole topology if node was not in topology or we cache metrics.
                if (nodeAdded || topCache)
                {
                    node = ClearAttributes(node);

                    _nodes[node.Id] = node;
                }

                if (nodeAdded)
                {
                    FireEvents(new TopologyEvent[] { new TopologyEvent(true, node) });
                }

                return(node);
            }
            finally {
                busyLock.ReleaseWriterLock();
            }
        }
예제 #2
0
        /**
         * <summary>
         * Creates projection with specified client.</summary>
         *
         * <param name="cfg">Progjection configuration.</param>
         * <param name="nodes">Collections of nodes included in this projection.</param>
         * <param name="filter">Node filter to be applied.</param>
         * <param name="balancer">Balancer to use.</param>
         */
        protected internal GridClientAbstractProjection(IGridClientProjectionConfig cfg, IEnumerable <N> nodes,
                                                        Predicate <N> filter, IGridClientLoadBalancer balancer)
        {
            A.NotNull(cfg, "projection config");

            this.cfg       = cfg;
            this._nodes    = nodes == null ? null : new List <N>(nodes);
            this._filter   = filter;
            this._balancer = balancer;
        }
예제 #3
0
        /**
         * <summary>
         * Adds topology listener.</summary>
         *
         * <param name="lsnr">Topology listener.</param>
         */
        public void AddTopologyListener(IGridClientTopologyListener lsnr)
        {
            A.NotNull(lsnr, "lsnr");

            busyLock.AcquireWriterLock(Timeout.Infinite);

            try {
                topLsnrs.Add(lsnr);
            }
            finally {
                busyLock.ReleaseWriterLock();
            }
        }