Search in sources :

Example 16 with ProgressStatus

use of org.glassfish.api.admin.ProgressStatus in project Payara by payara.

the class ProgressStatusClient method mirror.

/**
 * Applies event on existing structures. If not appliable do nothing.
 */
public synchronized void mirror(ProgressStatusEvent event) {
    if (event == null) {
        return;
    }
    ProgressStatus effected = map.get(event.getSourceId());
    ProgressStatus result = event.apply(effected);
    if (event instanceof ProgressStatusEventCreateChild) {
        map.put(((ProgressStatusEventCreateChild) event).getChildId(), result);
    }
}
Also used : ProgressStatusEventCreateChild(org.glassfish.api.admin.progress.ProgressStatusEventCreateChild) ProgressStatus(org.glassfish.api.admin.ProgressStatus)

Example 17 with ProgressStatus

use of org.glassfish.api.admin.ProgressStatus in project Payara by payara.

the class CommandProgressImplTest method testCreateMirroringChild.

// @BeforeClass
// public static void setUpClass() throws Exception {
// }
// 
// @AfterClass
// public static void tearDownClass() throws Exception {
// }
@Test
public void testCreateMirroringChild() {
    CommandProgressImpl cp = new CommandProgressImpl("first", "a");
    cp.setTotalStepCount(2);
    ProgressStatusMirroringImpl ch1 = cp.createMirroringChild(1);
    assertNotNull(ch1);
    ProgressStatus ch2 = cp.createChild(1);
    assertNotNull(ch1);
    assertTrue(ch2 instanceof ProgressStatusImpl);
}
Also used : ProgressStatus(org.glassfish.api.admin.ProgressStatus) ProgressStatusMirroringImpl(org.glassfish.api.admin.progress.ProgressStatusMirroringImpl) ProgressStatusImpl(org.glassfish.api.admin.progress.ProgressStatusImpl) Test(org.junit.Test)

Example 18 with ProgressStatus

use of org.glassfish.api.admin.ProgressStatus in project Payara by payara.

the class ProgressStatusEventCreateChild method apply.

@Override
public ProgressStatus apply(ProgressStatus ps) {
    ProgressStatus chld;
    if (ps instanceof ProgressStatusBase) {
        ProgressStatusBase psb = (ProgressStatusBase) ps;
        chld = psb.createChild(name, allocatedSteps, totalSteps);
    } else {
        chld = ps.createChild(name, allocatedSteps);
        if (totalSteps >= 0) {
            chld.setTotalStepCount(totalSteps);
        }
    }
    return chld;
}
Also used : ProgressStatus(org.glassfish.api.admin.ProgressStatus)

Example 19 with ProgressStatus

use of org.glassfish.api.admin.ProgressStatus in project Payara by payara.

the class ProgressStatusImplTest method testCreateChild.

@Test
public void testCreateChild() {
    ProgressStatusImpl psi = new ProgressStatusImpl("A", 10, parent, null);
    ProgressStatus ch1 = psi.createChild(2);
    ProgressStatus ch2 = psi.createChild("A.2", 3);
    assertEquals(5, psi.getRemainingStepCount());
    ProgressStatus ch3 = psi.createChild("A.3", 10);
    assertEquals(0, psi.getRemainingStepCount());
    assertEquals(15, psi.getTotalStepCount());
    parent.lastEvent = null;
    ch1.progress(1);
    assertNotNull(parent.lastEvent);
    psi.complete();
    assertTrue(psi.isComplete());
    assertTrue(ch1.isComplete());
    assertTrue(ch2.isComplete());
    assertTrue(ch3.isComplete());
    psi = new ProgressStatusImpl("B", 10, parent, null);
    ch1 = psi.createChild("B.1", 3);
    psi.progress(2);
    assertEquals(5, psi.getRemainingStepCount());
    ch2 = psi.createChild("B.2", 8);
    assertEquals(11, psi.getTotalStepCount());
    psi.setTotalStepCount(15);
    assertEquals(4, psi.getRemainingStepCount());
    psi.complete();
    assertTrue(psi.isComplete());
    assertTrue(ch1.isComplete());
    assertTrue(ch2.isComplete());
}
Also used : ProgressStatus(org.glassfish.api.admin.ProgressStatus)

Example 20 with ProgressStatus

use of org.glassfish.api.admin.ProgressStatus in project Payara by payara.

the class ProgressStatusMirroringImplTest method testProgress.

@Test
public void testProgress() {
    ProgressStatusMirroringImpl prog = new ProgressStatusMirroringImpl("first", parent, null);
    ProgressStatus ch1 = prog.createChild("A1", 0);
    assertNotNull(ch1);
    ProgressStatus ch2 = prog.createChild("A2", 0);
    assertNotNull(ch2);
    assertEquals(0, prog.currentStepCount);
    parent.lastEvent = null;
    ch1.progress(1);
    assertNotNull(parent.lastEvent);
    parent.lastEvent = null;
    assertEquals(1, prog.currentStepCount);
    ch2.progress(2, "Some message");
    assertEquals(3, prog.currentStepCount);
}
Also used : ProgressStatus(org.glassfish.api.admin.ProgressStatus) Test(org.junit.Test)

Aggregations

ProgressStatus (org.glassfish.api.admin.ProgressStatus)20 Test (org.junit.Test)4 ActionReport (org.glassfish.api.ActionReport)3 File (java.io.File)1 IOException (java.io.IOException)1 CommandRunner (org.glassfish.api.admin.CommandRunner)1 Outbound (org.glassfish.api.admin.Payload.Outbound)1 ProgressStatusBase (org.glassfish.api.admin.progress.ProgressStatusBase)1 ProgressStatusDTO (org.glassfish.api.admin.progress.ProgressStatusDTO)1 ProgressStatusEventCreateChild (org.glassfish.api.admin.progress.ProgressStatusEventCreateChild)1 ProgressStatusImpl (org.glassfish.api.admin.progress.ProgressStatusImpl)1 ProgressStatusMirroringImpl (org.glassfish.api.admin.progress.ProgressStatusMirroringImpl)1