• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java RspList类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.jgroups.util.RspList的典型用法代码示例。如果您正苦于以下问题:Java RspList类的具体用法?Java RspList怎么用?Java RspList使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



RspList类属于org.jgroups.util包,在下文中一共展示了RspList类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getMemUsage

import org.jgroups.util.RspList; //导入依赖的package包/类
@Override
public long getMemUsage(String user) {
	try {
		if (iCheckLocal && iContainer.hasSolver(user))
			return iContainer.getMemUsage(user);

		RspList<Long> ret = iContainer.getDispatcher().callRemoteMethods(null, "getMemUsage", new Object[] { user }, new Class[] { String.class }, SolverServerImplementation.sAllResponses);
		long total = 0, count = 0;
		for (Rsp<Long> rsp : ret) {
			if (rsp != null && rsp.getValue() != null && rsp.getValue() > 0) {
				total += rsp.getValue();
				count ++;
			}
		}
		
		return count == 0 ? 0 : total / count;
	} catch (Exception e) {
		sLog.error("Failed to retrieve allocated memory " + user + ": " + e.getMessage(), e);
	}
	return 0;
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:22,代码来源:SolverContainerWrapper.java


示例2: cancelTask

import org.jgroups.util.RspList; //导入依赖的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


示例3: start

import org.jgroups.util.RspList; //导入依赖的package包/类
public void start() throws Exception {
    int     c;
    RspList rsps;

    channel=new JChannel(); // default props
    disp=new RpcDispatcher(channel, null, this, this);
    channel.connect("rpc-test");
    
    while(true) {
        System.out.println("[x]: exit [s]: send sync group RPC");
        System.out.flush();
        c=System.in.read();
        switch(c) {
            case 'x':
                channel.close();
                disp.stop();
            return;
        case 's':
            rsps=sendGroupRpc();
            System.out.println("responses:\n" + rsps);
            break;
        }
        
        System.in.skip(System.in.available());
    }
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:27,代码来源:RpcDispatcherBlocking.java


示例4: testMethodCallWithTimeoutNoInterrupt

import org.jgroups.util.RspList; //导入依赖的package包/类
public void testMethodCallWithTimeoutNoInterrupt() throws Exception {
    long timeout, block_time;
    RspList rsps;

    timeout=0;
    block_time=0;
    rsps=call(timeout, block_time);
    checkResults(rsps, 2, true);

    timeout=0;
    block_time=1000L;
    rsps=call(timeout, block_time);
    checkResults(rsps, 2, true);

    timeout=1000;
    block_time=0L;
    rsps=call(timeout, block_time);
    checkResults(rsps, 2, true);

    timeout=1000;
    block_time=10000L;
    rsps=call(timeout, block_time);
    checkResults(rsps, 2, false);
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:25,代码来源:RpcDispatcherInterruptTest.java


示例5: callRemote

import org.jgroups.util.RspList; //导入依赖的package包/类
public void callRemote(boolean useAnycast, boolean excludeSelf) throws Exception {
    // we need to copy the vector, otherwise the modification below will throw an exception because the underlying
    // vector is unmodifiable
    List<Address> v=new ArrayList<>(c.getView().getMembers());
    if(excludeSelf) v.remove(c.getAddress());
    RspList rsps=d.callRemoteMethods(v, "doSomething", new Object[]{}, new Class[]{}, new RequestOptions(ResponseMode.GET_ALL, 20000, useAnycast));
    Map.Entry entry;
    for(Iterator it=rsps.entrySet().iterator(); it.hasNext();) {
        entry=(Map.Entry)it.next();
        Address member=(Address)entry.getKey();
        Rsp rsp=(Rsp)entry.getValue();
        if(!rsp.wasReceived())
            throw new RuntimeException("response from " + member + " was not received, rsp=" + rsp);
    }

}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:17,代码来源:RpcDispatcherAnycastServerObject.java


示例6: testOneChannel

import org.jgroups.util.RspList; //导入依赖的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


示例7: testTwoChannelsWithInitialMulticast

import org.jgroups.util.RspList; //导入依赖的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


示例8: outerMethod

import org.jgroups.util.RspList; //导入依赖的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


示例9: testAcceptLastResponseFilter

import org.jgroups.util.RspList; //导入依赖的package包/类
/**
 * Runs with response mode of GET_FIRST and the response filter accepts only the last response
 * @throws Exception
 */
public void testAcceptLastResponseFilter() throws Exception {
    RequestOptions options=new RequestOptions(ResponseMode.GET_FIRST, 10000, false,
                                              new RspFilter() {
                                                  int count=0;
                                                  public boolean isAcceptable(Object response, Address sender) {
                                                      return ++count >= 3;
                                                  }
                                                  public boolean needMoreResponses() {return count < 3;}
                                              });

    RspList rsps=disp1.callRemoteMethods(null, "foo", null, null, options);
    System.out.println("responses are:\n" + rsps);
    Util.assertEquals("there should be three response values", 3, rsps.size());
    Util.assertEquals("number of responses received should be 3", 1, rsps.numReceived());
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:20,代码来源:RpcDispatcherTest.java


示例10: setUp

import org.jgroups.util.RspList; //导入依赖的package包/类
@BeforeMethod
void setUp() throws Exception {
    rl=new RspList();
    a1=Util.createRandomAddress();
    a2=Util.createRandomAddress();
    a3=Util.createRandomAddress();
    a4=Util.createRandomAddress();
    a5=Util.createRandomAddress();
    rsp1=new Rsp(a1);
    rsp2=new Rsp(a2);
    rsp2.setSuspected();
    rsp3=new Rsp(a3, "hello world");
    rsp4=new Rsp(a4, Boolean.TRUE);
    rsp5=new Rsp(a5);
    rsp5.setSuspected();
    rl.put(a1, rsp1);
    rl.put(a2, rsp2);
    rl.put(a3, rsp3);
    rl.put(a4, rsp4);
    rl.put(a5, rsp5);
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:22,代码来源:RspListTest.java


示例11: remoteExecute

import org.jgroups.util.RspList; //导入依赖的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


示例12: futureDone

import org.jgroups.util.RspList; //导入依赖的package包/类
private <T> T futureDone(RspList<T> rspList) {
  Collection<Rsp<T>> values = rspList.values();

  values.parallelStream()
      .filter(Rsp::hasException)
      .forEach(rsp -> logWarn(() -> String.format("Execute method failed. Sender [%s], with exception [%s]", rsp.getSender(), rsp.getException())));

  T value = values.stream()
      .filter(Rsp::wasReceived)
      .filter(((Predicate<Rsp<T>>) Rsp::hasException).negate())
      .filter(((Predicate<Rsp<T>>) Rsp::wasUnreachable).negate())
      .map(Rsp::getValue)
      .filter((t) -> t != null)
      .reduce((a, b) -> a)
      .orElse(null);

  if (value instanceof DataHolder) {
    return ((DataHolder<T>) value).unwrap();
  } else {
    return value;
  }
}
 
开发者ID:vert-x3,项目名称:vertx-jgroups,代码行数:23,代码来源:DefaultRpcExecutorService.java


示例13: whereIsState

import org.jgroups.util.RspList; //导入依赖的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


示例14: throwWorkExceptionIfHasExption

import org.jgroups.util.RspList; //导入依赖的package包/类
private void throwWorkExceptionIfHasExption(RspList<ResponseValues> rspList) throws WorkException
{
   if (rspList != null && rspList.getFirst() != null)
   {
      for (Rsp<ResponseValues> rsp : rspList)
      {
         if (rsp.hasException())
         {
            Throwable t = rsp.getException();
            if (t instanceof WorkException)
            {
               throw (WorkException)t;
            }
            else
            {
               WorkException we = new WorkException(rsp.getException().getMessage());
               we.initCause(rsp.getException());
               throw we;
            }
         }
      }
   }
}
 
开发者ID:ironjacamar,项目名称:ironjacamar,代码行数:24,代码来源:JGroupsTransport.java


示例15: getSolvers

import org.jgroups.util.RspList; //导入依赖的package包/类
@Override
public Set<String> getSolvers() {
	Set<String> solvers = new HashSet<String>(iContainer.getSolvers());
	try {
		RspList<Set<String>> ret = iContainer.getDispatcher().callRemoteMethods(null, "getSolvers", new Object[] {}, new Class[] {}, SolverServerImplementation.sAllResponses);
		for (Rsp<Set<String>> rsp : ret) {
			if (rsp != null && rsp.getValue() != null)
				solvers.addAll(rsp.getValue());
		}
	} catch (Exception e) {
		sLog.error("Failed to retrieve solvers: " + e.getMessage(), e);
	}
	return solvers;
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:15,代码来源:SolverContainerWrapper.java


示例16: getSolver

import org.jgroups.util.RspList; //导入依赖的package包/类
@Override
public T getSolver(String user) {
	try {
		if (iCheckLocal) {
			T solver = iContainer.getSolver(user);
			if (solver != null) return solver;				
		}

		RspList<Boolean> ret = iContainer.getDispatcher().callRemoteMethods(null, "hasSolver", new Object[] { user }, new Class[] { String.class }, SolverServerImplementation.sAllResponses);
		List<Address> senders = new ArrayList<Address>();
		for (Rsp<Boolean> rsp : ret) {
			if (rsp != null && rsp.getValue() != null && rsp.getValue())
				senders.add(rsp.getSender());
		}
		if (senders.isEmpty())
			return null;
		else if (senders.size() == 1)
			return iContainer.createProxy(senders.get(0), user);
		else if (iContainer instanceof ReplicatedSolverContainer)
			return ((ReplicatedSolverContainer<T>)iContainer).createProxy(senders, user);
		else
			return iContainer.createProxy(ToolBox.random(senders), user);
	} catch (Exception e) {
		sLog.error("Failed to retrieve solver " + user + ": " + e.getMessage(), e);
	}
	return null;
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:28,代码来源:SolverContainerWrapper.java


示例17: hasSolver

import org.jgroups.util.RspList; //导入依赖的package包/类
@Override
public boolean hasSolver(String user) {
	try {
		if (iContainer.hasSolver(user)) return true;

		RspList<Boolean> ret = iContainer.getDispatcher().callRemoteMethods(null, "hasSolver", new Object[] { user }, new Class[] { String.class }, SolverServerImplementation.sAllResponses);
		for (Rsp<Boolean> rsp : ret)
			if (rsp.getValue()) return true;
		return false;
	} catch (Exception e) {
		sLog.error("Failed to check solver " + user + ": " + e.getMessage(), e);
	}
	return false;
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:15,代码来源:SolverContainerWrapper.java


示例18: unloadSolver

import org.jgroups.util.RspList; //导入依赖的package包/类
@Override
public void unloadSolver(String user) {
	try {
		if (iContainer.hasSolver(user))
			iContainer.unloadSolver(user);
		
		RspList<Boolean> ret = iContainer.getDispatcher().callRemoteMethods(null, "hasSolver", new Object[] { user }, new Class[] { String.class }, SolverServerImplementation.sAllResponses);
		for (Rsp<Boolean> rsp : ret) {
			if (rsp.getValue())
				iContainer.getDispatcher().callRemoteMethod(rsp.getSender(), "unloadSolver", new Object[] { user }, new Class[] { String.class }, SolverServerImplementation.sFirstResponse);
		}
	} catch (Exception e) {
		sLog.error("Failed to unload solver " + user + ": " + e.getMessage(), e);
	}
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:16,代码来源:SolverContainerWrapper.java


示例19: getUsage

import org.jgroups.util.RspList; //导入依赖的package包/类
@Override
public int getUsage() {
	int usage = 0;
	try {
		RspList<Integer> ret = iContainer.getDispatcher().callRemoteMethods(null, "getUsage", new Object[] {}, new Class[] {}, SolverServerImplementation.sAllResponses);
		for (Rsp<Integer> rsp : ret)
			usage += rsp.getValue();
	} catch (Exception e) {
		sLog.error("Failed to check solver server usage: " + e.getMessage(), e);
	}
	return usage;
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:13,代码来源:SolverContainerWrapper.java


示例20: getLocalAddress

import org.jgroups.util.RspList; //导入依赖的package包/类
@Override
public Address getLocalAddress() {
	try {
		RspList<Boolean> ret = iDispatcher.callRemoteMethods(null, "isLocal", new Object[] {}, new Class[] {}, sAllResponses);
		for (Rsp<Boolean> local: ret) {
			if (Boolean.TRUE.equals(local.getValue()))
				return local.getSender();
		}
		return null;
	} catch (Exception e) {
		sLog.error("Failed to retrieve local address: " + e.getMessage(), e);
		return null;
	}
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:15,代码来源:DummySolverServer.java



注:本文中的org.jgroups.util.RspList类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java IASTDeclaration类代码示例发布时间:2022-05-22
下一篇:
Java RefChange类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap