Search in sources :

Example 1 with ConnectorPluginManager

use of com.thinkbiganalytics.kylo.catalog.ConnectorPluginManager in project kylo by Teradata.

the class CatalogMetadataConfig method doPluginSyncAction.

private void doPluginSyncAction(ConnectorPluginManager pluginMgr, MetadataAccess metadata) {
    metadata.commit(() -> {
        List<ConnectorPlugin> plugins = pluginMgr.getPlugins();
        Map<String, Connector> connectorMap = connectorProvider().findAll(true).stream().collect(Collectors.toMap(Connector::getPluginId, c -> c));
        for (ConnectorPlugin plugin : plugins) {
            Connector connector = connectorMap.get(plugin.getId());
            ConnectorPluginDescriptor descr = plugin.getDescriptor();
            if (connector != null) {
                connectorMap.get(plugin.getId()).setActive(true);
                connectorMap.remove(plugin.getId());
            } else {
                String title = descr.getTitle();
                connector = connectorProvider().create(plugin.getId(), title);
            }
            connector.setIconColor(descr.getColor());
            connector.setIcon(descr.getIcon());
            if (StringUtils.isNotBlank(descr.getFormat())) {
                connector.getSparkParameters().setFormat(descr.getFormat());
            }
        }
        // least one data source, or removed if they don't.
        for (Connector connector : connectorMap.values()) {
            if (connector.getDataSources().isEmpty()) {
                connectorProvider().deleteById(connector.getId());
            } else {
                connector.setActive(false);
            }
        }
    }, MetadataAccess.SERVICE);
}
Also used : ConnectorProvider(com.thinkbiganalytics.metadata.api.catalog.ConnectorProvider) JcrDataSourceProvider(com.thinkbiganalytics.metadata.modeshape.catalog.datasource.JcrDataSourceProvider) Logger(org.slf4j.Logger) Session(javax.jcr.Session) ConnectorPlugin(com.thinkbiganalytics.kylo.catalog.spi.ConnectorPlugin) ConnectorAlreadyExistsException(com.thinkbiganalytics.metadata.api.catalog.ConnectorAlreadyExistsException) DataSourceProvider(com.thinkbiganalytics.metadata.api.catalog.DataSourceProvider) ConnectorPluginManager(com.thinkbiganalytics.kylo.catalog.ConnectorPluginManager) PostMetadataConfigAction(com.thinkbiganalytics.metadata.api.PostMetadataConfigAction) LoggerFactory(org.slf4j.LoggerFactory) StringUtils(org.apache.commons.lang3.StringUtils) Collectors(java.util.stream.Collectors) Configuration(org.springframework.context.annotation.Configuration) JcrDataSetProvider(com.thinkbiganalytics.metadata.modeshape.catalog.dataset.JcrDataSetProvider) List(java.util.List) DataSetProvider(com.thinkbiganalytics.metadata.api.catalog.DataSetProvider) ConnectorPluginDescriptor(com.thinkbiganalytics.kylo.catalog.rest.model.ConnectorPluginDescriptor) Connector(com.thinkbiganalytics.metadata.api.catalog.Connector) Workspace(org.modeshape.jcr.api.Workspace) Map(java.util.Map) JcrConnectorProvider(com.thinkbiganalytics.metadata.modeshape.catalog.connector.JcrConnectorProvider) Bean(org.springframework.context.annotation.Bean) MetadataAccess(com.thinkbiganalytics.metadata.api.MetadataAccess) JcrMetadataAccess(com.thinkbiganalytics.metadata.modeshape.JcrMetadataAccess) ConnectorPlugin(com.thinkbiganalytics.kylo.catalog.spi.ConnectorPlugin) Connector(com.thinkbiganalytics.metadata.api.catalog.Connector) ConnectorPluginDescriptor(com.thinkbiganalytics.kylo.catalog.rest.model.ConnectorPluginDescriptor)

Example 2 with ConnectorPluginManager

