Search in sources :

Example 6 with SqlRepositoryConfiguration

use of com.evolveum.midpoint.repo.sql.SqlRepositoryConfiguration in project midpoint by Evolveum.

the class Initializer method init.

public void init(OperationResult result) throws TaskManagerInitializationException {
    MidpointConfiguration midpointConfiguration = taskManager.getMidpointConfiguration();
    LOGGER.info("Task Manager initialization.");
    // get the configuration (general section + JDBC section as well)
    TaskManagerConfiguration configuration = taskManager.getConfiguration();
    configuration.checkAllowedKeys(midpointConfiguration);
    configuration.setBasicInformation(midpointConfiguration);
    configuration.validateBasicInformation();
    LOGGER.info("Task Manager: Quartz Job Store: " + (configuration.isJdbcJobStore() ? "JDBC" : "in-memory") + ", " + (configuration.isClustered() ? "" : "NOT ") + "clustered. Threads: " + configuration.getThreads());
    if (configuration.isJdbcJobStore()) {
        // quartz properties related to database connection will be taken from SQL repository
        String defaultJdbcUrlPrefix = null;
        SqlRepositoryConfiguration sqlConfig = null;
        try {
            SqlRepositoryFactory sqlRepositoryFactory = (SqlRepositoryFactory) taskManager.getBeanFactory().getBean("sqlRepositoryFactory");
            sqlConfig = sqlRepositoryFactory.getSqlConfiguration();
            if (sqlConfig.isEmbedded()) {
                defaultJdbcUrlPrefix = sqlRepositoryFactory.prepareJdbcUrlPrefix(sqlConfig);
            }
        } catch (NoSuchBeanDefinitionException e) {
            LOGGER.info("SqlRepositoryFactory is not available, JDBC Job Store configuration will be taken from taskManager section only.");
            LOGGER.trace("Reason is", e);
        } catch (RepositoryServiceFactoryException e) {
            LoggingUtils.logUnexpectedException(LOGGER, "Cannot determine default JDBC URL for embedded database", e);
        }
        configuration.setJdbcJobStoreInformation(midpointConfiguration, sqlConfig, defaultJdbcUrlPrefix);
        configuration.validateJdbcJobStoreInformation();
    }
    // register node
    // may throw initialization exception
    taskManager.getClusterManager().createNodeObject(result);
    if (!taskManager.getConfiguration().isTestMode()) {
        // in test mode do not start cluster manager thread nor verify cluster config
        // does not throw exceptions, sets the ERROR state if necessary, however
        taskManager.getClusterManager().checkClusterConfiguration(result);
    }
    NoOpTaskHandler.instantiateAndRegister(taskManager);
    WaitForSubtasksByPollingTaskHandler.instantiateAndRegister(taskManager);
    WaitForTasksTaskHandler.instantiateAndRegister(taskManager);
    // unfortunately, there seems to be no clean way of letting jobs know the taskManager
    JobExecutor.setTaskManagerQuartzImpl(taskManager);
    // the same here
    JobStarter.setTaskManagerQuartzImpl(taskManager);
    taskManager.getExecutionManager().initializeLocalScheduler();
    if (taskManager.getLocalNodeErrorStatus() != NodeErrorStatusType.OK) {
        taskManager.getExecutionManager().shutdownLocalSchedulerChecked();
    }
    // populate the scheduler with jobs (if RAM-based), or synchronize with midPoint repo
    if (taskManager.getExecutionManager().synchronizeJobStores(result) == false) {
        if (!configuration.isJdbcJobStore()) {
            LOGGER.error("Some or all tasks could not be imported from midPoint repository to Quartz job store. They will therefore not be executed.");
        } else {
            LOGGER.warn("Some or all tasks could not be synchronized between midPoint repository and Quartz job store. They may not function correctly.");
        }
    }
    LOGGER.trace("Quartz scheduler initialized (not yet started, however)");
    LOGGER.info("Task Manager initialized");
}
Also used : MidpointConfiguration(com.evolveum.midpoint.common.configuration.api.MidpointConfiguration) SqlRepositoryFactory(com.evolveum.midpoint.repo.sql.SqlRepositoryFactory) NoSuchBeanDefinitionException(org.springframework.beans.factory.NoSuchBeanDefinitionException) RepositoryServiceFactoryException(com.evolveum.midpoint.repo.api.RepositoryServiceFactoryException) SqlRepositoryConfiguration(com.evolveum.midpoint.repo.sql.SqlRepositoryConfiguration)

Example 7 with SqlRepositoryConfiguration

use of com.evolveum.midpoint.repo.sql.SqlRepositoryConfiguration in project midpoint by Evolveum.

the class TaskManagerConfiguration method setJdbcJobStoreInformation.

