本文整理汇总了C++中JCR::setJobType方法的典型用法代码示例。如果您正苦于以下问题:C++ JCR::setJobType方法的具体用法?C++ JCR::setJobType怎么用?C++ JCR::setJobType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JCR
的用法示例。
在下文中一共展示了JCR::setJobType方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: bstrdup
/*
* Setup a "daemon" JCR for the various standalone
* tools (e.g. bls, bextract, bscan, ...)
*/
JCR *setup_jcr(const char *name, char *dev_name,
BSR *bsr, DIRRES *director,
const char *VolumeName, int mode)
{
DCR *dcr;
JCR *jcr = new_jcr(sizeof(JCR), my_free_jcr);
jcr->bsr = bsr;
jcr->director = director;
jcr->VolSessionId = 1;
jcr->VolSessionTime = (uint32_t)time(NULL);
jcr->NumReadVolumes = 0;
jcr->NumWriteVolumes = 0;
jcr->JobId = 0;
jcr->setJobType(JT_CONSOLE);
jcr->setJobLevel(L_FULL);
jcr->JobStatus = JS_Terminated;
jcr->where = bstrdup("");
jcr->job_name = get_pool_memory(PM_FNAME);
pm_strcpy(jcr->job_name, "Dummy.Job.Name");
jcr->client_name = get_pool_memory(PM_FNAME);
pm_strcpy(jcr->client_name, "Dummy.Client.Name");
bstrncpy(jcr->Job, name, sizeof(jcr->Job));
jcr->fileset_name = get_pool_memory(PM_FNAME);
pm_strcpy(jcr->fileset_name, "Dummy.fileset.name");
jcr->fileset_md5 = get_pool_memory(PM_FNAME);
pm_strcpy(jcr->fileset_md5, "Dummy.fileset.md5");
new_plugins(jcr); /* instantiate plugins */
init_autochangers();
create_volume_lists();
dcr = setup_to_access_device(jcr, dev_name, VolumeName, mode);
if (!dcr) {
return NULL;
}
if (!bsr && VolumeName) {
bstrncpy(dcr->VolumeName, VolumeName, sizeof(dcr->VolumeName));
}
bstrncpy(dcr->pool_name, "Default", sizeof(dcr->pool_name));
bstrncpy(dcr->pool_type, "Backup", sizeof(dcr->pool_type));
return jcr;
}
示例2: LockRes
/*
* Create a Job Control Record for a control "job",
* filling in all the appropriate fields.
*/
JCR *new_control_jcr(const char *base_name, int job_type)
{
JCR *jcr;
jcr = new_jcr(sizeof(JCR), dird_free_jcr);
/*
* The job and defaults are not really used, but
* we set them up to ensure that everything is correctly
* initialized.
*/
LockRes();
jcr->job = (JOB *)GetNextRes(R_JOB, NULL);
set_jcr_defaults(jcr, jcr->job);
UnlockRes();
jcr->sd_auth_key = bstrdup("dummy"); /* dummy Storage daemon key */
create_unique_job_name(jcr, base_name);
jcr->sched_time = jcr->start_time;
jcr->setJobType(job_type);
jcr->setJobLevel(L_NONE);
jcr->setJobStatus(JS_Running);
jcr->JobId = 0;
return jcr;
}
示例3: LockRes
void *device_initialization(void *arg)
{
DEVRES *device;
DCR *dcr;
JCR *jcr;
DEVICE *dev;
int errstat;
LockRes();
pthread_detach(pthread_self());
jcr = new_jcr(sizeof(JCR), stored_free_jcr);
new_plugins(jcr); /* instantiate plugins */
jcr->setJobType(JT_SYSTEM);
/*
* Initialize job start condition variable
*/
errstat = pthread_cond_init(&jcr->job_start_wait, NULL);
if (errstat != 0) {
berrno be;
Jmsg1(jcr, M_ABORT, 0, _("Unable to init job start cond variable: ERR=%s\n"), be.bstrerror(errstat));
}
/*
* Initialize job end condition variable
*/
errstat = pthread_cond_init(&jcr->job_end_wait, NULL);
if (errstat != 0) {
berrno be;
Jmsg1(jcr, M_ABORT, 0, _("Unable to init job endstart cond variable: ERR=%s\n"), be.bstrerror(errstat));
}
foreach_res(device, R_DEVICE) {
Dmsg1(90, "calling init_dev %s\n", device->device_name);
dev = init_dev(NULL, device);
Dmsg1(10, "SD init done %s\n", device->device_name);
if (!dev) {
Jmsg1(NULL, M_ERROR, 0, _("Could not initialize %s\n"), device->device_name);
continue;
}
jcr->dcr = dcr = new_dcr(jcr, NULL, dev, NULL);
generate_plugin_event(jcr, bsdEventDeviceInit, dcr);
if (dev->is_autochanger()) {
/* If autochanger set slot in dev structure */
get_autochanger_loaded_slot(dcr);
}
if (device->cap_bits & CAP_ALWAYSOPEN) {
Dmsg1(20, "calling first_open_device %s\n", dev->print_name());
if (!first_open_device(dcr)) {
Jmsg1(NULL, M_ERROR, 0, _("Could not open device %s\n"), dev->print_name());
Dmsg1(20, "Could not open device %s\n", dev->print_name());
free_dcr(dcr);
jcr->dcr = NULL;
continue;
}
}
if (device->cap_bits & CAP_AUTOMOUNT && dev->is_open()) {
switch (read_dev_volume_label(dcr)) {
case VOL_OK:
memcpy(&dev->VolCatInfo, &dcr->VolCatInfo, sizeof(dev->VolCatInfo));
volume_unused(dcr); /* mark volume "released" */
break;
default:
Jmsg1(NULL, M_WARNING, 0, _("Could not mount device %s\n"), dev->print_name());
break;
}
}
free_dcr(dcr);
jcr->dcr = NULL;
}
示例4: main
//.........这里部分代码省略.........
break;
case 'p':
path = optarg;
break;
case 'f':
file = optarg;
break;
case 'j':
jobids = optarg;
break;
case 'T':
clean = true;
break;
case '?':
default:
usage();
}
}
argc -= optind;
argv += optind;
if (argc != 0) {
Pmsg0(0, _("Wrong number of arguments: \n"));
usage();
}
JCR *bjcr = new_jcr(sizeof(JCR), NULL);
bjcr->JobId = getpid();
bjcr->setJobType(JT_CONSOLE);
bjcr->setJobLevel(L_FULL);
bjcr->JobStatus = JS_Running;
bjcr->client_name = get_pool_memory(PM_FNAME);
pm_strcpy(bjcr->client_name, "Dummy.Client.Name");
bstrncpy(bjcr->Job, "bvfs_test", sizeof(bjcr->Job));
#if defined(HAVE_DYNAMIC_CATS_BACKENDS)
backend_directories = New(alist(10, owned_by_alist));
backend_directories->append((char *)backend_directory);
db_set_backend_dirs(backend_directories);
#endif
if ((db = db_init_database(NULL, NULL, db_name, db_user, db_password, db_host, 0, NULL)) == NULL) {
Emsg0(M_ERROR_TERM, 0, _("Could not init Bareos database\n"));
}
Dmsg1(0, "db_type=%s\n", db_get_type(db));
if (!db_open_database(NULL, db)) {
Emsg0(M_ERROR_TERM, 0, db_strerror(db));
}
Dmsg0(200, "Database opened\n");
if (verbose) {
Pmsg2(000, _("Using Database: %s, User: %s\n"), db_name, db_user);
}
bjcr->db = db;
if (clean) {
Pmsg0(0, "Clean old table\n");
db_sql_query(db, "DELETE FROM PathHierarchy", NULL, NULL);
db_sql_query(db, "UPDATE Job SET HasCache=0", NULL, NULL);
示例5: 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");
setup_tsd_key();
jcr = (JCR *)malloc(size);
memset(jcr, 0, size);
jcr->msg_queue = New(dlist(item, &item->link));
if ((status = pthread_mutex_init(&jcr->msg_queue_mutex, NULL)) != 0) {
berrno be;
Jmsg(NULL, M_ABORT, 0, _("Could not init msg_queue mutex. ERR=%s\n"),
be.bstrerror(status));
}
jcr->job_end_push.init(1, false);
jcr->sched_time = time(NULL);
jcr->initial_sched_time = jcr->sched_time;
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;
jcr->comment = get_pool_memory(PM_FNAME);
jcr->comment[0] = 0;
/*
* Setup some dummy values
*/
bstrncpy(jcr->Job, "*System*", sizeof(jcr->Job));
jcr->JobId = 0;
jcr->setJobType(JT_SYSTEM); /* internal job until defined */
jcr->setJobLevel(L_NONE);
jcr->setJobStatus(JS_Created); /* ready to run */
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;
}
示例6: main
//.........这里部分代码省略.........
verbose++;
break;
case 'f':
if (nb < 10 ) {
files[nb++] = optarg;
}
break;
case '?':
default:
usage();
}
}
argc -= optind;
argv += optind;
if (argc != 0) {
Pmsg0(0, _("Wrong number of arguments: \n"));
usage();
}
if (restore_list) {
uint64_t nb_file=0;
btime_t start, end;
/* To use the -r option, the catalog should already contains records */
if ((db = db_init_database(NULL, db_driver, db_name, db_user, db_password,
db_host, 0, NULL, false, disable_batch)) == NULL) {
Emsg0(M_ERROR_TERM, 0, _("Could not init Bareos database\n"));
}
if (!db_open_database(NULL, db)) {
Emsg0(M_ERROR_TERM, 0, db_strerror(db));
}
start = get_current_btime();
db_get_file_list(NULL, db, restore_list, false, false, list_handler, &nb_file);
end = get_current_btime();
Pmsg3(0, _("Computing file list for jobid=%s files=%lld secs=%d\n"),
restore_list, nb_file, (uint32_t)btime_to_unix(end-start));
free(restore_list);
return 0;
}
if (disable_batch) {
printf("Without new Batch mode\n");
} else {
printf("With new Batch mode\n");
}
i = nb;
while (--i >= 0) {
pthread_t thid;
JCR *bjcr = new_jcr(sizeof(JCR), NULL);
bjcr->bsr = NULL;
bjcr->VolSessionId = 1;
bjcr->VolSessionTime = (uint32_t)time(NULL);
bjcr->NumReadVolumes = 0;
bjcr->NumWriteVolumes = 0;
bjcr->JobId = getpid();
bjcr->setJobType(JT_CONSOLE);
bjcr->setJobLevel(L_FULL);
bjcr->JobStatus = JS_Running;
bjcr->where = bstrdup(files[i]);
bjcr->job_name = get_pool_memory(PM_FNAME);
pm_strcpy(bjcr->job_name, "Dummy.Job.Name");
bjcr->client_name = get_pool_memory(PM_FNAME);
pm_strcpy(bjcr->client_name, "Dummy.Client.Name");
bstrncpy(bjcr->Job, "bbatch", sizeof(bjcr->Job));
bjcr->fileset_name = get_pool_memory(PM_FNAME);
pm_strcpy(bjcr->fileset_name, "Dummy.fileset.name");
bjcr->fileset_md5 = get_pool_memory(PM_FNAME);
pm_strcpy(bjcr->fileset_md5, "Dummy.fileset.md5");
if ((db = db_init_database(NULL, db_driver, db_name, db_user, db_password,
db_host, 0, NULL, false, false)) == NULL) {
Emsg0(M_ERROR_TERM, 0, _("Could not init Bareos database\n"));
}
if (!db_open_database(NULL, db)) {
Emsg0(M_ERROR_TERM, 0, db_strerror(db));
}
Dmsg0(200, "Database opened\n");
if (verbose) {
Pmsg2(000, _("Using Database: %s, User: %s\n"), db_name, db_user);
}
bjcr->db = db;
pthread_create(&thid, NULL, do_batch, bjcr);
}
while (nb > 0) {
bmicrosleep(1,0);
}
return 0;
}