Search in sources :

Example 1 with EmptyPicker

use of io.grpc.util.RoundRobinLoadBalancer.EmptyPicker in project grpc-java by grpc.

the class RoundRobinLoadBalancerTest 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.util.RoundRobinLoadBalancer.EmptyPicker) Test(org.junit.Test)

Example 2 with EmptyPicker

use of io.grpc.util.RoundRobinLoadBalancer.EmptyPicker in project grpc-java by grpc.

the class RoundRobinLoadBalancerTest 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), 0);
    ReadyPicker ready2 = new ReadyPicker(Arrays.asList(sc1), 0);
    ReadyPicker ready3 = new ReadyPicker(Arrays.asList(sc2, sc1), 1);
    ReadyPicker ready4 = new ReadyPicker(Arrays.asList(sc1, sc2), 1);
    ReadyPicker ready5 = new ReadyPicker(Arrays.asList(sc2, sc1), 0);
    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));
}
Also used : EmptyPicker(io.grpc.util.RoundRobinLoadBalancer.EmptyPicker) Subchannel(io.grpc.LoadBalancer.Subchannel) ReadyPicker(io.grpc.util.RoundRobinLoadBalancer.ReadyPicker) Test(org.junit.Test)

Aggregations

EmptyPicker (io.grpc.util.RoundRobinLoadBalancer.EmptyPicker)2 Test (org.junit.Test)2 Subchannel (io.grpc.LoadBalancer.Subchannel)1 SubchannelPicker (io.grpc.LoadBalancer.SubchannelPicker)1 ReadyPicker (io.grpc.util.RoundRobinLoadBalancer.ReadyPicker)1