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


Java Promise类代码示例

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


Promise类属于org.jgroups.util包,在下文中一共展示了Promise类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: setUp

import org.jgroups.util.Promise; //导入依赖的package包/类
@BeforeMethod
void setUp() throws Exception {
    StackType type=Util.getIpStackType();
    if(type == StackType.IPv6)
        bind_addr="::1";
    else
        bind_addr="127.0.0.1";
    promise=new Promise<>();
    gossip_router_port=ResourceManager.getNextTcpPort(InetAddress.getByName(bind_addr));
    gossip_router_hosts=bind_addr + "[" + gossip_router_port + "]";
    gossipRouter=new GossipRouter(gossip_router_port, bind_addr);
    gossipRouter.start();
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:14,代码来源:TUNNELDeadLockTest.java

示例7: 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

示例8: 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

示例9: 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

示例10: PromisedMessageListener

import org.jgroups.util.Promise; //导入依赖的package包/类
public PromisedMessageListener(Promise<Message> promise) {
    this.promise=promise;
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:4,代码来源:TUNNEL_Test.java

示例11: Requester

import org.jgroups.util.Promise; //导入依赖的package包/类
public Requester(Promise<Integer> p) {
    this.promise=p;
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:4,代码来源:LargeStateTransferTest.java

示例12: MyReceiver

import org.jgroups.util.Promise; //导入依赖的package包/类
public MyReceiver(int numExpected, Promise<Boolean> p) {
    this.numExpected = numExpected ;
    this.numReceived = 0 ;
    this.p = p ;
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:6,代码来源:UnicastLoopbackTest.java

示例13: SimpleReceiver

import org.jgroups.util.Promise; //导入依赖的package包/类
public SimpleReceiver(Promise<Boolean> promise) {
    this.promise=promise;
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:4,代码来源:MessageBundlingTest.java

示例14: setPromise

import org.jgroups.util.Promise; //导入依赖的package包/类
public void setPromise(Promise<Integer> promise) {
    this.promise=promise;
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:4,代码来源:MessageBundlingTest.java

示例15: MyReceiver

import org.jgroups.util.Promise; //导入依赖的package包/类
public MyReceiver(final Promise<Long> p,final long num_msgs_expected,String channel_name) {
    this.p=p;
    this.num_msgs_expected=num_msgs_expected;
    this.channel_name=channel_name;
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:6,代码来源:DiscardTest.java


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