Ejemplo n.º 1
0
  public synchronized void createConnection(
      String catalogName, String connectorName, Map<String, String> properties) {
    checkNotNull(catalogName, "catalogName is null");
    checkNotNull(connectorName, "connectorName is null");
    checkNotNull(properties, "properties is null");

    ConnectorFactory connectorFactory = connectorFactories.get(connectorName);
    checkArgument(connectorFactory != null, "No factory for connector %s", connectorName);
    try (ThreadContextClassLoader ignored =
        new ThreadContextClassLoader(connectorFactory.getClass().getClassLoader())) {
      createConnection(catalogName, connectorFactory, properties);
    }
  }
Ejemplo n.º 2
0
 public void createCatalog(
     String catalogName, ConnectorFactory connectorFactory, Map<String, String> properties) {
   nodeManager.addCurrentNodeDatasource(catalogName);
   connectorManager.createConnection(catalogName, connectorFactory, properties);
 }
Ejemplo n.º 3
0
 public void createCatalog(
     String catalogName, String connectorName, Map<String, String> properties) {
   connectorManager.createConnection(catalogName, connectorName, properties);
   updateDatasourcesAnnouncement(announcer, catalogName);
 }
Ejemplo n.º 4
0
  public LocalQueryRunner(Session defaultSession) {
    requireNonNull(defaultSession, "defaultSession is null");
    this.executor = newCachedThreadPool(daemonThreadsNamed("local-query-runner-%s"));

    this.sqlParser = new SqlParser();
    this.nodeManager = new InMemoryNodeManager();
    this.typeRegistry = new TypeRegistry();
    this.indexManager = new IndexManager();
    this.pageSinkManager = new PageSinkManager();

    this.splitManager = new SplitManager();
    this.blockEncodingSerde = new BlockEncodingManager(typeRegistry);
    this.metadata =
        new MetadataManager(
            new FeaturesConfig().setExperimentalSyntaxEnabled(true),
            typeRegistry,
            splitManager,
            blockEncodingSerde,
            new SessionPropertyManager(),
            new TablePropertyManager());
    this.accessControl = new TestingAccessControlManager();
    this.pageSourceManager = new PageSourceManager();

    this.compiler = new ExpressionCompiler(metadata);

    this.connectorManager =
        new ConnectorManager(
            metadata,
            accessControl,
            splitManager,
            pageSourceManager,
            indexManager,
            pageSinkManager,
            new HandleResolver(),
            ImmutableMap.<String, ConnectorFactory>of(),
            nodeManager);

    Connector systemConnector =
        new SystemConnector(
            nodeManager,
            ImmutableSet.of(
                new NodeSystemTable(nodeManager),
                new CatalogSystemTable(metadata),
                new TablePropertiesSystemTable(metadata)));

    connectorManager.createConnection(SystemConnector.NAME, systemConnector);

    // rewrite session to use managed SessionPropertyMetadata
    this.defaultSession =
        new Session(
            defaultSession.getIdentity(),
            defaultSession.getSource(),
            defaultSession.getCatalog(),
            defaultSession.getSchema(),
            defaultSession.getTimeZoneKey(),
            defaultSession.getLocale(),
            defaultSession.getRemoteUserAddress(),
            defaultSession.getUserAgent(),
            defaultSession.getStartTime(),
            defaultSession.getSystemProperties(),
            defaultSession.getCatalogProperties(),
            metadata.getSessionPropertyManager());

    dataDefinitionTask =
        ImmutableMap.<Class<? extends Statement>, DataDefinitionTask<?>>builder()
            .put(CreateTable.class, new CreateTableTask())
            .put(
                CreateView.class,
                new CreateViewTask(
                    jsonCodec(ViewDefinition.class),
                    sqlParser,
                    accessControl,
                    new FeaturesConfig()))
            .put(DropTable.class, new DropTableTask())
            .put(DropView.class, new DropViewTask())
            .put(RenameColumn.class, new RenameColumnTask())
            .put(RenameTable.class, new RenameTableTask())
            .put(ResetSession.class, new ResetSessionTask())
            .put(SetSession.class, new SetSessionTask())
            .build();
  }
Ejemplo n.º 5
0
 @Inject
 public SystemTablesRegistrar(
     ConnectorManager manager, GlobalSystemConnectorFactory globalSystemConnectorFactory) {
   manager.createConnection(
       GlobalSystemConnector.NAME, globalSystemConnectorFactory, ImmutableMap.of());
 }