Exemplo n.º 1
0
        public bool ClusterBadge(Clusterable badge, Cluster cluster)
        {
            if (badge.IsInCluster())
            {
                //two or more clients sent clustering requests in the same time. first wins
                Log.Warn("cluster failed: badge=" + badge.GetId() + " cluster=" + cluster.GetId() +
                         " current cluster of badge=" + badge.GetCluster().GetId());
                return(false);
            }

            badge.Cluster(cluster);
            cluster.Add(badge);
            return(true);
        }
Exemplo n.º 2
0
        public void UnclusterBadge(Clusterable badge, int usrId)
        {
            if (!badge.IsInCluster())
            {
                Log.Warn("badge " + badge.GetId() + " is already unclustered");
                return;
            }

            //1 remove from cluster
            var affectedCluster = badge.GetCluster();

            affectedCluster.Remove(badge);
            badge.Uncluster();
            if (onUnclusterBadge != null)
            {
                onUnclusterBadge(badge, affectedCluster, usrId);
            }

            //2 if cluster is empty, delete cluster
            if (affectedCluster.IsEmpty())
            {
                DeleteCluster(affectedCluster, usrId);
            }
        }
Exemplo n.º 3
0
        public bool ClusterBadge(Clusterable badge, Cluster cluster)
        {
            if (badge.IsInCluster())
            {
                //two or more clients sent clustering requests in the same time. first wins
                Log.Warn("cluster failed: badge=" + badge.GetId() + " cluster=" + cluster.GetId() +
                          " current cluster of badge=" + badge.GetCluster().GetId());
                return false;
            }

            badge.Cluster(cluster);
            cluster.Add(badge);
            return true;
        }
Exemplo n.º 4
0
        public void UnclusterBadge(Clusterable badge, int usrId)
        {
            if (!badge.IsInCluster())
            {
                Log.Warn("badge " + badge.GetId() + " is already unclustered");
                return;
            }

            //1 remove from cluster            
            var affectedCluster = badge.GetCluster();
            affectedCluster.Remove(badge);
            badge.Uncluster();
            if (onUnclusterBadge != null)
                onUnclusterBadge(badge, affectedCluster, usrId);

            //2 if cluster is empty, delete cluster
            if (affectedCluster.IsEmpty())
            {
                DeleteCluster(affectedCluster, usrId);
            }
        }