Search in sources :

Example 1 with ObjectPoolConfiguration

use of org.identityconnectors.common.pooling.ObjectPoolConfiguration in project midpoint by Evolveum.

the class ConnIdConfigurationTransformer method transformConnectorConfiguration.

/**
	 * Transforms midPoint XML configuration of the connector to the ICF
	 * configuration.
	 * <p/>
	 * The "configuration" part of the XML resource definition will be used.
	 * <p/>
	 * The provided ICF APIConfiguration will be modified, some values may be
	 * overwritten.
	 * 
	 * @param apiConfig
	 *            ICF connector configuration
	 * @param resourceType
	 *            midPoint XML configuration
	 * @throws SchemaException
	 * @throws ConfigurationException
	 */
public APIConfiguration transformConnectorConfiguration(PrismContainerValue configuration) throws SchemaException, ConfigurationException {
    APIConfiguration apiConfig = cinfo.createDefaultAPIConfiguration();
    ConfigurationProperties configProps = apiConfig.getConfigurationProperties();
    // The namespace of all the configuration properties specific to the
    // connector instance will have a connector instance namespace. This
    // namespace can be found in the resource definition.
    String connectorConfNs = connectorType.getNamespace();
    PrismContainer configurationPropertiesContainer = configuration.findContainer(SchemaConstants.CONNECTOR_SCHEMA_CONFIGURATION_PROPERTIES_ELEMENT_QNAME);
    if (configurationPropertiesContainer == null) {
        // Also try this. This is an older way.
        configurationPropertiesContainer = configuration.findContainer(new QName(connectorConfNs, SchemaConstants.CONNECTOR_SCHEMA_CONFIGURATION_PROPERTIES_ELEMENT_LOCAL_NAME));
    }
    transformConnectorConfigurationProperties(configProps, configurationPropertiesContainer, connectorConfNs);
    PrismContainer connectorPoolContainer = configuration.findContainer(new QName(SchemaConstants.NS_ICF_CONFIGURATION, ConnectorFactoryConnIdImpl.CONNECTOR_SCHEMA_CONNECTOR_POOL_CONFIGURATION_XML_ELEMENT_NAME));
    ObjectPoolConfiguration connectorPoolConfiguration = apiConfig.getConnectorPoolConfiguration();
    transformConnectorPoolConfiguration(connectorPoolConfiguration, connectorPoolContainer);
    PrismProperty producerBufferSizeProperty = configuration.findProperty(new QName(SchemaConstants.NS_ICF_CONFIGURATION, ConnectorFactoryConnIdImpl.CONNECTOR_SCHEMA_PRODUCER_BUFFER_SIZE_XML_ELEMENT_NAME));
    if (producerBufferSizeProperty != null) {
        apiConfig.setProducerBufferSize(parseInt(producerBufferSizeProperty));
    }
    PrismContainer connectorTimeoutsContainer = configuration.findContainer(new QName(SchemaConstants.NS_ICF_CONFIGURATION, ConnectorFactoryConnIdImpl.CONNECTOR_SCHEMA_TIMEOUTS_XML_ELEMENT_NAME));
    transformConnectorTimeoutsConfiguration(apiConfig, connectorTimeoutsContainer);
    PrismContainer resultsHandlerConfigurationContainer = configuration.findContainer(new QName(SchemaConstants.NS_ICF_CONFIGURATION, ConnectorFactoryConnIdImpl.CONNECTOR_SCHEMA_RESULTS_HANDLER_CONFIGURATION_ELEMENT_LOCAL_NAME));
    ResultsHandlerConfiguration resultsHandlerConfiguration = apiConfig.getResultsHandlerConfiguration();
    transformResultsHandlerConfiguration(resultsHandlerConfiguration, resultsHandlerConfigurationContainer);
    return apiConfig;
}
Also used : PrismProperty(com.evolveum.midpoint.prism.PrismProperty) ObjectPoolConfiguration(org.identityconnectors.common.pooling.ObjectPoolConfiguration) ResultsHandlerConfiguration(org.identityconnectors.framework.api.ResultsHandlerConfiguration) QName(javax.xml.namespace.QName) APIConfiguration(org.identityconnectors.framework.api.APIConfiguration) PrismContainer(com.evolveum.midpoint.prism.PrismContainer) ConfigurationProperties(org.identityconnectors.framework.api.ConfigurationProperties) GuardedString(org.identityconnectors.common.security.GuardedString) PolyString(com.evolveum.midpoint.prism.polystring.PolyString)

