use of org.camunda.bpm.engine.impl.ProcessEngineImpl in project camunda-bpm-platform by camunda.
the class SequentialJobAcquisitionRunnable method run.
public synchronized void run() {
LOG.startingToAcquireJobs(jobExecutor.getName());
JobAcquisitionStrategy acquisitionStrategy = initializeAcquisitionStrategy();
while (!isInterrupted) {
acquisitionContext.reset();
acquisitionContext.setAcquisitionTime(System.currentTimeMillis());
Iterator<ProcessEngineImpl> engineIterator = jobExecutor.engineIterator();
try {
while (engineIterator.hasNext()) {
ProcessEngineImpl currentProcessEngine = engineIterator.next();
if (!jobExecutor.hasRegisteredEngine(currentProcessEngine)) {
// if engine has been unregistered meanwhile
continue;
}
AcquiredJobs acquiredJobs = acquireJobs(acquisitionContext, acquisitionStrategy, currentProcessEngine);
executeJobs(acquisitionContext, currentProcessEngine, acquiredJobs);
}
} catch (Exception e) {
LOG.exceptionDuringJobAcquisition(e);
acquisitionContext.setAcquisitionException(e);
}
acquisitionContext.setJobAdded(isJobAdded);
configureNextAcquisitionCycle(acquisitionContext, acquisitionStrategy);
// The clear had to be done after the configuration, since a hint can be
// appear in the suspend and the flag shouldn't be cleaned in this case.
// The loop will restart after suspend with the isJobAdded flag and
// reconfigure with this flag
clearJobAddedNotification();
long waitTime = acquisitionStrategy.getWaitTime();
// wait the requested wait time minus the time that acquisition itself took
// this makes the intervals of job acquisition more constant and therefore predictable
waitTime = Math.max(0, (acquisitionContext.getAcquisitionTime() + waitTime) - System.currentTimeMillis());
suspendAcquisition(waitTime);
}
LOG.stoppedJobAcquisition(jobExecutor.getName());
}
use of org.camunda.bpm.engine.impl.ProcessEngineImpl in project camunda-bpm-platform by camunda.
the class DatabaseHistoryPropertyAutoTest method secondEngineCopiesHistoryLevelFromFirst.
@Test
public void secondEngineCopiesHistoryLevelFromFirst() {
// given
buildEngine(config("true", ProcessEngineConfiguration.HISTORY_FULL));
// when
ProcessEngineImpl processEngineTwo = buildEngine(config("true", ProcessEngineConfiguration.HISTORY_AUTO));
// then
assertThat(processEngineTwo.getProcessEngineConfiguration().getHistory(), is(ProcessEngineConfiguration.HISTORY_AUTO));
assertThat(processEngineTwo.getProcessEngineConfiguration().getHistoryLevel(), is(HistoryLevel.HISTORY_LEVEL_FULL));
}
use of org.camunda.bpm.engine.impl.ProcessEngineImpl in project camunda-bpm-platform by camunda.
the class DatabaseHistoryPropertyAutoTest method buildEngine.
protected ProcessEngineImpl buildEngine(ProcessEngineConfigurationImpl engineConfiguration) {
ProcessEngineImpl engine = (ProcessEngineImpl) engineConfiguration.buildProcessEngine();
processEngines.add(engine);
return engine;
}
use of org.camunda.bpm.engine.impl.ProcessEngineImpl in project camunda-bpm-platform by camunda.
the class DmnDisabledTest method createProcessEngineImpl.
protected static ProcessEngineImpl createProcessEngineImpl(boolean dmnEnabled) {
StandaloneInMemProcessEngineConfiguration config = (StandaloneInMemProcessEngineConfiguration) new CustomStandaloneInMemProcessEngineConfiguration().setProcessEngineName("database-dmn-test-engine").setDatabaseSchemaUpdate("false").setHistory(ProcessEngineConfiguration.HISTORY_FULL).setJdbcUrl("jdbc:h2:mem:DatabaseDmnTest");
config.setDmnEnabled(dmnEnabled);
return (ProcessEngineImpl) config.buildProcessEngine();
}
use of org.camunda.bpm.engine.impl.ProcessEngineImpl in project camunda-bpm-platform by camunda.
the class PurgeDatabaseTest method assertAndEnsureCleanDb.
/**
* Ensures that the database is clean after the test. This means the test has to remove
* all resources it entered to the database.
* If the DB is not clean, it is cleaned by performing a create a drop.
*
* @param processEngine the {@link ProcessEngine} to check
* @param fail if true the method will throw an {@link AssertionError} if the database is not clean
* @return the database summary if fail is set to false or null if database was clean
* @throws AssertionError if the database was not clean and fail is set to true
*/
public static void assertAndEnsureCleanDb(ProcessEngine processEngine) {
ProcessEngineConfigurationImpl processEngineConfiguration = ((ProcessEngineImpl) processEngine).getProcessEngineConfiguration();
String databaseTablePrefix = processEngineConfiguration.getDatabaseTablePrefix().trim();
Map<String, Long> tableCounts = processEngine.getManagementService().getTableCount();
StringBuilder outputMessage = new StringBuilder();
for (String tableName : tableCounts.keySet()) {
String tableNameWithoutPrefix = tableName.replace(databaseTablePrefix, "");
if (!TABLENAMES_EXCLUDED_FROM_DB_CLEAN_CHECK.contains(tableNameWithoutPrefix)) {
Long count = tableCounts.get(tableName);
if (count != 0L) {
outputMessage.append("\t").append(tableName).append(": ").append(count).append(" record(s)\n");
}
}
}
if (outputMessage.length() > 0) {
outputMessage.insert(0, "DB NOT CLEAN: \n");
/**
* skip drop and recreate if a table prefix is used
*/
if (databaseTablePrefix.isEmpty()) {
processEngineConfiguration.getCommandExecutorSchemaOperations().execute(new Command<Object>() {
public Object execute(CommandContext commandContext) {
PersistenceSession persistenceSession = commandContext.getSession(PersistenceSession.class);
persistenceSession.dbSchemaDrop();
persistenceSession.dbSchemaCreate();
HistoryLevelSetupCommand.dbCreateHistoryLevel(commandContext);
return null;
}
});
}
Assert.fail(outputMessage.toString());
}
}
Aggregations