Search in sources :

Example 1 with HetuConfig

use of io.prestosql.utils.HetuConfig in project hetu-core by openlookeng.

the class TestStateStoreLauncherAndProvider method testRegisterDiscoveryService.

@Test(timeOut = 5000, expectedExceptions = ThreadTimeoutException.class)
public void testRegisterDiscoveryService() throws Exception {
    String failurehost = "failurehost";
    String otherhost = "otherhost";
    String localHostName = "localhost";
    int port = 8888;
    URI uri = new URI("http://" + localHostName + ":" + port);
    MockStateMap discoveryServiceMap = new MockStateMap(DISCOVERY_SERVICE, new HashMap<>());
    // Mock
    StateStore stateStore = mock(StateStore.class);
    Lock lock = mock(ReentrantLock.class);
    InternalCommunicationConfig internalCommunicationConfig = mock(InternalCommunicationConfig.class);
    HttpServerInfo httpServerInfo = mock(HttpServerInfo.class);
    when(httpServerInfo.getHttpUri()).thenReturn(uri);
    when(internalCommunicationConfig.isHttpsRequired()).thenReturn(false);
    when(stateStore.getStateCollection(DISCOVERY_SERVICE)).thenReturn(discoveryServiceMap);
    when(stateStore.getLock(DISCOVERY_SERVICE_LOCK)).thenReturn(lock);
    EmbeddedStateStoreLauncher launcher = new EmbeddedStateStoreLauncher(new SeedStoreManager(new FileSystemClientManager()), internalCommunicationConfig, httpServerInfo, new HetuConfig());
    launcher.setStateStore(stateStore);
    when(lock.tryLock(DISCOVERY_REGISTRY_LOCK_TIMEOUT, TimeUnit.MILLISECONDS)).thenReturn(true);
    // discoveryServiceMap is empty, so the current coordinator can get the lock and register itself(register=true)
    discoveryServiceMap.clear();
    assertTrue(launcher.registerDiscoveryService(failurehost));
    assertEquals(discoveryServiceMap.size(), 1);
    assertTrue(discoveryServiceMap.getAll().keySet().contains(localHostName));
    // discoveryServiceMap contains the failure host, so the current coordinator can get the lock and register itself(register=true)
    discoveryServiceMap.clear();
    discoveryServiceMap.put(failurehost, String.valueOf(port));
    assertTrue(launcher.registerDiscoveryService(failurehost));
    assertEquals(discoveryServiceMap.size(), 1);
    assertTrue(discoveryServiceMap.getAll().keySet().contains(localHostName));
    // discoveryServiceMap is already updated by other coordinator(otherhosts)
    // the current coordinator can grab the lock but will not register itself(register=false)
    discoveryServiceMap.clear();
    discoveryServiceMap.put(otherhost, String.valueOf(port));
    assertFalse(launcher.registerDiscoveryService(failurehost));
    assertEquals(discoveryServiceMap.size(), 1);
    assertFalse(discoveryServiceMap.containsKey(localHostName));
    when(lock.tryLock(DISCOVERY_REGISTRY_LOCK_TIMEOUT, TimeUnit.MILLISECONDS)).thenReturn(false);
    // discoveryServiceMap is already updated by other coordinator(otherhosts)
    // the current coordinator cannot grab the lock and not register itself
    discoveryServiceMap.clear();
    discoveryServiceMap.put(otherhost, String.valueOf(port));
    assertFalse(launcher.registerDiscoveryService(failurehost));
    assertEquals(discoveryServiceMap.size(), 1);
    assertFalse(discoveryServiceMap.containsKey(localHostName));
    // discoveryServiceMap contains failure host.
    // The current coordinator cannot get the lock and retry will cause timeout exception
    discoveryServiceMap.clear();
    discoveryServiceMap.put(failurehost, String.valueOf(port));
    launcher.registerDiscoveryService(failurehost);
}
Also used : StateStore(io.prestosql.spi.statestore.StateStore) HazelcastStateStore(io.hetu.core.statestore.hazelcast.HazelcastStateStore) URI(java.net.URI) HetuConfig(io.prestosql.utils.HetuConfig) ReentrantLock(java.util.concurrent.locks.ReentrantLock) Lock(java.util.concurrent.locks.Lock) FileSystemClientManager(io.prestosql.filesystem.FileSystemClientManager) InternalCommunicationConfig(io.prestosql.server.InternalCommunicationConfig) SeedStoreManager(io.prestosql.seedstore.SeedStoreManager) HttpServerInfo(io.airlift.http.server.HttpServerInfo) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest) AfterTest(org.testng.annotations.AfterTest)

