@Override public Host getHostForSegment(String scope, String stream, long segmentId) { return new Host("localhost", 1000, ""); } }
public static Map<Host, Set<Integer>> getHostContainerMap(String host, int port, int containerCount) { Exceptions.checkNotNullOrEmpty(host, "host"); Preconditions.checkArgument(port > 0, "port"); Preconditions.checkArgument(containerCount > 0, "containerCount"); Map<Host, Set<Integer>> hostContainerMap = new HashMap<>(); hostContainerMap.put(new Host(host, port, null), IntStream.range(0, containerCount).boxed().collect(Collectors.toSet())); return hostContainerMap; } }
private void attachZKSegmentManager(ServiceBuilder builder) { builder.withContainerManager(setup -> new ZKSegmentContainerManager(setup.getContainerRegistry(), this.zkClient, new Host(this.serviceConfig.getPublishedIPAddress(), this.serviceConfig.getPublishedPort(), null), setup.getCoreExecutor())); }
hosts.add(new Host("host1", 123, null)); rebalance = balancer.rebalance(new HashMap<>(), hosts); assertEquals(1, rebalance.size()); hosts.add(new Host("host2", 123, null)); rebalance = balancer.rebalance(rebalance, hosts); assertEquals(2, rebalance.size()); hosts.add(new Host("host3", 123, null)); hosts.add(new Host("host4", 123, null)); rebalance = balancer.rebalance(rebalance, hosts); assertEquals(4, rebalance.size()); hosts.remove(new Host("host2", 123, null)); rebalance = balancer.rebalance(rebalance, hosts); assertEquals(3, rebalance.size()); hosts.add(new Host("host2", 123, null)); hosts.add(new Host("host5", 123, null)); hosts.add(new Host("host6", 123, null)); hosts.add(new Host("host7", 123, null)); hosts.add(new Host("host8", 123, null)); hosts.add(new Host("host9", 123, null)); hosts.remove(new Host("host1", 123, null)); hosts.remove(new Host("host3", 123, null)); hosts.remove(new Host("host4", 123, null)); rebalance = balancer.rebalance(rebalance, hosts); assertEquals(6, rebalance.size());
clusterZKInstance1.registerHost(new Host(HOST_1, PORT, null)); assertEquals(HOST_1, nodeAddedQueue.poll(5, TimeUnit.SECONDS)); clusterZKInstance1.registerHost(new Host(HOST_2, PORT, null)); assertEquals(HOST_2, nodeAddedQueue.poll(5, TimeUnit.SECONDS)); assertEquals(2, clusterListener.getClusterMembers().size());
cluster.registerHost(new Host("localhost1", 1, null)); assertTrue(sync.tryAcquire(10, TimeUnit.SECONDS)); assertEquals(1, hostStore.getHostContainersMap().size()); cluster.registerHost(new Host("localhost2", 2, null)); cluster.registerHost(new Host("localhost3", 3, null)); cluster.registerHost(new Host("localhost4", 4, null)); cluster.deregisterHost(new Host("localhost1", 1, null)); assertTrue(sync.tryAcquire(10, TimeUnit.SECONDS)); assertEquals(3, hostStore.getHostContainersMap().size()); cluster.registerHost(new Host("localhost1", 1, null));
Host host = new Host(hostName, getPort(), UUID.randomUUID().toString());
public void clusterListenerStarterTest() throws InterruptedException, ExecutionException { String hostName = "localhost"; Host host = new Host(hostName, 10, "originalhost"); Host newHost = new Host(hostName, 20, "newHost1"); clusterZK.registerHost(newHost); validateAddedNode(newHost.getHostId()); newHost = new Host(hostName, 20, "newHost2"); clusterZK.registerHost(newHost); validateAddedNode(newHost.getHostId());
when(mockCluster.getClusterMembers()).thenReturn(Collections.singleton(new Host("localhost", 9090, null))); controllerService = new ControllerServiceImpl( new ControllerService(streamStore, hostStore, streamMetadataTasks, streamTransactionMetadataTasks,
final CountDownLatch latch = new CountDownLatch(1); cluster.addListener((type, host) -> latch.countDown()); cluster.registerHost(new Host("localhost", 9090, null)); latch.await();