Search in sources :

Example 1 with EmptyPicker

use of io.grpc.xds.LeastRequestLoadBalancer.EmptyPicker in project grpc-java by grpc.

the class LeastRequestLoadBalancerTest method internalPickerComparisons.

@Test
public void internalPickerComparisons() {
    EmptyPicker emptyOk1 = new EmptyPicker(Status.OK);
    EmptyPicker emptyOk2 = new EmptyPicker(Status.OK.withDescription("different OK"));
    EmptyPicker emptyErr = new EmptyPicker(Status.UNKNOWN.withDescription("¯\\_(ツ)_//¯"));
    Iterator<Subchannel> subchannelIterator = subchannels.values().iterator();
    Subchannel sc1 = subchannelIterator.next();
    Subchannel sc2 = subchannelIterator.next();
    ReadyPicker ready1 = new ReadyPicker(Arrays.asList(sc1, sc2), 2, mockRandom);
    ReadyPicker ready2 = new ReadyPicker(Arrays.asList(sc1), 2, mockRandom);
    ReadyPicker ready3 = new ReadyPicker(Arrays.asList(sc2, sc1), 2, mockRandom);
    ReadyPicker ready4 = new ReadyPicker(Arrays.asList(sc1, sc2), 2, mockRandom);
    ReadyPicker ready5 = new ReadyPicker(Arrays.asList(sc2, sc1), 2, mockRandom);
    ReadyPicker ready6 = new ReadyPicker(Arrays.asList(sc2, sc1), 8, mockRandom);
    assertTrue(emptyOk1.isEquivalentTo(emptyOk2));
    assertFalse(emptyOk1.isEquivalentTo(emptyErr));
    assertFalse(ready1.isEquivalentTo(ready2));
    assertTrue(ready1.isEquivalentTo(ready3));
    assertTrue(ready3.isEquivalentTo(ready4));
    assertTrue(ready4.isEquivalentTo(ready5));
    assertFalse(emptyOk1.isEquivalentTo(ready1));
    assertFalse(ready1.isEquivalentTo(emptyOk1));
    assertFalse(ready5.isEquivalentTo(ready6));
}
Also used : EmptyPicker(io.grpc.xds.LeastRequestLoadBalancer.EmptyPicker) Subchannel(io.grpc.LoadBalancer.Subchannel) ReadyPicker(io.grpc.xds.LeastRequestLoadBalancer.ReadyPicker) Test(org.junit.Test)

Example 2 with EmptyPicker

use of io.grpc.xds.LeastRequestLoadBalancer.EmptyPicker in project grpc-java by grpc.

the class LeastRequestLoadBalancerTest method pickerEmptyList.

@Test
public void pickerEmptyList() throws Exception {
    SubchannelPicker picker = new EmptyPicker(Status.UNKNOWN);
    assertEquals(null, picker.pickSubchannel(mockArgs).getSubchannel());
    assertEquals(Status.UNKNOWN, picker.pickSubchannel(mockArgs).getStatus());
}
Also used : SubchannelPicker(io.grpc.LoadBalancer.SubchannelPicker) EmptyPicker(io.grpc.xds.LeastRequestLoadBalancer.EmptyPicker) Test(org.junit.Test)

Aggregations

EmptyPicker (io.grpc.xds.LeastRequestLoadBalancer.EmptyPicker)2 Test (org.junit.Test)2 Subchannel (io.grpc.LoadBalancer.Subchannel)1 SubchannelPicker (io.grpc.LoadBalancer.SubchannelPicker)1 ReadyPicker (io.grpc.xds.LeastRequestLoadBalancer.ReadyPicker)1