@Test(expected = IllegalArgumentException.class) public void invalidOffset() { Master master = EasyMock.createMock(Master.class); ServerContext context = EasyMock.createMock(ServerContext.class); EasyMock.expect(context.getConfiguration()).andReturn(config).anyTimes(); ZooReader reader = EasyMock.createMock(ZooReader.class); EasyMock.expect(master.getContext()).andReturn(context); EasyMock.expect(master.getInstanceID()).andReturn("1234"); EasyMock.replay(master, reader); MasterReplicationCoordinator coordinator = new MasterReplicationCoordinator(master, reader); TServerInstance inst1 = new TServerInstance(HostAndPort.fromParts("host1", 1234), "session"); assertEquals(inst1, coordinator.getRandomTServer(Collections.singleton(inst1), 1)); }
protected TServerInstance getRandomTServer(Set<TServerInstance> tservers, int offset) { checkArgument(tservers.size() > offset, "Must provide an offset less than the size of the set"); Iterator<TServerInstance> iter = tservers.iterator(); while (offset > 0) { iter.next(); offset--; } return iter.next(); }
MasterReplicationCoordinator implements ReplicationCoordinator.Iface { protected TServerInstance getRandomTServer(Set<TServerInstance> tservers, int offset) { checkArgument(tservers.size() > offset, "Must provide an offset less than the size of the set"); Iterator<TServerInstance> iter = tservers.iterator(); while (offset > 0) { iter.next(); offset--; } return iter.next(); } }
MasterReplicationCoordinator implements ReplicationCoordinator.Iface { protected TServerInstance getRandomTServer(Set<TServerInstance> tservers, int offset) { checkArgument(tservers.size() > offset, "Must provide an offset less than the size of the set"); Iterator<TServerInstance> iter = tservers.iterator(); while (offset > 0) { iter.next(); offset--; } return iter.next(); } MasterReplicationCoordinator(Master master); protected  MasterReplicationCoordinator(Master master, ZooReader reader); }
MasterReplicationCoordinator implements ReplicationCoordinator.Iface { protected TServerInstance getRandomTServer(Set<TServerInstance> tservers, int offset) { checkArgument(tservers.size() > offset, "Must provide an offset less than the size of the set"); Iterator<TServerInstance> iter = tservers.iterator(); while (offset > 0) { iter.next(); offset--; } return iter.next(); } MasterReplicationCoordinator(Master master); protected  MasterReplicationCoordinator(Master master, ZooReader reader); @Override String getServicerAddress(String remoteTableId, TCredentials creds); }
MasterReplicationCoordinator implements ReplicationCoordinator.Iface { protected TServerInstance getRandomTServer(Set<TServerInstance> tservers, int offset) { checkArgument(tservers.size() > offset, "Must provide an offset less than the size of the set"); Iterator<TServerInstance> iter = tservers.iterator(); while (offset > 0) { iter.next(); offset--; } return iter.next(); } MasterReplicationCoordinator(Master master); protected  MasterReplicationCoordinator(Master master, ZooReader reader); @Override String getServicerAddress(String remoteTableId, TCredentials creds);  }