use of com.twitter.heron.common.basics.Pair in project heron by twitter.
the class CommonPackingTests method testScaleDownHomogenousFirst.
@Test
public void testScaleDownHomogenousFirst() throws Exception {
@SuppressWarnings({ "unchecked", "rawtypes" }) Pair<Integer, InstanceId>[] initialComponentInstances = new Pair[] { new Pair<>(1, new InstanceId(A, 1, 0)), new Pair<>(1, new InstanceId(A, 2, 1)), new Pair<>(1, new InstanceId(B, 3, 0)), new Pair<>(3, new InstanceId(B, 4, 1)), new Pair<>(3, new InstanceId(B, 5, 2)), new Pair<>(3, new InstanceId(B, 6, 3)), new Pair<>(3, new InstanceId(B, 7, 4)) };
Map<String, Integer> componentChanges = new HashMap<>();
componentChanges.put(B, -4);
@SuppressWarnings({ "unchecked", "rawtypes" }) Pair<Integer, InstanceId>[] expectedComponentInstances = new Pair[] { new Pair<>(1, new InstanceId(A, 1, 0)), new Pair<>(1, new InstanceId(A, 2, 1)), new Pair<>(1, new InstanceId(B, 3, 0)) };
doScaleDownTest(initialComponentInstances, componentChanges, expectedComponentInstances);
}
use of com.twitter.heron.common.basics.Pair in project heron by twitter.
the class PackingPlanBuilderTest method testInvalidContainerRemoveFromPackingPlan.
@Test(expected = PackingException.class)
public void testInvalidContainerRemoveFromPackingPlan() throws ResourceExceededException {
PackingPlan plan = doCreatePackingPlanTest(testContainerInstances);
@SuppressWarnings({ "unchecked", "rawtypes" }) Pair<Integer, String>[] removed = new Pair[] { new Pair<>(7, "componentA") };
PackingTestHelper.removeFromTestPackingPlan(TOPOLOGY_ID, plan, removed, 0);
}
use of com.twitter.heron.common.basics.Pair in project heron by twitter.
the class ZkUtilsTest method testSetupZkTunnel.
/**
* Test setupZkTunnel
*/
@Test
public void testSetupZkTunnel() throws Exception {
String host0 = "host0";
int port0 = 12;
InetSocketAddress address0 = NetworkUtils.getInetSocketAddress(String.format("%s:%d", host0, port0));
String host1 = "host1";
int port1 = 13;
InetSocketAddress address1 = NetworkUtils.getInetSocketAddress(String.format("%s:%d", host1, port1));
String host2 = "host2";
int port2 = 9049;
InetSocketAddress address2 = NetworkUtils.getInetSocketAddress(String.format("%s:%d", host2, port2));
String tunnelHost = "tunnelHost";
int tunnelPort = 9519;
InetSocketAddress tunnelAddress = NetworkUtils.getInetSocketAddress(String.format("%s:%d", tunnelHost, tunnelPort));
// Original connection String
String connectionString = String.format("%s:%d, %s:%d, %s:%d ", host0, port0, host1, port1, host2, port2);
Config config = mock(Config.class);
when(config.getStringValue(Key.STATEMGR_CONNECTION_STRING)).thenReturn(connectionString);
NetworkUtils.TunnelConfig tunnelConfig = NetworkUtils.TunnelConfig.build(config, NetworkUtils.HeronSystem.STATE_MANAGER);
Process process = mock(Process.class);
// Mock the invocation of establishSSHTunnelIfNeeded
// address0 and address1 are directly reachable
// address2 are reachable after tunneling
PowerMockito.spy(NetworkUtils.class);
PowerMockito.doReturn(new Pair<>(address0, process)).when(NetworkUtils.class, "establishSSHTunnelIfNeeded", eq(address0), anyString(), any(NetworkUtils.TunnelType.class), anyInt(), anyInt(), anyInt(), anyInt());
PowerMockito.doReturn(new Pair<>(address1, process)).when(NetworkUtils.class, "establishSSHTunnelIfNeeded", eq(address1), anyString(), any(NetworkUtils.TunnelType.class), anyInt(), anyInt(), anyInt(), anyInt());
PowerMockito.doReturn(new Pair<>(tunnelAddress, process)).when(NetworkUtils.class, "establishSSHTunnelIfNeeded", eq(address2), anyString(), any(NetworkUtils.TunnelType.class), anyInt(), anyInt(), anyInt(), anyInt());
Pair<String, List<Process>> ret = ZkUtils.setupZkTunnel(config, tunnelConfig);
// Assert with expected results
String expectedConnectionString = String.format("%s,%s,%s", address0.toString(), address1.toString(), tunnelAddress.toString());
assertEquals(expectedConnectionString, ret.first);
assertEquals(3, ret.second.size());
for (Process p : ret.second) {
assertEquals(process, p);
}
}
use of com.twitter.heron.common.basics.Pair in project incubator-heron by apache.
the class PackingPlanBuilderTest method testExceededCapacityAddingToPackingPlan.
@Test(expected = ResourceExceededException.class)
public void testExceededCapacityAddingToPackingPlan() throws ResourceExceededException {
PackingPlan plan = doCreatePackingPlanTest(testContainerInstances);
@SuppressWarnings({ "unchecked", "rawtypes" }) Pair<Integer, InstanceId>[] added = new Pair[] { new Pair<>(3, new InstanceId("componentB", 4, 1)) };
PackingTestHelper.addToTestPackingPlan(TOPOLOGY_ID, plan, PackingTestHelper.toContainerIdComponentNames(added), 0);
}
use of com.twitter.heron.common.basics.Pair in project incubator-heron by apache.
the class PackingPlanBuilderTest method testInvalidContainerRemoveFromPackingPlan.
@Test(expected = PackingException.class)
public void testInvalidContainerRemoveFromPackingPlan() throws ResourceExceededException {
PackingPlan plan = doCreatePackingPlanTest(testContainerInstances);
@SuppressWarnings({ "unchecked", "rawtypes" }) Pair<Integer, String>[] removed = new Pair[] { new Pair<>(7, "componentA") };
PackingTestHelper.removeFromTestPackingPlan(TOPOLOGY_ID, plan, removed, 0);
}
Aggregations