private LogCopier(Builder builder) { this.srcFs = builder.srcFs; this.destFs = builder.destFs; this.srcLogDir = this.srcFs.makeQualified(builder.srcLogDir); this.destLogDir = this.destFs.makeQualified(builder.destLogDir); this.sourceLogFileMonitorInterval = builder.sourceLogFileMonitorInterval; this.copyInterval = builder.copyInterval; this.maxMinutesPerLogFile = builder.maxMinutesPerLogFile; this.maxBytesPerLogFile = builder.maxBytesPerLogFile; this.timeUnit = builder.timeUnit; this.logFileExtensions = builder.logFileExtensions; this.includingRegexPatterns = Optional.fromNullable(builder.includingRegexPatterns); this.excludingRegexPatterns = Optional.fromNullable(builder.excludingRegexPatterns); this.logFileNamePrefix = Optional.fromNullable(builder.logFileNamePrefix); this.linesWrittenBeforeFlush = builder.linesWrittenBeforeFlush; this.scheduler = TaskSchedulerFactory.get(builder.schedulerName, Optional.<String> absent()); }
/** * Gets an instance of the {@link TaskScheduler} with the specified type and ensures that it is started. If * the type is unknown an instance of the default {@link TaskScheduler} will be returned. * * @param type the type of the {@link TaskScheduler} * @param name the name associated threads created by the {@link TaskScheduler} * @param <K> the type of the key for the {@link ScheduledTask} * @param <T> the type of the {@link ScheduledTask} * @return an instance of {@link TaskScheduler} */ public static <K, T extends ScheduledTask<K>> TaskScheduler<K, T> get(String type, Optional<String> name) { TaskSchedulerType taskSchedulerType = TaskSchedulerType.parse(type); return get(taskSchedulerType, name); }
@Override protected TaskScheduler<String, Task> getTaskScheduler(String name) { return TaskSchedulerFactory.get("ScheduledExecutorService", Optional.of(name)); } }
@Override protected TaskScheduler<String, Task> getTaskScheduler(String name) { return TaskSchedulerFactory.get("HashedWheelTimer", Optional.of(name)); } }
@Test public void testGet() { TaskScheduler<Object, ScheduledTask<Object>> taskScheduler = TaskSchedulerFactory.get("", Optional.<String>absent()); Assert.assertTrue(Matchers.instanceOf(ScheduledExecutorServiceTaskScheduler.class).matches(taskScheduler)); taskScheduler = TaskSchedulerFactory.get(StringUtils.EMPTY, Optional.<String>absent()); Assert.assertTrue(Matchers.instanceOf(ScheduledExecutorServiceTaskScheduler.class).matches(taskScheduler)); taskScheduler = TaskSchedulerFactory.get("ScheduledExecutorService", Optional.<String>absent()); Assert.assertTrue(Matchers.instanceOf(ScheduledExecutorServiceTaskScheduler.class).matches(taskScheduler)); taskScheduler = TaskSchedulerFactory.get("HashedWheelTimer", Optional.<String>absent()); Assert.assertTrue(Matchers.instanceOf(HashedWheelTimerTaskScheduler.class).matches(taskScheduler)); } }
private LogCopier(Builder builder) { this.srcFs = builder.srcFs; this.destFs = builder.destFs; this.srcLogDir = this.srcFs.makeQualified(builder.srcLogDir); this.destLogDir = this.destFs.makeQualified(builder.destLogDir); this.sourceLogFileMonitorInterval = builder.sourceLogFileMonitorInterval; this.copyInterval = builder.copyInterval; this.maxMinutesPerLogFile = builder.maxMinutesPerLogFile; this.maxBytesPerLogFile = builder.maxBytesPerLogFile; this.timeUnit = builder.timeUnit; this.logFileExtensions = builder.logFileExtensions; this.includingRegexPatterns = Optional.fromNullable(builder.includingRegexPatterns); this.excludingRegexPatterns = Optional.fromNullable(builder.excludingRegexPatterns); this.logFileNamePrefix = Optional.fromNullable(builder.logFileNamePrefix); this.linesWrittenBeforeFlush = builder.linesWrittenBeforeFlush; this.scheduler = TaskSchedulerFactory.get(builder.schedulerName, Optional.<String> absent()); }
/** * Gets an instance of the {@link TaskScheduler} with the specified type and ensures that it is started. If * the type is unknown an instance of the default {@link TaskScheduler} will be returned. * * @param type the type of the {@link TaskScheduler} * @param name the name associated threads created by the {@link TaskScheduler} * @param <K> the type of the key for the {@link ScheduledTask} * @param <T> the type of the {@link ScheduledTask} * @return an instance of {@link TaskScheduler} */ public static <K, T extends ScheduledTask<K>> TaskScheduler<K, T> get(String type, Optional<String> name) { TaskSchedulerType taskSchedulerType = TaskSchedulerType.parse(type); return get(taskSchedulerType, name); }