Beispiel #1
0
 public void addConnectorFactory(ConnectorFactory connectorFactory) {
   ConnectorFactory existingConnectorFactory =
       connectorFactories.putIfAbsent(connectorFactory.getName(), connectorFactory);
   checkArgument(
       existingConnectorFactory == null,
       "Connector %s is already registered",
       connectorFactory.getName());
 }
Beispiel #2
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);
    }
  }
Beispiel #3
0
  public synchronized void createConnection(
      String catalogName, ConnectorFactory connectorFactory, Map<String, String> properties) {
    checkNotNull(catalogName, "catalogName is null");
    checkNotNull(properties, "properties is null");
    checkNotNull(connectorFactory, "connectorFactory is null");

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

    Connector connector = connectorFactory.create(connectorId, properties);
    connectors.put(connectorId, connector);

    addConnector(catalogName, connectorId, connector);
  }