use of org.wso2.carbon.registry.api.Collection in project carbon-business-process by wso2.
the class BPELPackageRepository method createCollectionWithBPELPackageWithoutContentForCurrentVersion.
/**
* This repository persist the BPEL package versions inside the BPEL Package collection
* under the child collection 'versions'. The collection name is same as directory with version
* attached to it's name(Example: HelloWorld-3).
* <p/>
* For the 'HelloWorld' BPEL package, extracted BPEL package will be stored in a registry
* location like '<config_registry_root>/bpel/packages/HelloWorld/versions/HelloWorld-3'.
*
* @param deploymentContext containing information on current BPEL deployment.
* @throws RegistryException if an error occurred during import of file system content to
* registry.
*/
private void createCollectionWithBPELPackageWithoutContentForCurrentVersion(BPELDeploymentContext deploymentContext) throws RegistryException {
String collectionLocation = BPELPackageRepositoryUtils.getResourcePathForBPELPackageContent(deploymentContext);
Collection collection = configRegistry.newCollection();
configRegistry.put(collectionLocation, collection);
}
use of org.wso2.carbon.registry.api.Collection in project carbon-business-process by wso2.
the class Instance method getPaginatedInstanceList.
public PaginatedInstanceList getPaginatedInstanceList(String filter, final String order, final int limit, final int page) throws InstanceManagementException {
String tFilter = filter;
final PaginatedInstanceList instanceList = new PaginatedInstanceList();
Integer tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
TenantProcessStoreImpl tenantProcessStore = (TenantProcessStoreImpl) bpelServer.getMultiTenantProcessStore().getTenantsProcessStore(tenantId);
if (tenantProcessStore.getProcessConfigMap().size() <= 0) {
instanceList.setPages(0);
return instanceList;
}
if (!tFilter.contains(" pid=")) {
tFilter = tFilter + getTenantsProcessList(tenantProcessStore.getProcessConfigMap().keySet());
}
if (log.isDebugEnabled()) {
log.debug("Instance Filter:" + tFilter);
}
final InstanceFilter instanceFilter = new InstanceFilter(tFilter, order, limit);
try {
BpelDatabase bpelDb = bpelServer.getODEBPELServer().getBpelDb();
bpelDb.exec(new BpelDatabase.Callable<Object>() {
public Object run(BpelDAOConnection conn) throws InstanceManagementException {
Collection<ProcessInstanceDAO> instances = conn.instanceQuery(instanceFilter);
int pageNum = page;
if (pageNum < 0 || pageNum == Integer.MAX_VALUE) {
pageNum = 0;
}
int startIndexOfCurrentPage = pageNum * BPELConstants.ITEMS_PER_PAGE;
int endIndexOfCurrentPage = (pageNum + 1) * BPELConstants.ITEMS_PER_PAGE;
int instanceListSize = instances.size();
int pages = (int) Math.ceil((double) instanceListSize / BPELConstants.ITEMS_PER_PAGE);
instanceList.setPages(pages);
ProcessInstanceDAO[] instanceArray = instances.toArray(new ProcessInstanceDAO[instanceListSize]);
for (int i = startIndexOfCurrentPage; (i < endIndexOfCurrentPage && i < instanceListSize); i++) {
instanceList.addInstance(createLimitedInstanceInfoObject(instanceArray[i]));
}
return null;
}
});
} catch (Exception e) {
String errMsg = "Error querying instances from database. Instance Filter:" + instanceFilter.toString();
log.error(errMsg, e);
throw new InstanceManagementException(errMsg, e);
}
return instanceList;
}
use of org.wso2.carbon.registry.api.Collection in project carbon-business-process by wso2.
the class TenantProcessStoreImpl method handleUndeployOnSlaveNode.
/**
* Undeployment scenario in a worker node( Slave ) in the clustered setup
* When the BPELDeployer get called for undeploying the bpel package, following has already taken place.
* The package information stored in the registry as well as the zip archive is deleted
* Process, Instance information have been removed from the ODE database
* However, on the slave node, the bpel process and the web services associated with the bpel process
* is still in memory. We need to unload the bpel process and the associated web services
*
* @param bpelPackageName bpel package name
* @return
*/
private int handleUndeployOnSlaveNode(String bpelPackageName) {
List<String> packageList = findMatchingProcessByPackageName(bpelPackageName);
if (packageList.size() < 1) {
log.debug("Handling un-deploy operation on salve (worker) node : package list is empty");
return -1;
}
for (String packageName : packageList) {
// location for extracted BPEL package
String bpelPackageLocation = parentProcessStore.getLocalDeploymentUnitRepo().getAbsolutePath() + File.separator + tenantId + File.separator + packageName;
File bpelPackage = new File(bpelPackageLocation);
// removing extracted bpel package at repository/bpel/tenantID/
deleteBpelPackageFromRepo(bpelPackage);
for (QName pid : getProcessesInPackage(packageName)) {
ProcessConfigurationImpl processConf = (ProcessConfigurationImpl) getProcessConfiguration(pid);
// This property is read when we removing the axis service for this process.
// So that we can decide whether we should persist service QOS configs
processConf.setUndeploying(true);
}
}
Collection<QName> undeployedProcesses = new ArrayList<QName>();
for (String nameWithVersion : packageList) {
undeploySpecificVersionOfBPELPackage(nameWithVersion, undeployedProcesses);
}
BPELServerImpl instance = BPELServerImpl.getInstance();
BpelServerImpl odeBpelServer = instance.getODEBPELServer();
for (QName pid : undeployedProcesses) {
odeBpelServer.unregister(pid);
ProcessConf pConf = parentProcessStore.getProcessConfiguration(pid);
if (pConf != null) {
if (log.isDebugEnabled()) {
log.debug("Cancelling all cron scheduled jobs for process " + pid);
}
odeBpelServer.getContexts().cronScheduler.cancelProcessCronJobs(pid, true);
}
log.info("Process " + pid + " un-deployed.");
}
parentProcessStore.updateProcessAndDUMapsForSalve(tenantId, bpelPackageName, undeployedProcesses);
return 0;
}
use of org.wso2.carbon.registry.api.Collection in project ballerina by ballerina-lang.
the class Types method checkForeachTypes.
List<BType> checkForeachTypes(BLangNode collection, int variableSize) {
BType collectionType = collection.type;
List<BType> errorTypes;
int maxSupportedTypes;
switch(collectionType.tag) {
case TypeTags.ARRAY:
BArrayType bArrayType = (BArrayType) collectionType;
if (variableSize == 1) {
return Lists.of(bArrayType.eType);
} else if (variableSize == 2) {
return Lists.of(symTable.intType, bArrayType.eType);
} else {
maxSupportedTypes = 2;
errorTypes = Lists.of(symTable.intType, bArrayType.eType);
}
break;
case TypeTags.MAP:
BMapType bMapType = (BMapType) collectionType;
if (variableSize == 1) {
return Lists.of(bMapType.constraint);
} else if (variableSize == 2) {
return Lists.of(symTable.stringType, bMapType.constraint);
} else {
maxSupportedTypes = 2;
errorTypes = Lists.of(symTable.stringType, bMapType.constraint);
}
break;
case TypeTags.JSON:
if (variableSize == 1) {
return Lists.of(symTable.jsonType);
} else {
maxSupportedTypes = 1;
errorTypes = Lists.of(symTable.jsonType);
}
break;
case TypeTags.XML:
if (variableSize == 1) {
return Lists.of(symTable.xmlType);
} else if (variableSize == 2) {
return Lists.of(symTable.intType, symTable.xmlType);
} else {
maxSupportedTypes = 2;
errorTypes = Lists.of(symTable.intType, symTable.xmlType);
}
break;
case TypeTags.TABLE:
BTableType tableType = (BTableType) collectionType;
if (variableSize == 1) {
return Lists.of(tableType.constraint);
} else {
maxSupportedTypes = 1;
errorTypes = Lists.of(tableType.constraint);
}
break;
case TypeTags.ERROR:
return Collections.nCopies(variableSize, symTable.errType);
default:
dlog.error(collection.pos, DiagnosticCode.ITERABLE_NOT_SUPPORTED_COLLECTION, collectionType);
return Collections.nCopies(variableSize, symTable.errType);
}
dlog.error(collection.pos, DiagnosticCode.ITERABLE_TOO_MANY_VARIABLES, collectionType);
errorTypes.addAll(Collections.nCopies(variableSize - maxSupportedTypes, symTable.errType));
return errorTypes;
}
use of org.wso2.carbon.registry.api.Collection in project ballerina by ballerina-lang.
the class CodeGenerator method visit.
public void visit(BLangForeach foreach) {
// Calculate temporary scope variables for iteration.
Operand iteratorVar = getLVIndex(TypeTags.ITERATOR);
Operand conditionVar = getLVIndex(TypeTags.BOOLEAN);
// Create new Iterator for given collection.
this.genNode(foreach.collection, env);
this.emit(InstructionCodes.ITR_NEW, foreach.collection.regIndex, iteratorVar);
Operand foreachStartAddress = new Operand(nextIP());
Operand foreachEndAddress = new Operand(-1);
Instruction gotoStartInstruction = InstructionFactory.get(InstructionCodes.GOTO, foreachStartAddress);
Instruction gotoEndInstruction = InstructionFactory.get(InstructionCodes.GOTO, foreachEndAddress);
// Checks given iterator has a next value.
this.emit(InstructionCodes.ITR_HAS_NEXT, iteratorVar, conditionVar);
this.emit(InstructionCodes.BR_FALSE, conditionVar, foreachEndAddress);
// assign variables.
generateForeachVarAssignment(foreach, iteratorVar);
this.loopResetInstructionStack.push(gotoStartInstruction);
this.loopExitInstructionStack.push(gotoEndInstruction);
// generate foreach body.
this.genNode(foreach.body, env);
this.loopResetInstructionStack.pop();
this.loopExitInstructionStack.pop();
// move to next iteration.
this.emit(gotoStartInstruction);
foreachEndAddress.value = this.nextIP();
}
Aggregations