use of com.facebook.presto.spi.connector.ConnectorFactory in project presto by prestodb.
the class TestPrestoSparkLauncherIntegrationSmokeTest method setUp.
@BeforeClass
public void setUp() throws Exception {
assertEquals(DateTimeZone.getDefault(), TIME_ZONE, "Timezone not configured correctly. Add -Duser.timezone=America/Bahia_Banderas to your JVM arguments");
// the default temporary directory location on MacOS is not sharable to docker
tempDir = new File("/tmp", randomUUID().toString());
createDirectories(tempDir.toPath());
sparkWorkDirectory = new File(tempDir, "work");
createDirectories(sparkWorkDirectory.toPath());
File composeYaml = extractResource("docker-compose.yml", tempDir);
dockerCompose = new DockerCompose(composeYaml);
dockerCompose.verifyInstallation();
dockerCompose.pull();
composeProcess = dockerCompose.up(ImmutableMap.of("spark-master", 1, "spark-worker", 2, "hadoop-master", 1));
Session session = testSessionBuilder().setCatalog("hive").setSchema("default").build();
localQueryRunner = new LocalQueryRunner(session);
HiveHadoop2Plugin plugin = new HiveHadoop2Plugin();
ConnectorFactory hiveConnectorFactory = getOnlyElement(plugin.getConnectorFactories());
addStaticResolution("hadoop-master", "127.0.0.1");
String hadoopMasterAddress = dockerCompose.getContainerAddress("hadoop-master");
// datanode is accessed via the internal docker IP address that is not accessible from the host
addStaticResolution(hadoopMasterAddress, "127.0.0.1");
localQueryRunner.createCatalog("hive", hiveConnectorFactory, ImmutableMap.of("hive.metastore.uri", "thrift://127.0.0.1:9083", "hive.time-zone", TIME_ZONE.getID(), "hive.experimental-optimized-partition-update-serialization-enabled", "true"));
localQueryRunner.createCatalog("tpch", new TpchConnectorFactory(), ImmutableMap.of());
// it may take some time for the docker container to start
ensureHiveIsRunning(localQueryRunner, new Duration(10, MINUTES));
importTables(localQueryRunner, "lineitem", "orders");
importTablesBucketed(localQueryRunner, ImmutableList.of("orderkey"), "lineitem", "orders");
File projectRoot = resolveProjectRoot();
prestoLauncher = resolveFile(new File(projectRoot, "presto-spark-launcher/target"), Pattern.compile("presto-spark-launcher-[\\d\\.]+(-SNAPSHOT)?\\.jar"));
logPackageInfo(prestoLauncher);
prestoPackage = resolveFile(new File(projectRoot, "presto-spark-package/target"), Pattern.compile("presto-spark-package-.+\\.tar\\.gz"));
logPackageInfo(prestoPackage);
configProperties = new File(tempDir, "config.properties");
storeProperties(configProperties, ImmutableMap.of("query.hash-partition-count", "10"));
catalogDirectory = new File(tempDir, "catalogs");
createDirectories(catalogDirectory.toPath());
storeProperties(new File(catalogDirectory, "hive.properties"), ImmutableMap.of("connector.name", "hive-hadoop2", "hive.metastore.uri", "thrift://hadoop-master:9083", // the getnetgrent dependency is missing
"hive.dfs.require-hadoop-native", "false", "hive.time-zone", TIME_ZONE.getID()));
storeProperties(new File(catalogDirectory, "tpch.properties"), ImmutableMap.of("connector.name", "tpch", "tpch.splits-per-node", "4", "tpch.partitioning-enabled", "false"));
}
use of com.facebook.presto.spi.connector.ConnectorFactory in project presto by prestodb.
the class TestThriftPlugin method testPlugin.
@Test
public void testPlugin() {
ThriftPlugin plugin = loadPlugin(ThriftPlugin.class);
ConnectorFactory factory = getOnlyElement(plugin.getConnectorFactories());
assertInstanceOf(factory, ThriftConnectorFactory.class);
Map<String, String> config = ImmutableMap.of("presto.thrift.client.addresses", "localhost:7779");
Connector connector = factory.create("test", config, new TestingConnectorContext());
assertNotNull(connector);
assertInstanceOf(connector, ThriftConnector.class);
}
use of com.facebook.presto.spi.connector.ConnectorFactory in project presto by prestodb.
the class TestBigQueryPlugin method testStartup.
@Test
public void testStartup() {
BigQueryPlugin plugin = new BigQueryPlugin();
ConnectorFactory factory = getOnlyElement(plugin.getConnectorFactories());
assertInstanceOf(factory, BigQueryConnectorFactory.class);
}
use of com.facebook.presto.spi.connector.ConnectorFactory in project presto by prestodb.
the class PluginManager method installPlugin.
public void installPlugin(Plugin plugin) {
for (BlockEncoding blockEncoding : plugin.getBlockEncodings()) {
log.info("Registering block encoding %s", blockEncoding.getName());
blockEncodingManager.addBlockEncoding(blockEncoding);
}
for (Type type : plugin.getTypes()) {
log.info("Registering type %s", type.getTypeSignature());
metadata.getFunctionAndTypeManager().addType(type);
}
for (ParametricType parametricType : plugin.getParametricTypes()) {
log.info("Registering parametric type %s", parametricType.getName());
metadata.getFunctionAndTypeManager().addParametricType(parametricType);
}
for (ConnectorFactory connectorFactory : plugin.getConnectorFactories()) {
if (disabledConnectors.contains(connectorFactory.getName())) {
log.info("Skipping disabled connector %s", connectorFactory.getName());
continue;
}
log.info("Registering connector %s", connectorFactory.getName());
connectorManager.addConnectorFactory(connectorFactory);
}
for (Class<?> functionClass : plugin.getFunctions()) {
log.info("Registering functions from %s", functionClass.getName());
metadata.registerBuiltInFunctions(extractFunctions(functionClass));
}
for (FunctionNamespaceManagerFactory functionNamespaceManagerFactory : plugin.getFunctionNamespaceManagerFactories()) {
log.info("Registering function namespace manager %s", functionNamespaceManagerFactory.getName());
metadata.getFunctionAndTypeManager().addFunctionNamespaceFactory(functionNamespaceManagerFactory);
}
for (SessionPropertyConfigurationManagerFactory sessionConfigFactory : plugin.getSessionPropertyConfigurationManagerFactories()) {
log.info("Registering session property configuration manager %s", sessionConfigFactory.getName());
sessionPropertyDefaults.addConfigurationManagerFactory(sessionConfigFactory);
}
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 (TempStorageFactory tempStorageFactory : plugin.getTempStorageFactories()) {
log.info("Registering temp storage %s", tempStorageFactory.getName());
tempStorageManager.addTempStorageFactory(tempStorageFactory);
}
for (QueryPrerequisitesFactory queryPrerequisitesFactory : plugin.getQueryPrerequisitesFactories()) {
log.info("Registering query prerequisite factory %s", queryPrerequisitesFactory.getName());
queryPrerequisitesManager.addQueryPrerequisitesFactory(queryPrerequisitesFactory);
}
for (NodeTtlFetcherFactory nodeTtlFetcherFactory : plugin.getNodeTtlFetcherFactories()) {
log.info("Registering Ttl fetcher factory %s", nodeTtlFetcherFactory.getName());
nodeTtlFetcherManager.addNodeTtlFetcherFactory(nodeTtlFetcherFactory);
}
for (ClusterTtlProviderFactory clusterTtlProviderFactory : plugin.getClusterTtlProviderFactories()) {
log.info("Registering Cluster Ttl provider factory %s", clusterTtlProviderFactory.getName());
clusterTtlProviderManager.addClusterTtlProviderFactory(clusterTtlProviderFactory);
}
}
use of com.facebook.presto.spi.connector.ConnectorFactory in project presto by prestodb.
the class ConnectorManager method addCatalogConnector.
private synchronized void addCatalogConnector(String catalogName, ConnectorId connectorId, ConnectorFactory factory, Map<String, String> properties) {
// create all connectors before adding, so a broken connector does not leave the system half updated
MaterializedConnector connector = new MaterializedConnector(connectorId, createConnector(connectorId, factory, properties));
MaterializedConnector informationSchemaConnector = new MaterializedConnector(createInformationSchemaConnectorId(connectorId), new InformationSchemaConnector(catalogName, nodeManager, metadataManager, accessControlManager, connector.getSessionProperties()));
ConnectorId systemId = createSystemTablesConnectorId(connectorId);
SystemTablesProvider systemTablesProvider;
if (nodeManager.getCurrentNode().isCoordinator()) {
systemTablesProvider = new DelegatingSystemTablesProvider(new StaticSystemTablesProvider(connector.getSystemTables()), new MetadataBasedSystemTablesProvider(metadataManager, catalogName));
} else {
systemTablesProvider = new StaticSystemTablesProvider(connector.getSystemTables());
}
MaterializedConnector systemConnector = new MaterializedConnector(systemId, new SystemConnector(systemId, nodeManager, systemTablesProvider, transactionId -> transactionManager.getConnectorTransaction(transactionId, connectorId), connector.getSessionProperties()));
Catalog catalog = new Catalog(catalogName, connector.getConnectorId(), connector.getConnector(), informationSchemaConnector.getConnectorId(), informationSchemaConnector.getConnector(), systemConnector.getConnectorId(), systemConnector.getConnector());
try {
addConnectorInternal(connector);
addConnectorInternal(informationSchemaConnector);
addConnectorInternal(systemConnector);
catalogManager.registerCatalog(catalog);
} catch (Throwable e) {
catalogManager.removeCatalog(catalog.getCatalogName());
removeConnectorInternal(systemConnector.getConnectorId());
removeConnectorInternal(informationSchemaConnector.getConnectorId());
removeConnectorInternal(connector.getConnectorId());
throw e;
}
}
Aggregations