void setJdbcJobStoreInformation(MidpointConfiguration masterConfig, SqlRepositoryConfiguration sqlConfig, String defaultJdbcUrlPrefix) {
    Configuration c = masterConfig.getConfiguration(TASK_MANAGER_CONFIG_SECTION);
    jdbcDriver = c.getString(JDBC_DRIVER_CONFIG_ENTRY, sqlConfig != null ? sqlConfig.getDriverClassName() : null);
    String explicitJdbcUrl = c.getString(JDBC_URL_CONFIG_ENTRY, null);
    if (explicitJdbcUrl == null) {
        if (sqlConfig.isEmbedded()) {
            jdbcUrl = defaultJdbcUrlPrefix + "-quartz;MVCC=TRUE;DB_CLOSE_ON_EXIT=FALSE";
        } else {
            jdbcUrl = sqlConfig.getJdbcUrl();
        }
    } else {
        jdbcUrl = explicitJdbcUrl;
    }
    dataSource = c.getString(DATA_SOURCE_CONFIG_ENTRY, null);
    if (dataSource == null && explicitJdbcUrl == null && sqlConfig != null) {
        // we want to use quartz-specific JDBC if there is one (i.e. we do not want to inherit data source from repo in such a case)
        dataSource = sqlConfig.getDataSource();
    }
    if (dataSource != null) {
        LOGGER.info("Quartz database is at {} (a data source)", dataSource);
    } else {
        LOGGER.info("Quartz database is at {} (a JDBC URL)", jdbcUrl);
    }
    jdbcUser = c.getString(JDBC_USER_CONFIG_ENTRY, sqlConfig != null ? sqlConfig.getJdbcUsername() : null);
    jdbcPassword = c.getString(JDBC_PASSWORD_CONFIG_ENTRY, sqlConfig != null ? sqlConfig.getJdbcPassword() : null);
    hibernateDialect = sqlConfig != null ? sqlConfig.getHibernateDialect() : "";
    String defaultSqlSchemaFile = schemas.get(hibernateDialect);
    String defaultDriverDelegate = delegates.get(hibernateDialect);
    sqlSchemaFile = c.getString(SQL_SCHEMA_FILE_CONFIG_ENTRY, defaultSqlSchemaFile);
    jdbcDriverDelegateClass = c.getString(JDBC_DRIVER_DELEGATE_CLASS_CONFIG_ENTRY, defaultDriverDelegate);
    createQuartzTables = c.getBoolean(CREATE_QUARTZ_TABLES_CONFIG_ENTRY, CREATE_QUARTZ_TABLES_DEFAULT);
}
Also used : MidpointConfiguration(com.evolveum.midpoint.common.configuration.api.MidpointConfiguration) Configuration(org.apache.commons.configuration.Configuration) SqlRepositoryConfiguration(com.evolveum.midpoint.repo.sql.SqlRepositoryConfiguration)

Example 8 with SqlRepositoryConfiguration

use of com.evolveum.midpoint.repo.sql.SqlRepositoryConfiguration in project midpoint by Evolveum.

the class ObjectUpdater method adjustExtensionValuesHandling.

private RepoModifyOptions adjustExtensionValuesHandling(RepoModifyOptions options, boolean noFetchExtensionValueInsertionForbidden) {
    RepoModifyOptions rv = options != null ? options.clone() : new RepoModifyOptions();
    SqlRepositoryConfiguration config = getConfiguration();
    rv.setUseNoFetchExtensionValuesInsertion(config.isEnableNoFetchExtensionValuesInsertion() && !noFetchExtensionValueInsertionForbidden && !Boolean.FALSE.equals(rv.getUseNoFetchExtensionValuesInsertion()));
    // TODO implement more complex heuristics when the options come with null value for no-fetch deletion
    // (e.g. doing that for extensions having index-only values, and by comparing # of values to deleted
    // with overall # of values)
    rv.setUseNoFetchExtensionValuesDeletion(config.isEnableNoFetchExtensionValuesDeletion() && !Boolean.FALSE.equals(rv.getUseNoFetchExtensionValuesDeletion()));
    return rv;
}
Also used : SqlRepositoryConfiguration(com.evolveum.midpoint.repo.sql.SqlRepositoryConfiguration)

Aggregations

SqlRepositoryConfiguration (com.evolveum.midpoint.repo.sql.SqlRepositoryConfiguration)8 MidpointConfiguration (com.evolveum.midpoint.common.configuration.api.MidpointConfiguration)3 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)2 RepositoryFactory (com.evolveum.midpoint.init.RepositoryFactory)1 RepositoryServiceFactoryException (com.evolveum.midpoint.repo.api.RepositoryServiceFactoryException)1 SqlRepositoryFactory (com.evolveum.midpoint.repo.sql.SqlRepositoryFactory)1 TestSqlRepositoryFactory (com.evolveum.midpoint.repo.sql.testing.TestSqlRepositoryFactory)1 PostConstruct (javax.annotation.PostConstruct)1 Configuration (org.apache.commons.configuration.Configuration)1 Configuration (org.apache.commons.configuration2.Configuration)1 Session (org.hibernate.Session)1 NoSuchBeanDefinitionException (org.springframework.beans.factory.NoSuchBeanDefinitionException)1