Example 2 with HetuConfig

use of io.prestosql.utils.HetuConfig in project hetu-core by openlookeng.

the class TestHetuServiceInventory method testGetDiscoveryUriSupplierHttp.

@Test
public void testGetDiscoveryUriSupplierHttp() {
    InternalCommunicationConfig internalCommunicationConfig = new InternalCommunicationConfig().setHttpsRequired(false);
    HetuConfig hetuConfig = new HetuConfig();
    hetuConfig.setMultipleCoordinatorEnabled(true);
    HetuServiceInventory inventory = new HetuServiceInventory(hetuConfig, null, createMockStateStoreProvider(), internalCommunicationConfig, new ServiceInventoryConfig(), new NodeInfo(new NodeConfig().setEnvironment("hetutest")), JsonCodec.jsonCodec(ServiceDescriptorsRepresentation.class), new TestingHttpClient(new MockExchangeRequestProcessor(new DataSize(0, BYTE))));
    Iterable<ServiceDescriptor> serviceDescriptors = inventory.getServiceDescriptors("discovery");
    List<URI> uris = new ArrayList<>();
    serviceDescriptors.forEach(serviceDescriptor -> {
        uris.add(URI.create(serviceDescriptor.getProperties().get("http")));
    });
    URI checkUri = URI.create("http://127.0.0.1:8090");
    assertEquals(uris.size(), 1);
    uris.contains(checkUri);
}
Also used : ServiceInventoryConfig(io.airlift.discovery.client.ServiceInventoryConfig) ArrayList(java.util.ArrayList) HetuConfig(io.prestosql.utils.HetuConfig) URI(java.net.URI) InternalCommunicationConfig(io.prestosql.server.InternalCommunicationConfig) ServiceDescriptorsRepresentation(io.airlift.discovery.client.ServiceDescriptorsRepresentation) MockExchangeRequestProcessor(io.prestosql.operator.MockExchangeRequestProcessor) ServiceDescriptor(io.airlift.discovery.client.ServiceDescriptor) NodeInfo(io.airlift.node.NodeInfo) TestingHttpClient(io.airlift.http.client.testing.TestingHttpClient) DataSize(io.airlift.units.DataSize) NodeConfig(io.airlift.node.NodeConfig) Test(org.testng.annotations.Test)

Example 3 with HetuConfig

use of io.prestosql.utils.HetuConfig in project hetu-core by openlookeng.

the class TestAnalyzer method testTooManyGroupingElements.

@Test
public void testTooManyGroupingElements() {
    Session session = testSessionBuilder(new SessionPropertyManager(new SystemSessionProperties(new QueryManagerConfig(), new TaskManagerConfig(), new MemoryManagerConfig(), new FeaturesConfig().setMaxGroupingSets(2048), new HetuConfig(), new SnapshotConfig()))).build();
    analyze(session, "SELECT a, b, c, d, e, f, g, h, i, j, k, SUM(l)" + "FROM (VALUES (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12))\n" + "t (a, b, c, d, e, f, g, h, i, j, k, l)\n" + "GROUP BY CUBE (a, b, c, d, e, f), CUBE (g, h, i, j, k)");
    assertFails(session, TOO_MANY_GROUPING_SETS, "line 3:10: GROUP BY has 4096 grouping sets but can contain at most 2048", "SELECT a, b, c, d, e, f, g, h, i, j, k, l, SUM(m)" + "FROM (VALUES (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13))\n" + "t (a, b, c, d, e, f, g, h, i, j, k, l, m)\n" + "GROUP BY CUBE (a, b, c, d, e, f), CUBE (g, h, i, j, k, l)");
    assertFails(session, TOO_MANY_GROUPING_SETS, format("line 3:10: GROUP BY has more than %s grouping sets but can contain at most 2048", Integer.MAX_VALUE), "SELECT a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, " + "q, r, s, t, u, v, x, w, y, z, aa, ab, ac, ad, ae, SUM(af)" + "FROM (VALUES (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, " + "17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32))\n" + "t (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, " + "q, r, s, t, u, v, x, w, y, z, aa, ab, ac, ad, ae, af)\n" + "GROUP BY CUBE (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, " + "q, r, s, t, u, v, x, w, y, z, aa, ab, ac, ad, ae)");
}
Also used : SnapshotConfig(io.prestosql.snapshot.SnapshotConfig) SessionPropertyManager(io.prestosql.metadata.SessionPropertyManager) QueryManagerConfig(io.prestosql.execution.QueryManagerConfig) TaskManagerConfig(io.prestosql.execution.TaskManagerConfig) MemoryManagerConfig(io.prestosql.memory.MemoryManagerConfig) HetuConfig(io.prestosql.utils.HetuConfig) Session(io.prestosql.Session) SystemSessionProperties(io.prestosql.SystemSessionProperties) Test(org.testng.annotations.Test)

