Search in sources :

Example 91 with Start

use of org.wso2.carbon.humantask.core.engine.commands.Start in project carbon-business-process by wso2.

the class BPMNInstanceService method getPaginatedHistoryInstances.

/**
 * Get paginated history instances
 *
 * @param start
 * @param size
 * @return list of BPMNInstances
 */
public BPMNInstance[] getPaginatedHistoryInstances(int start, int size) {
    BPMNInstance bpmnInstance;
    Integer tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
    List<BPMNInstance> bpmnInstances = new ArrayList<>();
    HistoryService historyService = BPMNServerHolder.getInstance().getEngine().getHistoryService();
    HistoricProcessInstanceQuery query = historyService.createHistoricProcessInstanceQuery().processInstanceTenantId(tenantId.toString()).finished().includeProcessVariables();
    historyInstanceCount = (int) query.count();
    List<HistoricProcessInstance> historicProcessInstances = query.listPage(start, size);
    for (HistoricProcessInstance instance : historicProcessInstances) {
        bpmnInstance = new BPMNInstance();
        bpmnInstance.setInstanceId(instance.getId());
        bpmnInstance.setProcessId(instance.getProcessDefinitionId());
        bpmnInstance.setStartTime(instance.getStartTime());
        bpmnInstance.setEndTime(instance.getEndTime());
        bpmnInstance.setVariables(formatVariables(instance.getProcessVariables()));
        bpmnInstances.add(bpmnInstance);
    }
    return bpmnInstances.toArray(new BPMNInstance[bpmnInstances.size()]);
}
Also used : BPMNInstance(org.wso2.carbon.bpmn.core.mgt.model.BPMNInstance) HistoricProcessInstanceQuery(org.activiti.engine.history.HistoricProcessInstanceQuery) HistoricProcessInstance(org.activiti.engine.history.HistoricProcessInstance) ArrayList(java.util.ArrayList) HistoryService(org.activiti.engine.HistoryService)

Example 92 with Start

use of org.wso2.carbon.humantask.core.engine.commands.Start in project carbon-business-process by wso2.

the class BPMNEngineServerStartupObserver method completedServerStartup.

@Override
public void completedServerStartup() {
    if (!CarbonUtils.isChildNode() && TRUE.equalsIgnoreCase(BPMNActivitiConfiguration.getInstance().getBPMNPropertyValue(BPMNConstants.SUBSTITUTION_CONFIG, BPMNConstants.SUBSTITUTION_ENABLED))) {
        String activationIntervalString = BPMNActivitiConfiguration.getInstance().getBPMNPropertyValue(BPMNConstants.SUBSTITUTION_CONFIG, BPMNConstants.SUBSTITUTION_SCHEDULER_INTERVAL);
        long interval = BPMNConstants.DEFAULT_SUBSTITUTION_INTERVAL_IN_MINUTES * 60 * 1000;
        if (activationIntervalString != null) {
            interval = Long.parseLong(activationIntervalString) * 60 * 1000;
        }
        BPMNServerHolder.getInstance().setSubstitutionScheduler(new SubstitutionScheduler(interval));
        BPMNServerHolder.getInstance().getSubstitutionScheduler().start();
        log.info("BPMN Substitution scheduler started.");
    }
}
Also used : SubstitutionScheduler(org.wso2.carbon.bpmn.people.substitution.scheduler.SubstitutionScheduler)

Example 93 with Start

use of org.wso2.carbon.humantask.core.engine.commands.Start in project product-iots by wso2.

the class APIUtil method getAllEventsForDevice.

