Example #1
0
 /// <summary>
 /// Функция реализует работу централизованной балансировки
 /// </summary>
 void CentralizedHandler()
 {
     NotBalancedHandler();
     int[] dev = deviation_average_weight(compute_mean_weigth());
     for (int i = 0; i < RegionsCount; i++)
     {
         RBN rbn_i = (RBN)Regions[i];
         for (int j = 0; (j < RegionsCount); j++)
         {
             if (i != j)
             {
                 RBN rbn_j = (RBN)Regions[j];
                 if (dev[i] > dev[j] && !rbn_j.QueueIsFull() &&
                     !rbn_i.QueueIsEmpty())
                 {
                     rbn_j.SetNewQuery(rbn_i.GetLastQueryFromQueue());
                 }
                 if (dev[i] < dev[j] && !rbn_i.QueueIsFull() &&
                     !rbn_j.QueueIsEmpty())
                 {
                     rbn_i.SetNewQuery(rbn_j.GetLastQueryFromQueue());
                 }
             }
         }
         SendAns(rbn_i);
     }
 }
Example #2
0
 /// <summary>
 /// Функция реализует работу второго варианта централизованной балансировки
 /// </summary>
 void CentralizedHandlerType2()
 {
     NotBalancedHandler();
     for (int i = 0; i < RegionsCount; i++)
     {
         RBN rbn = (RBN)Regions[i];
         if (rbn.IsSleep())
         {
             RBN another_rbn = MaxWeightRegion(i);
             if (another_rbn != null)
             {
                 if (!rbn.QueueIsFull() && another_rbn.CanGetQuery())
                 {
                     rbn.SetNewQuery(another_rbn.GetQueryFromQueue());
                 }
             }
         }
         SendAns(rbn);
     }
 }