Search in sources :

Example 1 with LockHistory

use of org.ow2.proactive.resourcemanager.core.history.LockHistory in project scheduling by ow2-proactive.

the class RMDBManagerTest method testCreateLockEntryOrUpdateEnabled.

@Test
public void testCreateLockEntryOrUpdateEnabled() {
    int nbEntries = 42;
    Map<String, Integer> entries = insertEntries(nbEntries);
    List<LockHistory> lockHistories = dbManager.getLockHistories();
    assertThat(lockHistories).hasSize(nbEntries);
    for (int i = 0; i < nbEntries; i++) {
        Integer found = entries.remove("nodeSource" + i);
        assertThat(found).isNotNull();
        assertThat(found).isEqualTo(i);
    }
    assertThat(entries).hasSize(0);
}
Also used : MutableInteger(org.objectweb.proactive.core.util.MutableInteger) LockHistory(org.ow2.proactive.resourcemanager.core.history.LockHistory) Test(org.junit.Test)

Example 2 with LockHistory

use of org.ow2.proactive.resourcemanager.core.history.LockHistory in project scheduling by ow2-proactive.

the class RMDBManager method entityToMap.

public Map<String, MutableInteger> entityToMap(List<LockHistory> lockHistoryResult) {
    if (lockHistoryResult == null || lockHistoryResult.isEmpty()) {
        return Maps.newHashMap();
    }
    Map<String, MutableInteger> result = new HashMap<>(lockHistoryResult.size(), 1f);
    for (Object entry : lockHistoryResult) {
        LockHistory lockHistory = (LockHistory) entry;
        int lockCount = lockHistory.getLockCount();
        if (lockCount > 0) {
            result.put(lockHistory.getNodeSource(), new MutableInteger(lockCount));
        }
    }
    return result;
}
Also used : LockHistory(org.ow2.proactive.resourcemanager.core.history.LockHistory) HashMap(java.util.HashMap) MutableInteger(org.objectweb.proactive.core.util.MutableInteger)

Aggregations

MutableInteger (org.objectweb.proactive.core.util.MutableInteger)2 LockHistory (org.ow2.proactive.resourcemanager.core.history.LockHistory)2 HashMap (java.util.HashMap)1 Test (org.junit.Test)1