本文整理汇总了Java中org.fusesource.hawtdispatch.Dispatch.createQueue方法的典型用法代码示例。如果您正苦于以下问题:Java Dispatch.createQueue方法的具体用法?Java Dispatch.createQueue怎么用?Java Dispatch.createQueue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.fusesource.hawtdispatch.Dispatch
的用法示例。
在下文中一共展示了Dispatch.createQueue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setup
import org.fusesource.hawtdispatch.Dispatch; //导入方法依赖的package包/类
@Before
public void setup() throws Exception
{
DispatchQueue queue = Dispatch.createQueue();
HashMap<String, SerializationStrategy> map = new HashMap<String, SerializationStrategy>();
server = new ServerInvokerImpl("tcp://localhost:0", queue, map);
server.start();
client = new ClientInvokerImpl(queue, map);
client.start();
// server.stop();
server.registerService("service-id", new ServerInvoker.ServiceFactory()
{
public Object get()
{
return new TestServiceImpl();
}
public void unget()
{}
}, TestServiceImpl.class.getClassLoader());
InvocationHandler handler = client.getProxy(server.getConnectAddress(), "service-id", TestServiceImpl.class.getClassLoader());
testService = (TestService)Proxy.newProxyInstance(HelloImpl.class.getClassLoader(), new Class[]{TestService.class}, handler);
}
示例2: setup
import org.fusesource.hawtdispatch.Dispatch; //导入方法依赖的package包/类
@Before
public void setup() throws Exception
{
DispatchQueue queue = Dispatch.createQueue();
HashMap<String, SerializationStrategy> map = new HashMap<String, SerializationStrategy>();
server = new ServerInvokerImpl("tcp://localhost:0", queue, map);
server.start();
client = new ClientInvokerImpl(queue, map);
client.start();
// server.stop();
server.registerService("service-id", new ServerInvoker.ServiceFactory()
{
public Object get()
{
return new TestServiceImpl();
}
public void unget()
{}
}, TestServiceImpl.class.getClassLoader());
InvocationHandler handler = client.getProxy(server.getConnectAddress(), "service-id", TestServiceImpl.class.getClassLoader());
testService = (TestService)Proxy.newProxyInstance(HelloImpl.class.getClassLoader(), new Class[]{TestService.class}, handler);
Activator.INSTANCE = new Activator();
Activator.INSTANCE.client = client;
Activator.INSTANCE.server = server;
}
示例3: testObjectMethods
import org.fusesource.hawtdispatch.Dispatch; //导入方法依赖的package包/类
@Test
public void testObjectMethods() throws Exception {
DispatchQueue queue = Dispatch.createQueue();
HashMap<String, SerializationStrategy> map = new HashMap<String, SerializationStrategy>();
map.put("protobuf", new ProtobufSerializationStrategy());
ServerInvokerImpl server = new ServerInvokerImpl("tcp://localhost:0", queue, map);
server.start();
ClientInvokerImpl client = new ClientInvokerImpl(queue, map);
client.start();
final HelloImpl serviceImpl = new HelloImpl();
try {
server.registerService("service-id", new ServerInvoker.ServiceFactory() {
public Object get() {
return serviceImpl;
}
public void unget() {
}
}, HelloImpl.class.getClassLoader());
InvocationHandler handler = client.getProxy(server.getConnectAddress(), "service-id", HelloImpl.class.getClassLoader());
Hello hello = (Hello) Proxy.newProxyInstance(HelloImpl.class.getClassLoader(), new Class[] { Hello.class }, handler);
assertNotEquals("Hashcode should be handled by the proxy and not be a remote call",-7, hello.hashCode());
assertFalse("equals should be handled by the proxy and not be a remote call",hello.equals(serviceImpl));
}
finally {
server.stop();
client.stop();
}
}
示例4: testNoOverflow
import org.fusesource.hawtdispatch.Dispatch; //导入方法依赖的package包/类
@Test(timeout=30*1000)
public void testNoOverflow() throws Exception {
DispatchQueue queue = Dispatch.createQueue();
HashMap<String, SerializationStrategy> map = new HashMap<String, SerializationStrategy>();
map.put("protobuf", new ProtobufSerializationStrategy());
ServerInvokerImpl server = new ServerInvokerImpl("tcp://localhost:0", queue, map);
server.start();
ClientInvokerImpl client = new ClientInvokerImpl(queue, map);
client.start();
try {
server.registerService("service-id", new ServerInvoker.ServiceFactory() {
public Object get() {
return new HelloImpl();
}
public void unget() {
}
}, HelloImpl.class.getClassLoader());
InvocationHandler handler = client.getProxy(server.getConnectAddress(), "service-id", HelloImpl.class.getClassLoader());
Hello hello = (Hello) Proxy.newProxyInstance(HelloImpl.class.getClassLoader(), new Class[] { Hello.class }, handler);
char[] chars = new char[65*1024];
String payload = new String(chars);
for(int i = 0; i < 100; i++) {
hello.hello(payload);
}
}
finally {
server.stop();
client.stop();
}
}
示例5: testInvoke
import org.fusesource.hawtdispatch.Dispatch; //导入方法依赖的package包/类
@Test(timeout=30*1000)
public void testInvoke() throws Exception {
DispatchQueue queue = Dispatch.createQueue();
HashMap<String, SerializationStrategy> map = new HashMap<String, SerializationStrategy>();
map.put("protobuf", new ProtobufSerializationStrategy());
ServerInvokerImpl server = new ServerInvokerImpl("tcp://localhost:0", queue, map);
server.start();
ClientInvokerImpl client = new ClientInvokerImpl(queue, map);
client.start();
try {
server.registerService("service-id", new ServerInvoker.ServiceFactory() {
public Object get() {
return new HelloImpl();
}
public void unget() {
}
}, HelloImpl.class.getClassLoader());
InvocationHandler handler = client.getProxy(server.getConnectAddress(), "service-id", HelloImpl.class.getClassLoader());
Hello hello = (Hello) Proxy.newProxyInstance(HelloImpl.class.getClassLoader(), new Class[] { Hello.class }, handler);
assertEquals("Hello Fabric!", hello.hello("Fabric"));
assertEquals("Hello World!", hello.helloworld());
// Verification the we can pick the right overloaded method even if using a mixure
// of primitives / objects and array dimensions.
assertEquals('a', hello.mix(0));
assertEquals('b', hello.mix(new int[]{0}));
assertEquals('c', hello.mix(new Integer(0)));
assertEquals('d', hello.mix(new Integer[]{new Integer(0)}));
assertEquals('e', hello.mix(new int[0][0]));
assertEquals('f', hello.mix(new Integer[0][0]));
AsyncCallbackFuture<String> future1 = new AsyncCallbackFuture<String>();
hello.hello("Hiram", future1);
assertEquals("Hello Hiram!", future1.get(2, TimeUnit.SECONDS));
assertEquals("Hello Hiram!", hello.protobuf(stringValue("Hiram")).getValue());
AsyncCallbackFuture<StringValue.Getter> future2 = new AsyncCallbackFuture<StringValue.Getter>();
hello.protobuf(stringValue("Hiram Async"), future2);
assertEquals("Hello Hiram Async!", future2.get(2, TimeUnit.SECONDS).getValue());
}
finally {
server.stop();
client.stop();
}
}
示例6: testOverflowAsync
import org.fusesource.hawtdispatch.Dispatch; //导入方法依赖的package包/类
@Test(timeout=30*1000)
public void testOverflowAsync() throws Exception {
DispatchQueue queue = Dispatch.createQueue();
HashMap<String, SerializationStrategy> map = new HashMap<String, SerializationStrategy>();
map.put("protobuf", new ProtobufSerializationStrategy());
ServerInvokerImpl server = new ServerInvokerImpl("tcp://localhost:0", queue, map);
server.start();
ClientInvokerImpl client = new ClientInvokerImpl(queue, map);
client.start();
try {
server.registerService("service-id", new ServerInvoker.ServiceFactory() {
public Object get() {
return new HelloImpl();
}
public void unget() {
}
}, HelloImpl.class.getClassLoader());
InvocationHandler handler = client.getProxy(server.getConnectAddress(), "service-id", HelloImpl.class.getClassLoader());
Hello hello = (Hello) Proxy.newProxyInstance(HelloImpl.class.getClassLoader(), new Class[] { Hello.class }, handler);
char[] chars = new char[65*1024];
String payload = new String(chars);
final List<AsyncCallbackFuture<String>> futures = new ArrayList<AsyncCallbackFuture<String>>();
for(int i = 0; i < 100; i++) {
AsyncCallbackFuture<String> future = new AsyncCallbackFuture<String>();
hello.hello(payload, future);
futures.add(future);
}
for(Future<String> f : futures) {
f.get(3, TimeUnit.SECONDS);
}
// future2.get(2, TimeUnit.SECONDS);
//assertEquals("Hello Hiram!", future1.get(2, TimeUnit.SECONDS));
//assertEquals("Hello Hiram!", hello.protobuf(stringValue(payload)).getValue());
}
finally {
server.stop();
client.stop();
}
}
示例7: testOverflow
import org.fusesource.hawtdispatch.Dispatch; //导入方法依赖的package包/类
@Test(timeout=30*1000)
public void testOverflow() throws Exception {
DispatchQueue queue = Dispatch.createQueue();
HashMap<String, SerializationStrategy> map = new HashMap<String, SerializationStrategy>();
map.put("protobuf", new ProtobufSerializationStrategy());
ServerInvokerImpl server = new ServerInvokerImpl("tcp://localhost:0", queue, map);
server.start();
ClientInvokerImpl client = new ClientInvokerImpl(queue, map);
client.start();
try {
server.registerService("service-id", new ServerInvoker.ServiceFactory() {
public Object get() {
return new HelloImpl();
}
public void unget() {
}
}, HelloImpl.class.getClassLoader());
InvocationHandler handler = client.getProxy(server.getConnectAddress(), "service-id", HelloImpl.class.getClassLoader());
final Hello hello = (Hello) Proxy.newProxyInstance(HelloImpl.class.getClassLoader(), new Class[] { Hello.class }, handler);
final AtomicInteger requests = new AtomicInteger(0);
final AtomicInteger responses = new AtomicInteger(0);
final AtomicInteger failures = new AtomicInteger(0);
char[] chars = new char[65*1024];
final String payload = new String(chars);
Thread[] threads = new Thread[BENCHMARK_CLIENTS];
for (int t = 0; t < BENCHMARK_CLIENTS; t++) {
threads[t] = new Thread() {
public void run() {
try {
requests.incrementAndGet();
hello.hello(payload);
responses.incrementAndGet();
} catch (Throwable t) {
failures.incrementAndGet();
}
}
};
threads[t].start();
}
for (int t = 0; t < BENCHMARK_CLIENTS; t++) {
threads[t].join(10000);
System.err.format("REQUEST: %d of %d%n", requests.get(), BENCHMARK_CLIENTS);
System.err.format("RESPONSES: %d of %d%n", responses.get(), BENCHMARK_CLIENTS);
assertEquals(threads[t].isAlive(), false);
}
assertEquals(BENCHMARK_CLIENTS, requests.get());
assertEquals(BENCHMARK_CLIENTS, responses.get());
assertEquals(0, failures.get());
}
finally {
server.stop();
client.stop();
}
}
示例8: testInvoke
import org.fusesource.hawtdispatch.Dispatch; //导入方法依赖的package包/类
@Test
public void testInvoke() throws Exception {
DispatchQueue queue = Dispatch.createQueue();
HashMap<String, SerializationStrategy> map = new HashMap<String, SerializationStrategy>();
map.put("protobuf", new ProtobufSerializationStrategy());
ServerInvokerImpl server = new ServerInvokerImpl("tcp://localhost:0", queue, map);
server.start();
ClientInvokerImpl client = new ClientInvokerImpl(queue, map);
client.start();
try {
server.registerService("service-id", new ServerInvoker.ServiceFactory() {
public Object get() {
return new HelloImpl();
}
public void unget() {
}
}, HelloImpl.class.getClassLoader());
InvocationHandler handler = client.getProxy(server.getConnectAddress(), "service-id", HelloImpl.class.getClassLoader());
Hello hello = (Hello) Proxy.newProxyInstance(HelloImpl.class.getClassLoader(), new Class[]{Hello.class}, handler);
AsyncCallbackFuture<String> future1 = new AsyncCallbackFuture<String>();
hello.hello("Guillaume", future1);
long t0 = System.currentTimeMillis();
try {
assertEquals("Hello Guillaume!", future1.get(MAX_DELAY, TimeUnit.MILLISECONDS));
fail("Should have thrown an exception");
} catch (Exception e) {
// Expected
long t1 = System.currentTimeMillis();
assertTrue(t1 - t0 > SLEEP_TIME / 2);
assertTrue(t1 - t0 < MAX_DELAY / 2);
}
}
finally {
server.stop();
client.stop();
}
}
示例9: load
import org.fusesource.hawtdispatch.Dispatch; //导入方法依赖的package包/类
public DispatchQueue load(String key) throws Exception {
return Dispatch.createQueue(key);
}
示例10: JettyWebServer
import org.fusesource.hawtdispatch.Dispatch; //导入方法依赖的package包/类
public JettyWebServer(Broker broker) {
super(Dispatch.createQueue());
this.broker = broker;
}
示例11: VirtualHost
import org.fusesource.hawtdispatch.Dispatch; //导入方法依赖的package包/类
public VirtualHost(Broker broker) {
super(Dispatch.createQueue("virtual-host"));
this.broker = broker;
}
示例12: AbstractConnection
import org.fusesource.hawtdispatch.Dispatch; //导入方法依赖的package包/类
protected AbstractConnection() {
super(Dispatch.createQueue());
}
示例13: Broker
import org.fusesource.hawtdispatch.Dispatch; //导入方法依赖的package包/类
public Broker() {
super(Dispatch.createQueue("broker"));
initXPathEvaluator();
initDefaultVirtualHostConfig();
initDefaultConnectorConfig();
}
示例14: WsTransportServer
import org.fusesource.hawtdispatch.Dispatch; //导入方法依赖的package包/类
public WsTransportServer(URI uri) {
super(Dispatch.createQueue("web sockets dispatch queue"));
this.uri = uri;
}
示例15: TaskTracker
import org.fusesource.hawtdispatch.Dispatch; //导入方法依赖的package包/类
public TaskTracker(String name, Long timeout) {
this.name = name;
done = false;
queue = Dispatch.createQueue("tracker: " + name);
this.timeout = timeout;
}