本文整理汇总了Java中org.reactivestreams.Processor类的典型用法代码示例。如果您正苦于以下问题:Java Processor类的具体用法?Java Processor怎么用?Java Processor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Processor类属于org.reactivestreams包,在下文中一共展示了Processor类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: sendToKeyBoundBus
import org.reactivestreams.Processor; //导入依赖的package包/类
private boolean sendToKeyBoundBus(RxQueueKey key, Object event)
{
RxQueueKey keyToUse = key.clone();
boolean send = false;
Processor processor;
if (mKey instanceof String)
keyToUse.withId((String)mKey);
else if (mKey instanceof Integer)
keyToUse.withId((Integer)mKey);
processor = RxBus.getInstance().getProcessor(keyToUse, false);
// only send event, if processor exists => this means someone has at least once subscribed to it
if (processor != null)
{
if (mCast == null)
processor.onNext(event);
else
processor.onNext(mCast.cast(event));
send = true;
}
return send;
}
开发者ID:MFlisar,项目名称:RxBus2,代码行数:23,代码来源:RxBusSenderBuilder.java
示例2: shouldHandleAddCommands
import org.reactivestreams.Processor; //导入依赖的package包/类
@Test
public void shouldHandleAddCommands() {
// given:
final UUID uuid1 = UUID.randomUUID();
final UUID uuid2 = UUID.randomUUID();
final Processor<USet.USetCommand<UUID>, USet.USetCommand<UUID>> inputStream = ReplayProcessor.create();
final TestSubscriber<CrdtCommand> subscriber = TestSubscriber.create();
final USet<UUID> set = new USet<>("ID_1");
set.subscribeTo(inputStream);
set.subscribe(subscriber);
final USet.AddCommand<UUID> command1 = new USet.AddCommand<>(set.getCrdtId(), uuid1);
final USet.AddCommand<UUID> command2 = new USet.AddCommand<>(set.getCrdtId(), uuid2);
// when:
inputStream.onNext(command1);
inputStream.onNext(command2);
// then:
assertThat(set, hasSize(2));
assertThat(subscriber.valueCount(), is(2));
subscriber.assertNotComplete();
subscriber.assertNoErrors();
}
开发者ID:netopyr,项目名称:wurmloch-crdt,代码行数:25,代码来源:USetTest.java
示例3: shouldHandleRemoveCommands
import org.reactivestreams.Processor; //导入依赖的package包/类
@Test
public void shouldHandleRemoveCommands() {
// given:
final UUID uuid1 = UUID.randomUUID();
final Processor<USet.USetCommand<UUID>, USet.USetCommand<UUID>> inputStream = ReplayProcessor.create();
final TestSubscriber<CrdtCommand> subscriber = TestSubscriber.create();
final USet<UUID> set = new USet<>("ID_1");
set.subscribeTo(inputStream);
set.subscribe(subscriber);
final USet.AddCommand<UUID> command1 = new USet.AddCommand<>(set.getCrdtId(), uuid1);
final USet.RemoveCommand<UUID> command2 = new USet.RemoveCommand<>(set.getCrdtId(), uuid1);
// when:
inputStream.onNext(command1);
inputStream.onNext(command2);
// then:
assertThat(set, empty());
assertThat(subscriber.valueCount(), is(2));
subscriber.assertNotComplete();
subscriber.assertNoErrors();
}
开发者ID:netopyr,项目名称:wurmloch-crdt,代码行数:24,代码来源:USetTest.java
示例4: itShouldOverwriteOnlyPartialCommandsFromReceivedCommand
import org.reactivestreams.Processor; //导入依赖的package包/类
@Test
public void itShouldOverwriteOnlyPartialCommandsFromReceivedCommand() {
// given
final TestSubscriber<MVRegister.SetCommand<String>> outCommands1 = TestSubscriber.create();
final Processor<MVRegister.SetCommand<String>, MVRegister.SetCommand<String>> inCommands2 = ReplayProcessor.create();
final MVRegister<String> register1 = new MVRegister<>(NODE_ID_1, CRDT_ID);
register1.subscribe(outCommands1);
final MVRegister<String> register2 = new MVRegister<>(NODE_ID_2, CRDT_ID);
register2.subscribeTo(inCommands2);
register1.set("Hello World");
register2.set("Goodbye World");
inCommands2.onNext(outCommands1.values().get(0));
// when
register1.set("42");
inCommands2.onNext(outCommands1.values().get(1));
// then
assertThat(register1.get(), containsInAnyOrder("42"));
assertThat(register2.get(), containsInAnyOrder("42", "Goodbye World"));
}
开发者ID:netopyr,项目名称:wurmloch-crdt,代码行数:23,代码来源:MVRegisterTest.java
示例5: shouldHandleAddCommands
import org.reactivestreams.Processor; //导入依赖的package包/类
@Test
public void shouldHandleAddCommands() {
// given:
final Processor<ORSet.ORSetCommand<String>, ORSet.ORSetCommand<String>> inputStream = ReplayProcessor.create();
final TestSubscriber<CrdtCommand> subscriber = TestSubscriber.create();
final ORSet<String> set = new ORSet<>("ID_1");
set.subscribeTo(inputStream);
set.subscribe(subscriber);
final ORSet.AddCommand<String> command1 = new ORSet.AddCommand<>(set.getCrdtId(), new ORSet.Element<>("1", UUID.randomUUID()));
final ORSet.AddCommand<String> command2 = new ORSet.AddCommand<>(set.getCrdtId(), new ORSet.Element<>("2", UUID.randomUUID()));
final ORSet.AddCommand<String> command3 = new ORSet.AddCommand<>(set.getCrdtId(), new ORSet.Element<>("1", UUID.randomUUID()));
// when:
inputStream.onNext(command1);
inputStream.onNext(command2);
inputStream.onNext(command3);
// then:
assertThat(set, hasSize(2));
assertThat(subscriber.valueCount(), is(3));
subscriber.assertNotComplete();
subscriber.assertNoErrors();
}
开发者ID:netopyr,项目名称:wurmloch-crdt,代码行数:25,代码来源:ORSetTest.java
示例6: shouldHandleDuplicateCommands
import org.reactivestreams.Processor; //导入依赖的package包/类
@Test
public void shouldHandleDuplicateCommands() {
// given:
final Processor<ORSet.ORSetCommand<String>, ORSet.ORSetCommand<String>> inputStream = ReplayProcessor.create();
final TestSubscriber<CrdtCommand> subscriber = TestSubscriber.create();
final ORSet<String> set = new ORSet<>("ID_1");
set.subscribeTo(inputStream);
set.subscribe(subscriber);
final ORSet.AddCommand<String> command = new ORSet.AddCommand<>(set.getCrdtId(), new ORSet.Element<>("1", UUID.randomUUID()));
// when:
inputStream.onNext(command);
inputStream.onNext(command);
// then:
assertThat(set, hasSize(1));
assertThat(subscriber.valueCount(), is(1));
subscriber.assertNotComplete();
subscriber.assertNoErrors();
}
开发者ID:netopyr,项目名称:wurmloch-crdt,代码行数:22,代码来源:ORSetTest.java
示例7: shouldHandleAddCommands
import org.reactivestreams.Processor; //导入依赖的package包/类
@Test
public void shouldHandleAddCommands() {
// given:
final Processor<GSet.AddCommand<String>, GSet.AddCommand<String>> inputStream = ReplayProcessor.create();
final TestSubscriber<CrdtCommand> subscriber = TestSubscriber.create();
final GSet<String> set = new GSet<>("ID_1");
set.subscribeTo(inputStream);
set.subscribe(subscriber);
final GSet.AddCommand<String> command1 = new GSet.AddCommand<>(set.getCrdtId(), "1");
final GSet.AddCommand<String> command2 = new GSet.AddCommand<>(set.getCrdtId(), "2");
final GSet.AddCommand<String> command3 = new GSet.AddCommand<>(set.getCrdtId(), "1");
// when:
inputStream.onNext(command1);
inputStream.onNext(command2);
inputStream.onNext(command3);
// then:
assertThat(set, hasSize(2));
assertThat(subscriber.valueCount(), is(2));
subscriber.assertNotComplete();
subscriber.assertNoErrors();
}
开发者ID:netopyr,项目名称:wurmloch-crdt,代码行数:25,代码来源:GSetTest.java
示例8: shouldHandleDuplicateCommands
import org.reactivestreams.Processor; //导入依赖的package包/类
@Test
public void shouldHandleDuplicateCommands() {
// given:
final Processor<GSet.AddCommand<String>, GSet.AddCommand<String>> inputStream = ReplayProcessor.create();
final TestSubscriber<CrdtCommand> subscriber = TestSubscriber.create();
final GSet<String> set = new GSet<>("ID_1");
set.subscribeTo(inputStream);
set.subscribe(subscriber);
final GSet.AddCommand<String> command = new GSet.AddCommand<>(set.getCrdtId(), "1");
// when:
inputStream.onNext(command);
inputStream.onNext(command);
// then:
assertThat(set, hasSize(1));
assertThat(subscriber.valueCount(), is(1));
subscriber.assertNotComplete();
subscriber.assertNoErrors();
}
开发者ID:netopyr,项目名称:wurmloch-crdt,代码行数:22,代码来源:GSetTest.java
示例9: shouldHandleAddCommands
import org.reactivestreams.Processor; //导入依赖的package包/类
@Test
public void shouldHandleAddCommands() {
// given:
final Processor<TwoPSet.TwoPSetCommand<String>, TwoPSet.TwoPSetCommand<String>> inputStream = ReplayProcessor.create();
final TestSubscriber<CrdtCommand> subscriber = TestSubscriber.create();
final TwoPSet<String> set = new TwoPSet<>("ID_1");
set.subscribeTo(inputStream);
set.subscribe(subscriber);
final TwoPSet.AddCommand<String> command1 = new TwoPSet.AddCommand<>(set.getCrdtId(), "1");
final TwoPSet.AddCommand<String> command2 = new TwoPSet.AddCommand<>(set.getCrdtId(), "2");
final TwoPSet.AddCommand<String> command3 = new TwoPSet.AddCommand<>(set.getCrdtId(), "1");
// when:
inputStream.onNext(command1);
inputStream.onNext(command2);
inputStream.onNext(command3);
// then:
assertThat(set, hasSize(2));
assertThat(subscriber.valueCount(), is(2));
subscriber.assertNotComplete();
subscriber.assertNoErrors();
}
开发者ID:netopyr,项目名称:wurmloch-crdt,代码行数:25,代码来源:TwoPSetTest.java
示例10: shouldHandleRemoveCommands
import org.reactivestreams.Processor; //导入依赖的package包/类
@Test
public void shouldHandleRemoveCommands() {
// given:
final Processor<TwoPSet.TwoPSetCommand<String>, TwoPSet.TwoPSetCommand<String>> inputStream = ReplayProcessor.create();
final TestSubscriber<CrdtCommand> subscriber = TestSubscriber.create();
final TwoPSet<String> set = new TwoPSet<>("ID_1");
set.subscribeTo(inputStream);
set.subscribe(subscriber);
final TwoPSet.AddCommand<String> command1 = new TwoPSet.AddCommand<>(set.getCrdtId(), "1");
final TwoPSet.AddCommand<String> command2 = new TwoPSet.AddCommand<>(set.getCrdtId(), "1");
final TwoPSet.RemoveCommand<String> command3 = new TwoPSet.RemoveCommand<>(set.getCrdtId(), "1");
// when:
inputStream.onNext(command1);
inputStream.onNext(command2);
inputStream.onNext(command3);
// then:
assertThat(set, empty());
assertThat(subscriber.valueCount(), is(2));
subscriber.assertNotComplete();
subscriber.assertNoErrors();
}
开发者ID:netopyr,项目名称:wurmloch-crdt,代码行数:25,代码来源:TwoPSetTest.java
示例11: shouldHandleRemoveCommandArrivesBeforeAddCommand
import org.reactivestreams.Processor; //导入依赖的package包/类
@Test
public void shouldHandleRemoveCommandArrivesBeforeAddCommand() {
// given:
final Processor<TwoPSet.TwoPSetCommand<String>, TwoPSet.TwoPSetCommand<String>> inputStream = ReplayProcessor.create();
final TestSubscriber<CrdtCommand> subscriber = TestSubscriber.create();
final TwoPSet<String> set = new TwoPSet<>("ID_1");
set.subscribeTo(inputStream);
set.subscribe(subscriber);
final TwoPSet.RemoveCommand<String> command1 = new TwoPSet.RemoveCommand<>(set.getCrdtId(), "1");
final TwoPSet.AddCommand<String> command2 = new TwoPSet.AddCommand<>(set.getCrdtId(), "1");
final TwoPSet.AddCommand<String> command3 = new TwoPSet.AddCommand<>(set.getCrdtId(), "1");
// when:
inputStream.onNext(command1);
inputStream.onNext(command2);
inputStream.onNext(command3);
// then:
assertThat(set, empty());
assertThat(subscriber.valueCount(), is(1));
subscriber.assertNotComplete();
subscriber.assertNoErrors();
}
开发者ID:netopyr,项目名称:wurmloch-crdt,代码行数:25,代码来源:TwoPSetTest.java
示例12: onNext
import org.reactivestreams.Processor; //导入依赖的package包/类
/**
* Emits the specified value from the observable associated with the specified key
* if there is an associated observable. If no observable has subscribed to the key,
* this operation is a noop. If no value is not emitted it will be faulted in later
* should another query request it
*
* @param key key with which the specified value is to be associated
* @param valueProvider the method to be called to create the new value in the case of a hit
* @param missHandler the callback for when a subscriber has not been bound
*/
public void onNext(K key, final Callable<V> valueProvider, Action missHandler)
{
emitUpdate(key, new Consumer<Processor<V, V>>() {
@Override
public void accept(Processor<V, V> subject)
{
try {
subject.onNext(valueProvider.call());
}
catch (Exception error) {
subject.onError(error);
}
}
}, missHandler);
}
开发者ID:mproberts,项目名称:rxtools,代码行数:26,代码来源:SubjectMap.java
示例13: setupFakeProtocolListener
import org.reactivestreams.Processor; //导入依赖的package包/类
private void setupFakeProtocolListener() throws Exception {
broadcaster = TopicProcessor.create();
final Processor<List<String>, List<String>> processor =
WorkQueueProcessor.<List<String>>builder().autoCancel(false).build();
Flux.from(broadcaster)
.buffer(5)
.subscribe(processor);
httpServer = HttpServer.create(0)
.newRouter(r -> r.get("/data",
(req, resp) -> resp.options(NettyPipeline.SendOptions::flushOnEach)
.send(Flux.from(processor)
.log("server")
.timeout(Duration.ofSeconds(
2),
Flux.empty())
.concatWith(Flux.just(
new ArrayList<>()))
.map(new DummyListEncoder(
resp.alloc()
)))))
.block(Duration.ofSeconds(30));
}
开发者ID:reactor,项目名称:reactor-netty,代码行数:24,代码来源:ClientServerHttpTests.java
示例14: start
import org.reactivestreams.Processor; //导入依赖的package包/类
@BeforeClass
public void start() throws Exception {
executorService = Executors.newCachedThreadPool();
actorSystem = ActorSystem.create();
materializer = ActorMaterializer.create(actorSystem);
helper = new HttpHelper(materializer);
eventLoop = new NioEventLoopGroup();
ProcessorHttpServer server = new ProcessorHttpServer(eventLoop);
// A flow that echos HttpRequest bodies in HttpResponse bodies
final Flow<HttpRequest, HttpResponse, NotUsed> flow = Flow.<HttpRequest>create().map(
new Function<HttpRequest, HttpResponse>() {
public HttpResponse apply(HttpRequest request) throws Exception {
return helper.echo(request);
}
}
);
serverBindChannel = server.bind(new InetSocketAddress("127.0.0.1", 0), new Callable<Processor<HttpRequest, HttpResponse>>() {
@Override
public Processor<HttpRequest, HttpResponse> call() throws Exception {
return AkkaStreamsUtil.flowToProcessor(flow, materializer);
}
}).await().channel();
}
开发者ID:playframework,项目名称:netty-reactive-streams,代码行数:26,代码来源:FullStackHttpIdentityProcessorVerificationTest.java
示例15: onError
import org.reactivestreams.Processor; //导入依赖的package包/类
@Override
public void onError(Throwable t) {
if (done) {
Operators.onErrorDropped(t, actual.currentContext());
return;
}
done = true;
Processor<T, T> w = window;
if (w != null) {
window = null;
w.onError(t);
}
actual.onError(t);
}
开发者ID:reactor,项目名称:reactor-core,代码行数:17,代码来源:FluxWindow.java
示例16: main
import org.reactivestreams.Processor; //导入依赖的package包/类
public static void main(String[] args) throws InterruptedException {
Environment env = Environment.initialize();
Processor<String, String> p = RingBufferProcessor.create("testProcessor", 32);
Stream<String> s1 = Streams.wrap(p);
s1.consume(ev -> System.out.println(Thread.currentThread() + " data=" + ev));
s1.consume(ev -> System.out.println(Thread.currentThread() + " data=" + ev));
s1.consume(ev -> System.out.println(Thread.currentThread() + " data=" + ev));
p.onNext("One");
p.onNext("Two");
p.onNext("Three");
p.onComplete();
Environment.terminate();
}
开发者ID:iproduct,项目名称:low-latency-high-throughput,代码行数:19,代码来源:RingBufferProcessorDemo.java
示例17: main
import org.reactivestreams.Processor; //导入依赖的package包/类
public static void main(String[] args) throws InterruptedException {
Environment env = Environment.initialize();
Processor<String, String> p = RingBufferWorkProcessor.create("testProcessor", 32);
Stream<String> s1 = Streams.wrap(p);
s1.consume(ev -> System.out.println(Thread.currentThread() + " data=" + ev));
s1.consume(ev -> System.out.println(Thread.currentThread() + " data=" + ev));
s1.consume(ev -> System.out.println(Thread.currentThread() + " data=" + ev));
p.onNext("One");
p.onNext("Two");
p.onNext("Three");
p.onNext("Four");
p.onNext("Five");
p.onComplete();
Environment.terminate();
}
开发者ID:iproduct,项目名称:low-latency-high-throughput,代码行数:21,代码来源:RingBufferWorkProcessorDemo.java
示例18: onError
import org.reactivestreams.Processor; //导入依赖的package包/类
@Override
public void onError(Throwable t) {
if (done) {
UnsignalledExceptions.onErrorDropped(t);
return;
}
for (Processor<T, T> w : windows) {
w.onError(t);
}
windows.clear();
error = t;
done = true;
drain();
}
开发者ID:reactor,项目名称:reactive-streams-commons,代码行数:17,代码来源:PublisherWindow.java
示例19: write
import org.reactivestreams.Processor; //导入依赖的package包/类
public Processor<Buffer, Void> write() {
return new BaseProcessor<Buffer, Void>() {
@Override
public void doNext(Buffer value) {
asyncFile.write(value);
if (!asyncFile.writeQueueFull()) {
sendRequest();
handled();
} else {
asyncFile.drainHandler(new Handler<Void>() {
@Override
public void handle(Void event) {
sendRequest();
handled();
}
});
}
}
};
}
开发者ID:bckfnn,项目名称:react-streams,代码行数:21,代码来源:RsAsyncFile.java
示例20: sendToUnboundBus
import org.reactivestreams.Processor; //导入依赖的package包/类
private boolean sendToUnboundBus(RxQueueKey key, Object event)
{
boolean send = false;
Processor processor = RxBus.getInstance().getProcessor(key, false);
// only send event, if processor exists => this means someone has at least once subscribed to it
if (processor != null)
{
if (mCast == null)
processor.onNext(event);
else
processor.onNext(mCast.cast(event));
send = true;
}
return send;
}
开发者ID:MFlisar,项目名称:RxBus2,代码行数:16,代码来源:RxBusSenderBuilder.java
注:本文中的org.reactivestreams.Processor类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论