Search in sources :

Example 1 with DataEndpointAgentConfigurationException

use of org.wso2.carbon.databridge.agent.exception.DataEndpointAgentConfigurationException in project carbon-apimgt by wso2.

the class AbstractEventPublisherAction method initDataPublisher.

public final void initDataPublisher(String type, String receiverURLSet, String authURLSet, String username, String password, String configPath) throws DataEndpointAuthenticationException, DataEndpointAgentConfigurationException, TransportException, DataEndpointException, DataEndpointConfigurationException {
    AgentHolder.setConfigPath(configPath);
    dataPublisher = new DataPublisher(type, receiverURLSet, authURLSet, username, password);
}
Also used : DataPublisher(org.wso2.carbon.databridge.agent.DataPublisher)

Example 2 with DataEndpointAgentConfigurationException

use of org.wso2.carbon.databridge.agent.exception.DataEndpointAgentConfigurationException in project carbon-business-process by wso2.

the class BPMNDataPublisher method configDataPublishing.

/**
 * Configure for data publishing to DAS for analytics
 *
 * @param receiverURLSet             Analytics receiver's url
 * @param username                   Analytics server's username
 * @param password                   Analytics server's password
 * @param authURLSet                 Analytics Auth URL set
 * @param type                       Bpmn Analytics Publisher Type
 * @param asyncDataPublishingEnabled is async Data Publishing Enabled
 * @param genericAnalyticsEnabled    is generic Analytics Enabled
 * @param kpiAnalyticsEnabled        is KPI Analytics Enabled
 * @throws DataEndpointAuthenticationException
 * @throws DataEndpointAgentConfigurationException
 * @throws TransportException
 * @throws DataEndpointException
 * @throws DataEndpointConfigurationException
 */
void configDataPublishing(String receiverURLSet, String username, String password, String authURLSet, String type, boolean asyncDataPublishingEnabled, boolean genericAnalyticsEnabled, boolean kpiAnalyticsEnabled) throws DataEndpointAuthenticationException, DataEndpointAgentConfigurationException, TransportException, DataEndpointException, DataEndpointConfigurationException {
    if (receiverURLSet != null && username != null && password != null) {
        // Configure data publisher to be used by all data publishing listeners
        if (log.isDebugEnabled()) {
            log.debug("Creating BPMN analytics data publisher with Receiver URL: " + receiverURLSet + ", Auth URL: " + authURLSet + " and Data publisher type: " + type);
        }
        dataPublisher = new DataPublisher(type, receiverURLSet, authURLSet, username, password);
        BPMNAnalyticsHolder.getInstance().setAsyncDataPublishingEnabled(asyncDataPublishingEnabled);
        BPMNEngineService engineService = BPMNAnalyticsHolder.getInstance().getBpmnEngineService();
        // Attach data publishing listeners to all existing processes
        if (log.isDebugEnabled()) {
            log.debug("Attaching data publishing listeners to already deployed processes...");
        }
        RepositoryService repositoryService = engineService.getProcessEngine().getRepositoryService();
        List<ProcessDefinition> processDefinitions = repositoryService.createProcessDefinitionQuery().list();
        for (ProcessDefinition processDefinition : processDefinitions) {
            // Process definition returned by the query does not contain all details such as task definitions.
            // And it is also not the actual process definition, but a copy of it, so attaching listners to
            // them is useless. Therefore, we have to fetch the complete process definition from the repository
            // again.
            ProcessDefinition completeProcessDefinition = repositoryService.getProcessDefinition(processDefinition.getId());
            if (completeProcessDefinition instanceof ProcessDefinitionEntity) {
                ProcessDefinitionEntity processDefinitionEntity = (ProcessDefinitionEntity) completeProcessDefinition;
                if (genericAnalyticsEnabled) {
                    processDefinitionEntity.addExecutionListener(PvmEvent.EVENTNAME_END, new ProcessTerminationListener());
                }
                if (kpiAnalyticsEnabled) {
                    processDefinitionEntity.addExecutionListener(PvmEvent.EVENTNAME_END, new ProcessTerminationKPIListener());
                }
                Map<String, TaskDefinition> tasks = processDefinitionEntity.getTaskDefinitions();
                List<ActivityImpl> activities = processDefinitionEntity.getActivities();
                for (ActivityImpl activity : activities) {
                    if (activity.getProperty("type").toString().equalsIgnoreCase("usertask")) {
                        tasks.get(activity.getId()).addTaskListener(TaskListener.EVENTNAME_COMPLETE, new TaskCompletionListener());
                    }
                // We are publishing analytics data of service tasks in process termination ATM.
                // else if(activity.getProperty("type").toString().equalsIgnoreCase("servicetask")){
                // activity.addExecutionListener(PvmEvent.EVENTNAME_END,new
                // ServiceTaskCompletionListener());
                // }
                }
            }
        }
        // Configure parse handlers, which attaches data publishing listeners to new processes
        if (log.isDebugEnabled()) {
            log.debug("Associating parse handlers for processes and tasks, so that data publishing listeners " + "will be attached to new processes.");
        }
        ProcessEngineConfigurationImpl engineConfig = (ProcessEngineConfigurationImpl) engineService.getProcessEngine().getProcessEngineConfiguration();
        if (engineConfig.getPostBpmnParseHandlers() == null) {
            engineConfig.setPostBpmnParseHandlers(new ArrayList<BpmnParseHandler>());
        }
        if (genericAnalyticsEnabled) {
            engineConfig.getPostBpmnParseHandlers().add(new ProcessParseHandler());
            engineConfig.getPostBpmnParseHandlers().add(new TaskParseHandler());
            engineConfig.getBpmnDeployer().getBpmnParser().getBpmnParserHandlers().addHandler(new ProcessParseHandler());
            engineConfig.getBpmnDeployer().getBpmnParser().getBpmnParserHandlers().addHandler(new TaskParseHandler());
        }
        if (kpiAnalyticsEnabled) {
            engineConfig.getPostBpmnParseHandlers().add(new ProcessKPIParseHandler());
            engineConfig.getBpmnDeployer().getBpmnParser().getBpmnParserHandlers().addHandler(new ProcessKPIParseHandler());
        }
    } else {
        log.warn("Required fields for data publisher are not configured. Receiver URLs, username and password " + "are mandatory. Data publishing will not be enabled.");
    }
}
Also used : TaskCompletionListener(org.wso2.carbon.bpmn.analytics.publisher.listeners.TaskCompletionListener) TaskParseHandler(org.wso2.carbon.bpmn.analytics.publisher.handlers.TaskParseHandler) ProcessDefinition(org.activiti.engine.repository.ProcessDefinition) ProcessParseHandler(org.wso2.carbon.bpmn.analytics.publisher.handlers.ProcessParseHandler) BpmnParseHandler(org.activiti.engine.parse.BpmnParseHandler) ProcessKPIParseHandler(org.wso2.carbon.bpmn.analytics.publisher.handlers.ProcessKPIParseHandler) ProcessTerminationKPIListener(org.wso2.carbon.bpmn.analytics.publisher.listeners.ProcessTerminationKPIListener) BPMNEngineService(org.wso2.carbon.bpmn.core.BPMNEngineService) TaskDefinition(org.activiti.engine.impl.task.TaskDefinition) ActivityImpl(org.activiti.engine.impl.pvm.process.ActivityImpl) ProcessTerminationListener(org.wso2.carbon.bpmn.analytics.publisher.listeners.ProcessTerminationListener) DataPublisher(org.wso2.carbon.databridge.agent.DataPublisher) ProcessDefinitionEntity(org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity) ProcessEngineConfigurationImpl(org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl) RepositoryService(org.activiti.engine.RepositoryService)

