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

项目:paraflow    文件:HDFSConnectorFactory.java   
@Override
public Connector create(String connectorId, Map<String, String> config, ConnectorContext context)
{
    requireNonNull(config, "config is null");

    try {
        Bootstrap app = new Bootstrap(
                new JsonModule(),
                new HDFSModule(connectorId, context.getTypeManager())
        );

        Injector injector = app
                .strictConfig()
                .doNotInitializeLogging()
                .setRequiredConfigurationProperties(config)
                .initialize();

        return injector.getInstance(HDFSConnector.class);
    }
    catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}
项目:presto-kudu    文件:KuduConnectorFactory.java   
@Override
public Connector create(final String connectorId, Map<String, String> requiredConfig, ConnectorContext context)
{
    requireNonNull(requiredConfig, "config is null");

    try {
        Bootstrap app = new Bootstrap(
                binder -> binder.bind(NodeManager.class).toInstance(context.getNodeManager()),
                new KuduModule(connectorId));

        Injector injector = app
                .strictConfig()
                .doNotInitializeLogging()
                .setRequiredConfigurationProperties(requiredConfig)
                .initialize();

        return injector.getInstance(KuduConnector.class);
    }
    catch (Exception e) {
        throw Throwables.propagate(e);
    }
}
项目:presto-plugins    文件:SpreadsheetConnectorFactory.java   
@Override
public Connector create(String connectorId, Map<String, String> config, ConnectorContext context) {
  Path basePath = new Path(config.get(BASEPATH));
  String spreadsheetSubDir = config.get(SUBDIR);
  String useFileCacheStr = config.get(USE_FILE_CACHE);
  String proxyUserStr = config.get(PROXY_USER);
  boolean proxyUser = false;
  if (proxyUserStr != null) {
    proxyUser = Boolean.parseBoolean(proxyUserStr);
  }
  boolean useFileCache = true;
  if (useFileCacheStr != null) {
    useFileCache = Boolean.parseBoolean(useFileCacheStr);
  }
  try {
    return new SpreadsheetConnector(UserGroupInformation.getCurrentUser(), _configuration, basePath,
        spreadsheetSubDir, useFileCache, proxyUser);
  } catch (IOException e) {
    throw new RuntimeException(e);
  }
}
项目:presto-rest    文件:RestConnectorFactory.java   
@Override
public Connector create(String s, Map<String, String> config, ConnectorContext context)
{
    NodeManager nodeManager = context.getNodeManager();

    return new RestConnector(nodeManager, restFactory.create(config));
}
项目:presto-ethereum    文件:EthereumConnectorFactory.java   
@Override
    public Connector create(String connectorId, Map<String, String> config, ConnectorContext context) {
        requireNonNull(connectorId, "connectorId is null");
        requireNonNull(config, "config is null");

        try {
            Bootstrap app = new Bootstrap(
//                    new JsonModule(),
                    new EthereumConnectorModule(),
                    binder -> {
                        binder.bind(EthereumConnectorId.class).toInstance(new EthereumConnectorId(connectorId));
                        binder.bind(TypeManager.class).toInstance(context.getTypeManager());
                        binder.bind(NodeManager.class).toInstance(context.getNodeManager());
                    }
            );

            Injector injector = app.strictConfig()
                    .doNotInitializeLogging()
                    .setRequiredConfigurationProperties(config)
                    .initialize();

            return injector.getInstance(EthereumConnector.class);
        }
        catch (Exception e) {
            throw Throwables.propagate(e);
        }
    }