public static List<SensorRecord> getAllEventsForDevice(String tableName, String query, List<SortByField> sortByFields) throws AnalyticsException {
    int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
    AnalyticsDataAPI analyticsDataAPI = getAnalyticsDataAPI();
    int eventCount = analyticsDataAPI.searchCount(tenantId, tableName, query);
    // limiting the data read from the server
    int start = 0;
    int dataCount = 100;
    if (eventCount == 0) {
        return null;
    } else if (eventCount >= dataCount) {
        start = eventCount - dataCount;
    }
    List<SearchResultEntry> resultEntries = analyticsDataAPI.search(tenantId, tableName, query, start, eventCount, sortByFields);
    List<String> recordIds = getRecordIds(resultEntries);
    AnalyticsDataResponse response = analyticsDataAPI.get(tenantId, tableName, 1, null, recordIds);
    Map<String, SensorRecord> sensorDatas = createSensorData(AnalyticsDataAPIUtil.listRecords(analyticsDataAPI, response));
    List<SensorRecord> sortedSensorData = getSortedSensorData(sensorDatas, resultEntries);
    return sortedSensorData;
}
Also used : AnalyticsDataResponse(org.wso2.carbon.analytics.dataservice.commons.AnalyticsDataResponse) AnalyticsDataAPI(org.wso2.carbon.analytics.api.AnalyticsDataAPI) SearchResultEntry(org.wso2.carbon.analytics.dataservice.commons.SearchResultEntry)

Example 94 with Start

use of org.wso2.carbon.humantask.core.engine.commands.Start in project product-iots by wso2.

the class CarbonServerManagerExtension method startServerUsingCarbonHome.

public synchronized void startServerUsingCarbonHome(String carbonHome, Map<String, String> commandMap) throws AutomationFrameworkException {
    if (this.process == null) {
        this.portOffset = this.checkPortAvailability(commandMap);
        Process tempProcess = null;
        try {
            if (!commandMap.isEmpty() && this.getPortOffsetFromCommandMap(commandMap) == 0) {
                System.setProperty("carbon.home", carbonHome);
            }
            File commandDir = new File(carbonHome);
            log.info("Starting carbon server............. ");
            String scriptName = TestFrameworkUtils.getStartupScriptFileName(carbonHome);
            String[] parameters = this.expandServerStartupCommandList(commandMap);
            String[] cmdArray;
            if (System.getProperty("os.name").toLowerCase().contains("windows")) {
                commandDir = new File(carbonHome + File.separator + "bin");
                cmdArray = new String[] { "cmd.exe", "/c", scriptName + ".bat" };
                cmdArray = this.mergePropertiesToCommandArray(parameters, cmdArray);
                tempProcess = Runtime.getRuntime().exec(cmdArray, (String[]) null, commandDir);
            } else {
                cmdArray = new String[] { "sh", "bin/" + scriptName + ".sh" };
                cmdArray = this.mergePropertiesToCommandArray(parameters, cmdArray);
                tempProcess = Runtime.getRuntime().exec(cmdArray, (String[]) null, commandDir);
            }
            this.errorStreamHandler = new ServerLogReader("errorStream", tempProcess.getErrorStream());
            this.inputStreamHandler = new ServerLogReader("inputStream", tempProcess.getInputStream());
            this.inputStreamHandler.start();
            this.errorStreamHandler.start();
            Runtime.getRuntime().addShutdownHook(new Thread() {

                public void run() {
                    try {
                        CarbonServerManagerExtension.this.serverShutdown(CarbonServerManagerExtension.this.portOffset);
                    } catch (Exception var2) {
                        CarbonServerManagerExtension.log.error("Error while server shutdown ..", var2);
                    }
                }
            });
            ClientConnectionUtil.waitForPort(defaultHttpPort + this.portOffset, DEFAULT_START_STOP_WAIT_MS, false, (String) this.automationContext.getInstance().getHosts().get("default"));
            long time = System.currentTimeMillis() + 60000L;
            // while(true) {
            // if(this.inputStreamHandler.getOutput().contains("Mgt Console URL") || System.currentTimeMillis() >= time) {
            // int httpsPort = defaultHttpsPort + this.portOffset;
            // String backendURL = this.automationContext.getContextUrls().getSecureServiceUrl().replaceAll("(:\\d+)", ":" + httpsPort);
            // User superUser = this.automationContext.getSuperTenant().getTenantAdmin();
            // ClientConnectionUtil.waitForLogin(backendURL, superUser);
            // log.info("Server started successfully.");
            // break;
            // }
            // }
            int httpsPort = defaultHttpsPort + this.portOffset;
            String backendURL = this.automationContext.getContextUrls().getSecureServiceUrl().replaceAll("(:\\d+)", ":" + httpsPort);
            User superUser = this.automationContext.getSuperTenant().getTenantAdmin();
            ClientConnectionUtil.waitForLogin(backendURL, superUser);
        } catch (XPathExpressionException | IOException var13) {
            throw new IllegalStateException("Unable to start server", var13);
        }
        this.process = tempProcess;
    }
}
Also used : User(org.wso2.carbon.automation.engine.context.beans.User) XPathExpressionException(javax.xml.xpath.XPathExpressionException) ServerLogReader(org.wso2.carbon.automation.extensions.servers.utils.ServerLogReader) IOException(java.io.IOException) XPathExpressionException(javax.xml.xpath.XPathExpressionException) IOException(java.io.IOException) AutomationFrameworkException(org.wso2.carbon.automation.engine.exceptions.AutomationFrameworkException) File(java.io.File)

