Search in sources :

Example 16 with DriverDeploymentInfo

use of org.kie.workbench.common.screens.datasource.management.model.DriverDeploymentInfo in project kie-wb-common by kiegroup.

the class AbstractDefChangeHandlerTest method verifyUnDeployed.

/**
 * Verifies that the given definition has been un-deployed.
 */
protected void verifyUnDeployed(Def def) throws Exception {
    // the definition should have been un-deployed.
    if (def instanceof DataSourceDef) {
        DataSourceDeploymentInfo deploymentInfo = runtimeManager.getDataSourceDeploymentInfo(def.getUuid());
        // is deployed by construction
        assertNotNull(deploymentInfo);
        verify(runtimeManager, times(1)).unDeployDataSource(deploymentInfo, UnDeploymentOptions.forcedUnDeployment());
    } else {
        DriverDeploymentInfo deploymentInfo = runtimeManager.getDriverDeploymentInfo(def.getUuid());
        // is deployed by construction
        assertNotNull(deploymentInfo);
        verify(runtimeManager, times(1)).unDeployDriver(deploymentInfo, UnDeploymentOptions.forcedUnDeployment());
    }
}
Also used : DriverDeploymentInfo(org.kie.workbench.common.screens.datasource.management.model.DriverDeploymentInfo) DataSourceDef(org.kie.workbench.common.screens.datasource.management.model.DataSourceDef) DataSourceDeploymentInfo(org.kie.workbench.common.screens.datasource.management.model.DataSourceDeploymentInfo)

Example 17 with DriverDeploymentInfo

use of org.kie.workbench.common.screens.datasource.management.model.DriverDeploymentInfo in project kie-wb-common by kiegroup.

the class DataSourceRuntimeManagerTest method testUnDeployDriver.

private void testUnDeployDriver(boolean hasDependants, UnDeploymentOptions options) {
    try {
        // simulate we have an already deployed driver
        deployDriver(driverDef);
        if (hasDependants) {
            // add a dependant data source.
            when(dataSourceProvider.deploy(dataSourceDef)).thenReturn(dataSourceDeploymentInfo);
            runtimeManager.deployDataSource(dataSourceDef, DeploymentOptions.create());
        }
        DriverDeploymentInfo deploymentInfo = runtimeManager.getDriverDeploymentInfo(driverDef.getUuid());
        assertNotNull(deploymentInfo);
        if (!hasDependants || options.isForcedUnDeployment()) {
            runtimeManager.unDeployDriver(deploymentInfo, options);
            when(driverProvider.getDeploymentInfo(driverDef.getUuid())).thenReturn(null);
            // the driver should have been un-deployed with the provider.
            verify(driverProvider, times(1)).undeploy(driverDeploymentInfo);
            deploymentInfo = runtimeManager.getDriverDeploymentInfo(driverDef.getUuid());
            // no deployment info should exist
            assertNull(deploymentInfo);
        } else if (options.isSoftUnDeployment()) {
            expectedException.expectMessage("Driver: " + deploymentInfo + " can't be un-deployed. " + "It's currently referenced by : " + 1 + " data sources");
            runtimeManager.unDeployDriver(driverDeploymentInfo, UnDeploymentOptions.softUnDeployment());
        }
    } catch (Exception e) {
        fail(e.getMessage());
    }
}
Also used : DriverDeploymentInfo(org.kie.workbench.common.screens.datasource.management.model.DriverDeploymentInfo) ExpectedException(org.junit.rules.ExpectedException)

Example 18 with DriverDeploymentInfo

use of org.kie.workbench.common.screens.datasource.management.model.DriverDeploymentInfo in project kie-wb-common by kiegroup.

the class DBCPDriverProvider method deploy.

@Override
public DriverDeploymentInfo deploy(DriverDef driverDef) throws Exception {
    final URI uri = artifactResolver.resolve(driverDef.getGroupId(), driverDef.getArtifactId(), driverDef.getVersion());
    if (uri == null) {
        throw new Exception("Unable to get driver library artifact for driver: " + driverDef);
    }
    final DriverDeploymentInfo deploymentInfo = new DriverDeploymentInfo(driverDef.getUuid(), driverDef.getUuid(), true, driverDef.getUuid(), driverDef.getDriverClass());
    deployedUris.put(driverDef.getUuid(), uri);
    deploymentInfos.put(driverDef.getUuid(), deploymentInfo);
    deployedDrivers.put(driverDef.getUuid(), driverDef);
    return deploymentInfo;
}
Also used : DriverDeploymentInfo(org.kie.workbench.common.screens.datasource.management.model.DriverDeploymentInfo) URI(java.net.URI)