项目:monarch    文件:AmpoolConnectorFactory.java   
public Connector create(final String connectorId, Map<String, String> requiredConfig,
                        ConnectorContext context) {
  requireNonNull(requiredConfig, "requiredConfig is null");

  final String
      locator_host =
      requiredConfig
          .getOrDefault(MonarchProperties.LOCATOR_HOST, MonarchProperties.LOCATOR_HOST_DEFAULT);
  final int
      locator_port =
      Integer.parseInt(requiredConfig
          .getOrDefault(MonarchProperties.LOCATOR_PORT, MonarchProperties.LOCATOR_PORT_DEFAULT));

  // Create a client that connects to the Ampool cluster via a locator (that is already running!).
  final Properties props = new Properties();
  props.setProperty(Constants.MClientCacheconfig.MONARCH_CLIENT_LOG, requiredConfig
      .getOrDefault(MonarchProperties.MONARCH_CLIENT_LOG, MonarchProperties.MONARCH_CLIENT_LOG_DEFAULT_LOCATION));
  final AmpoolClient aClient = new AmpoolClient(locator_host, locator_port, props);
  log.info("INFORMATION: AmpoolClient created successfully.");

  try {
    Bootstrap
        app =
        new Bootstrap(new AmpoolModule(connectorId, aClient, context.getTypeManager()));

    Injector injector = app
        .doNotInitializeLogging()
        .setRequiredConfigurationProperties(requiredConfig)
        .initialize();

    log.info("INFORMATION: Injector initialized successfully.");
    return injector.getInstance(AmpoolConnector.class);
  } catch (Exception e) {
    throw Throwables.propagate(e);
  }
}
项目:presto-kinesis    文件:KinesisConnectorFactory.java   
@Override
public Connector create(String connectorId, Map<String, String> config, ConnectorContext context)
{
    log.info("In connector factory create method.  Connector id: " + connectorId);
    requireNonNull(connectorId, "connectorId is null");
    requireNonNull(config, "config is null");

    try {
        Bootstrap app = new Bootstrap(
                new JsonModule(),
                new KinesisConnectorModule(),
                binder -> {
                    binder.bindConstant().annotatedWith(Names.named("connectorId")).to(connectorId);
                    binder.bind(ConnectorId.class).toInstance(new ConnectorId(connectorId));
                    binder.bind(TypeManager.class).toInstance(context.getTypeManager());
                    binder.bind(NodeManager.class).toInstance(context.getNodeManager());
                    // Note: moved creation from KinesisConnectorModule because connector manager accesses it earlier!
                    binder.bind(KinesisHandleResolver.class).toInstance(new KinesisHandleResolver(connectorName));

                    // Moved creation here from KinesisConnectorModule to make it easier to parameterize
                    if (altProviderClass.isPresent()) {
                        binder.bind(KinesisClientProvider.class).to(altProviderClass.get()).in(Scopes.SINGLETON);
                    }
                    else {
                        binder.bind(KinesisClientProvider.class).to(KinesisClientManager.class).in(Scopes.SINGLETON);
                    }

                    if (tableDescriptionSupplier.isPresent()) {
                        binder.bind(new TypeLiteral<Supplier<Map<SchemaTableName, KinesisStreamDescription>>>() {}).toInstance(tableDescriptionSupplier.get());
                    }
                    else {
                        binder.bind(new TypeLiteral<Supplier<Map<SchemaTableName, KinesisStreamDescription>>>() {}).to(KinesisTableDescriptionSupplier.class).in(Scopes.SINGLETON);
                    }
                }
        );

        this.injector = app.strictConfig()
                    .doNotInitializeLogging()
                    .setRequiredConfigurationProperties(config)
                    .setOptionalConfigurationProperties(optionalConfig)
                    .initialize();

        KinesisConnector connector = this.injector.getInstance(KinesisConnector.class);

        // Register objects for shutdown, at the moment only KinesisTableDescriptionSupplier
        if (!tableDescriptionSupplier.isPresent()) {
            // This will shutdown related dependent objects as well:
            KinesisTableDescriptionSupplier supp = getTableDescSupplier(this.injector);
            connector.registerShutdownObject(supp);
        }

        log.info("Done with injector.  Returning the connector itself.");
        return connector;
    }
    catch (Exception e) {
        throw Throwables.propagate(e);
    }
}