Jagger
 All Classes Namespaces Files Functions Variables Enumerator Groups Pages
void com.griddynamics.jagger.invoker.ExclusiveAccessLoadBalancer< Q, E >.init ( )

Definition at line 76 of file ExclusiveAccessLoadBalancer.java.

76  {
77  synchronized (lock) {
78  if (initialized) {
79  log.debug("already initialized. returning...");
80  return;
81  }
82 
83  super.init();
84 
85  PairSupplier<Q, E> pairSupplier = getPairSupplier();
86  List<Pair<Q, E>> pairList = new ArrayList<>(pairSupplier.size());
87 
88  int index = 0;
89  int step = 1;
90  if (kernelInfo != null) { // then from all the provided pairs pick only those under this node's index.
91  index = kernelInfo.getKernelId();
92  step = kernelInfo.getKernelsNumber();
93  }
94  for (; index < pairSupplier.size(); index += step) {
95  pairList.add(pairSupplier.get(index));
96  }
97 
98  if (Objects.nonNull(randomnessSeed)) {
99  log.info("'randomnessSeed' value is not null. Going to shuffle the pairs");
100  Collections.shuffle(pairList, new Random(randomnessSeed));
101  }
102 
103  log.info("{} pairs on this node to balance", pairList.size());
104  log.debug("Pairs to load balance: {}", pairList);
105 
106  pairQueue = new ArrayBlockingQueue<>(pairSupplier.size(), true, pairList);
107  }
108  }