use of com.thinkbiganalytics.kylo.catalog.ConnectorPluginManager in project kylo by Teradata.

the class TestSpringConfiguration method connectorPluginManager.

@Bean
public ConnectorPluginManager connectorPluginManager() {
    ConnectorPluginDescriptor descr = new ConnectorPluginDescriptor("dummy", "Dummy Connector", "jdbc");
    ConnectorPlugin plugin = Mockito.mock(ConnectorPlugin.class);
    Mockito.when(plugin.getDescriptor()).thenReturn(descr);
    ConnectorPluginManager mgr = Mockito.mock(ConnectorPluginManager.class);
    Mockito.when(mgr.getPlugin(anyString())).thenReturn(Optional.of(plugin));
    return mgr;
}
Also used : ConnectorPlugin(com.thinkbiganalytics.kylo.catalog.spi.ConnectorPlugin) ConnectorPluginManager(com.thinkbiganalytics.kylo.catalog.ConnectorPluginManager) ConnectorPluginDescriptor(com.thinkbiganalytics.kylo.catalog.rest.model.ConnectorPluginDescriptor) Bean(org.springframework.context.annotation.Bean)

Example 3 with ConnectorPluginManager

use of com.thinkbiganalytics.kylo.catalog.ConnectorPluginManager in project kylo by Teradata.

the class TemporaryConnectorPluginConfig method connectorPluginManager.

@Bean
public ConnectorPluginManager connectorPluginManager(Optional<List<ConnectorPlugin>> plugins) {
    List<ConnectorPlugin> list = plugins.orElse(Collections.emptyList());
    ConnectorPluginManager mgr = new DefaultConnectorPluginManager();
    list.forEach(plugin -> mgr.register(plugin));
    return mgr;
}
Also used : ConnectorPlugin(com.thinkbiganalytics.kylo.catalog.spi.ConnectorPlugin) ConnectorPluginManager(com.thinkbiganalytics.kylo.catalog.ConnectorPluginManager) Bean(org.springframework.context.annotation.Bean)

Aggregations

ConnectorPluginManager (com.thinkbiganalytics.kylo.catalog.ConnectorPluginManager)3 ConnectorPlugin (com.thinkbiganalytics.kylo.catalog.spi.ConnectorPlugin)3 Bean (org.springframework.context.annotation.Bean)3 ConnectorPluginDescriptor (com.thinkbiganalytics.kylo.catalog.rest.model.ConnectorPluginDescriptor)2 MetadataAccess (com.thinkbiganalytics.metadata.api.MetadataAccess)1 PostMetadataConfigAction (com.thinkbiganalytics.metadata.api.PostMetadataConfigAction)1 Connector (com.thinkbiganalytics.metadata.api.catalog.Connector)1 ConnectorAlreadyExistsException (com.thinkbiganalytics.metadata.api.catalog.ConnectorAlreadyExistsException)1 ConnectorProvider (com.thinkbiganalytics.metadata.api.catalog.ConnectorProvider)1 DataSetProvider (com.thinkbiganalytics.metadata.api.catalog.DataSetProvider)1 DataSourceProvider (com.thinkbiganalytics.metadata.api.catalog.DataSourceProvider)1 JcrMetadataAccess (com.thinkbiganalytics.metadata.modeshape.JcrMetadataAccess)1 JcrConnectorProvider (com.thinkbiganalytics.metadata.modeshape.catalog.connector.JcrConnectorProvider)1 JcrDataSetProvider (com.thinkbiganalytics.metadata.modeshape.catalog.dataset.JcrDataSetProvider)1 JcrDataSourceProvider (com.thinkbiganalytics.metadata.modeshape.catalog.datasource.JcrDataSourceProvider)1 List (java.util.List)1 Map (java.util.Map)1 Collectors (java.util.stream.Collectors)1 Session (javax.jcr.Session)1 StringUtils (org.apache.commons.lang3.StringUtils)1