Search in sources :

Example 1 with AMRegistrationException

use of org.apache.drill.yarn.appMaster.AMRegistrar.AMRegistrationException in project drill by apache.

the class TestAmRegistration method testAMRegistry.

@Test
public void testAMRegistry() throws Exception {
    try (TestingServer server = new TestingServer()) {
        server.start();
        String connStr = server.getConnectString();
        ZKClusterCoordinatorDriver driver = new ZKClusterCoordinatorDriver().setConnect(connStr, TEST_ZK_ROOT, TEST_CLUSTER_ID).build();
        // Register an AM using the above.
        driver.register(TEST_AM_HOST, TEST_AM_PORT, TEST_APP_ID);
        // Simulate a second AM for the same cluster.
        {
            ZKClusterCoordinatorDriver driver2 = new ZKClusterCoordinatorDriver().setConnect(connStr, TEST_ZK_ROOT, TEST_CLUSTER_ID).build();
            try {
                driver.register(PROBE_AM_HOST, PROBE_AM_PORT, PROBE_APP_ID);
                fail();
            } catch (AMRegistrationException e) {
                String msg = e.getMessage();
                assertTrue(msg.contains("Application Master already exists"));
                assertTrue(msg.contains(" " + TEST_ZK_ROOT + "/" + TEST_CLUSTER_ID + " "));
                assertTrue(msg.contains(" host: " + TEST_AM_HOST));
                assertTrue(msg.contains(" Application ID: " + TEST_APP_ID));
            }
            driver2.close();
        }
        {
            ZKClusterCoordinatorDriver driver2 = new ZKClusterCoordinatorDriver().setConnect(connStr, TEST_ZK_ROOT, PROBE_CLUSTER_ID).build();
            try {
                driver2.register(PROBE_AM_HOST, PROBE_AM_PORT, PROBE_APP_ID);
            } catch (AMRegistrationException e) {
                fail("Registration should be OK");
            }
            driver2.close();
        }
        {
            ZKClusterCoordinatorDriver driver2 = new ZKClusterCoordinatorDriver().setConnect(connStr, PROBE_ZK_ROOT, TEST_CLUSTER_ID).build();
            try {
                driver2.register(PROBE_AM_HOST, PROBE_AM_PORT, PROBE_APP_ID);
            } catch (AMRegistrationException e) {
                fail("Registration should be OK");
            }
            driver2.close();
        }
        // First AM exits.
        driver.close();
        {
            // Should be able to register an AM for the same cluster.
            ZKClusterCoordinatorDriver driver2 = new ZKClusterCoordinatorDriver().setConnect(connStr, TEST_ZK_ROOT, TEST_CLUSTER_ID).build();
            try {
                driver2.register(PROBE_AM_HOST, PROBE_AM_PORT, PROBE_APP_ID);
            } catch (AMRegistrationException e) {
                fail("Registration should be OK");
            }
            driver2.close();
        }
        server.stop();
    }
}
Also used : TestingServer(org.apache.curator.test.TestingServer) AMRegistrationException(org.apache.drill.yarn.appMaster.AMRegistrar.AMRegistrationException) BaseTest(org.apache.drill.test.BaseTest) Test(org.junit.Test)

Example 2 with AMRegistrationException

use of org.apache.drill.yarn.appMaster.AMRegistrar.AMRegistrationException in project drill by axbaretto.

the class TestAmRegistration method testAMRegistry.

@Test
public void testAMRegistry() throws Exception {
    try (TestingServer server = new TestingServer()) {
        server.start();
        String connStr = server.getConnectString();
        ZKClusterCoordinatorDriver driver = new ZKClusterCoordinatorDriver().setConnect(connStr, TEST_ZK_ROOT, TEST_CLUSTER_ID).build();
        // Register an AM using the above.
        driver.register(TEST_AM_HOST, TEST_AM_PORT, TEST_APP_ID);
        // Simulate a second AM for the same cluster.
        {
            ZKClusterCoordinatorDriver driver2 = new ZKClusterCoordinatorDriver().setConnect(connStr, TEST_ZK_ROOT, TEST_CLUSTER_ID).build();
            try {
                driver.register(PROBE_AM_HOST, PROBE_AM_PORT, PROBE_APP_ID);
                fail();
            } catch (AMRegistrationException e) {
                String msg = e.getMessage();
                assertTrue(msg.contains("Application Master already exists"));
                assertTrue(msg.contains(" " + TEST_ZK_ROOT + "/" + TEST_CLUSTER_ID + " "));
                assertTrue(msg.contains(" host: " + TEST_AM_HOST));
                assertTrue(msg.contains(" Application ID: " + TEST_APP_ID));
            }
            driver2.close();
        }
        {
            ZKClusterCoordinatorDriver driver2 = new ZKClusterCoordinatorDriver().setConnect(connStr, TEST_ZK_ROOT, PROBE_CLUSTER_ID).build();
            try {
                driver2.register(PROBE_AM_HOST, PROBE_AM_PORT, PROBE_APP_ID);
            } catch (AMRegistrationException e) {
                fail("Registration should be OK");
            }
            driver2.close();
        }
        {
            ZKClusterCoordinatorDriver driver2 = new ZKClusterCoordinatorDriver().setConnect(connStr, PROBE_ZK_ROOT, TEST_CLUSTER_ID).build();
            try {
                driver2.register(PROBE_AM_HOST, PROBE_AM_PORT, PROBE_APP_ID);
            } catch (AMRegistrationException e) {
                fail("Registration should be OK");
            }
            driver2.close();
        }
        // First AM exits.
        driver.close();
        {
            // Should be able to register an AM for the same cluster.
            ZKClusterCoordinatorDriver driver2 = new ZKClusterCoordinatorDriver().setConnect(connStr, TEST_ZK_ROOT, TEST_CLUSTER_ID).build();
            try {
                driver2.register(PROBE_AM_HOST, PROBE_AM_PORT, PROBE_APP_ID);
            } catch (AMRegistrationException e) {
                fail("Registration should be OK");
            }
            driver2.close();
        }
        server.stop();
    }
}
Also used : TestingServer(org.apache.curator.test.TestingServer) AMRegistrationException(org.apache.drill.yarn.appMaster.AMRegistrar.AMRegistrationException) Test(org.junit.Test)

Aggregations

TestingServer (org.apache.curator.test.TestingServer)2 AMRegistrationException (org.apache.drill.yarn.appMaster.AMRegistrar.AMRegistrationException)2 Test (org.junit.Test)2 BaseTest (org.apache.drill.test.BaseTest)1