public StoragePluginId( SourceConfig config, ConnectionConf<?, ?> connection, SourceCapabilities capabilities ) { this.config = Preconditions.checkNotNull(config); this.connection = connection; this.capabilities = capabilities; this.hashCode = Objects.hashCode(config, capabilities); assert Arrays.equals(connection.toBytes(), config.getConfig().toByteArray()); }
@Override public ConnectionConf<?, ?> getConnectionConf(SourceConfig config) { return (ConnectionConf<?, ?>) getConnectionConf(ConnectionReader.toType(config), config.getConfig()); }
@Override public void upgrade(UpgradeContext context) throws Exception { final NamespaceService namespaceService = new NamespaceServiceImpl(context.getKVStoreProvider()); List<SourceConfig> sources = namespaceService.getSources(); for (SourceConfig sourceConfig : sources) { // Pre-1.5, the config object for internal sources was null. Deleting the internal sources without a config will // ensure that they get recreated on startup. if (sourceConfig.getConfig() == null) { System.out.printf(" deleting '%s'%n", sourceConfig.getName()); // following may throw an exception, we let it propagate to fail the upgrade namespaceService.deleteSource(sourceConfig.getKey(), sourceConfig.getTag()); } } }
@Test public void testNASFileStore() throws Exception { final CatalogServiceImpl catalog = (CatalogServiceImpl) l(CatalogService.class); final SourceConfig config = catalog.getManagedSource(HomeFileSystemStoragePlugin.HOME_PLUGIN_NAME).getId().getClonedConfig(); final ByteString oldConfig = config.getConfig(); final HomeFileConf nasHomeFileStore = new HomeFileConf(new Path("file:///" + BaseTestServer.folder1.getRoot().toString() + "/" + "testNASFileStore/").toString(), "localhost"); nasHomeFileStore.getFilesystemAndCreatePaths("localhost"); config.setConnectionConf(nasHomeFileStore); catalog.getSystemUserCatalog().updateSource(config); HomeFileTool tool = l(HomeFileTool.class); try { runTests(nasHomeFileStore); } finally { tool.clear(); // reset plugin SourceConfig backConfig = catalog.getManagedSource(HomeFileSystemStoragePlugin.HOME_PLUGIN_NAME).getId().getClonedConfig(); backConfig.setConfig(oldConfig); catalog.getSystemUserCatalog().updateSource(backConfig); } }