Search in sources :

Example 46 with Instance

use of org.wso2.carbon.bpel.core.ode.integration.jmx.Instance in project carbon-business-process by wso2.

the class InstanceManagementServiceSkeleton method getInstanceInformationWithEvents.

private InstanceInfoWithEventsType getInstanceInformationWithEvents(final long iid) throws InstanceManagementException {
    final InstanceInfoWithEventsType instanceInfoWithEvents = new InstanceInfoWithEventsType();
    instanceInfoWithEvents.setIid(Long.toString(iid));
    dbexec(new BpelDatabase.Callable<Object>() {

        public Object run(BpelDAOConnection conn) throws InstanceManagementException {
            ProcessInstanceDAO instance = conn.getInstanceEagerly(iid, true);
            if (instance == null) {
                String errMsg = "Instance " + iid + " not found.";
                log.error(errMsg);
                throw new InstanceManagementException(errMsg);
            }
            fillInstanceInfoWithEvents(instanceInfoWithEvents, instance);
            return null;
        }
    });
    return instanceInfoWithEvents;
}
Also used : InstanceManagementException(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.InstanceManagementException) ProcessInstanceDAO(org.apache.ode.bpel.dao.ProcessInstanceDAO) BpelDatabase(org.apache.ode.bpel.engine.BpelDatabase) BpelDAOConnection(org.apache.ode.bpel.dao.BpelDAOConnection) InstanceInfoWithEventsType(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.InstanceInfoWithEventsType)

Example 47 with Instance

use of org.wso2.carbon.bpel.core.ode.integration.jmx.Instance in project carbon-business-process by wso2.

the class TenantProcessStoreImpl method undeploy.

/**
 * Undeploying BPEL package.
 *
 * @param bpelPackageName Name of the BPEL package which going to be undeployed
 */
public void undeploy(String bpelPackageName) throws RegistryException, BPELUIException {
    if (log.isDebugEnabled()) {
        log.debug("Un-deploying BPEL package " + bpelPackageName + " ....");
    }
    if (!repository.isExistingBPELPackage(bpelPackageName)) {
        // This can be a situation where we un-deploy the archive through management console,
        // so that, the archive is deleted from the repo. As a result this method get invoked.
        // to handle this case we just log the message but does not throw an exception.
        final String warningMsg = "Cannot find BPEL package with name " + bpelPackageName + " in the repository. If the bpel package is un-deployed through the management" + " console or if this node is a member of a cluster, please ignore this warning.";
        if (isConfigRegistryReadOnly()) {
            // This is for the deployment synchronizer scenarios where package un-deployment on a worker node
            // has to remove the deployed bpel package from the memory and remove associated services
            handleUndeployOnSlaveNode(bpelPackageName);
        } else {
            log.warn(warningMsg);
        }
        return;
    }
    if (repository.isExistingBPELPackage(bpelPackageName) && isConfigRegistryReadOnly()) {
        log.warn("This node seems to be a slave, since the configuration registry is in read-only mode, hence " + "processes cannot be directly undeployed from this node. Please undeploy the process in Master " + "node first.");
        return;
    }
    List<String> versionsOfThePackage;
    try {
        versionsOfThePackage = repository.getAllVersionsForPackage(bpelPackageName);
    } catch (RegistryException re) {
        String errMessage = "Cannot get all versions of the package " + bpelPackageName + " from registry.";
        log.error(errMessage);
        throw re;
    }
    // check the instance count to be deleted
    long instanceCount = getInstanceCountForPackage(versionsOfThePackage);
    if (instanceCount > BPELServerImpl.getInstance().getBpelServerConfiguration().getBpelInstanceDeletionLimit()) {
        throw new BPELUIException("Instance deletion limit reached.");
    }
    for (String nameWithVersion : versionsOfThePackage) {
        parentProcessStore.deleteDeploymentUnitDataFromDB(nameWithVersion);
        Utils.deleteInstances(getProcessesInPackage(nameWithVersion));
        // location for extracted BPEL package
        String bpelPackageLocation = parentProcessStore.getLocalDeploymentUnitRepo().getAbsolutePath() + File.separator + tenantId + File.separator + nameWithVersion;
        File bpelPackage = new File(bpelPackageLocation);
        // removing extracted bpel package at repository/bpel/0/
        deleteBpelPackageFromRepo(bpelPackage);
        for (QName pid : getProcessesInPackage(nameWithVersion)) {
            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);
        }
    }
    try {
        repository.handleBPELPackageUndeploy(bpelPackageName);
    } catch (RegistryException re) {
        String errMessage = "Cannot update the BPEL package repository for undeployment of" + "package " + bpelPackageName + ".";
        log.error(errMessage);
        throw re;
    }
    updateLocalInstanceWithUndeployment(bpelPackageName, versionsOfThePackage);