Example 4 with HetuConfig

use of io.prestosql.utils.HetuConfig in project hetu-core by openlookeng.

the class TestHetuServiceInventory method testGetDiscoveryUriSupplierHttps.

@Test
public void testGetDiscoveryUriSupplierHttps() {
    InternalCommunicationConfig internalCommunicationConfig = new InternalCommunicationConfig().setHttpsRequired(true);
    HetuConfig hetuConfig = new HetuConfig();
    hetuConfig.setMultipleCoordinatorEnabled(true);
    HetuServiceInventory inventory = new HetuServiceInventory(hetuConfig, null, createMockStateStoreProvider(), internalCommunicationConfig, new ServiceInventoryConfig(), new NodeInfo(new NodeConfig().setEnvironment("hetutest")), JsonCodec.jsonCodec(ServiceDescriptorsRepresentation.class), new TestingHttpClient(new MockExchangeRequestProcessor(new DataSize(0, BYTE))));
    Iterable<ServiceDescriptor> serviceDescriptors = inventory.getServiceDescriptors("discovery");
    List<URI> uris = new ArrayList<>();
    serviceDescriptors.forEach(serviceDescriptor -> {
        uris.add(URI.create(serviceDescriptor.getProperties().get("https")));
    });
    URI checkUri = URI.create("https://127.0.0.1:8090");
    assertEquals(uris.size(), 1);
    uris.contains(checkUri);
}
Also used : ServiceInventoryConfig(io.airlift.discovery.client.ServiceInventoryConfig) ArrayList(java.util.ArrayList) HetuConfig(io.prestosql.utils.HetuConfig) URI(java.net.URI) InternalCommunicationConfig(io.prestosql.server.InternalCommunicationConfig) ServiceDescriptorsRepresentation(io.airlift.discovery.client.ServiceDescriptorsRepresentation) MockExchangeRequestProcessor(io.prestosql.operator.MockExchangeRequestProcessor) ServiceDescriptor(io.airlift.discovery.client.ServiceDescriptor) NodeInfo(io.airlift.node.NodeInfo) TestingHttpClient(io.airlift.http.client.testing.TestingHttpClient) DataSize(io.airlift.units.DataSize) NodeConfig(io.airlift.node.NodeConfig) Test(org.testng.annotations.Test)

Example 5 with HetuConfig

use of io.prestosql.utils.HetuConfig in project hetu-core by openlookeng.

the class TestStateStoreLauncherAndProvider method testLaunchAndFailure.