Example 3 with DataEndpointAgentConfigurationException

use of org.wso2.carbon.databridge.agent.exception.DataEndpointAgentConfigurationException in project carbon-apimgt by wso2.

the class Init method execute.

@Override
public BValue execute(Context context) {
    BConnector bConnector = (BConnector) getRefArgument(context, 0);
    BMap optionMap = (BMap) bConnector.getRefField(0);
    BMap sharedMap = (BMap) bConnector.getRefField(1);
    System.setProperty("javax.net.ssl.trustStore", System.getProperty("ballerina.home") + File.separator + "bre" + File.separator + "security" + File.separator + "wso2carbon.jks");
    System.setProperty("javax.net.ssl.trustStorePassword", "wso2carbon");
    String type = optionMap.get(Constants.TYPE).stringValue();
    String receiverURLSet = optionMap.get(Constants.RECEIVER_URL_SET).stringValue();
    String authURLSet = optionMap.get(Constants.AUTH_URL_SET).stringValue();
    String username = optionMap.get(Constants.USERNAME).stringValue();
    String password = optionMap.get(Constants.PASSWORD).stringValue();
    String configPath = optionMap.get(Constants.CONFIG_PATH).stringValue();
    configPath = System.getProperty("ballerina.home") + File.separator + configPath;
    try {
        initDataPublisher(type, receiverURLSet, authURLSet, username, password, configPath);
        sharedMap.put(Constants.PUBLISHER_INSTANCE, this);
    } catch (DataEndpointAuthenticationException e) {
        log.error("Error occurred while authenticating.", e);
    } catch (DataEndpointAgentConfigurationException e) {
        log.error("Error occurred while configuring the publisher.", e);
    } catch (TransportException e) {
        log.error("Transport level exception occurred.", e);
    } catch (DataEndpointException e) {
        log.error("Data endpoint exception occurred.", e);
    } catch (DataEndpointConfigurationException e) {
        log.error("Data endpoint configuration exception occurred.", e);
    }
    return null;
}
Also used : BConnector(org.ballerinalang.model.values.BConnector) BMap(org.ballerinalang.model.values.BMap) DataEndpointAuthenticationException(org.wso2.carbon.databridge.agent.exception.DataEndpointAuthenticationException) DataEndpointAgentConfigurationException(org.wso2.carbon.databridge.agent.exception.DataEndpointAgentConfigurationException) DataEndpointException(org.wso2.carbon.databridge.agent.exception.DataEndpointException) TransportException(org.wso2.carbon.databridge.commons.exception.TransportException) DataEndpointConfigurationException(org.wso2.carbon.databridge.agent.exception.DataEndpointConfigurationException)

