Search in sources :

Example 1 with FileSystemClientManager

use of io.prestosql.filesystem.FileSystemClientManager 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 FileSystemClientManager

use of io.prestosql.filesystem.FileSystemClientManager in project hetu-core by openlookeng.

the class PrestoServer method run.

@Override
public void run() {
    verifyJvmRequirements();
    verifySystemTimeIsReasonable();
    Logger log = Logger.get(PrestoServer.class);
    ImmutableList.Builder<Module> modules = ImmutableList.builder();
    modules.add(new NodeModule(), Modules.override(new DiscoveryModule()).with(new HetuDiscoveryModule()), Modules.override(new HttpServerModule()).with(new HetuHttpServerModule()), new JsonModule(), new SmileModule(), new JaxrsModule(), new MBeanModule(), new PrefixObjectNameGeneratorModule("io.prestosql"), new HetuJmxModule(), new JmxHttpModule(), new LogJmxModule(), new TraceTokenModule(), new JsonEventModule(), new HttpEventModule(), new ServerSecurityModule(), new AccessControlModule(), new PasswordSecurityModule(), new EventListenerModule(), new ServerMainModule(sqlParserOptions), new NodeStateChangeModule(), new WarningCollectorModule());
    modules.addAll(getAdditionalModules());
    Bootstrap app = new Bootstrap(modules.build());
    try {
        Injector injector = app.strictConfig().initialize();
        logLocation(log, "Working directory", Paths.get("."));
        logLocation(log, "Etc directory", Paths.get("etc"));
        injector.getInstance(PluginManager.class).loadPlugins();
        FileSystemClientManager fileSystemClientManager = injector.getInstance(FileSystemClientManager.class);
        fileSystemClientManager.loadFactoryConfigs();
        injector.getInstance(SeedStoreManager.class).loadSeedStore();
        if (injector.getInstance(SeedStoreManager.class).isSeedStoreOnYarnEnabled()) {
            addSeedOnYarnInformation(injector.getInstance(ServerConfig.class), injector.getInstance(SeedStoreManager.class), (HetuHttpServerInfo) injector.getInstance(HttpServerInfo.class));
        }
        launchEmbeddedStateStore(injector.getInstance(HetuConfig.class), injector.getInstance(StateStoreLauncher.class));
        injector.getInstance(StateStoreProvider.class).loadStateStore();
        // relies on state-store
        injector.getInstance(HetuMetaStoreManager.class).loadHetuMetastore(fileSystemClientManager);
        // relies on metastore
        injector.getInstance(HeuristicIndexerManager.class).buildIndexClient();
        injector.getInstance(StaticFunctionNamespaceStore.class).loadFunctionNamespaceManagers();
        injector.getInstance(StaticCatalogStore.class).loadCatalogs();
        injector.getInstance(DynamicCatalogStore.class).loadCatalogStores(fileSystemClientManager);
        injector.getInstance(DynamicCatalogScanner.class).start();
        injector.getInstance(SessionPropertyDefaults.class).loadConfigurationManager();
        injector.getInstance(ResourceGroupManager.class).loadConfigurationManager();
        injector.getInstance(AccessControlManager.class).loadSystemAccessControl();
        injector.getInstance(PasswordAuthenticatorManager.class).loadPasswordAuthenticator();
        injector.getInstance(EventListenerManager.class).loadConfiguredEventListener();
        injector.getInstance(GroupProviderManager.class).loadConfiguredGroupProvider();
        // preload index (on coordinator only)
        if (injector.getInstance(ServerConfig.class).isCoordinator()) {
            HeuristicIndexerManager heuristicIndexerManager = injector.getInstance(HeuristicIndexerManager.class);
            heuristicIndexerManager.preloadIndex();
            heuristicIndexerManager.initCache();
        }
        // register dynamic filter listener
        registerStateStoreListeners(injector.getInstance(StateStoreListenerManager.class), injector.getInstance(DynamicFilterCacheManager.class), injector.getInstance(ServerConfig.class), injector.getInstance(NodeSchedulerConfig.class));
        // Initialize snapshot Manager
        injector.getInstance(SnapshotUtils.class).initialize();
        injector.getInstance(Announcer.class).start();
        injector.getInstance(ServerInfoResource.class).startupComplete();
        log.info("======== SERVER STARTED ========");
    } catch (Throwable e) {
        log.error(e);
        System.exit(1);
    }
}
Also used : AccessControlManager(io.prestosql.security.AccessControlManager) HetuDiscoveryModule(io.prestosql.discovery.HetuDiscoveryModule) DiscoveryModule(io.airlift.discovery.client.DiscoveryModule) StateStoreListenerManager(io.prestosql.statestore.listener.StateStoreListenerManager) JsonEventModule(io.airlift.event.client.JsonEventModule) PasswordAuthenticatorManager(io.prestosql.server.security.PasswordAuthenticatorManager) Announcer(io.airlift.discovery.client.Announcer) Injector(com.google.inject.Injector) StaticCatalogStore(io.prestosql.metadata.StaticCatalogStore) NodeModule(io.airlift.node.NodeModule) PasswordSecurityModule(io.prestosql.security.PasswordSecurityModule) HeuristicIndexerManager(io.prestosql.heuristicindex.HeuristicIndexerManager) StaticFunctionNamespaceStore(io.prestosql.metadata.StaticFunctionNamespaceStore) ResourceGroupManager(io.prestosql.execution.resourcegroups.ResourceGroupManager) LogJmxModule(io.airlift.log.LogJmxModule) JsonModule(io.airlift.json.JsonModule) EventListenerManager(io.prestosql.eventlistener.EventListenerManager) TraceTokenModule(io.airlift.tracetoken.TraceTokenModule) HttpServerModule(io.airlift.http.server.HttpServerModule) HetuHttpServerModule(io.prestosql.httpserver.HetuHttpServerModule) Module(com.google.inject.Module) MBeanModule(org.weakref.jmx.guice.MBeanModule) HetuJmxModule(io.prestosql.jmx.HetuJmxModule) HttpServerModule(io.airlift.http.server.HttpServerModule) HttpEventModule(io.airlift.event.client.http.HttpEventModule) TraceTokenModule(io.airlift.tracetoken.TraceTokenModule) SmileModule(io.prestosql.protocol.SmileModule) WarningCollectorModule(io.prestosql.execution.warnings.WarningCollectorModule) HetuHttpServerModule(io.prestosql.httpserver.HetuHttpServerModule) JaxrsModule(io.airlift.jaxrs.JaxrsModule) ServerSecurityModule(io.prestosql.server.security.ServerSecurityModule) JmxHttpModule(io.airlift.jmx.JmxHttpModule) HetuDiscoveryModule(io.prestosql.discovery.HetuDiscoveryModule) JsonEventModule(io.airlift.event.client.JsonEventModule) NodeModule(io.airlift.node.NodeModule) AccessControlModule(io.prestosql.security.AccessControlModule) EventListenerModule(io.prestosql.eventlistener.EventListenerModule) DiscoveryModule(io.airlift.discovery.client.DiscoveryModule) LogJmxModule(io.airlift.log.LogJmxModule) PasswordSecurityModule(io.prestosql.security.PasswordSecurityModule) JsonModule(io.airlift.json.JsonModule) JmxHttpModule(io.airlift.jmx.JmxHttpModule) MBeanModule(org.weakref.jmx.guice.MBeanModule) WarningCollectorModule(io.prestosql.execution.warnings.WarningCollectorModule) HetuJmxModule(io.prestosql.jmx.HetuJmxModule) ImmutableList(com.google.common.collect.ImmutableList) DynamicCatalogStore(io.prestosql.catalog.DynamicCatalogStore) HetuDiscoveryModule(io.prestosql.discovery.HetuDiscoveryModule) NodeSchedulerConfig(io.prestosql.execution.scheduler.NodeSchedulerConfig) Logger(io.airlift.log.Logger) HetuConfig(io.prestosql.utils.HetuConfig) StateStoreProvider(io.prestosql.statestore.StateStoreProvider) HttpEventModule(io.airlift.event.client.http.HttpEventModule) SeedStoreManager(io.prestosql.seedstore.SeedStoreManager) ServerSecurityModule(io.prestosql.server.security.ServerSecurityModule) SnapshotUtils(io.prestosql.snapshot.SnapshotUtils) Bootstrap(io.airlift.bootstrap.Bootstrap) HetuMetaStoreManager(io.prestosql.metastore.HetuMetaStoreManager) GroupProviderManager(io.prestosql.security.GroupProviderManager) EventListenerModule(io.prestosql.eventlistener.EventListenerModule) DynamicFilterCacheManager(io.prestosql.dynamicfilter.DynamicFilterCacheManager) AccessControlModule(io.prestosql.security.AccessControlModule) JaxrsModule(io.airlift.jaxrs.JaxrsModule) HetuHttpServerModule(io.prestosql.httpserver.HetuHttpServerModule) FileSystemClientManager(io.prestosql.filesystem.FileSystemClientManager) DynamicCatalogScanner(io.prestosql.catalog.DynamicCatalogScanner) SmileModule(io.prestosql.protocol.SmileModule) StateStoreLauncher(io.prestosql.statestore.StateStoreLauncher)

