Search in sources :

Example 1 with RMStateDelta

use of org.ow2.proactive.resourcemanager.common.event.dto.RMStateDelta in project scheduling by ow2-proactive.

the class RMInitialStateChunksTest method clientWentCrazy.

@Test
public void clientWentCrazy() {
    long latestExisted = counter - 1;
    final RMStateDelta response = this.rmInitialState.cloneAndFilter(latestExisted + 1000);
    assertEquals(1, response.getNodeSource().size());
    assertEquals(49, response.getNodesEvents().size());
    assertEquals(549, response.getLatestCounter());
}
Also used : RMStateDelta(org.ow2.proactive.resourcemanager.common.event.dto.RMStateDelta) Test(org.junit.Test)

Example 2 with RMStateDelta

use of org.ow2.proactive.resourcemanager.common.event.dto.RMStateDelta in project scheduling by ow2-proactive.

the class RMInitialStateTest method testCloneAndFilter0.

@Test
public void testCloneAndFilter0() {
    final RMStateDelta rmInitialState = this.rmInitialState.cloneAndFilter(1);
    assertEquals(4, rmInitialState.getNodesEvents().size());
    assertEquals(1, rmInitialState.getNodeSource().size());
}
Also used : RMStateDelta(org.ow2.proactive.resourcemanager.common.event.dto.RMStateDelta) Test(org.junit.Test)

Example 3 with RMStateDelta

use of org.ow2.proactive.resourcemanager.common.event.dto.RMStateDelta in project scheduling by ow2-proactive.

the class RMInitialState method cloneAndFilter.

/**
 * Clones current state events, but keep only those events which has counter bigger than provided 'filter'
 * Event counter can take values [0, +).
 * So if filter is '-1' then all events will returned.
 * @param filter
 * @return rmInitialState where all the events bigger than 'filter'
 */
public RMStateDelta cloneAndFilter(long filter) {
    long actualFilter = computeActualFilter(filter);
    final List<RMEvent> responseEvents = events.getSortedItems().tailSet(// because tailSet returns event which is equal or greater
    new RMEvent(actualFilter + 1)).stream().limit(PAResourceManagerProperties.RM_REST_MONITORING_MAXIMUM_CHUNK_SIZE.getValueAsInt()).collect(Collectors.toList());
    RMStateDelta response = new RMStateDelta();
    response.setNodeSource(getNodeSourceEvents(responseEvents));
    response.setNodesEvents(getNodeEvents(responseEvents));
    response.setLatestCounter(Math.max(actualFilter, findLargestCounter(responseEvents)));
    return response;
}
Also used : RMStateDelta(org.ow2.proactive.resourcemanager.common.event.dto.RMStateDelta)

Example 4 with RMStateDelta

use of org.ow2.proactive.resourcemanager.common.event.dto.RMStateDelta in project scheduling by ow2-proactive.

the class RMStateCaching method getRMInitialState.

/**
 * @return cached RM State as returned by {@link RMProxyUserInterface#getRMInitialState(long)}
 */
public static RMStateDelta getRMInitialState(long counter) {
    try {
        long startTime = System.currentTimeMillis();
        final RMStateDelta state = PAFuture.getFutureValue(rm.getRMInitialState(counter));
        long time = System.currentTimeMillis() - startTime;
        logger.debug(String.format("Updated RM initial state in %d ms", time));
        return state;
    } catch (Exception e) {
        logger.error("Exception occurrend while updating RM state cache, connection reset", e);
        throw e;
    }
}
Also used : RMStateDelta(org.ow2.proactive.resourcemanager.common.event.dto.RMStateDelta)

Example 5 with RMStateDelta

use of org.ow2.proactive.resourcemanager.common.event.dto.RMStateDelta in project scheduling by ow2-proactive.

the class RMInitialStateChunksTest method clientKnowsEverything.

@Test
public void clientKnowsEverything() {
    long latestExisted = counter - 1;
    final RMStateDelta response = this.rmInitialState.cloneAndFilter(latestExisted);
    assertEquals(0, response.getNodeSource().size());
    assertEquals(0, response.getNodesEvents().size());
    assertEquals(latestExisted, response.getLatestCounter());
}
Also used : RMStateDelta(org.ow2.proactive.resourcemanager.common.event.dto.RMStateDelta) Test(org.junit.Test)

Aggregations

RMStateDelta (org.ow2.proactive.resourcemanager.common.event.dto.RMStateDelta)10 Test (org.junit.Test)8