Search in sources :

Example 1 with StateStoreFactory

use of io.prestosql.spi.statestore.StateStoreFactory in project hetu-core by openlookeng.

the class LocalStateStoreProvider method setStateStore.

public void setStateStore(String stateStoreType, Map<String, String> properties) {
    requireNonNull(stateStoreType, "stateStoreType is null");
    requireNonNull(properties, "properties is null");
    log.info("-- Loading state store --");
    StateStoreFactory stateStoreFactory = stateStoreFactories.get(stateStoreType);
    checkState(stateStoreFactory != null, "State store %s is not registered", stateStoreType);
    try (ThreadContextClassLoader ignored = new ThreadContextClassLoader(stateStoreFactory.getClass().getClassLoader())) {
        String stateStoreName = properties.remove(STATE_STORE_NAME_PROPERTY_NAME);
        if (stateStoreName == null) {
            log.info("State store name not provided, using default state store name: %s", DEFAULT_STATE_STORE_NAME);
            stateStoreName = DEFAULT_STATE_STORE_NAME;
        }
        // Create state stores defined in config
        stateStore = stateStoreFactory.create(stateStoreName, seedStoreManager.getSeedStore(SeedStoreSubType.HAZELCAST), ImmutableMap.copyOf(properties));
        stateStore.registerClusterFailureHandler(this::handleClusterDisconnection);
        stateStore.init();
    } catch (Exception e) {
        throw new PrestoException(STATE_STORE_FAILURE, "Unable to create state store: " + e.getMessage());
    }
    log.info("-- Loaded state store %s --", stateStoreType);
}
Also used : PrestoException(io.prestosql.spi.PrestoException) ThreadContextClassLoader(io.prestosql.spi.classloader.ThreadContextClassLoader) PrestoException(io.prestosql.spi.PrestoException) StateStoreFactory(io.prestosql.spi.statestore.StateStoreFactory)

Example 2 with StateStoreFactory

use of io.prestosql.spi.statestore.StateStoreFactory in project hetu-core by openlookeng.

the class PluginManager method installPlugin.

