Search in sources :

Example 1 with ConnectorPlugin

use of com.netflix.metacat.common.server.connectors.ConnectorPlugin 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)

Example 2 with ConnectorPlugin

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

the class ConnectorManager method getPlugin.

/**
     * Returns the connector plugin for the given <code>catalogName</code>.
     *
     * @param connectorType connector type
     * @return Returns the plugin for the given <code>catalogName</code>
     */
private ConnectorPlugin getPlugin(final String connectorType) {
    Preconditions.checkNotNull(connectorType, "connectorType is null");
    final ConnectorPlugin result = plugins.get(connectorType);
    Preconditions.checkNotNull(result, "No connector plugin exists for type %s", connectorType);
    return result;
}
Also used : ConnectorPlugin(com.netflix.metacat.common.server.connectors.ConnectorPlugin)

Example 3 with ConnectorPlugin

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

the class PluginManager method loadPlugins.

/**
     * Loads the plugins.
     *
     * @throws Exception error
     */
public void loadPlugins() throws Exception {
    if (!this.pluginsLoading.compareAndSet(false, true)) {
        return;
    }
    final ServiceLoader<ConnectorPlugin> serviceLoader = ServiceLoader.load(ConnectorPlugin.class, this.getClass().getClassLoader());
    final List<ConnectorPlugin> connectorPlugins = ImmutableList.copyOf(serviceLoader);
    if (connectorPlugins.isEmpty()) {
        log.warn("No service providers of type {}", ConnectorPlugin.class.getName());
    }
    for (ConnectorPlugin connectorPlugin : connectorPlugins) {
        log.info("Installing {}", connectorPlugin.getClass().getName());
        this.installPlugin(connectorPlugin);
        log.info("-- Finished loading plugin {} --", connectorPlugin.getClass().getName());
    }
    this.pluginsLoaded.set(true);
}
Also used : ConnectorPlugin(com.netflix.metacat.common.server.connectors.ConnectorPlugin)

Aggregations

ConnectorPlugin (com.netflix.metacat.common.server.connectors.ConnectorPlugin)3 ConnectorFactory (com.netflix.metacat.common.server.connectors.ConnectorFactory)1 MetacatCatalogConfig (com.netflix.metacat.main.spi.MetacatCatalogConfig)1