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