use of org.ow2.proactive.resourcemanager.core.recovery.NodesRecoveryManager in project scheduling by ow2-proactive.
the class RMCoreTest method populateRMCore.
/**
* 6 nodes (same nodesource).
*/
private void populateRMCore() {
when(mockedCaller.checkPermission(any(Permission.class), any(String.class), any(Permission.class))).thenReturn(true);
when(mockedSelectionManager.selectNodes(any(Criteria.class), any(Client.class))).thenReturn(new NodeSet());
nodeSources = new HashMap<String, NodeSource>(1);
configureNodeSource(mockedNodeSource, "NODESOURCE-test");
nodeSources.put(mockedNodeSource.getName(), mockedNodeSource);
// MockedRMNodeParameters(String url, boolean isFree, boolean isDown, boolean isLocked, NodeSource nodeSource, RMNode rmNode)
configureRMNode(new MockedRMNodeParameters("mockedRemovableNode", true, true, false, mockedNodeSource, "NODESOURCE-test", mockedRemovableNode));
configureRMNode(new MockedRMNodeParameters("mockedUnremovableNode", false, true, false, mockedNodeSource, "NODESOURCE-test", mockedUnremovableNode));
configureRMNode(new MockedRMNodeParameters(RMDeployingNode.PROTOCOL_ID + "://removableNode", true, true, false, mockedNodeSource, "NODESOURCE-test", mockedRemovableNodeInDeploy));
configureRMNode(new MockedRMNodeParameters(RMDeployingNode.PROTOCOL_ID + "://unRemovableNode", false, false, false, mockedNodeSource, "NODESOURCE-test", mockedUnremovableNodeInDeploy));
configureRMNode(new MockedRMNodeParameters("mockedBusyNode", false, false, true, mockedNodeSource, "NODESOURCE-test", mockedBusyNode));
configureRMNode(new MockedRMNodeParameters("mockedFreeButLockedNode", true, false, true, mockedNodeSource, "NODESOURCE-test", mockedFreeButLockedNode));
HashMap<String, RMNode> nodes = new HashMap<>(6);
nodes.put(mockedRemovableNodeInDeploy.getNodeName(), mockedRemovableNodeInDeploy);
nodes.put(mockedUnremovableNodeInDeploy.getNodeName(), mockedUnremovableNodeInDeploy);
nodes.put(mockedRemovableNode.getNodeName(), mockedRemovableNode);
nodes.put(mockedUnremovableNode.getNodeName(), mockedUnremovableNode);
nodes.put(mockedBusyNode.getNodeName(), mockedBusyNode);
nodes.put(mockedFreeButLockedNode.getNodeName(), mockedFreeButLockedNode);
ArrayList<RMNode> freeNodes = new ArrayList<>(3);
freeNodes.add(mockedRemovableNodeInDeploy);
freeNodes.add(mockedRemovableNode);
freeNodes.add(mockedFreeButLockedNode);
rmCore = new RMCore(nodeSources, nodes, mockedCaller, mockedMonitoring, mockedSelectionManager, freeNodes, dbManager);
rmCore.signalRMCoreIsInitialized();
rmCore = spy(rmCore);
nodesLockRestorationManager = new NodesLockRestorationManager(rmCore);
nodesLockRestorationManager = spy(nodesLockRestorationManager);
doReturn(new Function<RMCore, NodesRecoveryManager>() {
@Override
public NodesRecoveryManager apply(RMCore rmCore) {
nodesRecoveryManager = new NodesRecoveryManager(rmCore);
nodesRecoveryManager = spy(nodesRecoveryManager);
return nodesRecoveryManager;
}
}).when(rmCore).getNodesRecoveryManagerBuilder();
doReturn(mockedCaller).when(rmCore).checkPermissionAndGetClientIsSuccessful();
rmCore.initiateRecoveryIfRequired();
}
use of org.ow2.proactive.resourcemanager.core.recovery.NodesRecoveryManager in project scheduling by ow2-proactive.
the class NodesRecoveryManagerTest method setUp.
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
nodesLockRestorationManager = null;
nodesRecoveryManager = new NodesRecoveryManager(rmCore);
nodesRecoveryManager = spy(nodesRecoveryManager);
nodesLockRestorationManager = null;
doReturn((Function<RMCore, NodesLockRestorationManager>) rmCore -> {
nodesLockRestorationManager = new NodesLockRestorationManager(rmCore);
nodesLockRestorationManager = spy(nodesLockRestorationManager);
doReturn(Maps.newHashMap()).when(nodesLockRestorationManager).findNodesLockedOnPreviousRun();
return nodesLockRestorationManager;
}).when(nodesRecoveryManager).getNodesLockRestorationManagerBuilder();
initialize();
}
Aggregations