Java 类com.facebook.presto.spi.connector.ConnectorFactory 实例源码

项目:presto    文件:RaptorPlugin.java   
@Override
public <T> List<T> getServices(Class<T> type)
{
    checkState(nodeManager != null, "NodeManager has not been set");
    checkState(blockEncodingSerde != null, "BlockEncodingSerde has not been set");
    checkState(typeManager != null, "TypeManager has not been set");

    if (type == ConnectorFactory.class) {
        return ImmutableList.of(type.cast(new RaptorConnectorFactory(
                name,
                metadataModule,
                backupProviders,
                optionalConfig,
                nodeManager,
                pageSorter,
                blockEncodingSerde,
                typeManager)));
    }
    return ImmutableList.of();
}
项目:presto    文件:RaptorBenchmarkQueryRunner.java   
public static LocalQueryRunner createLocalQueryRunner()
{
    Session session = testSessionBuilder()
            .setCatalog("raptor")
            .setSchema("benchmark")
            .build();
    LocalQueryRunner localQueryRunner = new LocalQueryRunner(session);

    // add tpch
    InMemoryNodeManager nodeManager = localQueryRunner.getNodeManager();
    localQueryRunner.createCatalog("tpch", new TpchConnectorFactory(nodeManager, 1), ImmutableMap.<String, String>of());

    // add raptor
    ConnectorFactory raptorConnectorFactory = createRaptorConnectorFactory(TPCH_CACHE_DIR, nodeManager);
    localQueryRunner.createCatalog("raptor", raptorConnectorFactory, ImmutableMap.of());

    if (!localQueryRunner.tableExists(session, "orders")) {
        localQueryRunner.execute("CREATE TABLE orders AS SELECT * FROM tpch.sf1.orders");
    }
    if (!localQueryRunner.tableExists(session, "lineitem")) {
        localQueryRunner.execute("CREATE TABLE lineitem AS SELECT * FROM tpch.sf1.lineitem");
    }
    return localQueryRunner;
}
项目:presto    文件:ConnectorManager.java   
private synchronized void addCatalogConnector(String catalogName, String connectorId, ConnectorFactory factory, Map<String, String> properties)
{
    Connector connector = createConnector(connectorId, factory, properties);

    addConnectorInternal(ConnectorType.STANDARD, catalogName, connectorId, connector);

    String informationSchemaId = makeInformationSchemaConnectorId(connectorId);
    addConnectorInternal(ConnectorType.INFORMATION_SCHEMA, catalogName, informationSchemaId, new InformationSchemaConnector(catalogName, nodeManager, metadataManager));

    String systemId = makeSystemTablesConnectorId(connectorId);
    addConnectorInternal(ConnectorType.SYSTEM, catalogName, systemId, new SystemConnector(
            systemId,
            nodeManager,
            connector.getSystemTables(),
            transactionId -> transactionManager.getConnectorTransaction(transactionId, connectorId)));

    // Register session and table properties once per catalog
    metadataManager.getSessionPropertyManager().addConnectorSessionProperties(catalogName, connector.getSessionProperties());
    metadataManager.getTablePropertyManager().addTableProperties(catalogName, connector.getTableProperties());
}
项目:presto-kinesis    文件:TestKinesisPlugin.java   
@Test
public ConnectorFactory testConnectorExists()
{
    KinesisPlugin plugin = TestUtils.createPluginInstance();

    // Create factory manually to double check everything is done right
    Iterable<ConnectorFactory> iter = plugin.getConnectorFactories();

    List<ConnectorFactory> factories = new ArrayList<>();
    for (ConnectorFactory cf : iter) {
        factories.add(cf);
    }
    assertNotNull(factories);
    assertEquals(factories.size(), 1);
    ConnectorFactory factory = factories.get(0);
    assertNotNull(factory);
    return factory;
}
项目:presto-kinesis    文件:TestUtils.java   
/**
 * Build a connector instance from the plug in, supplying the given properties.
 *
 * This can build a connector with the mock client which is normally done in testing.
 * The plug in is created first with createPluginInstance.
 *
 * @param plugin
 * @param properties
 * @param withMockClient
 * @return
 */