// We should use the deployment synchronizer, instead of the code below.
// parentProcessStore.sendProcessDeploymentNotificationsToCluster(
// new BPELPackageUndeployedCommand(versionsOfThePackage, bpelPackageName, tenantId),
// configurationContext);
}
Also used : QName(javax.xml.namespace.QName) RegistryException(org.wso2.carbon.registry.core.exceptions.RegistryException) File(java.io.File)

Example 48 with Instance

use of org.wso2.carbon.bpel.core.ode.integration.jmx.Instance in project carbon-business-process by wso2.

the class AnalyticsServerProfileBuilder method loadAnalyticsProfileFromRegistry.

/**
 * Load Analytics profile from given registry and registry path.
 *
 * @param analyticsServerProfile AnalyticsServerProfile instance
 * @param registry               Registry space where file is located
 * @param location               Registry path of the profile file
 */
private void loadAnalyticsProfileFromRegistry(AnalyticsServerProfile analyticsServerProfile, Registry registry, String location) {
    try {
        if (registry.resourceExists(location)) {
            Resource resource = registry.get(location);
            String resourceContent = new String((byte[]) resource.getContent());
            parseAnalyticsProfile(resourceContent, analyticsServerProfile);
        } else {
            String errMsg = "The resource: " + location + " does not exist.";
            handleError(errMsg);
        }
    } catch (RegistryException e) {
        String errMsg = "Error occurred while reading the resource from registry: " + location + " to build the Analytics server profile: " + profileLocation;
        handleError(errMsg, e);
    }
}
Also used : Resource(org.wso2.carbon.registry.api.Resource) RegistryException(org.wso2.carbon.registry.api.RegistryException)

Example 49 with Instance

use of org.wso2.carbon.bpel.core.ode.integration.jmx.Instance in project carbon-business-process by wso2.

the class AnalyticsServerProfileBuilder method build.

/**
 * Creates AnalyticsServerProfile for given tenant and Analytic profile.
 *
 * @return AnalyticsServerProfile instance
 */
public AnalyticsServerProfile build() {
    AnalyticsServerProfile analyticsServerProfile = new AnalyticsServerProfile();
    Registry registry;
    String location;
    if (profileLocation.startsWith(UnifiedEndpointConstants.VIRTUAL_CONF_REG)) {
        try {
            registry = BPELServiceComponent.getRegistryService().getConfigSystemRegistry(tenantId);
            location = profileLocation.substring(profileLocation.indexOf(UnifiedEndpointConstants.VIRTUAL_CONF_REG) + UnifiedEndpointConstants.VIRTUAL_CONF_REG.length());
            loadAnalyticsProfileFromRegistry(analyticsServerProfile, registry, location);
        } catch (RegistryException re) {
            String errMsg = "Error while loading Analytic profile from config registry.";
            handleError(errMsg, re);
        }
    } else if (profileLocation.startsWith(UnifiedEndpointConstants.VIRTUAL_GOV_REG)) {
        try {
            registry = BPELServiceComponent.getRegistryService().getGovernanceSystemRegistry(tenantId);
            location = profileLocation.substring(profileLocation.indexOf(UnifiedEndpointConstants.VIRTUAL_GOV_REG) + UnifiedEndpointConstants.VIRTUAL_GOV_REG.length());
            loadAnalyticsProfileFromRegistry(analyticsServerProfile, registry, location);
        } catch (RegistryException re) {
            String errMsg = "Error while loading Analytic profile from governance registry.";
            handleError(errMsg, re);
        }
    } else if (profileLocation.startsWith(UnifiedEndpointConstants.VIRTUAL_REG)) {
        try {
            registry = BPELServiceComponent.getRegistryService().getLocalRepository(tenantId);
            location = profileLocation.substring(profileLocation.indexOf(UnifiedEndpointConstants.VIRTUAL_REG) + UnifiedEndpointConstants.VIRTUAL_REG.length());
            loadAnalyticsProfileFromRegistry(analyticsServerProfile, registry, location);
        } catch (RegistryException re) {
            String errMsg = "Error while loading Analytic profile from local registry";
            handleError(errMsg, re);
        }
    } else if (profileLocation.startsWith(UnifiedEndpointConstants.VIRTUAL_FILE)) {
        location = profileLocation.substring(profileLocation.indexOf(UnifiedEndpointConstants.VIRTUAL_FILE) + UnifiedEndpointConstants.VIRTUAL_FILE.length());
        loadAnalyticsProfileFromFileSystem(analyticsServerProfile, location);
    } else {
        String errMsg = "Invalid analytics profile location: " + profileLocation;
        handleError(errMsg);
    }
    return analyticsServerProfile;
}
Also used : Registry(org.wso2.carbon.registry.api.Registry) RegistryException(org.wso2.carbon.registry.api.RegistryException)

