public DynamicTaskExecutor( int initialProcessorCount, int maxProcessorCount, int maxQueueSize, ParkStrategy parkStrategy, String processorThreadNamePrefix ) { this( initialProcessorCount, maxProcessorCount, maxQueueSize, parkStrategy, processorThreadNamePrefix, Suppliers.singleton( null ) ); }
@Override public void bulk( @Nonnull Consumer<Log> consumer ) { PrintWriter writer; synchronized ( this ) { writer = writerSupplier.get(); consumer.accept( new ConsistencyReportLog( Suppliers.singleton( writer ), lock, false ) ); } } }
/** * Creates a {@link FormattedLogProvider} instance that writes messages to a {@link PrintWriter}. * * @param writer A {@link PrintWriter} to write to * @return A {@link FormattedLogProvider} instance that writes to the specified PrintWriter */ public FormattedLogProvider toPrintWriter( PrintWriter writer ) { return toPrintWriter( Suppliers.singleton( writer ) ); }
/** * Creates a {@link FormattedLogProvider} instance that writes messages to an {@link OutputStream}. * * @param out An {@link OutputStream} to write to * @return A {@link FormattedLogProvider} instance that writes to the specified OutputStream */ public FormattedLogProvider toOutputStream( OutputStream out ) { return toPrintWriter( Suppliers.singleton( OUTPUT_STREAM_CONVERTER.apply( out ) ) ); }
/** * Creates a {@link FormattedLog} instance that writes messages to an {@link OutputStream}. * * @param out An {@link OutputStream} to write to * @return A {@link FormattedLog} instance that writes to the specified OutputStream */ public FormattedLog toOutputStream( OutputStream out ) { return toPrintWriter( Suppliers.singleton( OUTPUT_STREAM_CONVERTER.apply( out ) ) ); }
/** * Creates a {@link FormattedLog} instance that writes messages to a {@link PrintWriter}. * * @param writer A {@link PrintWriter} to write to * @return A {@link FormattedLog} instance that writes to the specified PrintWriter */ public FormattedLog toPrintWriter( PrintWriter writer ) { return toPrintWriter( Suppliers.singleton( writer ) ); }
@Override protected Logger getBulkLogger( @Nonnull PrintWriter out, @Nonnull Object lock ) { return new ConsistencyReportLogger( Suppliers.singleton( out ), lock, prefix, false ); } }
@Override protected Logger getBulkLogger( @Nonnull PrintWriter out, @Nonnull Object lock ) { return new FormattedLogger( formattedLog, Suppliers.singleton( out ), prefix, DATE_TIME_FORMATTER, () -> DEFAULT_CURRENT_DATE_TIME.apply( formattedLog.zoneId ) ); }
public static <T> UsageDataKey<T> key( String name, T defaultVal ) { return new UsageDataKey<>( name, singleton( defaultVal ) ); }
@Override public void bulk( @Nonnull Consumer<Log> consumer ) { PrintWriter writer; synchronized ( lock ) { writer = writerSupplier.get(); consumer.accept( new FormattedLog( Suppliers.singleton( writer ), zoneId, lock, category, levelRef.get(), false ) ); } if ( autoFlush ) { writer.flush(); } }
public Future<Void> cancel() { // Stop the population if ( storeScan != null ) { cancelled = true; storeScan.stop(); } return latchGuardedValue( Suppliers.singleton( null ), doneSignal, "Index population job cancel" ); }
private static FormattedLogProvider newFormattedLogProvider( StringWriter writer, Map<String, Level> levels ) { return new FormattedLogProvider( Suppliers.singleton( new PrintWriter( writer ) ), ZoneOffset.UTC, true, levels, Level.INFO, true ); } }
@Test void singletonSupplierShouldAlwaysReturnSame() { Object o = new Object(); Supplier<Object> supplier = Suppliers.singleton( o ); assertThat( supplier.get(), sameInstance( o ) ); assertThat( supplier.get(), sameInstance( o ) ); assertThat( supplier.get(), sameInstance( o ) ); }
private static FormattedLog newFormattedLog( StringWriter writer, Level level ) { return FormattedLog .withUTCTimeZone() .withCategory( "test" ) .withLogLevel( level ) .withTimeSupplier( DATE_TIME_SUPPLIER ) .toPrintWriter( Suppliers.singleton( new PrintWriter( writer ) ) ); }
@Test public void shouldClearPreviousChunks() { // GIVEN Consumer<long[]> consumer = mock( Consumer.class ); final AtomicBoolean safeThreshold = new AtomicBoolean( false ); DelayedBuffer<Long> buffer = new DelayedBuffer<>( singleton( 0L ), t -> safeThreshold.get(), 10, consumer ); // three chunks buffer.offer( 0 ); buffer.maintenance(); buffer.offer( 1 ); buffer.maintenance(); buffer.offer( 2 ); buffer.maintenance(); // WHEN safeThreshold.set( true ); buffer.clear(); buffer.maintenance(); // THEN verifyNoMoreInteractions( consumer ); }
@Test public void shouldClearCurrentChunk() { // GIVEN Consumer<long[]> consumer = mock( Consumer.class ); DelayedBuffer<Long> buffer = new DelayedBuffer<>( singleton( 0L ), Predicates.alwaysTrue(), 10, consumer ); buffer.offer( 0 ); buffer.offer( 1 ); buffer.offer( 2 ); // WHEN buffer.clear(); buffer.maintenance(); // THEN verifyNoMoreInteractions( consumer ); }
public DynamicTaskExecutor( int initialProcessorCount, int maxProcessorCount, int maxQueueSize, ParkStrategy parkStrategy, String processorThreadNamePrefix ) { this( initialProcessorCount, maxProcessorCount, maxQueueSize, parkStrategy, processorThreadNamePrefix, Suppliers.singleton( null ) ); }
@Override protected Logger getBulkLogger( @Nonnull PrintWriter out, @Nonnull Object lock ) { return new FormattedLogger( formattedLog, Suppliers.singleton( out ), prefix, DATE_TIME_FORMATTER, () -> DEFAULT_CURRENT_DATE_TIME.apply( formattedLog.zoneId ) ); }
/** * Creates a {@link FormattedLog} instance that writes messages to an {@link OutputStream}. * * @param out An {@link OutputStream} to write to * @return A {@link FormattedLog} instance that writes to the specified OutputStream */ public FormattedLog toOutputStream( OutputStream out ) { return toPrintWriter( Suppliers.singleton( OUTPUT_STREAM_CONVERTER.apply( out ) ) ); }
public Future<Void> cancel() { // Stop the population if ( storeScan != null ) { cancelled = true; storeScan.stop(); } return latchGuardedValue( Suppliers.singleton( null ), doneSignal, "Index population job cancel" ); }