Search in sources :

Example 1 with DataSourceDeploymentInfo

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

the class KieSQLDataSourceLocatorTest method setup.

@Before
public void setup() {
    dataSourceLocator = new KieSQLDataSourceLocator(queryService, runtimeManager);
    // initialize the list of existing data sources
    dataSourceDefInfos.add(new DataSourceDefInfo("uuid1", "DS1", new DataSourceDeploymentInfo()));
    dataSourceDefInfos.add(new DataSourceDefInfo("uuid2", "DS2", new DataSourceDeploymentInfo()));
    dataSourceDefInfos.add(new DataSourceDefInfo("uuid3", "DS3", new DataSourceDeploymentInfo()));
}
Also used : DataSourceDefInfo(org.kie.workbench.common.screens.datasource.management.model.DataSourceDefInfo) DataSourceDeploymentInfo(org.kie.workbench.common.screens.datasource.management.model.DataSourceDeploymentInfo) Before(org.junit.Before)

Example 2 with DataSourceDeploymentInfo

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

the class WildflyDataSourceProvider method deploy.

@Override
public DataSourceDeploymentInfo deploy(DataSourceDef dataSourceDef) throws Exception {
    // This random identifiers calculation should be removed when WF supports deletion
    // of data sources without letting them published on server until next restart.
    String random = "_" + generateRandomUUID();
    String deploymentId = DeploymentIdGenerator.generateDeploymentId(dataSourceDef) + random;
    String kieJndi = JndiNameGenerator.generateJNDIName(dataSourceDef);
    String deploymentJndi = kieJndi + random;
    DataSourceDeploymentInfo deploymentInfo = deploy(dataSourceDef, deploymentJndi, deploymentId);
    javax.sql.DataSource dataSource = (javax.sql.DataSource) jndiLookupDataSource(deploymentJndi);
    WildlfyDataSource wfDataSource = new WildlfyDataSource(dataSource, deploymentJndi);
    managedDataSources.put(deploymentId, wfDataSource);
    return deploymentInfo;
}
Also used : DataSourceDeploymentInfo(org.kie.workbench.common.screens.datasource.management.model.DataSourceDeploymentInfo) DataSource(org.kie.workbench.common.screens.datasource.management.backend.core.DataSource)

Example 3 with DataSourceDeploymentInfo

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

the class WildflyDataSourceProvider method undeploy.

@Override
public void undeploy(final DataSourceDeploymentInfo deploymentInfo) throws Exception {
    DataSourceDeploymentInfo currentDeploymentInfo = getDeploymentInfo(deploymentInfo.getUuid());
    if (currentDeploymentInfo == null) {
        throw new Exception("DataSource: " + deploymentInfo.getUuid() + " is not deployed");
    }
    dataSourceMgmtClient.deleteDataSource(currentDeploymentInfo.getDeploymentId());
    managedDataSources.remove(currentDeploymentInfo.getDeploymentId());
}
Also used : DataSourceDeploymentInfo(org.kie.workbench.common.screens.datasource.management.model.DataSourceDeploymentInfo)

Example 4 with DataSourceDeploymentInfo

use of org.kie.workbench.common.screens.datasource.management.model.DataSourceDeploymentInfo 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 5 with DataSourceDeploymentInfo

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

the class DataSourceProviderBaseTest method testLookupDataSourceForDeployed.

/**
 * Tests the lookup of a previously deployed data source.
 */
@Test
public void testLookupDataSourceForDeployed() throws Exception {
    setupDrivers();
    // emulate that the data source was deployed in an earlier time.
    deployDataSource(dataSourceDef);
    // query the deployment information in a later time.
    DataSourceDeploymentInfo deploymentInfo = dataSourceProvider.getDeploymentInfo(dataSourceDef.getUuid());
    // the deployment information for the previously deployed data source should be available and should be a
    // managed data source.
    assertNotNull(deploymentInfo);
    assertTrue(deploymentInfo.isManaged());
    // finally lookup the data source.
    DataSource dataSource = dataSourceProvider.lookupDataSource(deploymentInfo);
    // the lookup must return a value.
    assertNotNull(dataSource);
}
Also used : DataSourceDeploymentInfo(org.kie.workbench.common.screens.datasource.management.model.DataSourceDeploymentInfo) Test(org.junit.Test)

Aggregations

DataSourceDeploymentInfo (org.kie.workbench.common.screens.datasource.management.model.DataSourceDeploymentInfo)21 Test (org.junit.Test)7 DriverDeploymentInfo (org.kie.workbench.common.screens.datasource.management.model.DriverDeploymentInfo)4 SQLException (java.sql.SQLException)3 DataSourceDef (org.kie.workbench.common.screens.datasource.management.model.DataSourceDef)3 Before (org.junit.Before)2 DataSource (org.kie.workbench.common.screens.datasource.management.backend.core.DataSource)2 WildflyDataSourceDef (org.kie.workbench.common.screens.datasource.management.backend.integration.wildfly.WildflyDataSourceDef)2 DataSourceDefInfo (org.kie.workbench.common.screens.datasource.management.model.DataSourceDefInfo)2 DriverDef (org.kie.workbench.common.screens.datasource.management.model.DriverDef)2 URI (java.net.URI)1 ArrayList (java.util.ArrayList)1 Properties (java.util.Properties)1 ConnectionFactory (org.apache.commons.dbcp2.ConnectionFactory)1 PoolableConnection (org.apache.commons.dbcp2.PoolableConnection)1 PoolableConnectionFactory (org.apache.commons.dbcp2.PoolableConnectionFactory)1 PoolingDataSource (org.apache.commons.dbcp2.PoolingDataSource)1 GenericObjectPool (org.apache.commons.pool2.impl.GenericObjectPool)1 DataColumn (org.dashbuilder.dataset.DataColumn)1 DataSet (org.dashbuilder.dataset.DataSet)1