Search in sources :

Example 11 with ConnectorOperationalStatus

use of com.evolveum.midpoint.schema.statistics.ConnectorOperationalStatus 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)

Example 12 with ConnectorOperationalStatus

use of com.evolveum.midpoint.schema.statistics.ConnectorOperationalStatus in project midpoint by Evolveum.

the class TestUcfDummyMulti method test200BlockingSearch.

@Test
public void test200BlockingSearch() throws Exception {
    final String TEST_NAME = "test200BlockingSearch";
    TestUtil.displayTestTile(TEST_NAME);
    // GIVEN
    final OperationResult result = new OperationResult(this.getClass().getName() + "." + TEST_NAME);
    final ObjectClassComplexTypeDefinition accountDefinition = resourceSchema.findDefaultObjectClassDefinition(ShadowKindType.ACCOUNT);
    // Determine object class from the schema
    final List<PrismObject<ShadowType>> searchResults = new ArrayList<PrismObject<ShadowType>>();
    final ResultHandler<ShadowType> handler = new ResultHandler<ShadowType>() {

        @Override
        public boolean handle(PrismObject<ShadowType> shadow) {
            checkUcfShadow(shadow, accountDefinition);
            searchResults.add(shadow);
            return true;
        }
    };
    dummyResource.setBlockOperations(true);
    // WHEN
    Thread t = new Thread(new Runnable() {

        @Override
        public void run() {
            try {
                cc.search(accountDefinition, new ObjectQuery(), handler, null, null, null, null, result);
            } catch (CommunicationException | GenericFrameworkException | SchemaException | SecurityViolationException | ObjectNotFoundException e) {
                LOGGER.error("Error in the search: {}", e.getMessage(), e);
            }
        }
    });
    t.setName("search1");
    t.start();
    // Give the new thread a chance to get blocked
    Thread.sleep(500);
    ConnectorOperationalStatus opStat = cc.getOperationalStatus();
    display("stats (blocked)", opStat);
    assertEquals("Wrong pool active", (Integer) 1, opStat.getPoolStatusNumActive());
    assertEquals("Wrong pool active", (Integer) 0, opStat.getPoolStatusNumIdle());
    assertEquals("Unexpected number of search results", 0, searchResults.size());
    dummyResource.unblock();
    t.join();
    dummyResource.setBlockOperations(false);
    // THEN
    assertEquals("Unexpected number of search results", 1, searchResults.size());
    opStat = cc.getOperationalStatus();
    display("stats (final)", opStat);
    assertEquals("Wrong pool active", (Integer) 0, opStat.getPoolStatusNumActive());
    assertEquals("Wrong pool active", (Integer) 1, opStat.getPoolStatusNumIdle());
    PrismObject<ShadowType> searchResult = searchResults.get(0);
    display("Search result", searchResult);
}
Also used : ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) ArrayList(java.util.ArrayList) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectClassComplexTypeDefinition(com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition) ResultHandler(com.evolveum.midpoint.provisioning.ucf.api.ResultHandler) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) PrismObject(com.evolveum.midpoint.prism.PrismObject) ConnectorOperationalStatus(com.evolveum.midpoint.schema.statistics.ConnectorOperationalStatus) Test(org.testng.annotations.Test)

Example 13 with ConnectorOperationalStatus

use of com.evolveum.midpoint.schema.statistics.ConnectorOperationalStatus in project midpoint by Evolveum.

the class ResourceManager method getConnectorOperationalStatus.

public List<ConnectorOperationalStatus> getConnectorOperationalStatus(PrismObject<ResourceType> resource, OperationResult result) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException {
    List<ConnectorOperationalStatus> statuses = new ArrayList<>();
    for (ConnectorSpec connectorSpec : getAllConnectorSpecs(resource)) {
        ConnectorInstance connectorInstance = connectorManager.getConfiguredConnectorInstance(connectorSpec, false, result);
        ConnectorOperationalStatus operationalStatus = connectorInstance.getOperationalStatus();
        if (operationalStatus != null) {
            operationalStatus.setConnectorName(connectorSpec.getConnectorName());
            statuses.add(operationalStatus);
        }
    }
    return statuses;
}
Also used : ConnectorInstance(com.evolveum.midpoint.provisioning.ucf.api.ConnectorInstance) ArrayList(java.util.ArrayList) ConnectorOperationalStatus(com.evolveum.midpoint.schema.statistics.ConnectorOperationalStatus)

Example 14 with ConnectorOperationalStatus

use of com.evolveum.midpoint.schema.statistics.ConnectorOperationalStatus in project midpoint by Evolveum.

the class ModelInteractionServiceImpl method getConnectorOperationalStatus.

@Override
public List<ConnectorOperationalStatus> getConnectorOperationalStatus(String resourceOid, Task task, OperationResult parentResult) throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, ExpressionEvaluationException {
    OperationResult result = parentResult.createMinorSubresult(GET_CONNECTOR_OPERATIONAL_STATUS);
    List<ConnectorOperationalStatus> status;
    try {
        status = provisioning.getConnectorOperationalStatus(resourceOid, task, result);
    } catch (SchemaException | ObjectNotFoundException | CommunicationException | ConfigurationException | ExpressionEvaluationException e) {
        result.recordFatalError(e);
        throw e;
    }
    result.computeStatus();
    return status;
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ExpressionEvaluationException(com.evolveum.midpoint.util.exception.ExpressionEvaluationException) CommunicationException(com.evolveum.midpoint.util.exception.CommunicationException) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ConnectorOperationalStatus(com.evolveum.midpoint.schema.statistics.ConnectorOperationalStatus)

Aggregations

ConnectorOperationalStatus (com.evolveum.midpoint.schema.statistics.ConnectorOperationalStatus)14 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)9 Test (org.testng.annotations.Test)6 Task (com.evolveum.midpoint.task.api.Task)4 ArrayList (java.util.ArrayList)4 DummyConnector (com.evolveum.icf.dummy.connector.DummyConnector)3 PrismObject (com.evolveum.midpoint.prism.PrismObject)3 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)3 ResultHandler (com.evolveum.midpoint.provisioning.ucf.api.ResultHandler)3 ObjectClassComplexTypeDefinition (com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition)3 CommunicationException (com.evolveum.midpoint.util.exception.CommunicationException)3 ConfigurationException (com.evolveum.midpoint.util.exception.ConfigurationException)3 ExpressionEvaluationException (com.evolveum.midpoint.util.exception.ExpressionEvaluationException)3 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)3 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)3 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)3 ResourceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType)2 ConnectorInstance (com.evolveum.midpoint.provisioning.ucf.api.ConnectorInstance)1 List (java.util.List)1 Label (org.apache.wicket.markup.html.basic.Label)1