/* * This is the engine called by jobq.c:jobq_add() when we were pulled * from the work queue. * At this point, we are running in our own thread and all * necessary resources are allocated -- see jobq.c */ static void *job_thread(void *arg) { JCR *jcr = (JCR *)arg; pthread_detach(pthread_self()); Dsm_check(100); Dmsg0(200, "=====Start Job=========\n"); jcr->setJobStatus(JS_Running); /* this will be set only if no error */ jcr->start_time = time(NULL); /* set the real start time */ jcr->jr.StartTime = jcr->start_time; if (jcr->res.job->MaxStartDelay != 0 && jcr->res.job->MaxStartDelay < (utime_t)(jcr->start_time - jcr->sched_time)) { jcr->setJobStatus(JS_Canceled); Jmsg(jcr, M_FATAL, 0, _("Job canceled because max start delay time exceeded.\n")); } if (job_check_maxrunschedtime(jcr)) { jcr->setJobStatus(JS_Canceled); Jmsg(jcr, M_FATAL, 0, _("Job canceled because max run sched time exceeded.\n")); } /* TODO : check if it is used somewhere */ if (jcr->res.job->RunScripts == NULL) { Dmsg0(200, "Warning, job->RunScripts is empty\n"); jcr->res.job->RunScripts = New(alist(10, not_owned_by_alist)); } if (!db_update_job_start_record(jcr, jcr->db, &jcr->jr)) { Jmsg(jcr, M_FATAL, 0, "%s", db_strerror(jcr->db)); } /* Run any script BeforeJob on dird */ run_scripts(jcr, jcr->res.job->RunScripts, "BeforeJob"); /* * We re-update the job start record so that the start * time is set after the run before job. This avoids * that any files created by the run before job will * be saved twice. They will be backed up in the current * job, but not in the next one unless they are changed. * Without this, they will be backed up in this job and * in the next job run because in that case, their date * is after the start of this run. */ jcr->start_time = time(NULL); jcr->jr.StartTime = jcr->start_time; if (!db_update_job_start_record(jcr, jcr->db, &jcr->jr)) { Jmsg(jcr, M_FATAL, 0, "%s", db_strerror(jcr->db)); } generate_plugin_event(jcr, bDirEventJobRun); switch (jcr->getJobType()) { case JT_BACKUP: switch (jcr->getJobProtocol()) { case PT_NDMP: if (!job_canceled(jcr)) { if (do_ndmp_backup(jcr)) { do_autoprune(jcr); } else { ndmp_backup_cleanup(jcr, JS_ErrorTerminated); } } else { ndmp_backup_cleanup(jcr, JS_Canceled); } break; default: if (!job_canceled(jcr)) { if (jcr->is_JobLevel(L_VIRTUAL_FULL)) { if (do_native_vbackup(jcr)) { do_autoprune(jcr); } else { native_vbackup_cleanup(jcr, JS_ErrorTerminated); } } else { if (do_native_backup(jcr)) { do_autoprune(jcr); } else { native_backup_cleanup(jcr, JS_ErrorTerminated); } } } else { if (jcr->is_JobLevel(L_VIRTUAL_FULL)) { native_vbackup_cleanup(jcr, JS_Canceled); } else { native_backup_cleanup(jcr, JS_Canceled); } } break; } break; case JT_VERIFY: if (!job_canceled(jcr)) { if (do_verify(jcr)) { do_autoprune(jcr); } else { verify_cleanup(jcr, JS_ErrorTerminated); } } else { verify_cleanup(jcr, JS_Canceled); } break; case JT_RESTORE: switch (jcr->getJobProtocol()) { case PT_NDMP: if (!job_canceled(jcr)) { if (do_ndmp_restore(jcr)) { do_autoprune(jcr); } else { ndmp_restore_cleanup(jcr, JS_ErrorTerminated); } } else { ndmp_restore_cleanup(jcr, JS_Canceled); } break; default: if (!job_canceled(jcr)) { if (do_native_restore(jcr)) { do_autoprune(jcr); } else { native_restore_cleanup(jcr, JS_ErrorTerminated); } } else { native_restore_cleanup(jcr, JS_Canceled); } break; } break; case JT_ADMIN: if (!job_canceled(jcr)) { if (do_admin(jcr)) { do_autoprune(jcr); } else { admin_cleanup(jcr, JS_ErrorTerminated); } } else { admin_cleanup(jcr, JS_Canceled); } break; case JT_COPY: case JT_MIGRATE: if (!job_canceled(jcr)) { if (do_migration(jcr)) { do_autoprune(jcr); } else { migration_cleanup(jcr, JS_ErrorTerminated); } } else { migration_cleanup(jcr, JS_Canceled); } break; default: Pmsg1(0, _("Unimplemented job type: %d\n"), jcr->getJobType()); break; } run_scripts(jcr, jcr->res.job->RunScripts, "AfterJob"); /* Send off any queued messages */ if (jcr->msg_queue && jcr->msg_queue->size() > 0) { dequeue_messages(jcr); } generate_plugin_event(jcr, bDirEventJobEnd); Dmsg1(50, "======== End Job stat=%c ==========\n", jcr->JobStatus); Dsm_check(100); return NULL; }
int drmig_chrp_pmig(struct options *opts) { int rc; char *cmd = opts->p_option; char sys_src[20]; uint64_t stream_val; /* Ensure that this partition is migratable/mobile */ if (! pmig_capable()) { fprintf(stderr, "drmig_chrp_pmig: Partition Mobility is not " "supported on this kernel.\n"); return -1; } /* Today we do no pre-checks for migratability. The only check * we could do is whether the "ibm,suspend-me" RTAS call exists. * But if it doesn't, the firmware level doesn't support migration, * in which case why the heck are we being invoked anyways. */ if (strcmp(cmd, "check") == 0) { say(DEBUG, "check: Nothing to do...\n"); return 0; } /* The only other command is pre, any other command is invalid */ if (strcmp(cmd, "pre")) { say(DEBUG, "Invalid command \"%s\" specified\n", cmd); return 1; } if (opts->usr_drc_name == NULL) { say(ERROR, "No streamid specified\n"); return -1; } errno = 0; stream_val = strtoull(opts->usr_drc_name, NULL, 16); if (errno != 0) { say(ERROR, "Invalid streamid specified: %s\n", strerror(errno)); return -1; } /* Get the ID of the original system, for later logging */ get_str_attribute(OFDT_BASE, "system-id", sys_src, 20); sleep(5); /* Now do the actual migration */ do { if (action == MIGRATE) rc = do_migration(stream_val); else if (action == HIBERNATE) rc = do_hibernation(stream_val); else rc = -EINVAL; if (rc == NOT_SUSPENDABLE) sleep(1); } while (rc == NOT_SUSPENDABLE); syslog(LOG_LOCAL0 | LOG_INFO, "drmgr: %s rc %d\n", (action == MIGRATE ? "migration" : "hibernation"), rc); if (rc) return rc; post_mobility_update(action); say(DEBUG, "Refreshing RMC via refrsrc\n"); rc = system("/usr/sbin/rsct/bin/refrsrc IBM.ManagementServer"); return 0; }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); this->tracking_status=FALSE; QIcon* icon =new QIcon((QString)APATH+"clock.png"); ui->pushHour->setEnabled(FALSE); ui->pushHour->setIcon(*icon); ui->pushHour->setIconSize(QSize( ui->pushHour->size().width()-5,ui->pushHour->size().height()-5 )); QIcon* icon1 =new QIcon((QString)APATH+"add.png"); ui->pushAddEarlier->setIcon(*icon1); ui->pushAddEarlier->setIconSize(QSize( ui->pushAddEarlier->size().width()-5,ui->pushAddEarlier->size().height()-5 )); QIcon* icon3 =new QIcon((QString)APATH+"delete.png"); ui->pushDelete->setIcon(*icon3); ui->pushDelete->setIconSize(QSize( ui->pushDelete->size().width()-5,ui->pushDelete->size().height()-5 )); ui->pushDelete->setFocusPolicy(Qt::NoFocus); ui->pushAddEarlier->setFocusPolicy(Qt::NoFocus); ui->pushDelete->setEnabled(FALSE); QIcon* icon2 =new QIcon((QString)APATH+"hourglass.png"); this->setWindowIcon(*icon2); db1=QSqlDatabase::addDatabase("QMYSQL","hourglass"); db1.setDatabaseName("hourglass"); db1.setHostName(g_HOST); db1.setUserName(g_USER); db1.setPassword(g_PASS); db1=QSqlDatabase::database("hourglass"); // QPluginLoader *thePlugin = new QPluginLoader("/home/jim/qt/qt-4.6.3/plugins/sqldrivers/libqsqlmysql.so"); //qDebug() << thePlugin->load(); //qDebug() << thePlugin->isLoaded(); //qDebug() << thePlugin->errorString(); if (!db1.open()) { qDebug()<<"Απέτυχε η σύνδεση με τη βάση"; exit(0); } db2=QSqlDatabase::addDatabase("QMYSQL","asterisk"); db2.setDatabaseName("asterisk"); db2.setHostName(g_ASTERISK_SERVER); db2.setUserName(g_AST_MYSQL_USER); db2.setPassword(g_AST_MYSQL_PASS); db2=QSqlDatabase::database("asterisk"); if (!db2.open()) { qDebug()<<"Απέτυχε η σύνδεση με τη βάση"; //exit(0); } this->customer_model=new QSqlQueryModel(); this->project_model=new QSqlQueryModel(); this->places_model=new QSqlQueryModel(); this->tasks_model=new QSqlQueryModel(); this->tasks_full_model=new QSqlQueryModel(); this->daily_calls_model=new QSqlQueryModel(); this->full_calls_model=new QSqlQueryModel(); refresh_customers(); refresh_tasks(); refresh_full_tasks(); refresh_daily_calls(); refresh_full_calls(); this->timer=new QTimer; this->timer_asterisk=new QTimer; timer_asterisk->start(60000); QStringList sl; ui->comboGraph->insertItem(0,trUtf8("ΕΒΔΟΜΑΔΑ")); ui->comboGraph->insertItem(1,trUtf8("ΕΤΟΣ")); ui->comboGraph->insertItem(2,trUtf8("ΔΙΑΧΡΟΝΙΚΟ")); /* QDate simera; simera=QDate::currentDate(); int dayno=simera.dayOfWeek(); QList <int> minut; for (int i=0;i<dayno;++i) { QSqlQuery query(db1); query.exec("select sum(TIMESTAMPDIFF(MINUTE,t.start_time,t.end_time)) from tasks t where date(start_time)='"+simera.addDays(-i).toString("yy/M/d")+"'"); query.next(); minut.prepend(query.value(0).toInt()); qDebug()<<"MINUT:"<<minut; } WeekGraph *drb=new WeekGraph(this); drb->set_list(minut); drb->setFixedWidth(921); drb->setFixedHeight(181); drb->repaint(); */ drb=new WeekGraph(this); drb->setGeometry(180,10,611,151); //drb->setFixedWidth(621); //drb->setFixedHeight(161); connect(timer_asterisk,SIGNAL(timeout()),this,SLOT(refresh_calls())); connect(timer, SIGNAL(timeout()),this, SLOT(refresh_time())); connect(ui->action,SIGNAL(triggered()),this,SLOT(new_customer())); connect(ui->tableCustomers,SIGNAL(clicked(QModelIndex)),this,SLOT(customer_selection_changed())); connect(ui->tableCustomers,SIGNAL(doubleClicked(QModelIndex)),this,SLOT(edit_customer())); connect(ui->pushHour,SIGNAL(released()),this,SLOT(tracking_pressed())); connect(ui->textEdit,SIGNAL(textChanged()),this,SLOT(remove_invalid_chars())); connect(ui->tableView,SIGNAL(doubleClicked(QModelIndex)),this,SLOT(edit_task())); connect(ui->tableView_2,SIGNAL(doubleClicked(QModelIndex)),this,SLOT(edit_task_full())); connect(ui->pushAddEarlier,SIGNAL(released()),this,SLOT(add_earlier_task())); connect(ui->actionMigration,SIGNAL(triggered()),this,SLOT(do_migration())); connect(ui->action_2,SIGNAL(triggered()),this,SLOT(invoicing())); connect(ui->actionEmail,SIGNAL(triggered()),this,SLOT(email_tasks())); connect(ui->comboGraph,SIGNAL(currentIndexChanged(int)),this,SLOT(change_graph(int))); connect(ui->actionProjects,SIGNAL(triggered()),this,SLOT(projects())); connect(ui->actionReview,SIGNAL(triggered()),this,SLOT(invoice_review())); connect(ui->tableView,SIGNAL(clicked(QModelIndex)),this,SLOT(table_clicked())); connect(ui->tableView_2,SIGNAL(clicked(QModelIndex)),this,SLOT(table2_clicked())); connect(ui->pushDelete,SIGNAL(released()),this,SLOT(delete_clicked())); connect(ui->tabWidget,SIGNAL(currentChanged(int)),this,SLOT(tab_changed(int))); ui->comboGraph->setCurrentIndex(-1); ui->comboGraph->setCurrentIndex(0); ui->tableView->setContextMenuPolicy(Qt::CustomContextMenu); ui->tableTodayCalls->setContextMenuPolicy(Qt::CustomContextMenu); ui->tableAllCalls->setContextMenuPolicy(Qt::CustomContextMenu); ui->tableCustomers->setContextMenuPolicy(Qt::CustomContextMenu); connect(ui->tableView,SIGNAL(customContextMenuRequested(QPoint)),this,SLOT(context_menu(const QPoint&))); connect(ui->tableView_2->horizontalHeader(),SIGNAL(sectionClicked(int)),this,SLOT(sortbycolumn(int))); connect(ui->tableCustomers,SIGNAL(customContextMenuRequested(QPoint)),this,SLOT(dial_customer(const QPoint&))); connect(ui->tableTodayCalls,SIGNAL(customContextMenuRequested(QPoint)),this,SLOT(context_menu_daily_calls(QPoint))); connect(ui->tableAllCalls,SIGNAL(customContextMenuRequested(QPoint)),this,SLOT(context_menu_full_calls(QPoint))); Asterisk_CallerID_Monitor *ast_monitor=new Asterisk_CallerID_Monitor(this); connect (ast_monitor,SIGNAL(incoming_call(QString)),this,SLOT(incoming_call(QString))); ast_monitor->start_monitor(); }