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;
}
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);
}
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;
}
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;
}
Aggregations