Example 4 with DataEndpointAgentConfigurationException

use of org.wso2.carbon.databridge.agent.exception.DataEndpointAgentConfigurationException in project carbon-business-process by wso2.

the class AnalyticsPublisherExtensionOperation method getDataPublisher.

private DataPublisher getDataPublisher(ExtensionContext context, int tenantId, String analyticsServerProfileName) throws FaultException {
    DataPublisher dataPublisher = null;
    TenantProcessStore tenantsProcessStore = AnalyticsPublisherServiceComponent.getBPELServer().getMultiTenantProcessStore().getTenantsProcessStore(tenantId);
    String processName = context.getProcessModel().getName().toString();
    dataPublisher = (DataPublisher) tenantsProcessStore.getDataPublisher(processName);
    // Create new DataPublisher if not created already.
    if (dataPublisher == null) {
        AnalyticsServerProfile analyticsServerProfile = getAnalyticsServerProfile(tenantId, analyticsServerProfileName);
        try {
            dataPublisher = new DataPublisher(analyticsServerProfile.getType(), analyticsServerProfile.getReceiverURLSet(), analyticsServerProfile.getAuthURLSet(), analyticsServerProfile.getUserName(), analyticsServerProfile.getPassword());
        } catch (TransportException e) {
            String errorMsg = "Transport layer problem.";
            handleException(errorMsg, e);
        } catch (DataEndpointAuthenticationException e) {
            String errorMsg = "Data endpoint authentication problem.";
            handleException(errorMsg, e);
        } catch (DataEndpointAgentConfigurationException e) {
            String errorMsg = "Data endpoint agent configuration problem.";
            handleException(errorMsg, e);
        } catch (DataEndpointException e) {
            String errorMsg = "Data endpoint problem.";
            handleException(errorMsg, e);
        } catch (DataEndpointConfigurationException e) {
            String errorMsg = "Data endpoint configuration problem.";
            handleException(errorMsg, e);
        }
        if (log.isDebugEnabled()) {
            log.debug("Data Publisher Created : " + analyticsServerProfile.toString());
        }
        if (dataPublisher != null) {
            tenantsProcessStore.addDataPublisher(processName, dataPublisher);
        }
    }
    return dataPublisher;
}
Also used : DataEndpointAuthenticationException(org.wso2.carbon.databridge.agent.exception.DataEndpointAuthenticationException) DataPublisher(org.wso2.carbon.databridge.agent.DataPublisher) DataEndpointAgentConfigurationException(org.wso2.carbon.databridge.agent.exception.DataEndpointAgentConfigurationException) DataEndpointException(org.wso2.carbon.databridge.agent.exception.DataEndpointException) TenantProcessStore(org.wso2.carbon.bpel.core.ode.integration.store.TenantProcessStore) AnalyticsServerProfile(org.wso2.carbon.bpel.core.ode.integration.config.analytics.AnalyticsServerProfile) DataEndpointConfigurationException(org.wso2.carbon.databridge.agent.exception.DataEndpointConfigurationException)

Aggregations

DataPublisher (org.wso2.carbon.databridge.agent.DataPublisher)3 DataEndpointAgentConfigurationException (org.wso2.carbon.databridge.agent.exception.DataEndpointAgentConfigurationException)2 DataEndpointAuthenticationException (org.wso2.carbon.databridge.agent.exception.DataEndpointAuthenticationException)2 DataEndpointConfigurationException (org.wso2.carbon.databridge.agent.exception.DataEndpointConfigurationException)2 DataEndpointException (org.wso2.carbon.databridge.agent.exception.DataEndpointException)2 RepositoryService (org.activiti.engine.RepositoryService)1 ProcessEngineConfigurationImpl (org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl)1 ProcessDefinitionEntity (org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity)1 ActivityImpl (org.activiti.engine.impl.pvm.process.ActivityImpl)1 TaskDefinition (org.activiti.engine.impl.task.TaskDefinition)1 BpmnParseHandler (org.activiti.engine.parse.BpmnParseHandler)1 ProcessDefinition (org.activiti.engine.repository.ProcessDefinition)1 BConnector (org.ballerinalang.model.values.BConnector)1 BMap (org.ballerinalang.model.values.BMap)1 AnalyticsServerProfile (org.wso2.carbon.bpel.core.ode.integration.config.analytics.AnalyticsServerProfile)1 TenantProcessStore (org.wso2.carbon.bpel.core.ode.integration.store.TenantProcessStore)1 ProcessKPIParseHandler (org.wso2.carbon.bpmn.analytics.publisher.handlers.ProcessKPIParseHandler)1 ProcessParseHandler (org.wso2.carbon.bpmn.analytics.publisher.handlers.ProcessParseHandler)1 TaskParseHandler (org.wso2.carbon.bpmn.analytics.publisher.handlers.TaskParseHandler)1 ProcessTerminationKPIListener (org.wso2.carbon.bpmn.analytics.publisher.listeners.ProcessTerminationKPIListener)1