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);
}
}
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);
}
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;
}
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());
}
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);
}
Aggregations