This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Router router = Router.router(vertx); | |
router.route().handler(BodyHandler.create()); | |
router.get("/service/hystrix.stream").handler(this::hystrixStream); | |
vertx.createHttpServer().requestHandler(router::accept).listen(8090); | |
public void hystrixStream(RoutingContext ctx) { | |
//set the header parameters | |
ctx.response().setChunked(true); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Licensed to the Apache Software Foundation (ASF) under one or more | |
* contributor license agreements. See the NOTICE file distributed with | |
* this work for additional information regarding copyright ownership. | |
* The ASF licenses this file to You under the Apache License, Version 2.0 | |
* (the "License"); you may not use this file except in compliance with | |
* the License. You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Licensed to the Apache Software Foundation (ASF) under one or more | |
* contributor license agreements. See the NOTICE file distributed with | |
* this work for additional information regarding copyright ownership. | |
* The ASF licenses this file to You under the Apache License, Version 2.0 | |
* (the "License"); you may not use this file except in compliance with | |
* the License. You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class PingPong { | |
Agent<String> whoseTurn; | |
public PingPong(Agent<String> player) { | |
whoseTurn = player; | |
} | |
public boolean hit(final String opponent) { | |
final String x = Thread.currentThread().getName(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class PingPong { | |
//updates to Ref.View are synchronous | |
Ref.View<String> whoseTurn; | |
public PingPong(Ref.View<String> player) { | |
whoseTurn = player; | |
} | |
public boolean hit(final String opponent) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Game { | |
public static void main(String args[]) { | |
PingPong table = new PingPong(); | |
Thread alice = new Thread(new Player("bob", table)); | |
Thread bob = new Thread(new Player("alice", table)); | |
alice.setName("alice"); | |
bob.setName("bob"); | |
alice.start(); // alice starts playing | |
bob.start(); // bob starts playing |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class PingPong { | |
// state variable identifying whose turn it is. | |
private String whoseTurn = null; | |
public synchronized boolean hit(String opponent) { | |
String x = Thread.currentThread().getName(); | |
if (x.compareTo(whoseTurn) == 0) { | |
System.out.println("PING! (" + x + ")"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Player implements Runnable { | |
PingPong myTable; // Table where they play | |
String myOpponent; | |
public Player(String opponent, PingPong table) { | |
myTable = table; | |
myOpponent = opponent; | |
} | |
public void run() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// create a valid Application ID that will be used | |
// by the Search Node to authorize access to the collection | |
ApplicationInfo appinfo = factory.createApplicationInfo(applicationName); | |
appinfo.setPassword(applicationPassword); | |
// create a new Properties object. | |
Properties config = new Properties(); | |
config.setProperty("hostname", "OmniFindHostName"); | |
config.setProperty("port", "80"); | |
config.setProperty("timeout", "60"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Test | |
public void testEchoActor() { | |
ActorRef echoActorRef = _system.actorOf(new Props(EchoActor.class)); | |
// pass the reference to implicit sender testActor() otherwise | |
// message end up in dead mailbox | |
echoActorRef.tell("Hi there", super.testActor()); | |
expectMsg("Hi there"); | |
} | |
@Test |
NewerOlder