Search in sources :

Example 1 with DriverDeploymentInfo

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

the class DataSourceRuntimeManagerImpl method deployDataSource.

@Override
public synchronized DataSourceDeploymentInfo deployDataSource(DataSourceDef dataSourceDef, DeploymentOptions options) throws Exception {
    try {
        DataSourceDeploymentInfo dataSourceDeploymentInfo = dataSourceProvider.getDeploymentInfo(dataSourceDef.getUuid());
        DriverDeploymentInfo driverDeploymentInfo = driverProvider.getDeploymentInfo(dataSourceDef.getDriverUuid());
        if (dataSourceDeploymentInfo != null) {
            if (options.isCreateOrResyncDeployment()) {
                dataSourceDeploymentInfo = dataSourceProvider.resync(dataSourceDef, dataSourceDeploymentInfo);
            } else {
                throw new Exception("Data source: " + dataSourceDef + " is already deployed");
            }
        } else if (driverDeploymentInfo != null) {
            dataSourceDeploymentInfo = dataSourceProvider.deploy(dataSourceDef);
        } else {
            throw new Exception("Required driver: " + dataSourceDef.getDriverUuid() + " is not deployed.");
        }
        if (driverDeploymentInfo != null && driverDeploymentCache.get(driverDeploymentInfo) != null) {
            driverDeploymentCache.get(driverDeploymentInfo).addDependant(dataSourceDeploymentInfo);
        }
        return dataSourceDeploymentInfo;
    } catch (Exception e) {
        logger.error("Data source deployment failed for dataSourceDef: " + dataSourceDef, e);
        throw e;
    }
}
Also used : DriverDeploymentInfo(org.kie.workbench.common.screens.datasource.management.model.DriverDeploymentInfo) DataSourceDeploymentInfo(org.kie.workbench.common.screens.datasource.management.model.DataSourceDeploymentInfo)

Example 2 with DriverDeploymentInfo

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

the class DataSourceRuntimeManagerImpl method deployDriver.

@Override
public synchronized DriverDeploymentInfo deployDriver(DriverDef driverDef, DeploymentOptions options) throws Exception {
    try {
        DriverDeploymentInfo deploymentInfo = driverProvider.getDeploymentInfo(driverDef.getUuid());
        if (deploymentInfo != null) {
            if (options.isCreateOrResyncDeployment()) {
                deploymentInfo = driverProvider.resync(driverDef, deploymentInfo);
            } else {
                throw new Exception("Driver: " + driverDef + " is already deployed.");
            }
        } else {
            deploymentInfo = driverProvider.deploy(driverDef);
        }
        driverDeploymentCache.put(deploymentInfo, driverDef);
        return deploymentInfo;
    } catch (Exception e) {
        logger.error("Driver deployment failed for driverDef: " + driverDef, e);
        throw e;
    }
}
Also used : DriverDeploymentInfo(org.kie.workbench.common.screens.datasource.management.model.DriverDeploymentInfo)

Example 3 with DriverDeploymentInfo

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

the class DBCPDriverProviderTest method testDeployDriver.

@Test
public void testDeployDriver() throws Exception {
    super.testDeployDriver();
    // additional verification
    DriverDeploymentInfo deploymentInfo = driverProvider.getDeploymentInfo(driverDef1.getUuid());
    DriverDeploymentInfo expectedDeploymentInfo = new DriverDeploymentInfo(DRIVER1_UUID, DRIVER1_UUID, true, DRIVER1_UUID, DRIVER1_CLASS);
    assertEquals(expectedDeploymentInfo, deploymentInfo);
}
Also used : DriverDeploymentInfo(org.kie.workbench.common.screens.datasource.management.model.DriverDeploymentInfo) DriverProviderBaseTest(org.kie.workbench.common.screens.datasource.management.backend.core.DriverProviderBaseTest) Test(org.junit.Test)

Example 4 with DriverDeploymentInfo

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

the class WildflyDriverProvider method resync.

@Override
public DriverDeploymentInfo resync(DriverDef driverDef, DriverDeploymentInfo deploymentInfo) throws Exception {
    String deploymentId = DeploymentIdGenerator.generateDeploymentId(driverDef);
    DriverDeploymentInfo currentDeploymentInfo = findDeploymentInfo(deploymentId, driverDef);
    DriverDeploymentInfo result = new DriverDeploymentInfo(deploymentId, currentDeploymentInfo.getDriverDeploymentId(), true, driverDef.getUuid(), driverDef.getDriverClass());
    managedDrivers.put(result.getDeploymentId(), result);
    return result;
}
Also used : DriverDeploymentInfo(org.kie.workbench.common.screens.datasource.management.model.DriverDeploymentInfo)

Example 5 with DriverDeploymentInfo

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

the class WildflyDriverProvider method getDeploymentsInfo.

/**
 * Gets the deployment information for all the drivers currently deployed on the Wildfly server.
 * @return a list with the deployment information for all the drivers.
 * @throws Exception exceptions may be thrown if e.g. communication with the Wildfly server fails, etc.
 */
public List<DriverDeploymentInfo> getDeploymentsInfo() throws Exception {
    List<DriverDeploymentInfo> deploymentsInfo = new ArrayList<>();
    DriverDeploymentInfo deploymentInfo;
    String uuid;
    boolean managed;
    for (WildflyDriverDef internalDef : driverMgmtClient.getDeployedDrivers()) {
        try {
            uuid = DeploymentIdGenerator.extractUuid(internalDef.getDriverName());
        } catch (Exception e) {
            uuid = internalDef.getDriverName();
        }
        managed = managedDrivers.containsKey(internalDef.getDriverName());
        deploymentInfo = new DriverDeploymentInfo(internalDef.getDriverName(), internalDef.getDriverName(), managed, uuid, internalDef.getDriverClass());
        deploymentsInfo.add(deploymentInfo);
    }
    return deploymentsInfo;
}
Also used : DriverDeploymentInfo(org.kie.workbench.common.screens.datasource.management.model.DriverDeploymentInfo) ArrayList(java.util.ArrayList) WildflyDriverDef(org.kie.workbench.common.screens.datasource.management.backend.integration.wildfly.WildflyDriverDef)

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