Example 3 with FileSystemClientManager

use of io.prestosql.filesystem.FileSystemClientManager in project hetu-core by openlookeng.

the class TestSeedStoreManager method setUp.

@BeforeMethod
private void setUp() throws IOException {
    FileSystemClientManager mockFileSystemClientManager = mock(FileSystemClientManager.class);
    when(mockFileSystemClientManager.getFileSystemClient(anyString(), any())).thenReturn(null);
    seedStoreManager = new SeedStoreManager(mockFileSystemClientManager);
    SeedStore mockSeedStore = new MockSeedStore();
    mockSeedStore.add(new HashSet<>());
    SeedStoreFactory mockSeedStoreFactory = mock(SeedStoreFactory.class);
    when(mockSeedStoreFactory.getName()).thenReturn("filebased");
    when(mockSeedStoreFactory.create(any(String.class), any(SeedStoreSubType.class), any(HetuFileSystemClient.class), any(Map.class))).thenReturn(mockSeedStore);
    seedStoreManager.addSeedStoreFactory(mockSeedStoreFactory);
}
Also used : HetuFileSystemClient(io.prestosql.spi.filesystem.HetuFileSystemClient) SeedStore(io.prestosql.spi.seedstore.SeedStore) SeedStoreFactory(io.prestosql.spi.seedstore.SeedStoreFactory) Matchers.anyString(org.mockito.Matchers.anyString) HashMap(java.util.HashMap) Map(java.util.Map) FileSystemClientManager(io.prestosql.filesystem.FileSystemClientManager) SeedStoreSubType(io.prestosql.spi.seedstore.SeedStoreSubType) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 4 with FileSystemClientManager

