@Test public void testCycleTimeBased() throws Exception { Topology t = newTopology("testCycleTimeBased"); // establish a base path Path basePath = createTempFile("test1", "txt", new String[0]); String[] lines = getLines(); // build expected results // net one tuple per file with 250msec cycle config and 1 throttle List<List<String>> expResults = buildExpResults(lines, tuple -> true); // add delay so time cycle happens // also verifies only cycle if there's something to cycle // (i.e., these cycles happen faster than tuples are written) int throttleSec = 1; TStream<String> s = PlumbingStreams.blockingThrottle( t.strings(lines), throttleSec, TimeUnit.SECONDS); IFileWriterPolicy<String> policy = new FileWriterPolicy<String>( FileWriterFlushConfig.newImplicitConfig(), FileWriterCycleConfig.newTimeBasedConfig(TimeUnit.MILLISECONDS.toMillis(250)), FileWriterRetentionConfig.newFileCountBasedConfig(10) ); FileStreams.textFileWriter(s, () -> basePath.toString(), () -> policy); completeAndValidateWriter(t, (lines.length*throttleSec)+TMO_SEC, basePath, expResults); }
expectIAE(() -> FileWriterCycleConfig.newCountBasedConfig(0)); cfg = FileWriterCycleConfig.newTimeBasedConfig(10); checkFileWriterConfig(cfg, 0, 0, 10, null, trueTuple, falseTuple); expectIAE(() -> FileWriterCycleConfig.newTimeBasedConfig(0));