Package org.apache.giraph.zk

Examples of org.apache.giraph.zk.BspEvent


    /**
     * Make sure the the event is not signaled.
     */
    public void testWaitMsecsNoEvent() {
        BspEvent event = new PredicateLock();
        boolean gotPredicate = event.waitMsecs(50);
        assertTrue(gotPredicate == false);
    }
View Full Code Here


    /**
     * Single threaded case
     */
    public void testEvent() {
        BspEvent event = new PredicateLock();
        event.signal();
        boolean gotPredicate = event.waitMsecs(-1);
        assertTrue(gotPredicate == true);
        event.reset();
        gotPredicate = event.waitMsecs(0);
        assertTrue(gotPredicate == false);
    }
View Full Code Here

     * Make sure the the event is signaled correctly
     * @throws InterruptedException
     */
    public void testWaitMsecs() {
        System.out.println("testWaitMsecs:");
        BspEvent event = new PredicateLock();
        Thread signalThread = new SignalThread(event);
        signalThread.start();
        boolean gotPredicate = event.waitMsecs(2000);
        assertTrue(gotPredicate == true);
        try {
            signalThread.join();
        } catch (InterruptedException e) {
        }
        gotPredicate = event.waitMsecs(0);
        assertTrue(gotPredicate == true);
    }
View Full Code Here

  @Test
  public void testWaitMsecsNoEvent() {
    Time mockTime = mock(Time.class);
    when(mockTime.getMilliseconds()).
        thenReturn(0L).thenReturn(2L);
    BspEvent event = new PredicateLock(getStubProgressable(), 1, mockTime);
    boolean gotPredicate = event.waitMsecs(1);
    assertFalse(gotPredicate);
    assertEquals(0, progressCalled.get());
    when(mockTime.getMilliseconds()).
        thenReturn(0L).thenReturn(0L).thenReturn(2L);
    gotPredicate = event.waitMsecs(1);
    assertFalse(gotPredicate);
    assertEquals(1, progressCalled.get());
  }
View Full Code Here

  @Test
  public void testEvent() {
    Time mockTime = mock(Time.class);
    when(mockTime.getMilliseconds()).
        thenReturn(0L).thenReturn(2L);
    BspEvent event = new PredicateLock(getStubProgressable(), 1, mockTime);
    event.signal();
    boolean gotPredicate = event.waitMsecs(2);
    assertTrue(gotPredicate);
    event.reset();
    when(mockTime.getMilliseconds()).
        thenReturn(0L).thenReturn(2L);
    gotPredicate = event.waitMsecs(0);
    assertFalse(gotPredicate);
  }
View Full Code Here

  /**
   * Thread signaled test for {@link PredicateLock#waitForever()}
   */
  @Test
  public void testWaitForever() {
    BspEvent event = new PredicateLock(getStubProgressable());
    Thread signalThread = new SignalThread(event);
    signalThread.start();
    event.waitForever();
    try {
      signalThread.join();
    } catch (InterruptedException e) {
    }
    assertTrue(event.waitMsecs(0));
  }
View Full Code Here

   *
   * @throws InterruptedException
   */
  @Test
  public void testWaitMsecs() {
    BspEvent event = new PredicateLock(getStubProgressable());
    Thread signalThread = new SignalThread(event);
    signalThread.start();
    boolean gotPredicate = event.waitMsecs(2000);
    assertTrue(gotPredicate);
    try {
      signalThread.join();
    } catch (InterruptedException e) {
    }
    gotPredicate = event.waitMsecs(0);
    assertTrue(gotPredicate);
  }
View Full Code Here

TOP

Related Classes of org.apache.giraph.zk.BspEvent

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.