@Override public void upgrade(UpgradeContext context) throws Exception { final NamespaceService namespaceService = new NamespaceServiceImpl(context.getKVStoreProvider()); List<SourceConfig> sources = namespaceService.getSources(); for (SourceConfig sourceConfig : sources) { ConnectionConf<?, ?> connectionConf = context.getConnectionReader().getConnectionConf(sourceConfig); if (connectionConf instanceof S3PluginConfig) { S3PluginConfig s3PluginConfig = (S3PluginConfig) connectionConf; if ((s3PluginConfig.credentialType == AWSAuthenticationType.ACCESS_KEY) && isNullOrEmpty(s3PluginConfig.accessKey)) { s3PluginConfig.credentialType = AWSAuthenticationType.NONE; sourceConfig.setConnectionConf(s3PluginConfig); namespaceService.addOrUpdateSource(sourceConfig.getKey(), sourceConfig); } } } }
@Override public void upgrade(UpgradeContext context) { final NamespaceService namespace = new NamespaceServiceImpl(context.getKVStoreProvider()); for (SourceConfig sourceConfig : namespace.getSources()) { MetadataPolicy metadataPolicy = sourceConfig.getMetadataPolicy(); if (metadataPolicy != null) { long originalTTL = metadataPolicy.getDatasetDefinitionTtlMs(); metadataPolicy.setDatasetDefinitionRefreshAfterMs(originalTTL); if (originalTTL == ORIGINAL_DEFAULT_REFRESH_MILLIS) { metadataPolicy.setDatasetDefinitionExpireAfterMs(CatalogService.DEFAULT_EXPIRE_MILLIS); } else { metadataPolicy.setDatasetDefinitionExpireAfterMs(3 * originalTTL); } sourceConfig.setMetadataPolicy(metadataPolicy); System.out.println(" Updating source " + sourceConfig.getName()); try { namespace.addOrUpdateSource(new NamespaceKey(sourceConfig.getName()), sourceConfig); } catch (NamespaceException e) { Throwables.propagate(e); } } } }
public static SourceConfig addSourceWithRefreshAndGracePeriod(NamespaceService ns, String name, long refreshPeriod, long gracePeriod) throws Exception { final SourceConfig src = new SourceConfig() .setName(name) .setCtime(100L) .setLegacySourceTypeEnum(LegacySourceType.NAS) .setAccelerationRefreshPeriod(refreshPeriod) .setAccelerationGracePeriod(gracePeriod); ns.addOrUpdateSource(new NamespaceKey(name), src); return src; }
namespace.addOrUpdateSource(new NamespaceKey(sourceConfig.getName()), sourceConfig); } catch (NamespaceException e) { Throwables.propagate(e);
namespaceService.addOrUpdateSource(config.getKey(), config, attributes); } finally { if(pluginLock != null) {
@Test public void testPrivatesNoPrivateFields() throws Exception { final NASConf nasConf = new NASConf(); nasConf.path = "/mypath/"; SourceUI source = new SourceUI(); source.setConfig(nasConf); final NamespaceService namespaceService = newNamespaceService(); final NamespaceKey nameSpaceKey = new SourcePath("srcA").toNamespaceKey(); namespaceService.addOrUpdateSource(nameSpaceKey, source.asSourceConfig()); final SourceConfig config = namespaceService.getSource(nameSpaceKey); final ConnectionReader connectionReader = ConnectionReader.of(DremioTest.CLASSPATH_SCAN_RESULT, DremioTest.DEFAULT_SABOT_CONFIG); NASConf mySource = (NASConf) SourceUI.get(config, connectionReader).getConfig(); NASConf withPrivates = (NASConf) SourceUI.getWithPrivates(config, connectionReader).getConfig(); assertEquals(mySource, withPrivates); } }
namespaceService.addOrUpdateSource(new SourcePath("src").toNamespaceKey(), source.asSourceConfig());
@Test public void testPrivateFieldsSource() throws Exception { final SourceUI source = new SourceUI(); final APrivateSource priv = new APrivateSource(); priv.password = "ABC"; priv.username = "hello"; source.setConfig(priv); final NamespaceService namespaceService = newNamespaceService(); final NamespaceKey nameSpaceKey = new SourcePath("src").toNamespaceKey(); namespaceService.addOrUpdateSource(nameSpaceKey, source.asSourceConfig()); final SourceConfig config = namespaceService.getSource(nameSpaceKey); final ConnectionReader connectionReader = ConnectionReader.of(DremioTest.CLASSPATH_SCAN_RESULT, DremioTest.DEFAULT_SABOT_CONFIG); SourceUI mySource = SourceUI.get(config, connectionReader); APrivateSource myS3config = (APrivateSource) mySource.getConfig(); assertEquals(myS3config.password, ConnectionConf.USE_EXISTING_SECRET_VALUE); assertNotNull(myS3config.username); SourceUI withPrivatesSource = SourceUI.getWithPrivates(config, connectionReader); APrivateSource withPrivateS3Config = (APrivateSource) withPrivatesSource.getConfig(); assertNotNull(withPrivateS3Config.password); assertNotNull(withPrivateS3Config.username); assertEquals("ABC", withPrivateS3Config.password); assertEquals("hello", withPrivateS3Config.username); }
namespaceService.addOrUpdateSource(new NamespaceKey(src1.getName()), src1.setTag("0")); namespaceService.addOrUpdateSource(new NamespaceKey(src2.getName()), src2.setTag("0"));