Search in sources :

Example 1 with MutableInteger

use of org.objectweb.proactive.core.util.MutableInteger in project scheduling by ow2-proactive.

the class NodesLockRestorationManager method findNodesLockedOnPreviousRun.

Map<String, MutableInteger> findNodesLockedOnPreviousRun() {
    RMDBManager dbManager = rmCore.getDbManager();
    Map<String, MutableInteger> nodesLockedOnPreviousRun = dbManager.findNodesLockedOnPreviousRun();
    dbManager.clearLockHistory();
    return nodesLockedOnPreviousRun;
}
Also used : RMDBManager(org.ow2.proactive.resourcemanager.db.RMDBManager) MutableInteger(org.objectweb.proactive.core.util.MutableInteger)

Example 2 with MutableInteger

use of org.objectweb.proactive.core.util.MutableInteger in project scheduling by ow2-proactive.

the class NodesLockRestorationManagerTest method testHandleNotInitialized.

@Test
public void testHandleNotInitialized() {
    // creates a node that matches an entry in the table specifying the nodes to lock
    RMNodeImpl rmNode = RMNodeHelper.basicWithMockedInternals("ns1", "n1", "h1", "nurl1", "parurl1").getLeft();
    assertThat(rmNode.isLocked()).isFalse();
    Map<String, MutableInteger> table = Maps.newHashMap();
    MutableInteger putResult = table.put("ns", new MutableInteger(1));
    assertThat(putResult).isNull();
    doReturn(table).when(nodesLockRestorationManager).findNodesLockedOnPreviousRun();
    assertThat(table).hasSize(1);
    verify(rmCore, never()).lockNodes(anySetOf(String.class));
    nodesLockRestorationManager.handle(rmNode, caller);
    assertThat(table).hasSize(1);
    verify(rmCore, never()).lockNodes(anySetOf(String.class));
}
Also used : MutableInteger(org.objectweb.proactive.core.util.MutableInteger) RMNodeImpl(org.ow2.proactive.resourcemanager.rmnode.RMNodeImpl) Test(org.junit.Test)

Example 3 with MutableInteger

use of org.objectweb.proactive.core.util.MutableInteger in project scheduling by ow2-proactive.

the class NodesLockRestorationManagerTest method testHandleNodeAlreadyLocked.

@Test
public void testHandleNodeAlreadyLocked() {
    RMNodeImpl rmNode = RMNodeHelper.basicWithMockedInternals("ns1", "n1", "h1", "nurl1", "parurl1").getLeft();
    rmNode.lock(null);
    assertThat(rmNode.isLocked()).isTrue();
    Map<String, MutableInteger> table = Maps.newHashMap();
    MutableInteger putResult = table.put("ns", new MutableInteger(1));
    assertThat(putResult).isNull();
    doReturn(table).when(nodesLockRestorationManager).findNodesLockedOnPreviousRun();
    nodesLockRestorationManager.initialize();
    assertThat(nodesLockRestorationManager.isInitialized()).isTrue();
    verify(nodesLockRestorationManager).findNodesLockedOnPreviousRun();
    assertThat(table).hasSize(1);
    verify(rmCore, never()).lockNodes(anySetOf(String.class));
    nodesLockRestorationManager.handle(rmNode, caller);
    assertThat(table).hasSize(1);
    verify(rmCore, never()).lockNodes(anySetOf(String.class));
}
Also used : MutableInteger(org.objectweb.proactive.core.util.MutableInteger) RMNodeImpl(org.ow2.proactive.resourcemanager.rmnode.RMNodeImpl) Test(org.junit.Test)

Example 4 with MutableInteger

use of org.objectweb.proactive.core.util.MutableInteger in project scheduling by ow2-proactive.

the class NodesLockRestorationManagerTest method testHandleNoNodesToLock.

@Test
public void testHandleNoNodesToLock() {
    RMNodeImpl rmNode = RMNodeHelper.basicWithMockedInternals("ns1", "n1", "h1", "nurl1", "parurl1").getLeft();
    assertThat(rmNode.isLocked()).isFalse();
    Map<String, MutableInteger> table = Maps.newHashMap();
    doReturn(table).when(nodesLockRestorationManager).findNodesLockedOnPreviousRun();
    nodesLockRestorationManager.initialize();
    assertThat(nodesLockRestorationManager.isInitialized()).isTrue();
    verify(nodesLockRestorationManager).findNodesLockedOnPreviousRun();
    assertThat(table).hasSize(0);
    verify(rmCore, never()).lockNodes(anySetOf(String.class));
    nodesLockRestorationManager.handle(rmNode, caller);
    assertThat(table).hasSize(0);
    verify(rmCore, never()).lockNodes(anySetOf(String.class));
}
Also used : MutableInteger(org.objectweb.proactive.core.util.MutableInteger) RMNodeImpl(org.ow2.proactive.resourcemanager.rmnode.RMNodeImpl) Test(org.junit.Test)

Example 5 with MutableInteger

use of org.objectweb.proactive.core.util.MutableInteger in project scheduling by ow2-proactive.

the class NodesLockRestorationManagerTest method testHandleMatchingNode.

@Test
public void testHandleMatchingNode() {
    doReturn(new BooleanWrapper(true)).when(rmCore).lockNodes(anySetOf(String.class), eq(caller));
    RMNodeImpl rmNode = RMNodeHelper.basicWithMockedInternals("ns1", "n1", "h1", "nurl1", "parurl1").getLeft();
    assertThat(rmNode.isLocked()).isFalse();
    Map<String, MutableInteger> table = Maps.newHashMap();
    MutableInteger putResult = table.put("ns1", new MutableInteger(1));
    assertThat(putResult).isNull();
    doReturn(table).when(nodesLockRestorationManager).findNodesLockedOnPreviousRun();
    assertThat(table).hasSize(1);
    verify(rmCore, never()).lockNodes(anySetOf(String.class), eq(caller));
    nodesLockRestorationManager.initialize();
    assertThat(nodesLockRestorationManager.isInitialized()).isTrue();
    verify(nodesLockRestorationManager).findNodesLockedOnPreviousRun();
    nodesLockRestorationManager.handle(rmNode, caller);
    assertThat(table).hasSize(0);
    verify(rmCore).lockNodes(anySetOf(String.class), eq(caller));
}
Also used : BooleanWrapper(org.objectweb.proactive.core.util.wrapper.BooleanWrapper) MutableInteger(org.objectweb.proactive.core.util.MutableInteger) RMNodeImpl(org.ow2.proactive.resourcemanager.rmnode.RMNodeImpl) Test(org.junit.Test)

Aggregations

MutableInteger (org.objectweb.proactive.core.util.MutableInteger)10 Test (org.junit.Test)6 RMNodeImpl (org.ow2.proactive.resourcemanager.rmnode.RMNodeImpl)5 Stopwatch (com.google.common.base.Stopwatch)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 BooleanWrapper (org.objectweb.proactive.core.util.wrapper.BooleanWrapper)1 LockHistory (org.ow2.proactive.resourcemanager.core.history.LockHistory)1 RMDBManager (org.ow2.proactive.resourcemanager.db.RMDBManager)1