/** * Creates the transfer manager factory builder from the {@link Config} * using the configured {@link TransferPlugin}. Using this builder, the * feature-wrapped transfer manager can be built. * * @see TransferManagerBuilder * @param config Local folder configuration with transfer plugin settings * @return Transfer manager builder */ public static TransferManagerBuilder build(Config config) throws StorageException { TransferManager transferManager = config.getTransferPlugin().createTransferManager(config.getConnection(), config); logger.log(Level.INFO, "Building " + transferManager.getClass().getSimpleName() + " from config '" + config.getLocalDir().getName() + "' ..."); return new TransferManagerBuilder(config, transferManager); }
@Override public String getString(TransferPlugin plugin) { return plugin.getId(); } });
public static TransferSettings createTestLocalConnection() throws Exception { TransferPlugin plugin = Plugins.get("local", TransferPlugin.class); LocalTransferSettings conn = plugin.createEmptySettings(); File tempRepoDir = TestFileUtil.createTempDirectoryInSystemTemp(createUniqueName("repo", conn)); conn.setPath(tempRepoDir); // TODO [medium] : possible problem plugin.createTransferManager(conn, null).init(true); return conn; }
protected TransferSettings createTransferSettingsFromOptions(OptionSet options, OptionSpec<String> optionPlugin, OptionSpec<String> optionPluginOpts) throws Exception { TransferPlugin plugin; TransferSettings transferSettings; // Parse --plugin and --plugin-option values List<String> pluginOptionStrings = options.valuesOf(optionPluginOpts); Map<String, String> knownPluginSettings = parsePluginSettingsFromOptions(pluginOptionStrings); // Validation of some constraints if (!options.has(optionPlugin) && knownPluginSettings.size() > 0) { throw new IllegalArgumentException("Provided plugin settings without a plugin name."); } plugin = options.has(optionPlugin) ? initPlugin(options.valueOf(optionPlugin)) : askPlugin(); transferSettings = askPluginSettings(plugin.createEmptySettings(), knownPluginSettings); return transferSettings; }
TransferSettings childSettings = childPlugin.createEmptySettings();
public static InitOperationOptions createTestInitOperationOptions(String machineName) throws Exception { File tempLocalDir = TestFileUtil.createTempDirectoryInSystemTemp(createUniqueName("client-" + machineName, machineName)); File tempRepoDir = TestFileUtil.createTempDirectoryInSystemTemp(createUniqueName("repo", machineName)); tempLocalDir.mkdirs(); tempRepoDir.mkdirs(); RepoTO repoTO = createRepoTO(); // Create config TO ConfigTO configTO = new ConfigTO(); configTO.setMachineName(machineName + Math.abs(new Random().nextInt())); // Get Masterkey SaltedSecretKey masterKey = getMasterKey(); configTO.setMasterKey(masterKey); // Generic connection settings wont work anymore, because they are plugin dependent now. LocalTransferSettings transferSettings = Plugins.get("local", TransferPlugin.class).createEmptySettings(); transferSettings.setPath(tempRepoDir); configTO.setTransferSettings(transferSettings); InitOperationOptions operationOptions = new InitOperationOptions(); operationOptions.setLocalDir(tempLocalDir); operationOptions.setConfigTO(configTO); operationOptions.setRepoTO(repoTO); operationOptions.setEncryptionEnabled(cryptoEnabled); operationOptions.setCipherSpecs(CipherSpecs.getDefaultCipherSpecs()); operationOptions.setPassword(cryptoEnabled ? "some password" : null); return operationOptions; }
protected TransferManager createTransferManagerFromNullConfig(ConfigTO configTo) throws IllegalAccessException, InvocationTargetException, InstantiationException, NoSuchMethodException, StorageException { // Init plugin and transfer manager TransferPlugin plugin = Plugins.get(configTo.getTransferSettings().getType(), TransferPlugin.class); TransferSettings transferSettings = configTo.getTransferSettings(); transferSettings.setUserInteractionListener(listener); TransferManager transferManager = plugin.createTransferManager(transferSettings, config); // constructor is not visible and config seems to be null at this point, hence we cannot use the build method here Constructor<TransferManagerBuilder> tmbConstructor = TransferManagerBuilder.class.getDeclaredConstructor(Config.class, TransferManager.class); tmbConstructor.setAccessible(true); return tmbConstructor.newInstance(config, transferManager) .withFeature(ReadAfterWriteConsistent.class) .asDefault(); } }
private String findPluginId() { Class<? extends TransferPlugin> transferPluginClass = TransferPluginUtil.getTransferPluginClass(this.getClass()); try { if (transferPluginClass != null) { return transferPluginClass.newInstance().getId(); } throw new RuntimeException("Unable to read type: No TransferPlugin is defined for these settings"); } catch (Exception e) { logger.log(Level.SEVERE, "Unable to read type: No TransferPlugin is defined for these settings", e); throw new RuntimeException("Unable to read type: No TransferPlugin is defined for these settings", e); } }
public static InitOperationOptions createTestUnreliableInitOperationOptions(String machineName, List<String> failingOperationPatterns) throws Exception { InitOperationOptions initOperationOptions = createTestInitOperationOptions(machineName); // createTestInitOperationOptions always returns LocalTransferSettings File tempRpoDir = ((LocalTransferSettings) initOperationOptions.getConfigTO().getTransferSettings()).getPath(); UnreliableLocalTransferSettings transferSettings = Plugins.get("unreliable_local", TransferPlugin.class).createEmptySettings(); transferSettings.setPath(tempRpoDir); transferSettings.setFailingOperationPatterns(failingOperationPatterns); initOperationOptions.getConfigTO().setTransferSettings(transferSettings); return initOperationOptions; }
Map<ChunkChecksum, MultiChunkId> multiChunks = localDatabase.getMultiChunkIdsByChecksums(fileContent.getChunks()); TransferManager transferManager = config.getTransferPlugin().createTransferManager(config.getConnection(), config); Downloader downloader = new Downloader(config, transferManager); Assembler assembler = new Assembler(config, localDatabase);