Search in sources :

Example 1 with ConnectorOperationalContext

use of org.identityconnectors.framework.impl.api.local.operations.ConnectorOperationalContext in project midpoint by Evolveum.

the class ConnectorInstanceConnIdImpl method getOperationalStatus.

@Override
public ConnectorOperationalStatus getOperationalStatus() throws ObjectNotFoundException {
    if (!(connectorInfo 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) connectorInfo, (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());
        status.setPoolConfigMaxIdleTime(poolConfiguration.getMaxIdleTimeMillis());
    }
    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

ConnectorOperationalStatus (com.evolveum.midpoint.schema.statistics.ConnectorOperationalStatus)1 ObjectPoolConfiguration (org.identityconnectors.common.pooling.ObjectPoolConfiguration)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