@Test public void directoryStoreAndSqliteWithLotsOfFilesWorks() throws Exception { final Path descriptorTestFolder = Files.createTempDirectory("descriptorTest"); final InputStream dataStream = getClass() .getResourceAsStream( "/dir/2JRLWGXFSDJUYUKADO7VFO3INL27WUXB2YDR5FCI3REQDTJGX6FULIDCIMYDV4H23PFUECWFYBMTIUTNY2ESAFMQADFCFUYBHBBJT4I="); final byte[] data = IOUtils.toByteArray(dataStream); if (!(ManagementFactory.getOperatingSystemMXBean() instanceof UnixOperatingSystemMXBean)) { return; } final UnixOperatingSystemMXBean osMxBean = (UnixOperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean(); final long descriptorCount = osMxBean.getMaxFileDescriptorCount(); if (descriptorCount > 35000) { return; } for (int i = 0; i < descriptorCount; i++) { final String filename = new Base32().encodeToString(String.valueOf(i).getBytes()); final Path newFile = descriptorTestFolder.resolve(filename); Files.write(newFile, data); } final String[] args = new String[] { "-storetype", "dir", "-inputpath", descriptorTestFolder.toString(), "-outputfile", outputPath.toString(), "-exporttype", "sqlite", "-dbpass", "-dbuser" }; commandLine.execute(args); final CliResult result = commandLine.getExecutionResult(); }
@Override public CliResult execute(String... args) throws Exception { final StoreLoader storeLoader = storeType.getLoader(); storeLoader.load(inputpath); final DataExporter dataExporter; if (exportType == ExportType.JDBC) { if (dbconfig == null) { throw new IllegalArgumentException("dbconfig file path is required when no export type is defined."); } final Properties properties = new Properties(); try (InputStream inStream = Files.newInputStream(dbconfig)) { properties.load(inStream); } final String insertRow = Objects.requireNonNull( properties.getProperty("insertRow"), "No insertRow value defined in config file. "); final String createTable = Objects.requireNonNull( properties.getProperty("createTable"), "No createTable value defined in config file. "); final String jdbcUrl = Objects.requireNonNull( properties.getProperty("jdbcUrl"), "No jdbcUrl value defined in config file. "); dataExporter = new JdbcDataExporter(jdbcUrl, insertRow, singletonList(createTable)); } else { dataExporter = DataExporterFactory.create(exportType); } dataExporter.export(storeLoader, outputFile, username, password); System.out.printf("Exported data to %s", Objects.toString(outputFile)); System.out.println(); return new CliResult(0, true, null); }
CmdLineExecutor implements CliAdapter, Callable<CliResult> { @Override public CliResult execute(String... args) throws Exception { final StoreLoader storeLoader = storeType.getLoader(); storeLoader.load(inputpath); final DataExporter dataExporter; if (exportType == ExportType.JDBC) { if (dbconfig == null) { throw new IllegalArgumentException("dbconfig file path is required when no export type is defined."); } final Properties properties = new Properties(); try (InputStream inStream = Files.newInputStream(dbconfig)) { properties.load(inStream); } final String insertRow = Objects.requireNonNull( properties.getProperty("insertRow"), "No insertRow value defined in config file. "); final String createTable = Objects.requireNonNull( properties.getProperty("createTable"), "No createTable value defined in config file. "); final String jdbcUrl = Objects.requireNonNull( properties.getProperty("jdbcUrl"), "No jdbcUrl value defined in config file. "); dataExporter = new JdbcDataExporter(jdbcUrl, insertRow, singletonList(createTable)); } else { dataExporter = DataExporterFactory.create(exportType); } dataExporter.export(storeLoader, outputFile, username, password); System.out.printf("Exported data to %s", Objects.toString(outputFile)); System.out.println(); return new CliResult(0, true, null); } }
CmdLineExecutor implements CliAdapter, Callable<CliResult> { @Override public CliResult execute(String... args) throws Exception { final StoreLoader storeLoader = storeType.getLoader(); storeLoader.load(inputpath); final DataExporter dataExporter; if (exportType == ExportType.JDBC) { if (dbconfig == null) { throw new IllegalArgumentException("dbconfig file path is required when no export type is defined."); } final Properties properties = new Properties(); try (InputStream inStream = Files.newInputStream(dbconfig)) { properties.load(inStream); } final String insertRow = Objects.requireNonNull( properties.getProperty("insertRow"), "No insertRow value defined in config file. "); final String createTable = Objects.requireNonNull( properties.getProperty("createTable"), "No createTable value defined in config file. "); final String jdbcUrl = Objects.requireNonNull( properties.getProperty("jdbcUrl"), "No jdbcUrl value defined in config file. "); dataExporter = new JdbcDataExporter(jdbcUrl, insertRow, singletonList(createTable)); } else { dataExporter = DataExporterFactory.create(exportType); } dataExporter.export(storeLoader, outputFile, username, password); System.out.printf("Exported data to %s", Objects.toString(outputFile)); System.out.println(); return new CliResult(0, true, null); }  }
CmdLineExecutor implements CliAdapter, Callable<CliResult> { @Override public CliResult execute(String... args) throws Exception { final StoreLoader storeLoader = storeType.getLoader(); storeLoader.load(inputpath); final DataExporter dataExporter; if (exportType == ExportType.JDBC) { if (dbconfig == null) { throw new IllegalArgumentException("dbconfig file path is required when no export type is defined."); } final Properties properties = new Properties(); try (InputStream inStream = Files.newInputStream(dbconfig)) { properties.load(inStream); } final String insertRow = Objects.requireNonNull( properties.getProperty("insertRow"), "No insertRow value defined in config file. "); final String createTable = Objects.requireNonNull( properties.getProperty("createTable"), "No createTable value defined in config file. "); final String jdbcUrl = Objects.requireNonNull( properties.getProperty("jdbcUrl"), "No jdbcUrl value defined in config file. "); dataExporter = new JdbcDataExporter(jdbcUrl, insertRow, singletonList(createTable)); } else { dataExporter = DataExporterFactory.create(exportType); } dataExporter.export(storeLoader, outputFile, username, password); System.out.printf("Exported data to %s", Objects.toString(outputFile)); System.out.println(); return new CliResult(0, true, null); }  @Override CliResult call(); @Override CliType getType(); @Override CliResult execute(String... args); }
CmdLineExecutor implements CliAdapter, Callable<CliResult> { @Override public CliResult execute(String... args) throws Exception { final StoreLoader storeLoader = storeType.getLoader(); storeLoader.load(inputpath); final DataExporter dataExporter; if (exportType == ExportType.JDBC) { if (dbconfig == null) { throw new IllegalArgumentException("dbconfig file path is required when no export type is defined."); } final Properties properties = new Properties(); try (InputStream inStream = Files.newInputStream(dbconfig)) { properties.load(inStream); } final String insertRow = Objects.requireNonNull( properties.getProperty("insertRow"), "No insertRow value defined in config file. "); final String createTable = Objects.requireNonNull( properties.getProperty("createTable"), "No createTable value defined in config file. "); final String jdbcUrl = Objects.requireNonNull( properties.getProperty("jdbcUrl"), "No jdbcUrl value defined in config file. "); dataExporter = new JdbcDataExporter(jdbcUrl, insertRow, singletonList(createTable)); } else { dataExporter = DataExporterFactory.create(exportType); } dataExporter.export(storeLoader, outputFile, username, password); System.out.printf("Exported data to %s", Objects.toString(outputFile)); System.out.println(); return new CliResult(0, true, null); }  @Override CliResult call(); @Override CliType getType(); @Override CliResult execute(String... args);  }