当前位置: 首页>>代码示例>>Java>>正文


Java Promise.getResult方法代码示例

本文整理汇总了Java中org.jgroups.util.Promise.getResult方法的典型用法代码示例。如果您正苦于以下问题:Java Promise.getResult方法的具体用法?Java Promise.getResult怎么用?Java Promise.getResult使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jgroups.util.Promise的用法示例。


在下文中一共展示了Promise.getResult方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: installViewIfValidJoinRsp

import org.jgroups.util.Promise; //导入方法依赖的package包/类
protected boolean installViewIfValidJoinRsp(final Promise<JoinRsp> join_promise, boolean block_for_rsp) {
    boolean success=false;
    JoinRsp rsp=null;
    try {
        if(join_promise.hasResult())
            rsp=join_promise.getResult(1, true);
        else if(block_for_rsp)
            rsp=join_promise.getResult(gms.join_timeout, true);

        return success=rsp != null && isJoinResponseValid(rsp) && installView(rsp.getView(), rsp.getDigest());
    }
    finally {
        if(success)
            sendViewAck(rsp.getView().getCreator());
    }
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:17,代码来源:ClientGmsImpl.java

示例2: testLatencyWithoutMessageBundling

import org.jgroups.util.Promise; //导入方法依赖的package包/类
public void testLatencyWithoutMessageBundling() throws Exception {
    Message tmp=new Message().setFlag(Message.Flag.DONT_BUNDLE);
    setBundling(a, MAX_BYTES, 30);
    r2.setNumExpectedMesssages(1);
    Promise<Integer> promise=new Promise<>();
    r2.setPromise(promise);
    long time=System.currentTimeMillis();
    a.send(tmp);
    System.out.println(">>> sent message at " + new Date());
    promise.getResult(SLEEP);
    List<Long> list=r2.getTimes();
    Assert.assertEquals(1, list.size());
    Long time2=list.get(0);
    long diff=time2 - time;
    System.out.println("latency: " + diff + " ms");
    assertTrue("latency (" + diff + "ms) should be less than " + LATENCY + " ms", diff <= LATENCY);
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:18,代码来源:MessageBundlingTest.java

示例3: testLatencyWithMessageBundling

import org.jgroups.util.Promise; //导入方法依赖的package包/类
public void testLatencyWithMessageBundling() throws Exception {
    Message tmp=new Message();
    r2.setNumExpectedMesssages(1);
    Promise<Integer> promise=new Promise<>();
    r2.setPromise(promise);
    long time=System.currentTimeMillis();
    a.send(tmp);
    System.out.println(">>> sent message at " + new Date());
    promise.getResult(SLEEP);
    List<Long> list=r2.getTimes();
    Assert.assertEquals(1, list.size());
    Long time2=list.get(0);
    long diff=time2 - time;
    System.out.println("latency: " + diff + " ms");
    assertTrue("latency (" + diff + "ms) should be less than 2 times the LATENCY (" + LATENCY *2 + ")",
               diff <= LATENCY * 2);
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:18,代码来源:MessageBundlingTest.java

示例4: testLatencyWithMessageBundlingAndLoopback

import org.jgroups.util.Promise; //导入方法依赖的package包/类
public void testLatencyWithMessageBundlingAndLoopback() throws Exception {
    Message tmp=new Message();
    r2.setNumExpectedMesssages(1);
    Promise<Integer> promise=new Promise<>();
    r2.setPromise(promise);
    long time=System.currentTimeMillis();
    System.out.println(">>> sending message at " + new Date());
    a.send(tmp);
    promise.getResult(SLEEP);
    List<Long> list=r2.getTimes();
    Assert.assertEquals(1, list.size());
    Long time2=list.get(0);
    long diff=time2 - time;
    System.out.println("latency: " + diff + " ms");
    assertTrue("latency (" + diff + "ms) should be less than 2 times the LATENCY (" + LATENCY *2 + ")",
               diff <= LATENCY * 2);
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:18,代码来源:MessageBundlingTest.java

示例5: testLatencyWithMessageBundlingAndMaxBytes

import org.jgroups.util.Promise; //导入方法依赖的package包/类
public void testLatencyWithMessageBundlingAndMaxBytes() throws Exception {
    r2.setNumExpectedMesssages(10);
    Promise<Integer> promise=new Promise<>();
    r2.setPromise(promise);
    Util.sleep(LATENCY * 2);
    System.out.println(">>> sending 10 messages at " + new Date());
    for(int i=0; i < 10; i++)
        a.send(new Message(null, null, new byte[2000]));

    promise.getResult(SLEEP); // we should get the messages immediately because max_bundle_size has been exceeded by the 20 messages
    List<Long> list=r2.getTimes();
    Assert.assertEquals(10, list.size());

    for(Iterator<Long> it=list.iterator(); it.hasNext();) {
        Long val=it.next();
        System.out.println(val);
    }
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:19,代码来源:MessageBundlingTest.java

示例6: testGetResultNoTimeout

import org.jgroups.util.Promise; //导入方法依赖的package包/类
public static void testGetResultNoTimeout() {
    final Promise p=new Promise();
    Object result;
    new ResultSetter(p, 500).start();
    result=p.getResult(0);
    Assert.assertEquals(Boolean.TRUE, result);
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:8,代码来源:PromiseTest.java

示例7: testRepeatedGet

import org.jgroups.util.Promise; //导入方法依赖的package包/类
public static final void testRepeatedGet() {
    final Promise<Integer> p=new Promise<>();
    p.setResult(10);
    System.out.println("p: " + p);
    Integer result=p.getResult(100);
    System.out.println("result = " + result);

    result=p.getResult(100);
    System.out.println("result = " + result);
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:11,代码来源:PromiseTest.java

示例8: testGetResultNoTimeout_ResultAlreadySet

import org.jgroups.util.Promise; //导入方法依赖的package包/类
public static void testGetResultNoTimeout_ResultAlreadySet() {
    final Promise p=new Promise();
    Object result;
    new ResultSetter(p, 1).start();
    Util.sleep(100);
    result=p.getResult(0);
    Assert.assertEquals(Boolean.TRUE, result);
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:9,代码来源:PromiseTest.java


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