Search in sources :

Example 6 with RMNodeData

use of org.ow2.proactive.resourcemanager.db.RMNodeData in project scheduling by ow2-proactive.

the class RMDBManagerBufferTest method testLongDelayLeadsToLaterUpdatedNodeCanBeRetrievedFast.

@Test
public void testLongDelayLeadsToLaterUpdatedNodeCanBeRetrievedFast() {
    setPropertiesAndCreateDBManager(NODE_DB_OPERATION_DELAY, "true");
    RMNodeData rmNodeData = addRMNodeData(NODE_NAME_BASE, NODE_STATE_BASE);
    checkPendingNodeOperationsNbOperations(1);
    assertThat(dbManager.getAllNodes().size()).isEqualTo(1);
    checkPendingNodeOperationsIsEmpty();
    long beforeUpdate = System.currentTimeMillis();
    updateRMNodeData(rmNodeData, NodeState.BUSY);
    checkPendingNodeOperationsIsEmpty();
    assertThat(dbManager.getNodeByNameAndUrl(NODE_NAME_BASE, NODE_URL).getState()).isEqualTo(NodeState.BUSY);
    long afterRetrieve = System.currentTimeMillis();
    assertThat(afterRetrieve - beforeUpdate).isLessThan(ACCEPTABLE_DATABASE_OPERATION_TIME_LESS_THAN_DELAY);
}
Also used : RMNodeData(org.ow2.proactive.resourcemanager.db.RMNodeData) Test(org.junit.Test)

Example 7 with RMNodeData

use of org.ow2.proactive.resourcemanager.db.RMNodeData in project scheduling by ow2-proactive.

the class RMDBManagerBufferTest method testLongDelayAndSynchronousUpdatesDisabledLeadsToLaterUpdatedNodeCanOnlyBeRetrievedAfterDelay.

@Test
public void testLongDelayAndSynchronousUpdatesDisabledLeadsToLaterUpdatedNodeCanOnlyBeRetrievedAfterDelay() {
    setPropertiesAndCreateDBManager(NODE_DB_OPERATION_DELAY, "false");
    assertThat(PAResourceManagerProperties.RM_NODES_DB_SYNCHRONOUS_UPDATES.getValueAsBoolean()).isEqualTo(false);
    RMNodeData rmNodeData = addRMNodeData(NODE_NAME_BASE, NODE_STATE_BASE);
    checkPendingNodeOperationsNbOperations(1);
    assertThat(dbManager.getAllNodes().size()).isEqualTo(1);
    checkPendingNodeOperationsIsEmpty();
    long beforeUpdate = System.currentTimeMillis();
    updateRMNodeData(rmNodeData, NodeState.BUSY);
    checkPendingNodeOperationsNbOperations(1);
    assertThat(dbManager.getNodeByNameAndUrl(NODE_NAME_BASE, NODE_URL).getState()).isEqualTo(NodeState.BUSY);
    checkPendingNodeOperationsIsEmpty();
    long afterRetrieve = System.currentTimeMillis();
    assertThat(afterRetrieve - beforeUpdate).isGreaterThan(Long.valueOf(NODE_DB_OPERATION_DELAY));
}
Also used : RMNodeData(org.ow2.proactive.resourcemanager.db.RMNodeData) Test(org.junit.Test)

Example 8 with RMNodeData

use of org.ow2.proactive.resourcemanager.db.RMNodeData in project scheduling by ow2-proactive.

the class RMDBManagerBufferTest method testLongDelayAndImmediatelyUpdatedNodeLeadsToUpdatedNodeCanOnlyBeRetrievedAfterDelay.

@Test
public void testLongDelayAndImmediatelyUpdatedNodeLeadsToUpdatedNodeCanOnlyBeRetrievedAfterDelay() {
    setPropertiesAndCreateDBManager(NODE_DB_OPERATION_DELAY, "true");
    long beforeAdd = System.currentTimeMillis();
    RMNodeData rmNodeData = addRMNodeData(NODE_NAME_BASE, NODE_STATE_BASE);
    checkPendingNodeOperationsNbOperations(1);
    updateRMNodeData(rmNodeData, NodeState.BUSY);
    checkPendingNodeOperationsNbOperations(2);
    long afterUpdate = System.currentTimeMillis();
    assertThat(dbManager.getNodeByNameAndUrl(NODE_NAME_BASE, NODE_URL).getState()).isEqualTo(NodeState.BUSY);
    checkPendingNodeOperationsIsEmpty();
    long afterRetrieve = System.currentTimeMillis();
    // node add and update are asynchronous (update cannot proceed before add)
    assertThat(afterUpdate - beforeAdd).isLessThan(ACCEPTABLE_INSTRUCTIONS_TIME_LESS_THAN_DELAY);
    // node retrieve should synchronize after asynchronous add
    assertThat(afterRetrieve - beforeAdd).isGreaterThan(Long.valueOf(NODE_DB_OPERATION_DELAY));
}
Also used : RMNodeData(org.ow2.proactive.resourcemanager.db.RMNodeData) Test(org.junit.Test)

