use of com.hazelcast.function.FunctionEx in project hazelcast by hazelcast.
the class OrderedStreamParallelismTest method applyTransformAndGetDag.
private DAG applyTransformAndGetDag(FunctionEx<StreamStage<Integer>, StreamStage<Integer>> transform) {
PipelineImpl p = (PipelineImpl) Pipeline.create().setPreserveOrder(true);
StreamStage<Integer> source = p.readFrom(TestSources.items(1)).setLocalParallelism(UPSTREAM_PARALLELISM).addTimestamps(t -> 0, Long.MAX_VALUE);
StreamStage<Integer> applied = source.apply(transform);
applied.mapStateful(LongAccumulator::new, (s, x) -> x).writeTo(Sinks.noop());
return p.toDag(PIPELINE_CTX);
}
use of com.hazelcast.function.FunctionEx in project hazelcast by hazelcast.
the class StreamJmsPTest method initializeProcessor.
private void initializeProcessor(String destinationName, boolean isQueue, FunctionEx<Message, String> projectionFn) throws Exception {
processorConnection = getConnectionFactory().createConnection();
processorConnection.start();
FunctionEx<Session, MessageConsumer> consumerFn = s -> s.createConsumer(isQueue ? s.createQueue(destinationName) : s.createTopic(destinationName));
if (projectionFn == null) {
projectionFn = m -> ((TextMessage) m).getText();
}
processor = new StreamJmsP<>(processorConnection, consumerFn, Message::getJMSMessageID, projectionFn, noEventTime(), NONE);
outbox = new TestOutbox(1);
processor.init(outbox, new TestProcessorContext());
}
use of com.hazelcast.function.FunctionEx in project hazelcast by hazelcast.
the class RebalanceStreamStageTest method when_peekAndRebalanceAndMap_then_dagEdgeDistributed.
@Test
public void when_peekAndRebalanceAndMap_then_dagEdgeDistributed() {
// Given
List<Integer> input = sequence(itemCount);
StreamStage<Integer> srcStage = streamStageFromList(input);
FunctionEx<Integer, String> formatFn = i -> String.format("%04d-string", i);
// When
StreamStage<String> mapped = srcStage.peek().rebalance().map(formatFn);
// Then
mapped.writeTo(sink);
DAG dag = p.toDag();
Edge srcToMap = dag.getInboundEdges("map").get(0);
assertTrue("Rebalancing should make the edge distributed", srcToMap.isDistributed());
assertNull("Didn't rebalance by key, the edge must not be partitioned", srcToMap.getPartitioner());
execute();
assertEquals(streamToString(input.stream(), formatFn), streamToString(sinkStreamOf(String.class), identity()));
}
use of com.hazelcast.function.FunctionEx in project hazelcast by hazelcast.
the class TestHazelcastInstanceFactory method registerTestMetricsPublisher.
private void registerTestMetricsPublisher(HazelcastInstance hazelcastInstance) {
if (metricsRule != null && metricsRule.isEnabled()) {
MetricsService metricService = getNodeEngineImpl(hazelcastInstance).getService(MetricsService.SERVICE_NAME);
metricService.registerPublisher((FunctionEx<NodeEngine, MetricsPublisher>) nodeEngine -> metricsRule.getMetricsPublisher(hazelcastInstance));
}
}
Aggregations