// Test Launcher
@Test
public void testLaunchAndFailure() throws Exception {
    Set<Seed> seeds = new HashSet<>();
    SeedStore mockSeedStore = mock(SeedStore.class);
    Seed mockSeed1 = mock(Seed.class);
    Seed mockSeed2 = mock(Seed.class);
    seeds.add(mockSeed1);
    seeds.add(mockSeed2);
    when(mockSeed1.getLocation()).thenReturn(LOCALHOST + ":" + PORT1);
    when(mockSeed2.getLocation()).thenReturn(LOCALHOST + ":" + PORT2);
    when(mockSeedStore.get()).thenReturn(seeds);
    SeedStoreManager mockSeedStoreManager = mock(SeedStoreManager.class);
    when(mockSeedStoreManager.getSeedStore(SeedStoreSubType.HAZELCAST)).thenReturn(mockSeedStore);
    when(mockSeedStoreManager.addSeed(SeedStoreSubType.HAZELCAST, LOCALHOST, true)).thenReturn(seeds);
    when(mockSeedStoreManager.getFileSystemClient()).thenReturn(new HetuLocalFileSystemClient(new LocalConfig(new Properties()), Paths.get("/")));
    InternalCommunicationConfig mockInternalCommunicationConfig = mock(InternalCommunicationConfig.class);
    HttpServerInfo mockHttpServerInfo = mock(HttpServerInfo.class);
    when(mockHttpServerInfo.getHttpsUri()).thenReturn(new URI("https://" + LOCALHOST + ":" + PORT1));
    when(mockInternalCommunicationConfig.isHttpsRequired()).thenReturn(true);
    EmbeddedStateStoreLauncher launcher = new EmbeddedStateStoreLauncher(mockSeedStoreManager, mockInternalCommunicationConfig, mockHttpServerInfo, new HetuConfig());
    StateStoreBootstrapper bootstrapper = new HazelcastStateStoreBootstrapper();
    launcher.addStateStoreBootstrapper(bootstrapper);
    launcher.launchStateStore();
    StateStore second = setupSecondInstance();
    // mock "remove" second instance from cluster (delete from seed store)
    seeds.remove(mockSeed2);
    when(mockSeed1.getLocation()).thenReturn(LOCALHOST + ":" + PORT1);
    when(mockSeedStoreManager.addSeed(SeedStoreSubType.HAZELCAST, LOCALHOST, true)).thenReturn(seeds);
    ((HazelcastStateStore) second).shutdown();
    // Allow the first node to handle failure
    Thread.sleep(3000L);
}
Also used : HazelcastStateStore(io.hetu.core.statestore.hazelcast.HazelcastStateStore) LocalConfig(io.hetu.core.filesystem.LocalConfig) StateStore(io.prestosql.spi.statestore.StateStore) HazelcastStateStore(io.hetu.core.statestore.hazelcast.HazelcastStateStore) Properties(java.util.Properties) HazelcastStateStoreBootstrapper(io.hetu.core.statestore.hazelcast.HazelcastStateStoreBootstrapper) URI(java.net.URI) HetuConfig(io.prestosql.utils.HetuConfig) SeedStoreManager(io.prestosql.seedstore.SeedStoreManager) InternalCommunicationConfig(io.prestosql.server.InternalCommunicationConfig) Seed(io.prestosql.spi.seedstore.Seed) SeedStore(io.prestosql.spi.seedstore.SeedStore) HetuLocalFileSystemClient(io.hetu.core.filesystem.HetuLocalFileSystemClient) HttpServerInfo(io.airlift.http.server.HttpServerInfo) HazelcastStateStoreBootstrapper(io.hetu.core.statestore.hazelcast.HazelcastStateStoreBootstrapper) StateStoreBootstrapper(io.prestosql.spi.statestore.StateStoreBootstrapper) HashSet(java.util.HashSet) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest) AfterTest(org.testng.annotations.AfterTest)

Aggregations

HetuConfig (io.prestosql.utils.HetuConfig)5 Test (org.testng.annotations.Test)5 InternalCommunicationConfig (io.prestosql.server.InternalCommunicationConfig)4 URI (java.net.URI)4 ServiceDescriptor (io.airlift.discovery.client.ServiceDescriptor)2 ServiceDescriptorsRepresentation (io.airlift.discovery.client.ServiceDescriptorsRepresentation)2 ServiceInventoryConfig (io.airlift.discovery.client.ServiceInventoryConfig)2 TestingHttpClient (io.airlift.http.client.testing.TestingHttpClient)2 HttpServerInfo (io.airlift.http.server.HttpServerInfo)2 NodeConfig (io.airlift.node.NodeConfig)2 NodeInfo (io.airlift.node.NodeInfo)2 DataSize (io.airlift.units.DataSize)2 HazelcastStateStore (io.hetu.core.statestore.hazelcast.HazelcastStateStore)2 MockExchangeRequestProcessor (io.prestosql.operator.MockExchangeRequestProcessor)2 SeedStoreManager (io.prestosql.seedstore.SeedStoreManager)2 StateStore (io.prestosql.spi.statestore.StateStore)2 ArrayList (java.util.ArrayList)2 AfterTest (org.testng.annotations.AfterTest)2 BeforeTest (org.testng.annotations.BeforeTest)2 HetuLocalFileSystemClient (io.hetu.core.filesystem.HetuLocalFileSystemClient)1