Example 9 with RMNodeData

use of org.ow2.proactive.resourcemanager.db.RMNodeData in project scheduling by ow2-proactive.

the class RMDBManagerTest method testGetRMNodeDataByNodeSource.

@Test
public void testGetRMNodeDataByNodeSource() {
    RMNodeData rmNodeData1 = addRMNodeData(NODE_NAME_BASE + "1", NODE_STATE_BASE);
    // Add another RMNodeData with another NodeSourceData
    RMNodeData rmNodeData2 = new RMNodeData(NODE_NAME_BASE + "2", NODE_URL, null, null, null, NODE_STATE_BASE, STATE_CHANGE_TIME_BASE, HOSTNAME, JMX_URLS, JVM_NAME);
    NodeSourceData newNodeSourceData = new NodeSourceData();
    newNodeSourceData.setName("anotherNodeSourceName");
    newNodeSourceData.setPolicyType("aPolicyType");
    dbManager.addNodeSource(newNodeSourceData);
    rmNodeData2.setNodeSource(newNodeSourceData);
    dbManager.addNode(rmNodeData2, newNodeSourceData.getName());
    Collection<RMNodeData> nodes = dbManager.getNodesByNodeSource(nodeSourceData.getName());
    assertThat(nodes).hasSize(1);
    for (RMNodeData node : nodes) {
        assertThat(node).isEqualTo(rmNodeData1);
    }
}
Also used : RMNodeData(org.ow2.proactive.resourcemanager.db.RMNodeData) NodeSourceData(org.ow2.proactive.resourcemanager.db.NodeSourceData) Test(org.junit.Test)

Example 10 with RMNodeData

use of org.ow2.proactive.resourcemanager.db.RMNodeData in project scheduling by ow2-proactive.

the class RMDBManagerTest method testGetSeveralRMNodeDataByNodeSource.

@Test
public void testGetSeveralRMNodeDataByNodeSource() {
    RMNodeData rmNodeData1 = addRMNodeData(NODE_NAME_BASE + "1", NODE_STATE_BASE);
    // Add another RMNodeData with another NodeSourceData
    RMNodeData rmNodeData2 = new RMNodeData(NODE_NAME_BASE + "2", NODE_URL, null, null, null, NODE_STATE_BASE, STATE_CHANGE_TIME_BASE, HOSTNAME, JMX_URLS, JVM_NAME);
    NodeSourceData newNodeSourceData = new NodeSourceData();
    newNodeSourceData.setName("anotherNodeSourceName");
    newNodeSourceData.setPolicyType("aPolicyType");
    dbManager.addNodeSource(newNodeSourceData);
    rmNodeData2.setNodeSource(newNodeSourceData);
    dbManager.addNode(rmNodeData2, newNodeSourceData.getName());
    RMNodeData rmNodeData3 = addRMNodeData(NODE_NAME_BASE + "3", NODE_STATE_BASE);
    Collection<RMNodeData> nodes = dbManager.getNodesByNodeSource(nodeSourceData.getName());
    assertThat(nodes).hasSize(2);
    for (RMNodeData node : nodes) {
        assertThat(node).isAnyOf(rmNodeData1, rmNodeData3);
    }
}
Also used : RMNodeData(org.ow2.proactive.resourcemanager.db.RMNodeData) NodeSourceData(org.ow2.proactive.resourcemanager.db.NodeSourceData) Test(org.junit.Test)

Aggregations

RMNodeData (org.ow2.proactive.resourcemanager.db.RMNodeData)18 Test (org.junit.Test)12 RMNode (org.ow2.proactive.resourcemanager.rmnode.RMNode)4 HashMap (java.util.HashMap)2 NodeSourceData (org.ow2.proactive.resourcemanager.db.NodeSourceData)2 Node (org.objectweb.proactive.core.node.Node)1 NodeState (org.ow2.proactive.resourcemanager.common.NodeState)1 AbstractRMNode (org.ow2.proactive.resourcemanager.rmnode.AbstractRMNode)1 RMNodeImpl (org.ow2.proactive.resourcemanager.rmnode.RMNodeImpl)1