コード例 #1
0
ファイル: local_master.c プロジェクト: AltroCoin/altrocoin
/* Sends a message to a running work unit. */
int
DC_sendWUMessage(DC_Workunit *wu, const char *message)
{
	GString *dn;
	int ret;

	/*if (!_DC_wu_check(wu))
	  return(DC_ERR_UNKNOWN_WU);*/
	DC_log(LOG_DEBUG, "DC_sendWUMessage(%p-\"%s\", %s)",
	       wu, wu->name, message);
	dn= g_string_new(wu->workdir);
	g_string_append(dn, "/");
	g_string_append(dn, _DC_wu_cfg(wu, cfg_master_message_box));
	ret= _DC_create_message(dn->str, (char*)_DCAPI_MSG_MESSAGE, message, NULL);
	g_string_free(dn, TRUE);
	return(ret);
}
コード例 #2
0
/* Resumes computation of a previously suspended work unit. */
int
DC_resumeWU(DC_Workunit *wu)
{
    int ret;
    char *id;
    GString *dn;

    if (!_DC_wu_check(wu))
        return(DC_ERR_UNKNOWN_WU);

    DC_log(LOG_DEBUG, "DC_resumeWU(%p-\"%s\")", wu, wu->data.name);

    if (wu->data.state != DC_WU_SUSPENDED)
    {
        DC_log(LOG_NOTICE, "Can not resume a non-suspended wu");
        return(DC_ERR_INTERNAL);
    }
    dn= g_string_new(wu->data.workdir);
    g_string_append(dn, "/");
    g_string_append(dn, _DC_wu_cfg(wu, cfg_management_box));
    _DC_create_message(dn->str, _DCAPI_MSG_COMMAND, _DCAPI_CMD_RESUME,
                       NULL);
    g_string_free(dn, TRUE);
    ret= _DC_start_condor_job(wu);
    if (ret == 0)
    {
        _DC_wu_update_condor_events(wu);
        while (wu->condor_events->len == 0)
        {
            sleep(1);
            _DC_wu_update_condor_events(wu);
        }
        DC_log(LOG_DEBUG, "DC_ResumeWU...");
        _DC_wu_set_state(wu, DC_WU_RUNNING);
        id= DC_getWUId(wu);
        DC_log(LOG_INFO, "Condor id of wu's job: %s", id);
        g_free(id);
    }
    return(ret);
}
コード例 #3
0
/* Temporarily suspends the execution of a work unit. */
int
DC_suspendWU(DC_Workunit *wu)
{
    GString *dn;

    if (!_DC_wu_check(wu))
        return(DC_ERR_UNKNOWN_WU);

    DC_log(LOG_DEBUG, "DC_suspendWU(%p-\"%s\")", wu, wu->data.name);

    if (wu->data.state != DC_WU_RUNNING)
    {
        DC_log(LOG_NOTICE, "Can not suspend a non-running wu");
        return(DC_ERR_INTERNAL);
    }
    dn= g_string_new(wu->data.workdir);
    g_string_append(dn, "/");
    g_string_append(dn, _DC_wu_cfg(wu, cfg_management_box));
    _DC_create_message(dn->str, _DCAPI_MSG_COMMAND, _DCAPI_CMD_SUSPEND,
                       NULL);
    g_string_free(dn, TRUE);
    /*wu->asked_to_suspend= TRUE;*/
    return(DC_OK);
}