void Work::complete(CompleteResult result) { CLOG(DEBUG, "Work") << "completed " << getUniqueName(); auto& succ = mApp.getMetrics().NewMeter({"work", "unit", "success"}, "unit"); auto& fail = mApp.getMetrics().NewMeter({"work", "unit", "failure"}, "unit"); switch (result) { case WORK_COMPLETE_OK: setState(onSuccess()); break; case WORK_COMPLETE_FAILURE: setState(WORK_FAILURE_RETRY); break; case WORK_COMPLETE_FATAL: setState(WORK_FAILURE_FATAL); break; } switch (getState()) { case WORK_SUCCESS: succ.Mark(); CLOG(DEBUG, "Work") << "notifying parent of successful " << getUniqueName(); notifyParent(); break; case WORK_FAILURE_RETRY: fail.Mark(); onFailureRetry(); scheduleRetry(); break; case WORK_FAILURE_RAISE: case WORK_FAILURE_FATAL: fail.Mark(); onFailureRaise(); CLOG(DEBUG, "Work") << "notifying parent of failed " << getUniqueName(); notifyParent(); break; case WORK_PENDING: succ.Mark(); advance(); break; case WORK_RUNNING: succ.Mark(); scheduleRun(); break; default: assert(false); break; } }
void TestDataSetDAO::testCRUDDataSet() { // get the transactor std::auto_ptr<te::da::DataSourceTransactor> transactor = terrama2::core::ApplicationController::getInstance().getTransactor(); // create a new data provider and save it t the database terrama2::core::DataProviderPtr dataProvider(new terrama2::core::DataProvider("Server 1", terrama2::core::DataProvider::FTP_TYPE)); terrama2::core::DataProviderDAO::save(dataProvider, *transactor); // create a new dataset and save it to the database terrama2::core::DataSetPtr dataSet(new terrama2::core::DataSet(dataProvider, "Queimadas", terrama2::core::DataSet::OCCURENCE_TYPE)); te::dt::TimeDuration dataFrequency(2,0,0); dataSet->setDataFrequency(dataFrequency); terrama2::core::DataSetDAO::save(dataSet, *transactor); // assure we have a valid dataset identifier QVERIFY2(dataSet->id() > 0, "Id must be different than zero after save()!"); te::dt::TimeDuration schedule(12,0,0); dataSet->setSchedule(schedule); te::dt::TimeDuration scheduleTimeout(0,30,0); dataSet->setScheduleTimeout(scheduleTimeout); te::dt::TimeDuration scheduleRetry(0,5,0); dataSet->setScheduleRetry(scheduleRetry); dataSet->setStatus(terrama2::core::DataSet::ACTIVE); dataSet->setDescription("Description..."); dataSet->setName("New queimadas"); terrama2::core::DataSetDAO::update(dataSet, *transactor); terrama2::core::DataSetPtr findDataSet = terrama2::core::DataSetDAO::find(dataSet->id(), *transactor); QVERIFY2(dataSet->name() == findDataSet->name(), "Name must be the same!"); QVERIFY2(dataSet->status() == findDataSet->status(), "Status must be the same!"); QVERIFY2(dataSet->scheduleTimeout() == findDataSet->scheduleTimeout(), "Schedule timeout must be the same!"); QVERIFY2(dataSet->schedule() == findDataSet->schedule(), "Schedule must be the same!"); QVERIFY2(dataSet->scheduleRetry() == findDataSet->scheduleRetry(), "Schedule retry must be the same!"); QVERIFY2(dataSet->dataFrequency() == findDataSet->dataFrequency(), "Data frequency must be the same!"); }