Example 95 with Start

use of org.wso2.carbon.humantask.core.engine.commands.Start in project carbon-apimgt by wso2.

the class BrokerManager method start.

/**
 * Starting the broker
 */
public static void start() {
    try {
        StartupContext startupContext = new StartupContext();
        initConfigProvider(startupContext);
        BrokerConfigProvider service = startupContext.getService(BrokerConfigProvider.class);
        BrokerConfiguration brokerConfiguration = service.getConfigurationObject(BrokerConfiguration.NAMESPACE, BrokerConfiguration.class);
        DataSource dataSource = getDataSource(brokerConfiguration.getDataSource());
        startupContext.registerService(DataSource.class, dataSource);
        restServer = new BrokerRestServer(startupContext);
        broker = new Broker(startupContext);
        broker.startMessageDelivery();
        amqpServer = new Server(startupContext);
        amqpServer.start();
        restServer.start();
        loadUsers();
    } catch (Exception e) {
        log.error("Error while starting broker", e);
    }
}
Also used : StartupContext(org.wso2.broker.common.StartupContext) BrokerRestServer(org.wso2.broker.rest.BrokerRestServer) Broker(org.wso2.broker.core.Broker) Server(org.wso2.broker.amqp.Server) BrokerRestServer(org.wso2.broker.rest.BrokerRestServer) BrokerConfiguration(org.wso2.broker.core.configuration.BrokerConfiguration) BrokerConfigProvider(org.wso2.broker.common.BrokerConfigProvider) ConfigurationException(org.wso2.carbon.config.ConfigurationException) HikariDataSource(com.zaxxer.hikari.HikariDataSource) DataSource(javax.sql.DataSource)

Aggregations

SVGCoordinates (org.wso2.carbon.bpel.ui.bpel2svg.SVGCoordinates)57 ActivityInterface (org.wso2.carbon.bpel.ui.bpel2svg.ActivityInterface)47 Test (org.testng.annotations.Test)17 SiddhiAppRuntime (org.wso2.siddhi.core.SiddhiAppRuntime)17 SiddhiManager (org.wso2.siddhi.core.SiddhiManager)17 Event (org.wso2.siddhi.core.event.Event)17 InputHandler (org.wso2.siddhi.core.stream.input.InputHandler)13 SVGDimension (org.wso2.carbon.bpel.ui.bpel2svg.SVGDimension)11 StreamEventPool (org.wso2.siddhi.core.event.stream.StreamEventPool)11 ArrayList (java.util.ArrayList)10 OMElement (org.apache.axiom.om.OMElement)10 DiagnosticPos (org.wso2.ballerinalang.compiler.util.diagnotic.DiagnosticPos)10 Element (org.w3c.dom.Element)9 StreamCallback (org.wso2.siddhi.core.stream.output.StreamCallback)9 TopLevelNode (org.ballerinalang.model.tree.TopLevelNode)7 APIManagementException (org.wso2.carbon.apimgt.core.exception.APIManagementException)7 ZoneId (java.time.ZoneId)5 HashMap (java.util.HashMap)5 Analyzer (org.wso2.carbon.apimgt.core.api.Analyzer)5 ErrorDTO (org.wso2.carbon.apimgt.rest.api.common.dto.ErrorDTO)5