本文整理汇总了C++中JCR::set_JobLevel方法的典型用法代码示例。如果您正苦于以下问题:C++ JCR::set_JobLevel方法的具体用法?C++ JCR::set_JobLevel怎么用?C++ JCR::set_JobLevel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JCR
的用法示例。
在下文中一共展示了JCR::set_JobLevel方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: memset
/*
* Create a Job Control Record and link it into JCR chain
* Returns newly allocated JCR
* Note, since each daemon has a different JCR, he passes
* us the size.
*/
JCR *new_jcr(int size, JCR_free_HANDLER *daemon_free_jcr)
{
JCR *jcr;
MQUEUE_ITEM *item = NULL;
struct sigaction sigtimer;
int status;
Dmsg0(dbglvl, "Enter new_jcr\n");
status = pthread_once(&key_once, create_jcr_key);
if (status != 0) {
berrno be;
Jmsg1(NULL, M_ABORT, 0, _("pthread_once failed. ERR=%s\n"), be.bstrerror(status));
}
jcr = (JCR *)malloc(size);
memset(jcr, 0, size);
jcr->my_thread_id = pthread_self();
jcr->msg_queue = New(dlist(item, &item->link));
jcr->job_end_push.init(1, false);
jcr->sched_time = time(NULL);
jcr->daemon_free_jcr = daemon_free_jcr; /* plug daemon free routine */
jcr->init_mutex();
jcr->inc_use_count();
jcr->VolumeName = get_pool_memory(PM_FNAME);
jcr->VolumeName[0] = 0;
jcr->errmsg = get_pool_memory(PM_MESSAGE);
jcr->errmsg[0] = 0;
/* Setup some dummy values */
bstrncpy(jcr->Job, "*System*", sizeof(jcr->Job));
jcr->JobId = 0;
jcr->set_JobType(JT_SYSTEM); /* internal job until defined */
jcr->set_JobLevel(L_NONE);
set_jcr_job_status(jcr, JS_Created); /* ready to run */
set_jcr_in_tsd(jcr);
sigtimer.sa_flags = 0;
sigtimer.sa_handler = timeout_handler;
sigfillset(&sigtimer.sa_mask);
sigaction(TIMEOUT_SIGNAL, &sigtimer, NULL);
/*
* Locking jobs is a global lock that is needed
* so that the Director can stop new jobs from being
* added to the jcr chain while it processes a new
* conf file and does the job_end_push().
*/
lock_jobs();
lock_jcr_chain();
if (!jcrs) {
jcrs = New(dlist(jcr, &jcr->link));
}
jcrs->append(jcr);
unlock_jcr_chain();
unlock_jobs();
return jcr;
}
示例2: job_setattr
/* Returns: 0 for OK
* -1 for error
*/
int job_setattr(PyObject *self, char *attrname, PyObject *value)
{
JCR *jcr;
bool found = false;
char *strval = NULL;
int intval = 0;
int i;
Dmsg2(100, "In job_setattr=%s val=%p.\n", attrname, value);
if (value == NULL) { /* Cannot delete variables */
goto bail_out;
}
jcr = get_jcr_from_PyObject(self);
if (!jcr) {
goto bail_out;
}
/* Find attribute name in list */
for (i=0; setvars[i].name; i++) {
if (strcmp(setvars[i].name, attrname) == 0) {
found = true;
break;
}
}
if (!found) {
goto bail_out;
}
/* Get argument value */
if (setvars[i].fmt != NULL) {
switch (setvars[i].fmt[0]) {
case 's':
if (!PyArg_Parse(value, (char *)setvars[i].fmt, &strval)) {
PyErr_SetString(PyExc_TypeError, _("Read-only attribute"));
return -1;
}
break;
case 'i':
if (!PyArg_Parse(value, (char *)setvars[i].fmt, &intval)) {
PyErr_SetString(PyExc_TypeError, _("Read-only attribute"));
return -1;
}
break;
}
}
switch (i) {
case 0: /* JobReport */
Jmsg(jcr, M_INFO, 0, "%s", strval);
return 0;
case 1: /* VolumeName */
/* Make sure VolumeName is valid and we are in VolumeName event */
if (strcmp("NewVolume", jcr->event) == 0 &&
is_volume_name_legal(NULL, strval)) {
pm_strcpy(jcr->VolumeName, strval);
Dmsg1(100, "Set Vol=%s\n", strval);
return 0;
} else {
jcr->VolumeName[0] = 0;
}
break;
case 2: /* Priority */
Dmsg1(000, "Set priority=%d\n", intval);
if (intval >= 1 && intval <= 100) {
jcr->JobPriority = intval;
} else {
PyErr_SetString(PyExc_ValueError, _("Priority must be 1-100"));
return -1;
}
case 3: /* Job Level */
if (strcmp("JobInit", jcr->event) != 0) {
PyErr_SetString(PyExc_RuntimeError, _("Job Level can be set only during JobInit"));
return -1;
}
if (strval != NULL) {
for (i=0; joblevels[i].level_name; i++) {
if (strcmp(strval, joblevels[i].level_name) == 0) {
if (joblevels[i].job_type == jcr->get_JobType()) {
jcr->set_JobLevel(joblevels[i].level);
jcr->jr.JobLevel = jcr->get_JobLevel();
return 0;
}
}
}
}
PyErr_SetString(PyExc_ValueError, _("Bad JobLevel string"));
return -1;
}
bail_out:
PyErr_SetString(PyExc_AttributeError, attrname);
return -1;
}