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