6363import java .util .List ;
6464import java .util .Map ;
6565import java .util .Queue ;
66- import java .util .Random ;
6766import java .util .concurrent .ConcurrentHashMap ;
6867import java .util .concurrent .ConcurrentLinkedQueue ;
6968import java .util .concurrent .CyclicBarrier ;
@@ -174,8 +173,7 @@ public Void answer(InvocationOnMock invocation) throws Throwable {
174173 return subchannel ;
175174 }
176175 });
177- wrr = new WeightedRoundRobinLoadBalancer (helper , fakeClock .getDeadlineTicker (),
178- new FakeRandom ());
176+ wrr = new WeightedRoundRobinLoadBalancer (helper , fakeClock .getDeadlineTicker ());
179177 }
180178
181179 @ Test
@@ -968,7 +966,6 @@ public void testLargestPickedEveryGeneration() {
968966 public void testStaticStrideSchedulerGivenExample1 () {
969967 float [] weights = {10.0f , 20.0f , 30.0f };
970968 StaticStrideScheduler sss = new StaticStrideScheduler (weights );
971- Random random = new Random ();
972969 double totalWeight = 60 ;
973970 Map <Integer , Integer > pickCount = new HashMap <>();
974971 for (int i = 0 ; i < 1000 ; i ++) {
@@ -985,7 +982,6 @@ public void testStaticStrideSchedulerGivenExample1() {
985982 public void testStaticStrideSchedulerGivenExample2 () {
986983 float [] weights = {2.0f , 3.0f , 6.0f };
987984 StaticStrideScheduler sss = new StaticStrideScheduler (weights );
988- Random random = new Random ();
989985 double totalWeight = 11 ;
990986 Map <Integer , Integer > pickCount = new HashMap <>();
991987 for (int i = 0 ; i < 1000 ; i ++) {
@@ -1002,7 +998,6 @@ public void testStaticStrideSchedulerGivenExample2() {
1002998 public void testStaticStrideSchedulerNonIntegers1 () {
1003999 float [] weights = {2.0f , (float ) (10.0 / 3.0 ), 1.0f };
10041000 StaticStrideScheduler sss = new StaticStrideScheduler (weights );
1005- Random random = new Random ();
10061001 double totalWeight = 2 + 10.0 / 3.0 + 1.0 ;
10071002 Map <Integer , Integer > pickCount = new HashMap <>();
10081003 for (int i = 0 ; i < 1000 ; i ++) {
@@ -1019,7 +1014,6 @@ public void testStaticStrideSchedulerNonIntegers1() {
10191014 public void testStaticStrideSchedulerNonIntegers2 () {
10201015 float [] weights = {0.5f , 0.3f , 1.0f };
10211016 StaticStrideScheduler sss = new StaticStrideScheduler (weights );
1022- Random random = new Random ();
10231017 double totalWeight = 1.8 ;
10241018 Map <Integer , Integer > pickCount = new HashMap <>();
10251019 for (int i = 0 ; i < 1000 ; i ++) {
@@ -1036,7 +1030,6 @@ public void testStaticStrideSchedulerNonIntegers2() {
10361030 public void testTwoWeights () {
10371031 float [] weights = {1.0f , 2.0f };
10381032 StaticStrideScheduler sss = new StaticStrideScheduler (weights );
1039- Random random = new Random ();
10401033 double totalWeight = 3 ;
10411034 Map <Integer , Integer > pickCount = new HashMap <>();
10421035 for (int i = 0 ; i < 1000 ; i ++) {
@@ -1053,7 +1046,6 @@ public void testTwoWeights() {
10531046 public void testManyWeights1 () {
10541047 float [] weights = {1.0f , 2.0f , 3.0f , 4.0f , 5.0f };
10551048 StaticStrideScheduler sss = new StaticStrideScheduler (weights );
1056- Random random = new Random ();
10571049 double totalWeight = 15 ;
10581050 Map <Integer , Integer > pickCount = new HashMap <>();
10591051 for (int i = 0 ; i < 1000 ; i ++) {
@@ -1070,7 +1062,6 @@ public void testManyWeights1() {
10701062 public void testManyComplexWeights2 () {
10711063 float [] weights = {1.2f , 2.4f , 222.56f , 0f , 15.0f , 226342.0f , 5123.0f , 0.0001f };
10721064 StaticStrideScheduler sss = new StaticStrideScheduler (weights );
1073- Random random = new Random ();
10741065 double totalWeight = 1.2 + 2.4 + 222.56 + 15.0 + 226342.0 + 5123.0 + 0.0001 ;
10751066 Map <Integer , Integer > pickCount = new HashMap <>();
10761067 for (int i = 0 ; i < 1000 ; i ++) {
@@ -1094,12 +1085,4 @@ private static class FakeSocketAddress extends SocketAddress {
10941085 return "FakeSocketAddress-" + name ;
10951086 }
10961087 }
1097-
1098- private static class FakeRandom extends Random {
1099- @ Override
1100- public double nextDouble () {
1101- // return constant value to disable init deadline randomization in the scheduler
1102- return 0.322023 ;
1103- }
1104- }
11051088}
0 commit comments