Search in sources :

Example 1 with RMDBManager

use of org.ow2.proactive.resourcemanager.db.RMDBManager 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 RMDBManager

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

the class NodeHistoryTest method initDB.

@BeforeClass
public static void initDB() throws Exception {
    PAResourceManagerProperties.RM_ALIVE_EVENT_FREQUENCY.updateProperty("100");
    Configuration config = new Configuration().configure("/functionaltests/config/hibernate-unit.cfg.xml");
    dbManager = new RMDBManager(config, true, true);
}
Also used : RMDBManager(org.ow2.proactive.resourcemanager.db.RMDBManager) Configuration(org.hibernate.cfg.Configuration) BeforeClass(org.junit.BeforeClass)

Example 3 with RMDBManager

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

the class NodeHistoryTest method testSaveHistory.

public void testSaveHistory() throws Exception {
    Configuration config = new Configuration().configure("/functionaltests/config/hibernate-unit.cfg.xml");
    dbManager = new RMDBManager(config, true, true);
    NodeHistory expected = createNodeHistory(1);
    dbManager.saveNodeHistory(expected);
    List<?> rows = dbManager.executeSqlQuery("from NodeHistory");
    Assert.assertEquals(1, rows.size());
    NodeHistory actual = (NodeHistory) rows.get(0);
    assertEquals(expected, actual);
}
Also used : RMDBManager(org.ow2.proactive.resourcemanager.db.RMDBManager) NodeHistory(org.ow2.proactive.resourcemanager.core.history.NodeHistory) Configuration(org.hibernate.cfg.Configuration)

Example 4 with RMDBManager

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

the class NodeSourcesTest method setUp.

@Before
public void setUp() throws Exception {
    PAResourceManagerProperties.RM_ALIVE_EVENT_FREQUENCY.updateProperty("100");
    Configuration config = new Configuration().configure("/functionaltests/config/hibernate-unit.cfg.xml");
    dbManager = new RMDBManager(config, true, true);
    infrastructureVariables = new HashMap<>();
    infrastructureVariables.put(INFRASTRUCTURE_VARIABLE_KEY, INFRASTRUCTURE_VARIABLE_VALUE);
}
Also used : RMDBManager(org.ow2.proactive.resourcemanager.db.RMDBManager) Configuration(org.hibernate.cfg.Configuration) Before(org.junit.Before)

Example 5 with RMDBManager

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

the class RMDBManager method createUsingProperties.

private static RMDBManager createUsingProperties() {
    if (System.getProperty(RM_DATABASE_IN_MEMORY) != null) {
        return createInMemoryRMDBManager();
    } else {
        File configFile = new File(PAResourceManagerProperties.getAbsolutePath(PAResourceManagerProperties.RM_DB_HIBERNATE_CONFIG.getValueAsString()));
        boolean drop = PAResourceManagerProperties.RM_DB_HIBERNATE_DROPDB.getValueAsBoolean();
        boolean dropNS = PAResourceManagerProperties.RM_DB_HIBERNATE_DROPDB_NODESOURCES.getValueAsBoolean();
        if (logger.isInfoEnabled()) {
            logger.info("Starting RM DB Manager " + "with drop DB = " + drop + " and drop nodesources = " + dropNS + " and configuration file = " + configFile.getAbsolutePath());
        }
        Configuration configuration = new Configuration();
        if (configFile.getName().endsWith(".xml")) {
            configuration.configure(configFile);
        } else {
            try {
                Properties properties = new Properties();
                properties.load(Files.newBufferedReader(configFile.toPath(), Charset.defaultCharset()));
                configuration.addProperties(properties);
            } catch (IOException e) {
                throw new IllegalArgumentException(e);
            }
        }
        return new RMDBManager(configuration, drop, dropNS);
    }
}
Also used : Configuration(org.hibernate.cfg.Configuration) IOException(java.io.IOException) Properties(java.util.Properties) PAResourceManagerProperties(org.ow2.proactive.resourcemanager.core.properties.PAResourceManagerProperties) File(java.io.File)

Aggregations

Configuration (org.hibernate.cfg.Configuration)4 RMDBManager (org.ow2.proactive.resourcemanager.db.RMDBManager)4 File (java.io.File)1 IOException (java.io.IOException)1 Properties (java.util.Properties)1 Before (org.junit.Before)1 BeforeClass (org.junit.BeforeClass)1 MutableInteger (org.objectweb.proactive.core.util.MutableInteger)1 NodeHistory (org.ow2.proactive.resourcemanager.core.history.NodeHistory)1 PAResourceManagerProperties (org.ow2.proactive.resourcemanager.core.properties.PAResourceManagerProperties)1