Example 19 with DriverDeploymentInfo

use of org.kie.workbench.common.screens.datasource.management.model.DriverDeploymentInfo in project kie-wb-common by kiegroup.

the class WildflyDriverProvider method getDeploymentInfo.

/**
 * Gets the deployment information about a driver definition.
 * @param uuid the driver definition identifier.
 * @return the deployment information for the driver definition of null if the driver wasn't deployed.
 * @throws Exception exceptions may be thrown if e.g. communication with the Wildfly server fails, etc.
 */
@Override
public DriverDeploymentInfo getDeploymentInfo(final String uuid) throws Exception {
    String deploymentId = DeploymentIdGenerator.generateDeploymentId(uuid);
    DriverDeploymentInfo result;
    if ((result = managedDrivers.get(deploymentId)) == null) {
        for (DriverDeploymentInfo deploymentInfo : getDeploymentsInfo()) {
            if (uuid.equals(deploymentInfo.getUuid())) {
                result = deploymentInfo;
                break;
            }
        }
    }
    return result;
}
Also used : DriverDeploymentInfo(org.kie.workbench.common.screens.datasource.management.model.DriverDeploymentInfo)

Example 20 with DriverDeploymentInfo

use of org.kie.workbench.common.screens.datasource.management.model.DriverDeploymentInfo in project kie-wb-common by kiegroup.

the class WildflyDriverProvider method deploy.

/**
 * Deploys a driver definition on the Wildfly server.
 * @param driverDef A driver definition to be deployed.
 * @return The deployment information for the just deployed driver.
 * @throws Exception exceptions may be thrown if was not possible to deploy the driver.
 */
public DriverDeploymentInfo deploy(final DriverDef driverDef) throws Exception {
    final URI uri = artifactResolver.resolve(driverDef.getGroupId(), driverDef.getArtifactId(), driverDef.getVersion());
    if (uri == null) {
        throw new Exception("Unable to get driver library artifact for driver: " + driverDef);
    }
    String deploymentId = DeploymentIdGenerator.generateDeploymentId(driverDef);
    driverMgmtClient.deploy(deploymentId, uri);
    DriverDeploymentInfo generatedDeploymentInfo = findDeploymentInfo(deploymentId, driverDef);
    DriverDeploymentInfo deploymentInfo = new DriverDeploymentInfo(deploymentId, generatedDeploymentInfo.getDeploymentId(), true, driverDef.getUuid(), driverDef.getDriverClass());
    managedDrivers.put(deploymentInfo.getDeploymentId(), deploymentInfo);
    return deploymentInfo;
}
Also used : DriverDeploymentInfo(org.kie.workbench.common.screens.datasource.management.model.DriverDeploymentInfo) URI(java.net.URI)

Aggregations

DriverDeploymentInfo (org.kie.workbench.common.screens.datasource.management.model.DriverDeploymentInfo)21 Test (org.junit.Test)8 DataSourceDeploymentInfo (org.kie.workbench.common.screens.datasource.management.model.DataSourceDeploymentInfo)4 DriverProviderBaseTest (org.kie.workbench.common.screens.datasource.management.backend.core.DriverProviderBaseTest)3 URI (java.net.URI)2 ExpectedException (org.junit.rules.ExpectedException)2 DataSourceDef (org.kie.workbench.common.screens.datasource.management.model.DataSourceDef)2 DriverDef (org.kie.workbench.common.screens.datasource.management.model.DriverDef)2 ArrayList (java.util.ArrayList)1 Before (org.junit.Before)1 WildflyDataSourceDef (org.kie.workbench.common.screens.datasource.management.backend.integration.wildfly.WildflyDataSourceDef)1 WildflyDriverDef (org.kie.workbench.common.screens.datasource.management.backend.integration.wildfly.WildflyDriverDef)1 DriverDefInfo (org.kie.workbench.common.screens.datasource.management.model.DriverDefInfo)1