use of org.wso2.ballerinalang.compiler.codegen.CodeGenerator.VariableIndex.Kind.PACKAGE in project carbon-business-process by wso2.
the class HumanTaskStore method validateServiceCreationForTaskConfig.
/**
* When wsdl errors are there in the package, we use a dummy service creation step to validate all required parts
* are available in the wsdl
* @param taskConfig Task configuration object for this task package
* @throws HumanTaskDeploymentException HumanTaskDeployment Exception is thrown when an error happens
*/
private void validateServiceCreationForTaskConfig(HumanTaskBaseConfiguration taskConfig) throws HumanTaskDeploymentException {
try {
WSDL11ToAxisServiceBuilder serviceBuilder = createAxisServiceBuilder(taskConfig, taskConfig.getWSDL());
serviceBuilder.populateService();
} catch (AxisFault e) {
String errorMsg = "Error validating wsdl " + e.getMessage();
throw new HumanTaskDeploymentException(errorMsg, e);
}
}
use of org.wso2.ballerinalang.compiler.codegen.CodeGenerator.VariableIndex.Kind.PACKAGE in project carbon-business-process by wso2.
the class HumanTaskStore method deploy.
/**
* Handles the deployment steps for the master node and salve node in the cluster
* @param humanTaskFile
* @throws Exception
*/
public void deploy(File humanTaskFile) throws Exception {
// Currently using the registry read/write mount property to determine whether this node is a master node
// or a salve node.
// Handle this properly with hazelcast leader for cluster scenario TODO
boolean isMasterServer = !isServerReadOnly();
// Versions of this ht package is already deployed
boolean isExistingPackage = false;
// Exactly matching ht package already exists
boolean isPackageReload = false;
DeploymentUnitDAO currentlyActiveTaskPackage = null;
String md5sum = HumanTaskStoreUtils.getMD5Checksum(humanTaskFile);
String packageName = FilenameUtils.removeExtension(humanTaskFile.getName());
List<DeploymentUnitDAO> existingDeploymentUnitsForPackage = getExistingDeploymentUnitsForPackage(packageName.trim());
if (existingDeploymentUnitsForPackage != null && existingDeploymentUnitsForPackage.size() > 0) {
isExistingPackage = true;
for (DeploymentUnitDAO dao : existingDeploymentUnitsForPackage) {
if ((dao.getStatus() == (TaskPackageStatus.ACTIVE))) {
// extract the currently active task package
currentlyActiveTaskPackage = dao;
if (dao.getChecksum().equals(md5sum)) {
// Check whether the md5sum matches the active task package.
isPackageReload = true;
}
}
}
}
// We will only allow writes to db only for the master node to avoid duplicate version creation
if (isExistingPackage && isPackageReload) {
// Reload the existing versions of the human task package . No need of creating a new version of the package
// This could be due to server restart, deployment of the same package or master node has already deployed the
// new version of the package
// First check if the currently active task package is already loaded
String activePackageName = loadedPackages.get(currentlyActiveTaskPackage.getPackageName());
if (activePackageName != null && activePackageName.equals(currentlyActiveTaskPackage.getName())) {
if (log.isDebugEnabled()) {
log.debug("This task package and its previous versions are already loaded " + activePackageName);
}
// This task package and its previous versions are already loaded , hence return
return;
}
// Load the existing versions of the package
reloadExistingTaskVersions(existingDeploymentUnitsForPackage, humanTaskFile, md5sum, isMasterServer);
return;
}
// New version of the package is being deployed on top of the existing version
if (isExistingPackage && !isPackageReload) {
if (isMasterServer) {
// Retire the existing version of the package and deploy the new version
// This could be two scenarios. Server restart with new version and deploying on existing version.
String activePackageName = loadedPackages.get(currentlyActiveTaskPackage.getPackageName());
if (activePackageName == null) {
// This is a server restart, we need to load existing versions
reloadExistingTaskVersions(existingDeploymentUnitsForPackage, humanTaskFile, md5sum, isMasterServer);
}
long newVersion = getNextVersion();
HumanTaskDeploymentUnit newDeploymentUnit = createNewDeploymentUnit(humanTaskFile, tenantId, newVersion, md5sum);
validateTaskConfig(newDeploymentUnit);
retireTaskPackageConfigurations(currentlyActiveTaskPackage.getName());
currentlyActiveTaskPackage.setStatus(TaskPackageStatus.RETIRED);
updateDeploymentUnitDao(currentlyActiveTaskPackage);
// Retiring of currently active package is complete.
// Create and deploy new version
deployNewTaskVersion(newDeploymentUnit, newVersion);
// Add new version of human task package to registry
// Update the zip and package properties in the registry
repository.handleNewHumanTaskPackageAddition(newDeploymentUnit, humanTaskFile);
// Successfully deployed the packages.
return;
} else {
// Cannot allow creation of a new version from slave nodes, deploy the new version on the master node
// first to avoid duplicate version creation
// Write log, issue warning and return
log.warn("Cannot deploy new version of the task in slave node. Hence deploy the task archive in master" + "node fist");
return;
}
}
if (!isMasterServer) {
// Issue warning, write warn message and return as we cannot allow deployment of new versions on slave nodes
// before deployment of the ht package in the master node
log.warn("Cannot deploy a new version on the package on the salve node first, " + "Deploy the package on the master node first");
return;
}
// Create new version of deployment unit
// Process the human task configurations
// Store deployment unit information to the db
// Deploy axis2 services
// Adding HumanTask package the registry.
long newVersion = getNextVersion();
HumanTaskDeploymentUnit newDeploymentUnit = createNewDeploymentUnit(humanTaskFile, tenantId, newVersion, md5sum);
validateTaskConfig(newDeploymentUnit);
deployNewTaskVersion(newDeploymentUnit, newVersion);
repository.handleNewHumanTaskPackageAddition(newDeploymentUnit, humanTaskFile);
return;
}
use of org.wso2.ballerinalang.compiler.codegen.CodeGenerator.VariableIndex.Kind.PACKAGE in project carbon-business-process by wso2.
the class HumanTaskPackageRepository method updateHumanTaskPackageProperties.
/**
* Update the properties of existing human task package in the registry
*
* @param humanTaskDeploymentUnit
* @throws RegistryException
*/
private void updateHumanTaskPackageProperties(HumanTaskDeploymentUnit humanTaskDeploymentUnit) throws RegistryException {
String packageLocation = HumanTaskPackageRepositoryUtils.getResourcePathForHumanTaskPackage(humanTaskDeploymentUnit);
Resource humanTaskPackage = configRegistry.get(packageLocation);
humanTaskPackage.setProperty(HumanTaskConstants.HUMANTASK_PACKAGE_PROP_LATEST_CHECKSUM, humanTaskDeploymentUnit.getMd5sum());
if (log.isDebugEnabled()) {
log.debug(humanTaskDeploymentUnit.getPackageName() + " updated checksum to: " + humanTaskDeploymentUnit.getMd5sum());
}
humanTaskPackage.setProperty(HumanTaskConstants.HUMANTASK_PACKAGE_PROP_STATUS, String.valueOf(humanTaskDeploymentUnit.getTaskPackageStatus()));
humanTaskPackage.setProperty(HumanTaskConstants.HUMANTASK_PACKAGE_PROP_LATEST_VERSION, Long.toString(humanTaskDeploymentUnit.getVersion()));
configRegistry.put(packageLocation, humanTaskPackage);
}
use of org.wso2.ballerinalang.compiler.codegen.CodeGenerator.VariableIndex.Kind.PACKAGE in project carbon-business-process by wso2.
the class BPELPackageRepository method readPropertiesOfUpdatedDeploymentInfo.
/**
* Reads the updated properties from registry and sets the process configuration fields
*
* @param processConfiguration - Process's configuration details after updated
* @param bpelPackageName - the relevant bpel package
* @throws RegistryException on registry rollback error case, we'll init the cause to the
* original exception we got when accessing registry
* @throws ProcessManagementException
*/
public void readPropertiesOfUpdatedDeploymentInfo(ProcessConfigurationImpl processConfiguration, String bpelPackageName) throws RegistryException, ProcessManagementException {
String versionlessPackageName = BPELPackageRepositoryUtils.getVersionlessPackageName(bpelPackageName);
String packageLocation = BPELPackageRepositoryUtils.getResourcePathForDeployInfoUpdatedBPELPackage(processConfiguration.getPackage(), versionlessPackageName);
Resource bpelPackage = configRegistry.get(packageLocation);
String stateInString = bpelPackage.getProperty(BPELConstants.BPEL_PROCESS_STATE + processConfiguration.getProcessId());
String inMemoryInString = bpelPackage.getProperty(BPELConstants.BPEL_PROCESS_INMEMORY + processConfiguration.getProcessId());
String processEventsInString = bpelPackage.getProperty(BPELConstants.BPEL_PROCESS_EVENTS + processConfiguration.getProcessId());
String generateTypeString = bpelPackage.getProperty(BPELConstants.BPEL_PROCESS_EVENT_GENERATE + processConfiguration.getProcessId());
String successCleanupsInString = bpelPackage.getProperty(BPELConstants.BPEL_INSTANCE_CLEANUP_SUCCESS + processConfiguration.getProcessId());
String failureCleanupsInString = bpelPackage.getProperty(BPELConstants.BPEL_INSTANCE_CLEANUP_FAILURE + processConfiguration.getProcessId());
// editor has been updated, read the updated fields
if (stateInString != null) {
ProcessState state = BPELPackageRepositoryUtils.getProcessState(stateInString);
processConfiguration.setState(state);
processConfiguration.setIsTransient(Boolean.parseBoolean(inMemoryInString));
ProcessEventsListType processEventsList = new ProcessEventsListType();
EnableEventListType enabledEventList = BPELPackageRepositoryUtils.getEnabledEventsListFromString(processEventsInString);
processEventsList.setEnableEventsList(enabledEventList);
Generate_type1 generateType = BPELPackageRepositoryUtils.getProcessGenerateTypeFromString(generateTypeString);
processEventsList.setGenerate(generateType);
ScopeEventListType scopeEventList = new ScopeEventListType();
int j = 0;
while (bpelPackage.getProperty(BPELConstants.BPEL_PROCESS_SCOPE_EVENT + (j + 1) + processConfiguration.getProcessId()) != null) {
ScopeEventType scopeEvent = BPELPackageRepositoryUtils.getScopeEventFromString(bpelPackage.getProperty(BPELConstants.BPEL_PROCESS_SCOPE_EVENT + (j + 1) + processConfiguration.getProcessId()));
scopeEventList.addScopeEvent(scopeEvent);
j++;
}
processEventsList.setScopeEventsList(scopeEventList);
processConfiguration.setProcessEventsList(processEventsList);
CleanUpListType cleanUpList = new CleanUpListType();
CleanUpType successCleanUp = BPELPackageRepositoryUtils.getSuccessCleanUpType(successCleanupsInString);
cleanUpList.addCleanUp(successCleanUp);
CleanUpType failureCleanUp = BPELPackageRepositoryUtils.getFailureCleanUpType(failureCleanupsInString);
cleanUpList.addCleanUp(failureCleanUp);
processConfiguration.setProcessCleanupConfImpl(cleanUpList);
}
}
use of org.wso2.ballerinalang.compiler.codegen.CodeGenerator.VariableIndex.Kind.PACKAGE in project carbon-business-process by wso2.
the class BPELPackageRepository method createBPELPackageParentCollectionWithProperties.
/**
* Create parent collection to persisting BPEL package information. For example, if you deploy
* a BPEL archive called 'HelloWorld.zip', we store information of that package in collection
* named 'HelloWorld'. This will be the root for 'HelloWorld' BPEL package information and
* there will several versions of this BPEL package in this registry collection which relates
* to the versions deployed in BPEL engine.
*
* @param deploymentContext containing information on current deployment
* @throws RegistryException when there is a error accessing registry
* @throws IOException if file access error occurred during MD5 checksum generation
* @throws NoSuchAlgorithmException when there is a error during MD5 generation
*/
private void createBPELPackageParentCollectionWithProperties(BPELDeploymentContext deploymentContext) throws RegistryException, IOException, NoSuchAlgorithmException {
Collection bpelPackage = configRegistry.newCollection();
bpelPackage.setProperty(BPELConstants.BPEL_PACKAGE_PROP_LATEST_CHECKSUM, Utils.getMD5Checksum(deploymentContext.getBpelArchive()));
if (log.isDebugEnabled()) {
log.debug(deploymentContext.getBpelPackageName() + " updating checksum: " + Utils.getMD5Checksum(deploymentContext.getBpelArchive()) + " in registry");
}
if (deploymentContext.isFailed()) {
bpelPackage.setProperty(BPELConstants.BPEL_PACKAGE_PROP_STATUS, BPELConstants.STATUS_FAILED);
bpelPackage.setProperty(BPELConstants.BPEL_PACKAGE_PROP_DEPLOYMENT_ERROR_LOG, deploymentContext.getDeploymentFailureCause());
// bpelPackage.setProperty(BPELConstants.BPEL_PACKAGE_PROP_DEPLOYMENT_STACK_TRACE,
// ExceptionUtils.getStackTrace(deploymentContext.getStackTrace()));
} else {
bpelPackage.setProperty(BPELConstants.BPEL_PACKAGE_PROP_STATUS, BPELConstants.STATUS_DEPLOYED);
}
bpelPackage.setProperty(BPELConstants.BPEL_PACKAGE_PROP_LATEST_VERSION, Long.toString(deploymentContext.getVersion()));
configRegistry.put(BPELPackageRepositoryUtils.getResourcePathForBPELPackage(deploymentContext), bpelPackage);
}
Aggregations