use of io.prestosql.filesystem.FileSystemClientManager in project hetu-core by openlookeng.

the class TestTaskSnapshotManager method setup.

@BeforeMethod
public void setup() throws Exception {
    // Set up snapshot config
    snapshotConfig = new SnapshotConfig();
    // Set up mock file system client manager
    fileSystemClientManager = mock(FileSystemClientManager.class);
    when(fileSystemClientManager.getFileSystemClient(any(Path.class))).thenReturn(new HetuLocalFileSystemClient(new LocalConfig(new Properties()), Paths.get(SNAPSHOT_FILE_SYSTEM_DIR)));
    snapshotUtils = new SnapshotUtils(fileSystemClientManager, snapshotConfig, new InMemoryNodeManager());
    snapshotUtils.rootPath = SNAPSHOT_FILE_SYSTEM_DIR;
    snapshotUtils.initialize();
}
Also used : Path(java.nio.file.Path) LocalConfig(io.hetu.core.filesystem.LocalConfig) Properties(java.util.Properties) HetuLocalFileSystemClient(io.hetu.core.filesystem.HetuLocalFileSystemClient) FileSystemClientManager(io.prestosql.filesystem.FileSystemClientManager) InMemoryNodeManager(io.prestosql.metadata.InMemoryNodeManager) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 5 with FileSystemClientManager

