public String getUuid() { return driverDef.getUuid(); }
public static String generateDeploymentId( final DriverDef driverDef ) { return generateDeploymentId( driverDef.getUuid() ); }
private DriverDefInfo createDriverInfo(final org.uberfire.java.nio.file.Path path) { String content = ioService.readAllString(path); DriverDef driverDef = DriverDefSerializer.deserialize(content); DriverDeploymentInfo deploymentInfo = null; try { deploymentInfo = runtimeManager.getDriverDeploymentInfo(driverDef.getUuid()); } catch (Exception e) { logger.warn("It was not possible to read deployment info when building DriverDefInfo for driver: " + driverDef.getUuid(), e); } return new DriverDefInfo(driverDef.getUuid(), driverDef.getName(), Paths.convert(path), deploymentInfo); } }
@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; } }
@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; }
private void deployDriver(DriverDef driverDef) throws Exception { when(driverProvider.deploy(driverDef)).thenReturn(driverDeploymentInfo); runtimeManager.deployDriver(driverDef, DeploymentOptions.create()); when(driverProvider.getDeploymentInfo(driverDef.getUuid())).thenReturn(driverDeploymentInfo); }
/** * Checks if current driver has dependant data sources prior to execute an update operation. */ protected void executeSafeUpdateCommand( String onDependantsMessageKey, Command defaultCommand, Command yesCommand, Command noCommand ) { dataSourceManagerClient.call( new RemoteCallback< DriverDeploymentInfo >( ) { @Override public void callback( DriverDeploymentInfo deploymentInfo ) { if ( deploymentInfo != null && deploymentInfo.hasDependants( ) ) { popupsUtil.showYesNoPopup( CommonConstants.INSTANCE.Warning( ), editorHelper.getMessage( onDependantsMessageKey ), yesCommand, CommonConstants.INSTANCE.YES( ), ButtonType.WARNING, noCommand, CommonConstants.INSTANCE.NO( ), ButtonType.DEFAULT ); } else { defaultCommand.execute( ); } } } ).getDriverDeploymentInfo( getContent( ).getDef( ).getUuid( ) ); }
@Test public void testUnDeployDriver( ) throws Exception { // deploy the driver deployDriver( driverDef1 ); // the deployment info should be returned. DriverDeploymentInfo deploymentInfo = driverProvider.getDeploymentInfo( driverDef1.getUuid( ) ); // un-deploy the driver. unDeployDriver( deploymentInfo ); // query the deployment info again deploymentInfo = driverProvider.getDeploymentInfo( driverDef1.getUuid( ) ); // no deployment info should have been returned. assertNull( deploymentInfo ); }
/** * Tests the deployment info retrieval for a driver. */ @Test public void testGetDriverDeploymentInfo() { try { // simulate we have an already deployed driver deployDriver(driverDef); DriverDeploymentInfo deploymentInfo = runtimeManager.getDriverDeploymentInfo(driverDef.getUuid()); assertNotNull(deploymentInfo); } catch (Exception e) { fail(e.getMessage()); } }
/** * 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; }
@Before public void setup() { setupChangeHandler(); when(serviceHelper.getDefRegistry()).thenReturn(defRegistry); when(moduleService.resolveModule(path)).thenReturn(module); when(sessionInfo.getId()).thenReturn(SESSION_ID); when(sessionInfo.getIdentity()).thenReturn(identity); when(identity.getIdentifier()).thenReturn(IDENTIFIER); dataSourceDef = new DataSourceDef(); dataSourceDef.setUuid("uuid"); dataSourceDef.setName("dataSourceName"); dataSourceDef.setConnectionURL("connectionURL"); dataSourceDef.setUser("user"); dataSourceDef.setPassword("password"); driverDef = new DriverDef(); driverDef.setUuid("uuid"); driverDef.setName("driverName"); driverDef.setDriverClass(TestDriver.class.getName()); driverDef.setGroupId("groupId"); driverDef.setArtifactId("artifactId"); driverDef.setVersion("version"); when(registeredDataSourceDef.getUuid()).thenReturn("registeredDataSourceUuid"); when(registeredDataSourceDeploymentInfo.getUuid()).thenReturn("registeredDataSourceUuid"); when(originalDataSourceDef.getUuid()).thenReturn("originalDataSourceUuid"); when(originalDatasourceDeploymentInfo.getUuid()).thenReturn("originalDataSourceUuid"); when(registeredDriverDef.getUuid()).thenReturn("registeredDriverDefUuid"); when(registeredDriverDeploymentInfo.getUuid()).thenReturn("registeredDriverDefUuid"); when(originalDriverDef.getUuid()).thenReturn("originalDriverDefUuid"); when(originalDriverDeploymentInfo.getUuid()).thenReturn("originalDriverDefUuid"); }
private void testDeployDriver(boolean isDeployed, DeploymentOptions options) { try { if (isDeployed) { when(driverProvider.getDeploymentInfo(driverDef.getUuid())).thenReturn(driverDeploymentInfo); } if (!isDeployed) { runtimeManager.deployDriver(driverDef, options); verify(driverProvider, times(1)).deploy(driverDef); } else if (options.isCreateOrResyncDeployment()) { runtimeManager.deployDriver(driverDef, options); verify(driverProvider, times(1)).resync(driverDef, driverDeploymentInfo); } else { expectedException.expectMessage("Driver: " + driverDef + " is already deployed."); runtimeManager.deployDriver(driverDef, options); } } catch (Exception e) { fail(e.getMessage()); } }
public boolean validate( DriverDef driverDef ) { return hasValue( driverDef.getUuid( ) ) && hasValue( driverDef.getName( ) ) && hasValue( driverDef.getDriverClass( ) ) && hasValue( driverDef.getArtifactId( ) ) && hasValue( driverDef.getGroupId( ) ) && hasValue( driverDef.getVersion( ) ); }
DeploymentOptions.create()); DriverDeploymentInfo deploymentInfo = runtimeManager.getDriverDeploymentInfo(driverDef.getUuid()); assertNotNull(deploymentInfo); runtimeManager.unDeployDriver(deploymentInfo, options); when(driverProvider.getDeploymentInfo(driverDef.getUuid())).thenReturn(null); deploymentInfo = runtimeManager.getDriverDeploymentInfo(driverDef.getUuid());
@Test public void testDeployDriver( ) throws Exception { // the driver is deployed deployDriver( driverDef1 ); // then the deployment info should be returned. DriverDeploymentInfo deploymentInfo = driverProvider.getDeploymentInfo( driverDef1.getUuid( ) ); assertNotNull( deploymentInfo ); assertTrue( deploymentInfo.isManaged( ) ); }