@Test public void testIOString() throws Exception { StringBuilder sb = new StringBuilder(); iterable( byteCollection() ).transferTo( map( valueSerialization.serialize(), text( sb ) ) ); String output = sb.toString(); List<Byte> list = new ArrayList<Byte>(); text( output ).transferTo( map( valueSerialization.deserialize( Byte.class ), collection( list ) ) ); assertEquals( byteCollection(), list ); }
@Override public synchronized void run() { // TODO This should optionally use a CircuitBreaker if (started && configuration.get().enabled().get()) { Transforms.Counter counter = new Transforms.Counter(); try { long currentOffset = configuration.get().lastOffset().get(); source.events( currentOffset, Long.MAX_VALUE ).transferTo( Transforms.map( counter, output ) ); // Save new offset, to be used in next round configuration.get().lastOffset().set( currentOffset+counter.count() ); configuration.save(); } catch (Throwable throwable) { logger.warn( "Event handling failed", throwable ); } } }