本文整理汇总了Java中reactor.util.concurrent.Queues.one方法的典型用法代码示例。如果您正苦于以下问题:Java Queues.one方法的具体用法?Java Queues.one怎么用?Java Queues.one使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类reactor.util.concurrent.Queues
的用法示例。
在下文中一共展示了Queues.one方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: scanConcatMapImmediate
import reactor.util.concurrent.Queues; //导入方法依赖的package包/类
@Test
public void scanConcatMapImmediate() {
CoreSubscriber<Integer> actual = new LambdaSubscriber<>(null, e -> {}, null, null);
FluxConcatMap.ConcatMapImmediate<String, Integer> test = new FluxConcatMap.ConcatMapImmediate<>(
actual, s -> Mono.just(s.length()), Queues.one(), 123);
Subscription parent = Operators.emptySubscription();
test.onSubscribe(parent);
test.queue.offer("foo");
assertThat(test.scan(Scannable.Attr.BUFFERED)).isEqualTo(1);
assertThat(test.scan(Scannable.Attr.PREFETCH)).isEqualTo(123);
assertThat(test.scan(Scannable.Attr.DELAY_ERROR)).isFalse();
assertThat(test.scan(Scannable.Attr.PARENT)).isSameAs(parent);
assertThat(test.scan(Scannable.Attr.ACTUAL)).isSameAs(actual);
assertThat(test.scan(Scannable.Attr.TERMINATED)).isFalse();
test.onComplete();
assertThat(test.scan(Scannable.Attr.TERMINATED)).isTrue();
assertThat(test.scan(Scannable.Attr.CANCELLED)).isFalse();
test.cancelled = true;
assertThat(test.scan(Scannable.Attr.CANCELLED)).isTrue();
}
示例2: scanConcatMapImmediateError
import reactor.util.concurrent.Queues; //导入方法依赖的package包/类
@Test
public void scanConcatMapImmediateError() {
CoreSubscriber<Integer> actual = new LambdaSubscriber<>(null, e -> {}, null, null);
FluxConcatMap.ConcatMapImmediate<String, Integer> test = new FluxConcatMap.ConcatMapImmediate<>(
actual, s -> Mono.just(s.length()), Queues.one(), 123);
Subscription parent = Operators.emptySubscription();
test.onSubscribe(parent);
assertThat(test.scan(Scannable.Attr.DELAY_ERROR)).isFalse();
//note that most of the time, the error will be hidden by TERMINATED as soon as it has been propagated downstream :(
test.error = new IllegalStateException("boom");
assertThat(test.scan(Scannable.Attr.ERROR)).hasMessage("boom");
assertThat(test.scan(Scannable.Attr.TERMINATED)).isFalse();
test.onError(new IllegalStateException("boom2"));
assertThat(test.scan(Scannable.Attr.ERROR)).isSameAs(Exceptions.TERMINATED);
assertThat(test.scan(Scannable.Attr.TERMINATED)).isTrue();
}
示例3: scanMain
import reactor.util.concurrent.Queues; //导入方法依赖的package包/类
@Test
public void scanMain() {
CoreSubscriber<GroupedFlux<Integer, String>> actual = new LambdaSubscriber<>(null, e -> {}, null, null);
FluxGroupBy.GroupByMain<Integer, Integer, String> test = new FluxGroupBy.GroupByMain<>(actual,
Queues.<GroupedFlux<Integer, String>>one().get(), Queues.one(), 123, i -> i % 5, i -> String.valueOf(i));
Subscription sub = Operators.emptySubscription();
test.onSubscribe(sub);
assertThat(test.scan(Scannable.Attr.ACTUAL)).isSameAs(actual);
assertThat(test.scan(Scannable.Attr.PARENT)).isSameAs(sub);
assertThat(test.scan(Scannable.Attr.REQUESTED_FROM_DOWNSTREAM)).isEqualTo(Long.MAX_VALUE);
assertThat(test.scan(Scannable.Attr.PREFETCH)).isSameAs(123);
assertThat(test.scan(Scannable.Attr.BUFFERED)).isSameAs(0);
assertThat(test.scan(Scannable.Attr.CANCELLED)).isFalse();
assertThat(test.scan(Scannable.Attr.TERMINATED)).isFalse();
assertThat(test.scan(Scannable.Attr.ERROR)).isNull();
test.error = new IllegalStateException("boom");
assertThat(test.scan(Scannable.Attr.ERROR)).isSameAs(test.error);
}
示例4: scanUnicastGroupedFlux
import reactor.util.concurrent.Queues; //导入方法依赖的package包/类
@Test
public void scanUnicastGroupedFlux() {
CoreSubscriber<GroupedFlux<Integer, String>> actual = new LambdaSubscriber<>(null, e -> {}, null, null);
FluxGroupBy.GroupByMain<Integer, Integer, String> main = new FluxGroupBy.GroupByMain<>(actual,
Queues.<GroupedFlux<Integer, String>>one().get(), Queues.one(), 123, i -> i % 5, i -> String.valueOf(i));
FluxGroupBy.UnicastGroupedFlux<Integer, String> test = new FluxGroupBy.UnicastGroupedFlux<Integer, String>(1,
Queues.<String>one().get(), main, 123);
CoreSubscriber<String> sub = new LambdaSubscriber<>(null, e -> {}, null, null);
test.subscribe(sub);
assertThat(test.scan(Scannable.Attr.ACTUAL)).isSameAs(sub);
assertThat(test.scan(Scannable.Attr.PARENT)).isSameAs(main);
assertThat(test.scan(Scannable.Attr.REQUESTED_FROM_DOWNSTREAM)).isEqualTo(Long.MAX_VALUE);
assertThat(test.scan(Scannable.Attr.BUFFERED)).isSameAs(0);
assertThat(test.scan(Scannable.Attr.CANCELLED)).isFalse();
assertThat(test.scan(Scannable.Attr.TERMINATED)).isFalse();
assertThat(test.scan(Scannable.Attr.ERROR)).isNull();
test.error = new IllegalStateException("boom");
assertThat(test.scan(Scannable.Attr.ERROR)).isSameAs(test.error);
}
示例5: subscribe
import reactor.util.concurrent.Queues; //导入方法依赖的package包/类
@Override
public void subscribe(CoreSubscriber<? super R> actual) {
FluxPublishMulticast.FluxPublishMulticaster<T> multicast =
new FluxPublishMulticast.FluxPublishMulticaster<>(Integer.MAX_VALUE,
Queues.one(), actual.currentContext());
Mono<? extends R> out;
try {
out = Objects.requireNonNull(transform.apply(fromDirect(multicast)),
"The transform returned a null Mono");
}
catch (Throwable ex) {
Operators.error(actual, Operators.onOperatorError(ex, actual.currentContext()));
return;
}
if (out instanceof Fuseable) {
out.subscribe(new FluxPublishMulticast.CancelFuseableMulticaster<>(actual, multicast));
}
else {
out.subscribe(new FluxPublishMulticast.CancelMulticaster<>(actual, multicast));
}
source.subscribe(multicast);
}
示例6: scanConcatMapDelayed
import reactor.util.concurrent.Queues; //导入方法依赖的package包/类
@Test
public void scanConcatMapDelayed() {
CoreSubscriber<Integer> actual = new LambdaSubscriber<>(null, e -> {}, null, null);
FluxConcatMap.ConcatMapDelayed<String, Integer> test = new FluxConcatMap.ConcatMapDelayed<>(
actual, s -> Mono.just(s.length()), Queues.one(), 123, true);
Subscription parent = Operators.emptySubscription();
test.onSubscribe(parent);
test.error = new IllegalStateException("boom");
test.queue.offer("foo");
assertThat(test.scan(Scannable.Attr.BUFFERED)).isEqualTo(1);
assertThat(test.scan(Scannable.Attr.PREFETCH)).isEqualTo(123);
assertThat(test.scan(Scannable.Attr.DELAY_ERROR)).isTrue();
assertThat(test.scan(Scannable.Attr.ERROR)).hasMessage("boom");
assertThat(test.scan(Scannable.Attr.PARENT)).isSameAs(parent);
assertThat(test.scan(Scannable.Attr.ACTUAL)).isSameAs(actual);
assertThat(test.scan(Scannable.Attr.TERMINATED)).isFalse();
test.onError(new IllegalStateException("boom"));
assertThat(test.scan(Scannable.Attr.TERMINATED)).isTrue();
assertThat(test.scan(Scannable.Attr.CANCELLED)).isFalse();
test.cancelled = true;
assertThat(test.scan(Scannable.Attr.CANCELLED)).isTrue();
}
示例7: scanGroupJoinSubscription
import reactor.util.concurrent.Queues; //导入方法依赖的package包/类
@Test
public void scanGroupJoinSubscription() {
CoreSubscriber<String> actual = new LambdaSubscriber<>(null, e -> {}, null, sub -> sub.request(100));
FluxGroupJoin.GroupJoinSubscription<String, String, String, String, String> test =
new FluxGroupJoin.GroupJoinSubscription<String, String, String, String, String>(actual,
s -> Mono.just(s),
s -> Mono.just(s),
(l, r) -> l,
Queues.unbounded().get(),
Queues.one());
assertThat(test.scan(Scannable.Attr.ACTUAL)).isSameAs(actual);
test.request(123);
assertThat(test.scan(Scannable.Attr.REQUESTED_FROM_DOWNSTREAM)).isEqualTo(123);
test.queue.add(5);
test.queue.add(10);
assertThat(test.scan(Scannable.Attr.BUFFERED)).isEqualTo(1);
test.error = new IllegalArgumentException("boom");
assertThat(test.scan(Scannable.Attr.ERROR)).isSameAs(test.error);
assertThat(test.scan(Scannable.Attr.TERMINATED)).isFalse();
test.active = 0;
assertThat(test.scan(Scannable.Attr.TERMINATED)).isTrue();
assertThat(test.scan(Scannable.Attr.CANCELLED)).isFalse();
test.cancel();
assertThat(test.scan(Scannable.Attr.CANCELLED)).isTrue();
}
示例8: scanOperator
import reactor.util.concurrent.Queues; //导入方法依赖的package包/类
@Test
public void scanOperator() {
ParallelSource<Integer> source = new ParallelSource<>(Flux.just(500, 300), 10, 123, Queues.one());
ParallelPeek<Integer> test = new ParallelPeek<>(source, null, null, null, null, null, null, null, null);
assertThat(test.scan(Scannable.Attr.PARENT)).isSameAs(source);
assertThat(test.scan(Scannable.Attr.PREFETCH))
.isEqualTo(source.getPrefetch())
.isEqualTo(test.getPrefetch())
.isEqualTo(123);
}
示例9: scanOperator
import reactor.util.concurrent.Queues; //导入方法依赖的package包/类
@Test
public void scanOperator() {
Flux<Integer> source = Flux.range(1, 10);
BlockingIterable<Integer> test = new BlockingIterable<>(source, 35, Queues.one());
assertThat(test.scanUnsafe(Scannable.Attr.PARENT)).describedAs("PARENT").isSameAs(source);
//type safe attributes
assertThat(test.scanUnsafe(Attr.PREFETCH)).describedAs("PREFETCH unsafe").isEqualTo(35);
assertThat(test.scan(Attr.PREFETCH)).describedAs("PREFETCH").isEqualTo(35); //FIXME
}
示例10: scanOperatorLargePrefetchIsLimitedToIntMax
import reactor.util.concurrent.Queues; //导入方法依赖的package包/类
@Test
public void scanOperatorLargePrefetchIsLimitedToIntMax() {
Flux<Integer> source = Flux.range(1, 10);
BlockingIterable<Integer> test = new BlockingIterable<>(source,
Integer.MAX_VALUE,
Queues.one());
assertThat(test.scan(Attr.PREFETCH)).isEqualTo(Integer.MAX_VALUE);
}
示例11: scanOperator
import reactor.util.concurrent.Queues; //导入方法依赖的package包/类
@Test
public void scanOperator() {
Flux<Integer> source = Flux.range(1, 10).map(i -> i - 1);
FluxFlattenIterable<Integer, Integer> test = new FluxFlattenIterable<>(source, i -> new ArrayList<>(i), 35, Queues.one());
assertThat(test.scan(Scannable.Attr.PARENT)).isSameAs(source);
assertThat(test.scan(Attr.PREFETCH)).isEqualTo(35);
}
示例12: scanSubscriber
import reactor.util.concurrent.Queues; //导入方法依赖的package包/类
@Test
public void scanSubscriber() {
CoreSubscriber<Integer> actual = new LambdaSubscriber<>(null, e -> {}, null, null);
FluxFlattenIterable.FlattenIterableSubscriber<Integer, Integer> test =
new FluxFlattenIterable.FlattenIterableSubscriber<>(actual, i -> new ArrayList<>(i), 123, Queues.<Integer>one());
Subscription s = Operators.emptySubscription();
test.onSubscribe(s);
assertThat(test.scan(Scannable.Attr.PARENT)).isSameAs(s);
assertThat(test.scan(Scannable.Attr.ACTUAL)).isSameAs(actual);
assertThat(test.scan(Attr.PREFETCH)).isEqualTo(123);
test.requested = 35;
assertThat(test.scan(Attr.REQUESTED_FROM_DOWNSTREAM)).isEqualTo(35);
test.queue.add(5);
assertThat(test.scan(Attr.BUFFERED)).isEqualTo(1);
assertThat(test.scan(Scannable.Attr.ERROR)).isNull();
assertThat(test.scan(Scannable.Attr.TERMINATED)).isFalse();
test.error = new IllegalStateException("boom");
assertThat(test.scan(Scannable.Attr.ERROR)).hasMessage("boom");
test.onComplete();
assertThat(test.scan(Scannable.Attr.TERMINATED)).isTrue();
assertThat(test.scan(Scannable.Attr.CANCELLED)).isFalse();
test.cancel();
assertThat(test.scan(Scannable.Attr.CANCELLED)).isTrue();
}
示例13: scanMainSubscriber
import reactor.util.concurrent.Queues; //导入方法依赖的package包/类
@Test
public void scanMainSubscriber() {
CoreSubscriber<String>[] subs = new CoreSubscriber[1];
subs[0] = new LambdaSubscriber<>(null, e -> {}, null, null);
ParallelSource.ParallelSourceMain<String> test = new ParallelSource.ParallelSourceMain<>(
subs, 123, Queues.one());
Subscription parent = Operators.emptySubscription();
test.onSubscribe(parent);
assertThat(test.scan(Scannable.Attr.PARENT)).isSameAs(parent);
assertThat(test.scan(Scannable.Attr.PREFETCH)).isEqualTo(123);
assertThat(test.scan(Scannable.Attr.BUFFERED)).isZero();
test.queue.offer("foo");
assertThat(test.scan(Scannable.Attr.BUFFERED)).isEqualTo(1);
assertThat(test.scan(Scannable.Attr.TERMINATED)).isFalse();
assertThat(test.scan(Scannable.Attr.CANCELLED)).isFalse();
assertThat(test.scan(Scannable.Attr.ERROR)).isNull();
test.onError(new IllegalStateException("boom"));
assertThat(test.scan(Scannable.Attr.TERMINATED)).isTrue();
assertThat(test.scan(Scannable.Attr.CANCELLED)).isFalse();
assertThat(test.scan(Scannable.Attr.ERROR)).hasMessage("boom");
test.cancel();
assertThat(test.scan(Scannable.Attr.CANCELLED)).isTrue();
}
示例14: scanInnerSubscriber
import reactor.util.concurrent.Queues; //导入方法依赖的package包/类
@Test
public void scanInnerSubscriber() {
CoreSubscriber<String>[] subs = new CoreSubscriber[2];
subs[0] = new LambdaSubscriber<>(null, e -> {}, null, null);
subs[1] = new LambdaSubscriber<>(null, e -> {}, null, null);
ParallelSource.ParallelSourceMain<String> main = new ParallelSource.ParallelSourceMain<>(
subs, 123, Queues.one());
ParallelSource.ParallelSourceMain.ParallelSourceInner<String> test =
new ParallelSource.ParallelSourceMain.ParallelSourceInner<>(
main, 1, 10);
assertThat(test.scan(Scannable.Attr.PARENT)).isSameAs(main);
assertThat(test.scan(Scannable.Attr.ACTUAL)).isSameAs(subs[test.index]);
}
示例15: scanOperator
import reactor.util.concurrent.Queues; //导入方法依赖的package包/类
@Test
public void scanOperator() {
ParallelFlux<Integer> source = Flux.just(500, 300).parallel(10);
ParallelMergeSequential<Integer> test = new ParallelMergeSequential<>(source, 123, Queues.one());
assertThat(test.scan(Scannable.Attr.PARENT)).isSameAs(source);
assertThat(test.scan(Scannable.Attr.PREFETCH)).isEqualTo(123);
}