use of io.prestosql.filesystem.FileSystemClientManager in project hetu-core by openlookeng.

the class TestBinaryFileSpiller method setUp.

@BeforeMethod
public void setUp() throws IOException {
    Metadata metadata = createTestMetadataManager();
    FileSystemClientManager fileSystemClientManager = mock(FileSystemClientManager.class);
    when(fileSystemClientManager.getFileSystemClient(any(Path.class))).thenReturn(new HetuLocalFileSystemClient(new LocalConfig(new Properties()), Paths.get(spillPath.getCanonicalPath())));
    spillerStats = new SpillerStats();
    FeaturesConfig featuresConfig = new FeaturesConfig();
    try {
        featuresConfig.setSpillerSpillPaths(spillPath.getCanonicalPath());
    } catch (IOException e) {
        System.out.println(e.getStackTrace());
    }
    featuresConfig.setSpillMaxUsedSpaceThreshold(1.0);
    NodeSpillConfig nodeSpillConfig = new NodeSpillConfig();
    singleStreamSpillerFactory = new FileSingleStreamSpillerFactory(metadata, spillerStats, featuresConfig, nodeSpillConfig, fileSystemClientManager);
    factory = new GenericSpillerFactory(singleStreamSpillerFactory);
    PagesSerdeFactory pagesSerdeFactory = new PagesSerdeFactory(metadata.getFunctionAndTypeManager().getBlockEncodingSerde(), nodeSpillConfig.isSpillCompressionEnabled());
    pagesSerde = pagesSerdeFactory.createPagesSerde();
    memoryContext = newSimpleAggregatedMemoryContext();
}
Also used : Path(java.nio.file.Path) LocalConfig(io.hetu.core.filesystem.LocalConfig) FeaturesConfig(io.prestosql.sql.analyzer.FeaturesConfig) Metadata(io.prestosql.metadata.Metadata) IOException(java.io.IOException) Properties(java.util.Properties) FileSystemClientManager(io.prestosql.filesystem.FileSystemClientManager) TestingPagesSerdeFactory(io.prestosql.testing.TestingPagesSerdeFactory) PagesSerdeFactory(io.hetu.core.transport.execution.buffer.PagesSerdeFactory) HetuLocalFileSystemClient(io.hetu.core.filesystem.HetuLocalFileSystemClient) BeforeMethod(org.testng.annotations.BeforeMethod)

Aggregations

FileSystemClientManager (io.prestosql.filesystem.FileSystemClientManager)42 Test (org.testng.annotations.Test)27 HetuMetaStoreManager (io.prestosql.metastore.HetuMetaStoreManager)25 HeuristicIndexerManager (io.prestosql.heuristicindex.HeuristicIndexerManager)24 AllowAllAccessControl (io.prestosql.security.AllowAllAccessControl)18 Session (io.prestosql.Session)15 InMemoryTransactionManager.createTestTransactionManager (io.prestosql.transaction.InMemoryTransactionManager.createTestTransactionManager)15 TransactionManager (io.prestosql.transaction.TransactionManager)15 SeedStoreManager (io.prestosql.seedstore.SeedStoreManager)10 Split (io.prestosql.metadata.Split)7 PlanNodeId (io.prestosql.spi.plan.PlanNodeId)7 LocalStateStoreProvider (io.prestosql.statestore.LocalStateStoreProvider)7 HetuLocalFileSystemClient (io.hetu.core.filesystem.HetuLocalFileSystemClient)6 LocalConfig (io.hetu.core.filesystem.LocalConfig)6 DynamicFilterService (io.prestosql.dynamicfilter.DynamicFilterService)6 SqlStageExecution.createSqlStageExecution (io.prestosql.execution.SqlStageExecution.createSqlStageExecution)6 NoOpFailureDetector (io.prestosql.failuredetector.NoOpFailureDetector)6 QuerySnapshotManager (io.prestosql.snapshot.QuerySnapshotManager)6 QueryId (io.prestosql.spi.QueryId)6 StartTransaction (io.prestosql.sql.tree.StartTransaction)6