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