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()]);
}
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.");
}
}
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;
}
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;
}
}
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);
}
}
Aggregations