Example 2 with ObjectPoolConfiguration

use of org.identityconnectors.common.pooling.ObjectPoolConfiguration in project midpoint by Evolveum.

the class ConnectorInstanceConnIdImpl method getOperationalStatus.

@Override
public ConnectorOperationalStatus getOperationalStatus() throws ObjectNotFoundException {
    if (!(cinfo instanceof LocalConnectorInfoImpl)) {
        LOGGER.trace("Cannot get operational status of a remote connector {}", connectorType);
        return null;
    }
    if (apiConfig == null) {
        LOGGER.trace("Cannot get operational status of a connector {}: connector not yet configured", connectorType);
        throw new IllegalStateException("Connector " + connectorType + " not yet configured");
    }
    ConnectorOperationalStatus status = new ConnectorOperationalStatus();
    ConnectorOperationalContext connectorOperationalContext = new ConnectorOperationalContext((LocalConnectorInfoImpl) cinfo, (APIConfigurationImpl) apiConfig);
    Class<? extends Connector> connectorClass = connectorOperationalContext.getConnectorClass();
    if (connectorClass != null) {
        status.setConnectorClassName(connectorClass.getName());
    }
    ObjectPoolConfiguration poolConfiguration = apiConfig.getConnectorPoolConfiguration();
    if (poolConfiguration != null) {
        status.setPoolConfigMaxSize(poolConfiguration.getMaxObjects());
        status.setPoolConfigMinIdle(poolConfiguration.getMinIdle());
        status.setPoolConfigMaxIdle(poolConfiguration.getMaxIdle());
        status.setPoolConfigWaitTimeout(poolConfiguration.getMaxWait());
        status.setPoolConfigMinEvictableIdleTime(poolConfiguration.getMinEvictableIdleTimeMillis());
    }
    ObjectPool<PoolableConnector> pool = connectorOperationalContext.getPool();
    if (pool != null) {
        Statistics poolStats = pool.getStatistics();
        if (poolStats != null) {
            status.setPoolStatusNumActive(poolStats.getNumActive());
            status.setPoolStatusNumIdle(poolStats.getNumIdle());
        }
    }
    return status;
}
Also used : ObjectPoolConfiguration(org.identityconnectors.common.pooling.ObjectPoolConfiguration) LocalConnectorInfoImpl(org.identityconnectors.framework.impl.api.local.LocalConnectorInfoImpl) PoolableConnector(org.identityconnectors.framework.spi.PoolableConnector) ConnectorOperationalStatus(com.evolveum.midpoint.schema.statistics.ConnectorOperationalStatus) Statistics(org.identityconnectors.framework.impl.api.local.ObjectPool.Statistics) ConnectorOperationalContext(org.identityconnectors.framework.impl.api.local.operations.ConnectorOperationalContext)

Aggregations

ObjectPoolConfiguration (org.identityconnectors.common.pooling.ObjectPoolConfiguration)2 PrismContainer (com.evolveum.midpoint.prism.PrismContainer)1 PrismProperty (com.evolveum.midpoint.prism.PrismProperty)1 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)1 ConnectorOperationalStatus (com.evolveum.midpoint.schema.statistics.ConnectorOperationalStatus)1 QName (javax.xml.namespace.QName)1 GuardedString (org.identityconnectors.common.security.GuardedString)1 APIConfiguration (org.identityconnectors.framework.api.APIConfiguration)1 ConfigurationProperties (org.identityconnectors.framework.api.ConfigurationProperties)1 ResultsHandlerConfiguration (org.identityconnectors.framework.api.ResultsHandlerConfiguration)1 LocalConnectorInfoImpl (org.identityconnectors.framework.impl.api.local.LocalConnectorInfoImpl)1 Statistics (org.identityconnectors.framework.impl.api.local.ObjectPool.Statistics)1 ConnectorOperationalContext (org.identityconnectors.framework.impl.api.local.operations.ConnectorOperationalContext)1 PoolableConnector (org.identityconnectors.framework.spi.PoolableConnector)1