Example 50 with Instance

use of org.wso2.carbon.bpel.core.ode.integration.jmx.Instance in project carbon-business-process by wso2.

the class Instance method getInstanceInfoFromInstanceId.

@Override
public String[] getInstanceInfoFromInstanceId() {
    StringBuffer buffer = new StringBuffer();
    PaginatedInstanceList paginatedInstanceList;
    String[] instanceInfoArray = null;
    int arrayCount = 0;
    try {
        paginatedInstanceList = getPaginatedInstanceList(" ", "-last-active", 200, 0);
        LimitedInstanceInfoType[] instanceArray = paginatedInstanceList.getInstance();
        instanceInfoArray = new String[instanceArray.length];
        for (LimitedInstanceInfoType instance : instanceArray) {
            buffer.append("Instance id=" + instance.getIid());
            buffer.append("  ");
            buffer.append("Process id=" + instance.getPid());
            buffer.append(" ");
            buffer.append("Status =" + instance.getStatus());
            buffer.append(" ");
            buffer.append("Started Date=" + instance.getDateStarted().get(5));
            buffer.append("-" + instance.getDateStarted().get(2));
            buffer.append("-" + instance.getDateStarted().get(1));
            buffer.append("  ");
            buffer.append(instance.getDateStarted().get(11));
            buffer.append(":" + instance.getDateStarted().get(12));
            buffer.append(":" + instance.getDateStarted().get(13));
            buffer.append("  ");
            buffer.append("Date Last Activate=" + instance.getDateLastActive().get(5));
            buffer.append("-" + instance.getDateLastActive().get(2));
            buffer.append("-" + instance.getDateLastActive().get(1));
            buffer.append("  ");
            buffer.append(instance.getDateLastActive().get(11));
            buffer.append(":" + instance.getDateLastActive().get(12));
            buffer.append(":" + instance.getDateLastActive().get(13));
            buffer.append("  ");
            instanceInfoArray[arrayCount] = buffer.toString();
            arrayCount++;
            buffer.delete(0, buffer.length());
        }
    } catch (InstanceManagementException e) {
        String errMsg = "failed to get instance information from instance id";
        log.error(errMsg, e);
    }
    return instanceInfoArray;
}
Also used : InstanceManagementException(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.InstanceManagementException) LimitedInstanceInfoType(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.LimitedInstanceInfoType) PaginatedInstanceList(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.PaginatedInstanceList)

Aggregations

ArrayList (java.util.ArrayList)28 Test (org.junit.Test)23 Response (javax.ws.rs.core.Response)22 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)21 APIManagerFactory (org.wso2.carbon.apimgt.core.impl.APIManagerFactory)20 HashMap (java.util.HashMap)15 Path (javax.ws.rs.Path)15 RuntimeService (org.activiti.engine.RuntimeService)15 HistoricProcessInstance (org.activiti.engine.history.HistoricProcessInstance)15 InstanceManagementException (org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.InstanceManagementException)14 Produces (javax.ws.rs.Produces)13 RestResponseFactory (org.wso2.carbon.bpmn.rest.common.RestResponseFactory)13 IOException (java.io.IOException)12 APIMgtAdminServiceImpl (org.wso2.carbon.apimgt.core.impl.APIMgtAdminServiceImpl)12 GET (javax.ws.rs.GET)11 APIManagementException (org.wso2.carbon.apimgt.core.exception.APIManagementException)11 ActivitiObjectNotFoundException (org.activiti.engine.ActivitiObjectNotFoundException)10 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)9 APIMgtDAOException (org.wso2.carbon.apimgt.core.exception.APIMgtDAOException)9 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)8