Search in sources :

Example 1 with ConnectorFactory

use of com.netflix.metacat.common.server.connectors.ConnectorFactory in project metacat by Netflix.

the class ConnectorManager method getConnectorFactory.

/**
     * Returns the connector factory for the given <code>catalogName</code>.
     *
     * @param catalogName catalog name
     * @return Returns the connector factory for the given <code>catalogName</code>
     */
private ConnectorFactory getConnectorFactory(final String catalogName) {
    Preconditions.checkNotNull(catalogName, "catalogName is null");
    final ConnectorFactory result = connectorFactories.get(catalogName);
    if (result == null) {
        throw new CatalogNotFoundException(catalogName);
    }
    return result;
}
Also used : ConnectorFactory(com.netflix.metacat.common.server.connectors.ConnectorFactory) CatalogNotFoundException(com.netflix.metacat.common.server.connectors.exception.CatalogNotFoundException)

Example 2 with ConnectorFactory

use of com.netflix.metacat.common.server.connectors.ConnectorFactory in project metacat by Netflix.

the class ConnectorManager method createConnection.

/**
     * Creates a connection for the given catalog.
     *
     * @param catalogName   catalog name
     * @param connectorType connector type
     * @param properties    properties
     */
synchronized void createConnection(final String catalogName, final String connectorType, final Map<String, String> properties, final Registry registry) {
    Preconditions.checkState(!stopped.get(), "ConnectorManager is stopped");
    Preconditions.checkNotNull(catalogName, "catalogName is null");
    Preconditions.checkNotNull(connectorType, "connectorName is null");
    Preconditions.checkNotNull(properties, "properties is null");
    final ConnectorPlugin connectorPlugin = plugins.get(connectorType);
    if (connectorPlugin != null) {
        Preconditions.checkState(!connectorFactories.containsKey(catalogName), "A connector %s already exists", catalogName);
        final ConnectorFactory connectorFactory = connectorPlugin.create(this.config, catalogName, properties, registry);
        connectorFactories.put(catalogName, connectorFactory);
        final MetacatCatalogConfig catalogConfig = MetacatCatalogConfig.createFromMapAndRemoveProperties(connectorType, properties);
        catalogs.put(catalogName, catalogConfig);
    } else {
        log.warn("No plugin for connector with type %s", connectorType);
    }
}
Also used : ConnectorPlugin(com.netflix.metacat.common.server.connectors.ConnectorPlugin) ConnectorFactory(com.netflix.metacat.common.server.connectors.ConnectorFactory) MetacatCatalogConfig(com.netflix.metacat.main.spi.MetacatCatalogConfig)

Aggregations

ConnectorFactory (com.netflix.metacat.common.server.connectors.ConnectorFactory)2 ConnectorPlugin (com.netflix.metacat.common.server.connectors.ConnectorPlugin)1 CatalogNotFoundException (com.netflix.metacat.common.server.connectors.exception.CatalogNotFoundException)1 MetacatCatalogConfig (com.netflix.metacat.main.spi.MetacatCatalogConfig)1