Exemple #1
0
job::job(std::shared_ptr<job_metadata> job_meta,
	std::shared_ptr<worker_config> worker_conf,
	fs::path working_directory,
	fs::path source_path,
	fs::path result_path,
	std::shared_ptr<task_factory_interface> factory,
	std::shared_ptr<progress_callback_interface> progr_callback)
	: job_meta_(job_meta), worker_config_(worker_conf), working_directory_(working_directory),
	  source_path_(source_path), result_path_(result_path), factory_(factory), progress_callback_(progr_callback)
{
	// check construction parameters if they are in right format
	if (job_meta_ == nullptr) {
		throw job_exception("Job configuration cannot be null");
	} else if (worker_config_ == nullptr) {
		throw job_exception("Worker configuration cannot be null");
	} else if (factory_ == nullptr) {
		throw job_exception("Task factory pointer cannot be null");
	}

	// if progress callback is null, we have to use default one
	init_progress_callback();

	// check injected directories
	check_job_dirs();

	// prepare variables which will be used in job config
	prepare_job_vars();

	// construct system logger for this job
	init_logger();

	// build job from given job configuration
	build_job();
}
Exemple #2
0
int
main (int ac, char *av[])
{
	int rc;

	set_pname("ndmjob");
	dbopen(DBG_SUBDIR_CLIENT);
	config_init(0, NULL);

	NDMOS_MACRO_ZEROFILL(&the_session);
	d_debug = -1;

	/* ready the_param early so logging works during process_args() */
	NDMOS_MACRO_ZEROFILL (&the_param);
	the_param.log.deliver = ndmjob_log_deliver;
	the_param.log_level = 0;
	the_param.log_tag = "SESS";

#ifndef NDMOS_OPTION_NO_CONTROL_AGENT
	b_bsize = 20;
	index_fp = stderr;
	o_tape_addr = -1;
	o_from_addr = -1;
	o_to_addr = -1;
	p_ndmp_port = NDMPPORT;
#endif /* !NDMOS_OPTION_NO_CONTROL_AGENT */

	process_args (ac, av);

	if (the_param.log_level < d_debug)
		the_param.log_level = d_debug;
	if (the_param.log_level < v_verbose)
		the_param.log_level = v_verbose;
	the_param.config_file_name = o_config_file;

	if (the_mode == NDM_JOB_OP_DAEMON || the_mode == NDM_JOB_OP_TEST_DAEMON) {
		the_session.param = the_param;

		if (n_noop) {
			dump_settings();
			return 0;
		}

		ndma_daemon_session (&the_session, p_ndmp_port, the_mode == NDM_JOB_OP_TEST_DAEMON);
		return 0;
	}

#ifndef NDMOS_OPTION_NO_CONTROL_AGENT
	the_session.control_acb.swap_connect = (o_swap_connect != 0);

	build_job();		/* might not return */

	the_session.param = the_param;
	the_session.control_acb.job = the_job;

	if (n_noop) {
		dump_settings();
		return 0;
	}

	start_index_file ();

	rc = ndma_client_session (&the_session);

	sort_index_file ();

	if (rc == 0)
	    ndmjob_log (1, "Operation complete");
	else
	    ndmjob_log (1, "Operation complete but had problems.");
#endif /* !NDMOS_OPTION_NO_CONTROL_AGENT */

	dbclose();
	return 0;
}
Exemple #3
0
int
main (int ac, char *av[])
{
	int rc;

	NDMOS_MACRO_ZEROFILL (&E_environment);
	NDMOS_MACRO_ZEROFILL (&ji_environment);
	NDMOS_MACRO_ZEROFILL (&m_media);
	NDMOS_MACRO_ZEROFILL (&ji_media);

	NDMOS_MACRO_ZEROFILL (&the_session);
	d_debug = -1;

	/* ready the_param early so logging works during process_args() */
	NDMOS_MACRO_ZEROFILL (&the_param);
	the_param.log.deliver = ndmjob_log_deliver;
	the_param.log_level = 0;
	the_param.log_tag = "SESS";

#ifndef NDMOS_OPTION_NO_CONTROL_AGENT
	b_bsize = 20;
	index_fp = stderr;
	o_tape_addr = -1;
	o_from_addr = -1;
	o_to_addr = -1;
	p_ndmp_port = NDMPPORT;
#endif /* !NDMOS_OPTION_NO_CONTROL_AGENT */
	log_fp = stderr;

	process_args (ac, av);

	if (the_param.log_level < d_debug)
		the_param.log_level = d_debug;
	if (the_param.log_level < v_verbose)
		the_param.log_level = v_verbose;
	the_param.config_file_name = o_config_file;

	if (the_mode == NDM_JOB_OP_DAEMON) {
		the_session.param = &the_param;

		if (n_noop) {
			dump_settings ();
			exit_program ();
		}

		ndma_daemon_session (&the_session, p_ndmp_port);
		exit_program ();
	}

	ndmjob_register_callbacks (&the_session, &the_param.log);

#ifndef NDMOS_OPTION_NO_CONTROL_AGENT
	build_job();		/* might not return */

	the_session.param = &the_param;

	if (n_noop) {
		dump_settings ();
		exit_program ();
	}

	start_index_file ();

	rc = ndma_client_session (&the_session, &the_job, (o_swap_connect != 0));

	sort_index_file ();

	if (rc == 0)
	    ndmjob_log (1, "Operation complete");
	else
	    ndmjob_log (1, "Operation complete but had problems.");
#endif /* !NDMOS_OPTION_NO_CONTROL_AGENT */


	exit_program ();
}