本文整理汇总了Java中reactor.util.concurrent.Queues.small方法的典型用法代码示例。如果您正苦于以下问题:Java Queues.small方法的具体用法?Java Queues.small怎么用?Java Queues.small使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类reactor.util.concurrent.Queues
的用法示例。
在下文中一共展示了Queues.small方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: scanMainSubscriberError
import reactor.util.concurrent.Queues; //导入方法依赖的package包/类
@Test
public void scanMainSubscriberError() {
LambdaSubscriber<Integer> subscriber = new LambdaSubscriber<>(null, e -> { }, null,
s -> s.request(2));
MergeSequentialMain<Integer>
test = new MergeSequentialMain<>(subscriber, 4, 123, Queues.small());
subscriber.onSubscribe(test);
assertThat(test.scan(Scannable.Attr.TERMINATED)).isFalse();
assertThat(test.scan(Scannable.Attr.ERROR)).isNull();
test.onError(new IllegalStateException("boom"));
assertThat(test.scan(Scannable.Attr.TERMINATED)).isFalse();
assertThat(test.scan(Scannable.Attr.ERROR)).hasMessage("boom");
}
示例2: mainErrorUntilIsPropagatedToBothWindowAndMain
import reactor.util.concurrent.Queues; //导入方法依赖的package包/类
@Test
public void mainErrorUntilIsPropagatedToBothWindowAndMain() {
DirectProcessor<Integer> sp1 = DirectProcessor.create();
FluxWindowPredicate<Integer> windowUntil = new FluxWindowPredicate<>(
sp1, Queues.small(), Queues.unbounded(), Queues.SMALL_BUFFER_SIZE,
i -> i % 3 == 0, Mode.UNTIL);
StepVerifier.create(windowUntil.flatMap(Flux::materialize))
.expectSubscription()
.then(() -> sp1.onNext(1))
.expectNext(Signal.next(1))
.then(() -> sp1.onNext(2))
.expectNext(Signal.next(2))
.then(() -> sp1.onNext(3))
.expectNext(Signal.next(3), Signal.complete())
.then(() -> sp1.onNext(4))
.expectNext(Signal.next(4))
.then(() -> sp1.onError(new RuntimeException("forced failure")))
//this is the error in the window:
.expectNextMatches(signalErrorMessage("forced failure"))
//this is the error in the main:
.expectErrorMessage("forced failure")
.verify();
assertThat(sp1.hasDownstreams()).isFalse();
}
示例3: mainErrorUntilCutBeforeIsPropagatedToBothWindowAndMain
import reactor.util.concurrent.Queues; //导入方法依赖的package包/类
@Test
public void mainErrorUntilCutBeforeIsPropagatedToBothWindowAndMain() {
DirectProcessor<Integer> sp1 = DirectProcessor.create();
FluxWindowPredicate<Integer> windowUntilCutBefore =
new FluxWindowPredicate<>(sp1, Queues.small(), Queues.unbounded(), Queues.SMALL_BUFFER_SIZE,
i -> i % 3 == 0, Mode.UNTIL_CUT_BEFORE);
StepVerifier.create(windowUntilCutBefore.flatMap(Flux::materialize))
.expectSubscription()
.then(() -> sp1.onNext(1))
.expectNext(Signal.next(1))
.then(() -> sp1.onNext(2))
.expectNext(Signal.next(2))
.then(() -> sp1.onNext(3))
.expectNext(Signal.complete())
.expectNext(Signal.next(3))
.then(() -> sp1.onNext(4))
.expectNext(Signal.next(4))
.then(() -> sp1.onError(new RuntimeException("forced failure")))
//this is the error in the window:
.expectNextMatches(signalErrorMessage("forced failure"))
//this is the error in the main:
.expectErrorMessage("forced failure")
.verify();
assertThat(sp1.hasDownstreams()).isFalse();
}
示例4: scanMainSubscriberDoneAfterNComplete
import reactor.util.concurrent.Queues; //导入方法依赖的package包/类
@Test
public void scanMainSubscriberDoneAfterNComplete() {
LambdaSubscriber<Integer> subscriber = new LambdaSubscriber<>(null, e -> { }, null,
s -> s.request(2));
int n = 4;
MergeSequentialMain<Integer>
test = new MergeSequentialMain<>(subscriber, n, 123, Queues.small());
subscriber.onSubscribe(test);
for (int i = 0; i < n; i++) {
assertThat(test.scan(Scannable.Attr.TERMINATED)).as("complete " + i)
.isFalse();
test.onComplete();
}
assertThat(test.scan(Scannable.Attr.TERMINATED)).isTrue();
}
示例5: scanMainSubscriber
import reactor.util.concurrent.Queues; //导入方法依赖的package包/类
@Test
public void scanMainSubscriber() {
LambdaSubscriber<Integer> subscriber = new LambdaSubscriber<>(null, e -> { }, null,
s -> s.request(2));
MergeSequentialMain<Integer>
test = new MergeSequentialMain<>(subscriber, 4, 123, Queues.small());
subscriber.onSubscribe(test);
assertThat(test.scan(Scannable.Attr.ACTUAL)).isSameAs(subscriber);
assertThat(test.scan(Scannable.Attr.REQUESTED_FROM_DOWNSTREAM)).isEqualTo(2);
assertThat(test.scan(Scannable.Attr.TERMINATED)).isFalse();
assertThat(test.scan(Scannable.Attr.ERROR)).isNull();
assertThat(test.scan(Scannable.Attr.CANCELLED)).isFalse();
test.cancel();
assertThat(test.scan(Scannable.Attr.CANCELLED)).isTrue();
}
示例6: scanStartEndMain
import reactor.util.concurrent.Queues; //导入方法依赖的package包/类
@Test
public void scanStartEndMain() {
CoreSubscriber<List<String>> actual = new LambdaSubscriber<>(null, e -> {}, null, null);
FluxBufferWhen.BufferWhenMainSubscriber<String, Integer, Long, List<String>> test =
new FluxBufferWhen.BufferWhenMainSubscriber<String, Integer, Long, List<String>>(
actual, ArrayList::new, Queues.small(), Mono.just(1), u -> Mono.just(1L));
Subscription parent = Operators.emptySubscription();
test.onSubscribe(parent);
test.request(100L);
assertThat(test.scan(Scannable.Attr.PARENT)).isSameAs(parent);
assertThat(test.scan(Scannable.Attr.TERMINATED)).isFalse();
assertThat(test.scan(Scannable.Attr.CANCELLED)).isFalse();
assertThat(test.scan(Scannable.Attr.PREFETCH)).isEqualTo(Integer.MAX_VALUE);
assertThat(test.scan(Scannable.Attr.BUFFERED)).isEqualTo(0); //TODO
assertThat(test.scan(Scannable.Attr.REQUESTED_FROM_DOWNSTREAM)).isEqualTo(100L);
assertThat(test.scan(Scannable.Attr.ACTUAL)).isSameAs(actual);
test.onError(new IllegalStateException("boom"));
assertThat(test.scan(Scannable.Attr.TERMINATED)).isTrue();
}
示例7: scanWhenCloseSubscriber
import reactor.util.concurrent.Queues; //导入方法依赖的package包/类
@Test
public void scanWhenCloseSubscriber() {
//noinspection ConstantConditions
FluxBufferWhen.BufferWhenMainSubscriber<String, Integer, Long, List<String>> main =
new FluxBufferWhen.BufferWhenMainSubscriber<>(null,
ArrayList::new, Queues.small(), Mono.just(1),
u -> Mono.just(1L));
FluxBufferWhen.BufferWhenCloseSubscriber test = new FluxBufferWhen.BufferWhenCloseSubscriber<>(main, 5);
assertThat(test.scan(Scannable.Attr.REQUESTED_FROM_DOWNSTREAM)).isEqualTo(Long.MAX_VALUE);
Subscription parent = Operators.emptySubscription();
test.onSubscribe(parent);
assertThat(test.scan(Scannable.Attr.ACTUAL)).isSameAs(main);
assertThat(test.scan(Scannable.Attr.PARENT)).isSameAs(parent);
assertThat(test.scan(Scannable.Attr.CANCELLED)).isFalse();
test.dispose();
assertThat(test.isDisposed()).isTrue();
assertThat(test.scan(Scannable.Attr.CANCELLED)).isTrue();
}
示例8: normalUntil
import reactor.util.concurrent.Queues; //导入方法依赖的package包/类
@Test
public void normalUntil() {
DirectProcessor<Integer> sp1 = DirectProcessor.create();
FluxWindowPredicate<Integer> windowUntil = new FluxWindowPredicate<>(sp1,
Queues.small(),
Queues.unbounded(),
Queues.SMALL_BUFFER_SIZE,
i -> i % 3 == 0,
Mode.UNTIL);
StepVerifier.create(windowUntil.flatMap(Flux::materialize))
.expectSubscription()
.then(() -> sp1.onNext(1))
.expectNext(Signal.next(1))
.then(() -> sp1.onNext(2))
.expectNext(Signal.next(2))
.then(() -> sp1.onNext(3))
.expectNext(Signal.next(3), Signal.complete())
.then(() -> sp1.onNext(4))
.expectNext(Signal.next(4))
.then(() -> sp1.onNext(5))
.expectNext(Signal.next(5))
.then(() -> sp1.onNext(6))
.expectNext(Signal.next(6), Signal.complete())
.then(() -> sp1.onNext(7))
.expectNext(Signal.next(7))
.then(() -> sp1.onNext(8))
.expectNext(Signal.next(8))
.then(sp1::onComplete)
.expectNext(Signal.complete())
.verifyComplete();
assertThat(sp1.hasDownstreams()).isFalse();
}
示例9: predicateErrorUntil
import reactor.util.concurrent.Queues; //导入方法依赖的package包/类
@Test
public void predicateErrorUntil() {
DirectProcessor<Integer> sp1 = DirectProcessor.create();
FluxWindowPredicate<Integer> windowUntil = new FluxWindowPredicate<>(
sp1, Queues.small(), Queues.unbounded(), Queues.SMALL_BUFFER_SIZE,
i -> {
if (i == 5) throw new IllegalStateException("predicate failure");
return i % 3 == 0;
}, Mode.UNTIL);
StepVerifier.create(windowUntil.flatMap(Flux::materialize))
.expectSubscription()
.then(() -> sp1.onNext(1))
.expectNext(Signal.next(1))
.then(() -> sp1.onNext(2))
.expectNext(Signal.next(2))
.then(() -> sp1.onNext(3))
.expectNext(Signal.next(3), Signal.complete())
.then(() -> sp1.onNext(4))
.expectNext(Signal.next(4))
.then(() -> sp1.onNext(5))
//error in the window:
.expectNextMatches(signalErrorMessage("predicate failure"))
.expectErrorMessage("predicate failure")
.verify();
assertThat(sp1.hasDownstreams()).isFalse();
}
示例10: normalUntilCutBefore
import reactor.util.concurrent.Queues; //导入方法依赖的package包/类
@Test
public void normalUntilCutBefore() {
DirectProcessor<Integer> sp1 = DirectProcessor.create();
FluxWindowPredicate<Integer> windowUntilCutBefore = new FluxWindowPredicate<>(sp1,
Queues.small(), Queues.unbounded(), Queues.SMALL_BUFFER_SIZE,
i -> i % 3 == 0, Mode.UNTIL_CUT_BEFORE);
StepVerifier.create(windowUntilCutBefore.flatMap(Flux::materialize))
.expectSubscription()
.then(() -> sp1.onNext(1))
.expectNext(Signal.next(1))
.then(() -> sp1.onNext(2))
.expectNext(Signal.next(2))
.then(() -> sp1.onNext(3))
.expectNext(Signal.complete(), Signal.next(3))
.then(() -> sp1.onNext(4))
.expectNext(Signal.next(4))
.then(() -> sp1.onNext(5))
.expectNext(Signal.next(5))
.then(() -> sp1.onNext(6))
.expectNext(Signal.complete(), Signal.next(6))
.then(() -> sp1.onNext(7))
.expectNext(Signal.next(7))
.then(() -> sp1.onNext(8))
.expectNext(Signal.next(8))
.then(sp1::onComplete)
.expectNext(Signal.complete())
.verifyComplete();
assertThat(sp1.hasDownstreams()).isFalse();
}
示例11: predicateErrorUntilCutBefore
import reactor.util.concurrent.Queues; //导入方法依赖的package包/类
@Test
public void predicateErrorUntilCutBefore() {
DirectProcessor<Integer> sp1 = DirectProcessor.create();
FluxWindowPredicate<Integer> windowUntilCutBefore =
new FluxWindowPredicate<>(sp1, Queues.small(), Queues.unbounded(), Queues.SMALL_BUFFER_SIZE,
i -> {
if (i == 5) throw new IllegalStateException("predicate failure");
return i % 3 == 0;
}, Mode.UNTIL_CUT_BEFORE);
StepVerifier.create(windowUntilCutBefore.flatMap(Flux::materialize))
.expectSubscription()
.then(() -> sp1.onNext(1))
.expectNext(Signal.next(1))
.then(() -> sp1.onNext(2))
.expectNext(Signal.next(2))
.then(() -> sp1.onNext(3))
.expectNext(Signal.complete(), Signal.next(3))
.then(() -> sp1.onNext(4))
.expectNext(Signal.next(4))
.then(() -> sp1.onNext(5))
//error in the window:
.expectNextMatches(signalErrorMessage("predicate failure"))
.expectErrorMessage("predicate failure")
.verify();
assertThat(sp1.hasDownstreams()).isFalse();
}
示例12: normalWhile
import reactor.util.concurrent.Queues; //导入方法依赖的package包/类
@Test
public void normalWhile() {
DirectProcessor<Integer> sp1 = DirectProcessor.create();
FluxWindowPredicate<Integer> windowWhile = new FluxWindowPredicate<>(
sp1, Queues.small(), Queues.unbounded(), Queues.SMALL_BUFFER_SIZE,
i -> i % 3 != 0, Mode.WHILE);
StepVerifier.create(windowWhile.flatMap(Flux::materialize))
.expectSubscription()
.then(() -> sp1.onNext(1))
.expectNext(Signal.next(1))
.then(() -> sp1.onNext(2))
.expectNext(Signal.next(2))
.then(() -> sp1.onNext(3))
.expectNext(Signal.complete())
.then(() -> sp1.onNext(4))
.expectNext(Signal.next(4))
.then(() -> sp1.onNext(5))
.expectNext(Signal.next(5))
.then(() -> sp1.onNext(6))
.expectNext(Signal.complete())
.then(() -> sp1.onNext(7))
.expectNext(Signal.next(7))
.then(() -> sp1.onNext(8))
.expectNext(Signal.next(8))
.then(sp1::onComplete)
.expectNext(Signal.complete())
.verifyComplete();
assertThat(sp1.hasDownstreams()).isFalse();
}
示例13: normalWhileDoesntInitiallyMatch
import reactor.util.concurrent.Queues; //导入方法依赖的package包/类
@Test
public void normalWhileDoesntInitiallyMatch() {
DirectProcessor<Integer> sp1 = DirectProcessor.create();
FluxWindowPredicate<Integer> windowWhile = new FluxWindowPredicate<>(
sp1, Queues.small(), Queues.unbounded(), Queues.SMALL_BUFFER_SIZE,
i -> i % 3 == 0, Mode.WHILE);
StepVerifier.create(windowWhile.flatMap(Flux::materialize))
.expectSubscription()
.expectNoEvent(Duration.ofMillis(10))
.then(() -> sp1.onNext(1)) //closes initial, open 2nd
.expectNext(Signal.complete())
.then(() -> sp1.onNext(2)) //closes second, open 3rd
.expectNext(Signal.complete())
.then(() -> sp1.onNext(3)) //emits 3
.expectNext(Signal.next(3))
.expectNoEvent(Duration.ofMillis(10))
.then(() -> sp1.onNext(4)) //closes 3rd, open 4th
.expectNext(Signal.complete())
.then(() -> sp1.onNext(5)) //closes 4th, open 5th
.expectNext(Signal.complete())
.then(() -> sp1.onNext(6)) //emits 6
.expectNext(Signal.next(6))
.expectNoEvent(Duration.ofMillis(10))
.then(() -> sp1.onNext(7)) //closes 5th, open 6th
.expectNext(Signal.complete())
.then(() -> sp1.onNext(8)) //closes 6th, open 7th
.expectNext(Signal.complete())
.then(() -> sp1.onNext(9)) //emits 9
.expectNext(Signal.next(9))
.expectNoEvent(Duration.ofMillis(10))
.then(sp1::onComplete) // completion triggers completion of the last window (7th)
.expectNext(Signal.complete())
.expectComplete()
.verify(Duration.ofSeconds(1));
assertThat(sp1.hasDownstreams()).isFalse();
}
示例14: normalWhileDoesntMatch
import reactor.util.concurrent.Queues; //导入方法依赖的package包/类
@Test
public void normalWhileDoesntMatch() {
DirectProcessor<Integer> sp1 = DirectProcessor.create();
FluxWindowPredicate<Integer> windowWhile = new FluxWindowPredicate<>(
sp1, Queues.small(), Queues.unbounded(), Queues.SMALL_BUFFER_SIZE,
i -> i > 4, Mode.WHILE);
StepVerifier.create(windowWhile.flatMap(Flux::materialize))
.expectSubscription()
.expectNoEvent(Duration.ofMillis(10))
.then(() -> sp1.onNext(1))
.expectNext(Signal.complete())
.then(() -> sp1.onNext(2))
.expectNext(Signal.complete())
.then(() -> sp1.onNext(3))
.expectNext(Signal.complete())
.then(() -> sp1.onNext(4))
.expectNext(Signal.complete())
.expectNoEvent(Duration.ofMillis(10))
.then(() -> sp1.onNext(1))
.expectNext(Signal.complete())
.then(() -> sp1.onNext(2))
.expectNext(Signal.complete())
.then(() -> sp1.onNext(3))
.expectNext(Signal.complete())
.then(() -> sp1.onNext(4))
.expectNext(Signal.complete()) //closing window opened by 3
.expectNoEvent(Duration.ofMillis(10))
.then(sp1::onComplete)
.expectNext(Signal.complete()) //closing window opened by 4
.expectComplete()
.verify(Duration.ofSeconds(1));
assertThat(sp1.hasDownstreams()).isFalse();
}
示例15: predicateErrorWhile
import reactor.util.concurrent.Queues; //导入方法依赖的package包/类
@Test
public void predicateErrorWhile() {
DirectProcessor<Integer> sp1 = DirectProcessor.create();
FluxWindowPredicate<Integer> windowWhile = new FluxWindowPredicate<>(
sp1, Queues.small(), Queues.unbounded(), Queues.SMALL_BUFFER_SIZE,
i -> {
if (i == 3) return true;
if (i == 5) throw new IllegalStateException("predicate failure");
return false;
}, Mode.WHILE);
StepVerifier.create(windowWhile.flatMap(Flux::materialize))
.expectSubscription()
.then(() -> sp1.onNext(1)) //empty window
.expectNext(Signal.complete())
.then(() -> sp1.onNext(2)) //empty window
.expectNext(Signal.complete())
.then(() -> sp1.onNext(3)) //window opens
.expectNext(Signal.next(3))
.then(() -> sp1.onNext(4)) //previous window closes, new (empty) window
.expectNext(Signal.complete())
.then(() -> sp1.onNext(5)) //fails, the empty window receives onError
//error in the window:
.expectNextMatches(signalErrorMessage("predicate failure"))
.expectErrorMessage("predicate failure")
.verify(Duration.ofMillis(100));
assertThat(sp1.hasDownstreams()).isFalse();
}