本文整理汇总了Java中org.jgroups.blocks.ResponseMode类的典型用法代码示例。如果您正苦于以下问题:Java ResponseMode类的具体用法?Java ResponseMode怎么用?Java ResponseMode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ResponseMode类属于org.jgroups.blocks包,在下文中一共展示了ResponseMode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: cancelTask
import org.jgroups.blocks.ResponseMode; //导入依赖的package包/类
@Override
public boolean cancelTask(String hostname) {
try {
log.debug("Calling cancelTaskRpc for {}...", hostname);
MethodCall call = new MethodCall(getClass().getMethod("cancelTaskRpc", String.class));
RequestOptions ops = new RequestOptions(ResponseMode.GET_ALL, 5000);
call.setArgs(hostname);
RspList<CancelTaskRpcResponse> responses = rpcDispatcher.callRemoteMethods(
rpcDispatcher.getChannel()
.getView()
.getMembers()
.stream()
.filter(h -> h.toString().equalsIgnoreCase(hostname))
.collect(Collectors.toList()),
call, ops);
log.debug("Got answer: {}", responses);
return responses.getResults()
.stream()
.anyMatch(CancelTaskRpcResponse::isCancelled);
} catch (Exception e) {
log.catching(e);
return false;
}
}
开发者ID:ccremer,项目名称:clustercode,代码行数:25,代码来源:JGroupsMessageDispatcherImpl.java
示例2: mouseReleased
import org.jgroups.blocks.ResponseMode; //导入依赖的package包/类
public void mouseReleased(MouseEvent e) {
Point p=e.getPoint();
if(pick == null)
return;
pick.x=p.x;
pick.y=p.y;
pick.fixed=pickfixed;
try {
MethodCall call=new MethodCall("moveNode", new Object[]{pick}, new Class[]{Node.class});
wb.disp.callRemoteMethods(null, call, new RequestOptions(ResponseMode.GET_ALL, 0));
}
catch(Exception ex) {
log.error(ex.toString());
}
pick=null;
}
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:21,代码来源:GraphPanel.java
示例3: start
import org.jgroups.blocks.ResponseMode; //导入依赖的package包/类
public void start(String name) {
myname=name;
int xloc=(int)(10 + 250 * Math.random());
int yloc=(int)(10 + 250 * Math.random());
try {
MethodCall call=new MethodCall("addNode",
new Object[]{name,my_addr,new Integer(xloc),new Integer(yloc)},
new Class[]{String.class,Address.class,int.class,int.class});
wb.disp.callRemoteMethods(null, call, new RequestOptions(ResponseMode.GET_ALL, 0));
}
catch(Exception e) {
log.error(e.toString());
}
repaint();
}
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:17,代码来源:GraphPanel.java
示例4: testOneChannel
import org.jgroups.blocks.ResponseMode; //导入依赖的package包/类
/**
* Tests the deadlock resolution using self-calls on a single channel. The deadlock detection
* is turned on so the method call should go straight through. If there is a problem, JUnit will
* timeout.
*
* @throws Exception
*/
public void testOneChannel() throws Exception {
c1 = createChannel(true);
ServerObject serverObject = new ServerObject("obj1");
RpcDispatcher disp=new RpcDispatcher(c1, serverObject);
serverObject.setRpcDispatcher(disp);
c1.connect(name);
Address localAddress = c1.getAddress();
// call the nested group method on itself
MethodCall call = new MethodCall("outerMethod", new Object[0], new Class[0]);
log("calling outerMethod() on all members");
RspList rspList = disp.callRemoteMethods(null, call, new RequestOptions(ResponseMode.GET_ALL, 0));
log("results of outerMethod(): " + rspList);
Assert.assertEquals(1, rspList.size());
assertEquals("outerMethod[innerMethod]", rspList.getValue(localAddress));
assertTrue(rspList.isReceived(localAddress));
assertFalse(rspList.isSuspected(localAddress));
}
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:27,代码来源:Deadlock2Test.java
示例5: testTwoChannels
import org.jgroups.blocks.ResponseMode; //导入依赖的package包/类
/**
* Tests the deadlock resolution using two different channels. The deadlock detection
* is turned on. It implements the following scenario:
*
* Channel1 Channel2
* | |
* + -------------------------------> outerMethod()
* | RPC
* | |
* | |
* | |
* | <-- innerMethod() <-----------------+ ---------+
* | | |
* | | <-- innerMethod()
*
* If there is a deadlock, JUnit will timeout and fail the test.
*
*/
public void testTwoChannels() throws Throwable {
ServerObject obj1, obj2 = null;
c1 = createChannel(true);
obj1 = new ServerObject("obj1");
RpcDispatcher disp1=new RpcDispatcher(c1, obj1);
obj1.setRpcDispatcher(disp1);
c1.connect(name);
c2 = createChannel(c1);
obj2 = new ServerObject("obj2");
RpcDispatcher disp2=new RpcDispatcher(c2, obj2);
obj2.setRpcDispatcher(disp2);
c2.connect(name);
Address localAddress2 = c2.getAddress();
// call a point-to-point method on Member 2 that triggers a nested distributed RPC
MethodCall call = new MethodCall("outerMethod", new Object[0], new Class[0]);
log("calling outerMethod() on " + localAddress2);
Object retval = disp1.callRemoteMethod(localAddress2, call, new RequestOptions(ResponseMode.GET_ALL, 0));
log("results of outerMethod(): " + retval);
}
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:41,代码来源:Deadlock2Test.java
示例6: testTwoChannelsWithInitialMulticast
import org.jgroups.blocks.ResponseMode; //导入依赖的package包/类
public void testTwoChannelsWithInitialMulticast() throws Exception {
ServerObject obj1, obj2 = null;
c1 = createChannel(true);
obj1 = new ServerObject("obj1");
RpcDispatcher disp1=new RpcDispatcher(c1, obj1);
obj1.setRpcDispatcher(disp1);
c1.connect(name);
c2 = createChannel(c1);
obj2 = new ServerObject("obj2");
RpcDispatcher disp2=new RpcDispatcher(c2, obj2);
obj2.setRpcDispatcher(disp2);
c2.connect(name);
Vector<Address> dests=new Vector<>();
dests.add(c1.getAddress());
dests.add(c2.getAddress());
// call a point-to-point method on Member 2 that triggers a nested distributed RPC
MethodCall call = new MethodCall("outerMethod", new Object[0], new Class[0]);
log("calling outerMethod() on all members");
RspList rsps = disp1.callRemoteMethods(dests, call, new RequestOptions(ResponseMode.GET_ALL, 0));
log("results of outerMethod():\n" + rsps);
Assert.assertEquals(2, rsps.size());
}
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:27,代码来源:Deadlock2Test.java
示例7: outerMethod
import org.jgroups.blocks.ResponseMode; //导入依赖的package包/类
public String outerMethod() throws Exception {
log("**** outerMethod() received, calling innerMethod() on all members");
MethodCall call = new MethodCall("innerMethod", new Object[0], new Class[0]);
// RspList rspList = disp.callRemoteMethods(null, call, GroupResponseMode.GET_ALL, 5000);
RequestOptions opts=new RequestOptions(ResponseMode.GET_ALL, 0, false, null, (Message.Flag[])null);
opts.setFlags(Message.Flag.OOB);
RspList<String> rspList = disp.callRemoteMethods(null, call, opts);
List<String> results = rspList.getResults();
log("results of calling innerMethod():\n" + rspList);
StringBuilder sb=new StringBuilder("outerMethod[");
boolean first=true;
for(String s: results) {
if(first)
first=false;
else
sb.append(";");
sb.append(s);
}
sb.append("]");
return sb.toString();
}
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:22,代码来源:Deadlock2Test.java
示例8: remoteExecute
import org.jgroups.blocks.ResponseMode; //导入依赖的package包/类
@Override
public <T> T remoteExecute(MethodCall action, long timeout) {
logTrace(() -> String.format("RemoteExecute sync action %s with timeout %s", action, timeout));
RequestOptions options = new RequestOptions()
.setFlags(JGROUPS_FLAGS)
.setMode(ResponseMode.GET_ALL)
.setTimeout(timeout);
try {
NotifyingFuture<RspList<T>> notifyingFuture = this.<T>execute(action, options);
RspList<T> rspList = notifyingFuture.get(timeout, TimeUnit.MILLISECONDS);
return futureDone(rspList);
} catch (Exception e) {
throw new VertxException(e);
}
}
开发者ID:vert-x3,项目名称:vertx-jgroups,代码行数:17,代码来源:DefaultRpcExecutorService.java
示例9: whereIsState
import org.jgroups.blocks.ResponseMode; //导入依赖的package包/类
protected Address whereIsState(Serializable stateId, long timeout) throws Exception {
if (remoteMembers.isEmpty()) {
return null;
}
RspList<Boolean> resp = this.disp.callRemoteMethods(getRemoteMembersCopy(), new MethodCall((short)(methodMap.size() - 5), new Object[]{stateId}), new RequestOptions(ResponseMode.GET_ALL, timeout));
Collection<Rsp<Boolean>> values = resp.values();
Rsp<Boolean> rsp = null;
for (Rsp<Boolean> response : values) {
if (Boolean.TRUE.equals(response.getValue())) {
rsp = response;
break;
}
}
if (rsp == null) {
return null;
}
return rsp.getSender();
}
开发者ID:kenweezy,项目名称:teiid,代码行数:19,代码来源:JGroupsObjectReplicator.java
示例10: sendMessage
import org.jgroups.blocks.ResponseMode; //导入依赖的package包/类
private void sendMessage(int size) throws Exception {
long start, stop;
MyHandler handler=new MyHandler(new byte[size]);
d1.setRequestHandler(handler);
start=System.currentTimeMillis();
RspList rsps=d1.castMessage(null, new Message(), new RequestOptions(ResponseMode.GET_ALL, 0));
stop=System.currentTimeMillis();
System.out.println("rsps:\n" + rsps);
System.out.println("call took " + (stop - start) + " ms");
assertNotNull(rsps);
Assert.assertEquals(1, rsps.size());
byte[] buf=(byte[])rsps.getFirst();
assertNotNull(buf);
Assert.assertEquals(size, buf.length);
}
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:16,代码来源:MessageDispatcherUnitTest.java
示例11: sendMessageToBothChannels
import org.jgroups.blocks.ResponseMode; //导入依赖的package包/类
private void sendMessageToBothChannels(int size) throws Exception {
long start, stop;
d1.setRequestHandler(new MyHandler(new byte[size]));
b=createChannel(a);
b.setName("B");
d2=new MessageDispatcher(b, null, null, new MyHandler(new byte[size]));
b.connect("MessageDispatcherUnitTest");
Assert.assertEquals(2,b.getView().size());
System.out.println("casting message");
start=System.currentTimeMillis();
RspList rsps=d1.castMessage(null, new Message(), new RequestOptions(ResponseMode.GET_ALL, 0));
stop=System.currentTimeMillis();
System.out.println("rsps:\n" + rsps);
System.out.println("call took " + (stop - start) + " ms");
assertNotNull(rsps);
Assert.assertEquals(2,rsps.size());
Rsp rsp=rsps.get(a.getAddress());
assertNotNull(rsp);
byte[] ret=(byte[])rsp.getValue();
Assert.assertEquals(size, ret.length);
rsp=rsps.get(b.getAddress());
assertNotNull(rsp);
ret=(byte[])rsp.getValue();
Assert.assertEquals(size, ret.length);
Util.close(b);
}
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:31,代码来源:MessageDispatcherUnitTest.java
示例12: JGroupsOutputStream
import org.jgroups.blocks.ResponseMode; //导入依赖的package包/类
public JGroupsOutputStream(RpcDispatcher disp, List<Address> dests, Serializable stateId, short methodOffset, boolean sendCreate) throws IOException {
this.disp=disp;
this.dests=dests;
this.stateId=stateId;
this.methodOffset = methodOffset;
if (sendCreate) {
try {
disp.callRemoteMethods(this.dests, new MethodCall(methodOffset, new Object[] {stateId}), new RequestOptions(ResponseMode.GET_NONE, 0).setAnycasting(dests != null));
} catch(Exception e) {
throw new IOException(e);
}
}
}
开发者ID:kenweezy,项目名称:teiid,代码行数:14,代码来源:JGroupsOutputStream.java
示例13: close
import org.jgroups.blocks.ResponseMode; //导入依赖的package包/类
public void close() throws IOException {
if(closed) {
return;
}
flush();
try {
disp.callRemoteMethods(dests, new MethodCall((short)(methodOffset + 2), new Object[] {stateId}), new RequestOptions(ResponseMode.GET_NONE, 0).setAnycasting(dests != null));
} catch(Exception e) {
}
closed=true;
}
开发者ID:kenweezy,项目名称:teiid,代码行数:12,代码来源:JGroupsOutputStream.java
示例14: flush
import org.jgroups.blocks.ResponseMode; //导入依赖的package包/类
public void flush() throws IOException {
checkClosed();
try {
if(index == 0) {
return;
}
disp.callRemoteMethods(dests, new MethodCall((short)(methodOffset + 1), new Object[] {stateId, Arrays.copyOf(buffer, index)}), new RequestOptions(ResponseMode.GET_NONE, 0).setAnycasting(dests != null));
index=0;
} catch(Exception e) {
throw new IOException(e);
}
}
开发者ID:kenweezy,项目名称:teiid,代码行数:13,代码来源:JGroupsOutputStream.java
示例15: sendGroupRpc
import org.jgroups.blocks.ResponseMode; //导入依赖的package包/类
RspList sendGroupRpc() throws Exception {
return disp.callRemoteMethods(null, "print", new Object[]{new Integer(i++)}, new Class[] {int.class},
new RequestOptions(ResponseMode.GET_ALL, 0));
}
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:5,代码来源:RpcDispatcherBlocking.java
注:本文中的org.jgroups.blocks.ResponseMode类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论