public void installPlugin(Plugin plugin) {
    for (BlockEncoding blockEncoding : plugin.getBlockEncodings()) {
        log.info("Registering block encoding %s", blockEncoding.getName());
        metadataManager.getFunctionAndTypeManager().addBlockEncoding(blockEncoding);
    }
    for (Type type : plugin.getTypes()) {
        log.info("Registering type %s", type.getTypeSignature());
        metadataManager.getFunctionAndTypeManager().addType(type);
    }
    for (ParametricType parametricType : plugin.getParametricTypes()) {
        log.info("Registering parametric type %s", parametricType.getName());
        metadataManager.getFunctionAndTypeManager().addParametricType(parametricType);
    }
    for (ConnectorFactory connectorFactory : plugin.getConnectorFactories()) {
        log.info("Registering connector %s", connectorFactory.getName());
        connectorManager.addConnectorFactory(connectorFactory);
        ConnectorCache.addCatalogConfig(plugin, connectorFactory.getName());
    }
    for (SessionPropertyConfigurationManagerFactory sessionConfigFactory : plugin.getSessionPropertyConfigurationManagerFactories()) {
        log.info("Registering session property configuration manager %s", sessionConfigFactory.getName());
        sessionPropertyDefaults.addConfigurationManagerFactory(sessionConfigFactory);
    }
    for (FunctionNamespaceManagerFactory functionNamespaceManagerFactory : plugin.getFunctionNamespaceManagerFactories()) {
        log.info("Registering function namespace manager %s", functionNamespaceManagerFactory.getName());
        metadataManager.getFunctionAndTypeManager().addFunctionNamespaceFactory(functionNamespaceManagerFactory);
    }
    for (ResourceGroupConfigurationManagerFactory configurationManagerFactory : plugin.getResourceGroupConfigurationManagerFactories()) {
        log.info("Registering resource group configuration manager %s", configurationManagerFactory.getName());
        resourceGroupManager.addConfigurationManagerFactory(configurationManagerFactory);
    }
    for (SystemAccessControlFactory accessControlFactory : plugin.getSystemAccessControlFactories()) {
        log.info("Registering system access control %s", accessControlFactory.getName());
        accessControlManager.addSystemAccessControlFactory(accessControlFactory);
    }
    for (PasswordAuthenticatorFactory authenticatorFactory : plugin.getPasswordAuthenticatorFactories()) {
        log.info("Registering password authenticator %s", authenticatorFactory.getName());
        passwordAuthenticatorManager.addPasswordAuthenticatorFactory(authenticatorFactory);
    }
    for (EventListenerFactory eventListenerFactory : plugin.getEventListenerFactories()) {
        log.info("Registering event listener %s", eventListenerFactory.getName());
        eventListenerManager.addEventListenerFactory(eventListenerFactory);
    }
    for (GroupProviderFactory groupProviderFactory : plugin.getGroupProviderFactories()) {
        log.info("Registering group provider %s", groupProviderFactory.getName());
        groupProviderManager.addGroupProviderFactory(groupProviderFactory);
    }
    // Install StateStorePlugin
    for (StateStoreBootstrapper bootstrapper : plugin.getStateStoreBootstrappers()) {
        log.info("Registering  state store bootstrapper");
        stateStoreLauncher.addStateStoreBootstrapper(bootstrapper);
    }
    for (StateStoreFactory stateStoreFactory : plugin.getStateStoreFactories()) {
        log.info("Registering state store %s", stateStoreFactory.getName());
        localStateStoreProvider.addStateStoreFactory(stateStoreFactory);
    }
    for (SeedStoreFactory seedStoreFactory : plugin.getSeedStoreFactories()) {
        log.info("Registering seed store %s", seedStoreFactory.getName());
        seedStoreManager.addSeedStoreFactory(seedStoreFactory);
    }
    for (CubeProvider cubeProvider : plugin.getCubeProviders()) {
        log.info("Registering cube provider %s", cubeProvider.getName());
        cubeManager.addCubeProvider(cubeProvider);
    }
    for (HetuFileSystemClientFactory fileSystemClientFactory : plugin.getFileSystemClientFactory()) {
        log.info("Registering file system provider %s", fileSystemClientFactory.getName());
        fileSystemClientManager.addFileSystemClientFactories(fileSystemClientFactory);
    }
    for (HetuMetaStoreFactory hetuMetaStoreFactory : plugin.getHetuMetaStoreFactories()) {
        log.info("Registering hetu metastore %s", hetuMetaStoreFactory.getName());
        hetuMetaStoreManager.addHetuMetaStoreFactory(hetuMetaStoreFactory);
    }
    for (IndexFactory indexFactory : plugin.getIndexFactories()) {
        log.info("Loading index factory");
        heuristicIndexerManager.loadIndexFactories(indexFactory);
    }
    installFunctionsPlugin(plugin);
}
Also used : ResourceGroupConfigurationManagerFactory(io.prestosql.spi.resourcegroups.ResourceGroupConfigurationManagerFactory) EventListenerFactory(io.prestosql.spi.eventlistener.EventListenerFactory) HetuFileSystemClientFactory(io.prestosql.spi.filesystem.HetuFileSystemClientFactory) SeedStoreFactory(io.prestosql.spi.seedstore.SeedStoreFactory) SystemAccessControlFactory(io.prestosql.spi.security.SystemAccessControlFactory) ParametricType(io.prestosql.spi.type.ParametricType) Type(io.prestosql.spi.type.Type) PasswordAuthenticatorFactory(io.prestosql.spi.security.PasswordAuthenticatorFactory) ConnectorFactory(io.prestosql.spi.connector.ConnectorFactory) IndexFactory(io.prestosql.spi.heuristicindex.IndexFactory) HetuMetaStoreFactory(io.prestosql.spi.metastore.HetuMetaStoreFactory) ParametricType(io.prestosql.spi.type.ParametricType) CubeProvider(io.prestosql.spi.cube.CubeProvider) FunctionNamespaceManagerFactory(io.prestosql.spi.function.FunctionNamespaceManagerFactory) SessionPropertyConfigurationManagerFactory(io.prestosql.spi.session.SessionPropertyConfigurationManagerFactory) BlockEncoding(io.prestosql.spi.block.BlockEncoding) GroupProviderFactory(io.prestosql.spi.security.GroupProviderFactory) StateStoreBootstrapper(io.prestosql.spi.statestore.StateStoreBootstrapper) StateStoreFactory(io.prestosql.spi.statestore.StateStoreFactory)

Example 3 with StateStoreFactory

use of io.prestosql.spi.statestore.StateStoreFactory in project hetu-core by openlookeng.

the class TestDynamicFilterSourceOperator method prepareConfigFiles.

@BeforeTest
private void prepareConfigFiles() throws Exception {
    File launcherConfigFile = new File(STATE_STORE_CONFIGURATION_PATH);
    if (launcherConfigFile.exists()) {
        launcherConfigFile.delete();
    }
    launcherConfigFile.createNewFile();
    FileWriter configWriter = new FileWriter(STATE_STORE_CONFIGURATION_PATH);
    configWriter.write("state-store.type=hazelcast\n" + "state-store.name=test\n" + "state-store.cluster=test-cluster\n" + "hazelcast.discovery.mode=tcp-ip\n" + "hazelcast.discovery.port=7980\n");
    configWriter.close();
    Set<Seed> seeds = new HashSet<>();
    SeedStore mockSeedStore = mock(SeedStore.class);
    Seed mockSeed = mock(Seed.class);
    seeds.add(mockSeed);
    SeedStoreManager mockSeedStoreManager = mock(SeedStoreManager.class);
    when(mockSeedStoreManager.getSeedStore(SeedStoreSubType.HAZELCAST)).thenReturn(mockSeedStore);
    when(mockSeed.getLocation()).thenReturn("127.0.0.1:6991");
    when(mockSeedStore.get()).thenReturn(seeds);
    StateStoreFactory factory = new HazelcastStateStoreFactory();
    stateStoreProvider = new LocalStateStoreProvider(mockSeedStoreManager);
    stateStoreProvider.addStateStoreFactory(factory);
    createStateStoreCluster("6991");
    stateStoreProvider.loadStateStore();
}
Also used : LocalStateStoreProvider(io.prestosql.statestore.LocalStateStoreProvider) SeedStoreManager(io.prestosql.seedstore.SeedStoreManager) Seed(io.prestosql.spi.seedstore.Seed) FileWriter(java.io.FileWriter) SeedStore(io.prestosql.spi.seedstore.SeedStore) HazelcastStateStoreFactory(io.hetu.core.statestore.hazelcast.HazelcastStateStoreFactory) File(java.io.File) HashSet(java.util.HashSet) HazelcastStateStoreFactory(io.hetu.core.statestore.hazelcast.HazelcastStateStoreFactory) StateStoreFactory(io.prestosql.spi.statestore.StateStoreFactory) BeforeTest(org.testng.annotations.BeforeTest)