public static KinesisConnector createConnector(KinesisPlugin plugin, Map<String, String> properties, boolean withMockClient)
{
    requireNonNull(plugin, "Plugin instance should not be null");
    requireNonNull(properties, "Properties map should not be null (can be empty)");

    if (withMockClient) {
        plugin.setAltProviderClass(KinesisTestClientManager.class);
    }

    ConnectorFactory factory = plugin.getConnectorFactories().iterator().next();
    assertNotNull(factory);

    Connector connector = factory.create("kinesis", properties, new TestingConnectorContext() {});
    assertTrue(connector instanceof KinesisConnector);
    return (KinesisConnector) connector;
}
项目:presto-rest    文件:SlackPlugin.java   
@Override
public Iterable<ConnectorFactory> getConnectorFactories()
{
    return ImmutableList.of(new RestConnectorFactory(
            "slack", config -> new SlackRest(config.get("token"))
    ));
}
项目:presto-rest    文件:GithubPlugin.java   
@Override
public Iterable<ConnectorFactory> getConnectorFactories()
{
    return ImmutableList.of(new RestConnectorFactory(
            "github", config -> new GithubRest(config.get("token"))
    ));
}
项目:presto-rest    文件:TwitterPlugin.java   
@Override
public Iterable<ConnectorFactory> getConnectorFactories()
{
    return ImmutableList.of(new RestConnectorFactory(
            "twitter",
            config -> new TwitterRest(
                    config.get("customer_key"),
                    config.get("customer_secret"),
                    config.get("token"),
                    config.get("secret"))
    ));
}
项目:presto    文件:KafkaPlugin.java   
@Override
public synchronized <T> List<T> getServices(Class<T> type)
{
    if (type == ConnectorFactory.class) {
        return ImmutableList.of(type.cast(new KafkaConnectorFactory(typeManager, nodeManager, tableDescriptionSupplier, optionalConfig)));
    }
    return ImmutableList.of();
}
项目:presto    文件:TestKafkaPlugin.java   
@Test
public ConnectorFactory testConnectorExists()
{
    KafkaPlugin plugin = new KafkaPlugin();
    plugin.setTypeManager(new TestingTypeManager());
    plugin.setNodeManager(new TestingNodeManager());

    List<ConnectorFactory> factories = plugin.getServices(ConnectorFactory.class);
    assertNotNull(factories);
    assertEquals(factories.size(), 1);
    ConnectorFactory factory = factories.get(0);
    assertNotNull(factory);
    return factory;
}
项目:presto    文件:TestKafkaPlugin.java   
@Test
public void testSpinup()
{
    ConnectorFactory factory = testConnectorExists();
    Connector c = factory.create("test-connector", ImmutableMap.<String, String>builder()
            .put("kafka.table-names", "test")
            .put("kafka.nodes", "localhost:9092")
            .build());
    assertNotNull(c);
}
项目:presto    文件:RaptorBenchmarkQueryRunner.java   
private static ConnectorFactory createRaptorConnectorFactory(String cacheDir, NodeManager nodeManager)
{
    try {
        File dataDir = new File(cacheDir);
        File databaseDir = new File(dataDir, "db");

        Map<String, String> config = ImmutableMap.<String, String>builder()
                .put("metadata.db.type", "h2")
                .put("metadata.db.filename", databaseDir.getAbsolutePath())
                .put("storage.data-directory", dataDir.getAbsolutePath())
                .put("storage.compress", "false")
                .build();

        TypeManager typeManager = new TypeRegistry();
        BlockEncodingSerde blockEncodingSerde = new BlockEncodingManager(typeManager);

        RaptorPlugin plugin = new RaptorPlugin();

        plugin.setOptionalConfig(config);
        plugin.setNodeManager(nodeManager);
        plugin.setBlockEncodingSerde(blockEncodingSerde);
        plugin.setTypeManager(typeManager);

        return getOnlyElement(plugin.getServices(ConnectorFactory.class));
    }
    catch (Exception e) {
        throw Throwables.propagate(e);
    }
}
项目:presto    文件:TestRaptorPlugin.java   
@Test
public void testPlugin()
        throws Exception
{
    RaptorPlugin plugin = loadPlugin(RaptorPlugin.class);

    plugin.setNodeManager(new InMemoryNodeManager());

    TypeRegistry typeRegistry = new TypeRegistry();
    plugin.setTypeManager(typeRegistry);
    plugin.setBlockEncodingSerde(new BlockEncodingManager(typeRegistry));

    plugin.setPageSorter(new PagesIndexPageSorter());

    List<ConnectorFactory> factories = plugin.getServices(ConnectorFactory.class);
    ConnectorFactory factory = getOnlyElement(factories);
    assertInstanceOf(factory, RaptorConnectorFactory.class);

    File tmpDir = Files.createTempDir();
    try {
        Map<String, String> config = ImmutableMap.<String, String>builder()
                .put("metadata.db.type", "h2")
                .put("metadata.db.filename", tmpDir.getAbsolutePath())
                .put("storage.data-directory", tmpDir.getAbsolutePath())
                .build();

        factory.create("test", config);
    }
    finally {
        FileUtils.deleteRecursively(tmpDir);
    }
}
项目:presto    文件:BlackHolePlugin.java   
@Override
public <T> List<T> getServices(Class<T> type)
{
    if (type == ConnectorFactory.class) {
        return ImmutableList.of(type.cast(new BlackHoleConnectorFactory()));
    }
    return ImmutableList.of();
}
项目:presto    文件:IndexedTpchPlugin.java   
@Override
public <T> List<T> getServices(Class<T> type)
{
    if (type == ConnectorFactory.class) {
        requireNonNull(nodeManager, "nodeManager is null");
        return ImmutableList.of(type.cast(new IndexedTpchConnectorFactory(nodeManager, indexSpec, 4)));
    }
    return ImmutableList.of();
}
项目:presto    文件:JmxPlugin.java   
@Override
public synchronized <T> List<T> getServices(Class<T> type)
{
    if (type == ConnectorFactory.class) {
        return ImmutableList.of(type.cast(new JmxConnectorFactory(mBeanServer, nodeManager)));
    }
    return ImmutableList.of();
}
项目:presto    文件:ConnectorManager.java   
public void addConnectorFactory(ConnectorFactory connectorFactory)
{
    checkState(!stopped.get(), "ConnectorManager is stopped");
    ConnectorFactory existingConnectorFactory = connectorFactories.putIfAbsent(connectorFactory.getName(), connectorFactory);
    checkArgument(existingConnectorFactory == null, "Connector %s is already registered", connectorFactory.getName());
    handleResolver.addConnectorName(connectorFactory.getName(), connectorFactory.getHandleResolver());
}
项目:presto    文件:ConnectorManager.java   
public void createConnection(String catalogName, String connectorName, Map<String, String> properties)
{
    requireNonNull(connectorName, "connectorName is null");
    ConnectorFactory connectorFactory = connectorFactories.get(connectorName);
    checkArgument(connectorFactory != null, "No factory for connector %s", connectorName);
    createConnection(catalogName, connectorFactory, properties);
}
项目:presto    文件:ConnectorManager.java   
private synchronized void createConnection(String catalogName, ConnectorFactory connectorFactory, Map<String, String> properties)
{
    checkState(!stopped.get(), "ConnectorManager is stopped");
    requireNonNull(catalogName, "catalogName is null");
    requireNonNull(properties, "properties is null");
    requireNonNull(connectorFactory, "connectorFactory is null");
    checkArgument(!catalogs.contains(catalogName), "A catalog already exists for %s", catalogName);

    String connectorId = getConnectorId(catalogName);
    checkState(!connectors.containsKey(connectorId), "A connector %s already exists", connectorId);

    addCatalogConnector(catalogName, connectorId, connectorFactory, properties);

    catalogs.add(catalogName);
}
项目:presto    文件:ConnectorManager.java   
private static Connector createConnector(String connectorId, ConnectorFactory factory, Map<String, String> properties)
{
    Class<?> factoryClass = factory.getClass();
    if (factory instanceof LegacyTransactionConnectorFactory) {
        factoryClass = ((LegacyTransactionConnectorFactory) factory).getConnectorFactory().getClass();
    }

    try (ThreadContextClassLoader ignored = new ThreadContextClassLoader(factoryClass.getClassLoader())) {
        return factory.create(connectorId, properties);
    }
}
项目:presto    文件:LocalQueryRunner.java   
@Deprecated
public void createCatalog(String catalogName, com.facebook.presto.spi.ConnectorFactory connectorFactory, Map<String, String> properties)
{
    nodeManager.addCurrentNodeDatasource(catalogName);
    connectorManager.addConnectorFactory(connectorFactory);
    connectorManager.createConnection(catalogName, connectorFactory.getName(), properties);
}
项目:presto    文件:TpchPlugin.java   
@Override
public <T> List<T> getServices(Class<T> type)
{
    if (type == ConnectorFactory.class) {
        requireNonNull(nodeManager, "nodeManager is null");
        return ImmutableList.of(type.cast(new TpchConnectorFactory(nodeManager)));
    }
    return ImmutableList.of();
}
项目:presto    文件:SampledTpchPlugin.java   
@Override
public <T> List<T> getServices(Class<T> type)
{
    if (type == ConnectorFactory.class) {
        requireNonNull(nodeManager, "nodeManager is null");
        return ImmutableList.of(type.cast(new SampledTpchConnectorFactory(nodeManager, 1, 2)));
    }
    return ImmutableList.of();
}
项目:presto    文件:CassandraPlugin.java   
@Override
public <T> List<T> getServices(Class<T> type)
{
    if (type == ConnectorFactory.class) {
        return ImmutableList.of(type.cast(new CassandraConnectorFactory("cassandra", optionalConfig)));
    }
    return ImmutableList.of();
}
项目:presto-kinesis    文件:KinesisPlugin.java   
@Override
public synchronized Iterable<ConnectorFactory> getConnectorFactories()
{
    if(factory == null) {
        this.factory = new KinesisConnectorFactory(getClassLoader(), tableDescriptionSupplier, optionalConfig, altProviderClass);
    }
    return ImmutableList.of(this.factory);
}
项目:presto-kinesis    文件:TestKinesisPlugin.java   
@Parameters({
        "kinesis.awsAccessKey",
        "kinesis.awsSecretKey"
})
@Test
public void testSpinUp(String awsAccessKey, String awsSecretKey)
{
    ConnectorFactory factory = testConnectorExists();
    // Important: this has to be created before we setup the injector in the factory:
    assertNotNull(factory.getHandleResolver());

    Connector c = factory.create("kinesis.test-connector", ImmutableMap.<String, String>builder()
            .put("kinesis.hide-internal-columns", "false")
            .put("kinesis.access-key", TestUtils.noneToBlank(awsAccessKey))
            .put("kinesis.secret-key", TestUtils.noneToBlank(awsSecretKey))
            .build(), new TestingConnectorContext() {});
    assertNotNull(c);

    // Verify that the key objects have been created on the connector
    assertNotNull(c.getRecordSetProvider());
    assertNotNull(c.getSplitManager());
    ConnectorMetadata md = c.getMetadata(KinesisTransactionHandle.INSTANCE);
    assertNotNull(md);

    ConnectorTransactionHandle handle = c.beginTransaction(READ_COMMITTED, true);
    assertTrue(handle != null && handle instanceof KinesisTransactionHandle);
}
项目:paraflow    文件:HDFSPlugin.java   
@Override
public Iterable<ConnectorFactory> getConnectorFactories()
{
    return ImmutableList.of(new HDFSConnectorFactory());
}
项目:presto-ethereum    文件:EthereumPlugin.java   
@Override
public Iterable<ConnectorFactory> getConnectorFactories() {
    return ImmutableList.of(new EthereumConnectorFactory());
}
项目:monarch    文件:AmpoolPlugin.java   
@Override
public Iterable<ConnectorFactory> getConnectorFactories() {
    return ImmutableList.of(new AmpoolConnectorFactory());
}
项目:presto-kudu    文件:KuduPlugin.java   
@Override
public Iterable<ConnectorFactory> getConnectorFactories()
{
    return ImmutableList.of(new KuduConnectorFactory());
}
项目:presto    文件:LegacyTransactionConnectorFactory.java   
public LegacyTransactionConnectorFactory(com.facebook.presto.spi.ConnectorFactory connectorFactory)
{
    this.connectorFactory = requireNonNull(connectorFactory, "connectorFactory is null");
}
项目:presto    文件:LegacyTransactionConnectorFactory.java   
public com.facebook.presto.spi.ConnectorFactory getConnectorFactory()
{
    return connectorFactory;
}
项目:presto    文件:ConnectorManager.java   
@Deprecated
public void addConnectorFactory(com.facebook.presto.spi.ConnectorFactory connectorFactory)
{
    addConnectorFactory(new LegacyTransactionConnectorFactory(connectorFactory));
}
项目:presto    文件:LocalQueryRunner.java   
public void createCatalog(String catalogName, ConnectorFactory connectorFactory, Map<String, String> properties)
{
    nodeManager.addCurrentNodeDatasource(catalogName);
    connectorManager.addConnectorFactory(connectorFactory);
    connectorManager.createConnection(catalogName, connectorFactory.getName(), properties);
}
项目:presto-plugins    文件:SpreadsheetPlugin.java   
@Override
public Iterable<ConnectorFactory> getConnectorFactories() {
  return ImmutableList.of(new SpreadsheetConnectorFactory(getClassLoader()));
}