Example 4 with StateStoreFactory

use of io.prestosql.spi.statestore.StateStoreFactory in project hetu-core by openlookeng.

the class TestHazelcastClusterLifecycleListener method createStateStoreClient.

private StateStore createStateStoreClient(Set<Seed> seeds) {
    Map<String, String> config = new HashMap<>(0);
    config.put("hazelcast.discovery.mode", "tcp-ip");
    config.put("state-store.cluster", TEST_CLUSTER_NAME);
    config.put(DISCOVERY_PORT_CONFIG_NAME, PORT1);
    MockSeedStore mockSeedStore = new MockSeedStore();
    mockSeedStore.add(seeds);
    StateStoreFactory factory = new HazelcastStateStoreFactory();
    StateStore stateStore = factory.create("testHazelcast", mockSeedStore, config);
    stateStore.registerClusterFailureHandler(event -> isClusterShutdownEventCaptured = true);
    return stateStore;
}
Also used : HashMap(java.util.HashMap) StateStore(io.prestosql.spi.statestore.StateStore) StateStoreFactory(io.prestosql.spi.statestore.StateStoreFactory)

Example 5 with StateStoreFactory

use of io.prestosql.spi.statestore.StateStoreFactory in project hetu-core by openlookeng.

the class TestStateFetcher method stateStoreMockData.

private void stateStoreMockData() {
    stateFetcher.registerStateCollection(STATE_COLLECTION_QUERY);
    stateStoreFactory = Mockito.mock(StateStoreFactory.class);
    when(stateStoreFactory.getName()).then(new Returns(STATE_STORE_HAZELCAST));
    stateStore = Mockito.mock(StateStore.class);
    when(stateStore.getName()).then(new Returns(STATE_COLLECTION_QUERY));
    when(stateStoreFactory.create(any(), any(), any())).then(new Returns(stateStore));
    stateCollection = Mockito.mock(StateMap.class);
    when(stateStoreProvider.getStateStore()).then(new Returns(stateStore));
}
Also used : Returns(org.mockito.internal.stubbing.answers.Returns) StateMap(io.prestosql.spi.statestore.StateMap) StateStore(io.prestosql.spi.statestore.StateStore) StateStoreFactory(io.prestosql.spi.statestore.StateStoreFactory)

Aggregations

StateStoreFactory (io.prestosql.spi.statestore.StateStoreFactory)5 StateStore (io.prestosql.spi.statestore.StateStore)2 HazelcastStateStoreFactory (io.hetu.core.statestore.hazelcast.HazelcastStateStoreFactory)1 SeedStoreManager (io.prestosql.seedstore.SeedStoreManager)1 PrestoException (io.prestosql.spi.PrestoException)1 BlockEncoding (io.prestosql.spi.block.BlockEncoding)1 ThreadContextClassLoader (io.prestosql.spi.classloader.ThreadContextClassLoader)1 ConnectorFactory (io.prestosql.spi.connector.ConnectorFactory)1 CubeProvider (io.prestosql.spi.cube.CubeProvider)1 EventListenerFactory (io.prestosql.spi.eventlistener.EventListenerFactory)1 HetuFileSystemClientFactory (io.prestosql.spi.filesystem.HetuFileSystemClientFactory)1 FunctionNamespaceManagerFactory (io.prestosql.spi.function.FunctionNamespaceManagerFactory)1 IndexFactory (io.prestosql.spi.heuristicindex.IndexFactory)1 HetuMetaStoreFactory (io.prestosql.spi.metastore.HetuMetaStoreFactory)1 ResourceGroupConfigurationManagerFactory (io.prestosql.spi.resourcegroups.ResourceGroupConfigurationManagerFactory)1 GroupProviderFactory (io.prestosql.spi.security.GroupProviderFactory)1 PasswordAuthenticatorFactory (io.prestosql.spi.security.PasswordAuthenticatorFactory)1 SystemAccessControlFactory (io.prestosql.spi.security.SystemAccessControlFactory)1 Seed (io.prestosql.spi.seedstore.Seed)1 SeedStore (io.prestosql.spi.seedstore.SeedStore)1