Пример #1
0
qpid::types::Variant::List agocontrol::jsonToVariantList(Json::Value value) {
	Variant::List list;
	try {
		for (Json::ValueIterator it = value.begin(); it != value.end(); it++) {
			if ((*it).size() > 0) {
				// cout << "JSON Type: " << (*it).type() << endl;
				if ((*it).type() == 6) {
					list.push_back(jsonToVariantList((*it)));
				} else if ((*it).type() == 7) {
					list.push_back(jsonToVariantMap((*it)));
				}
			} else {
				if ((*it).isString()) list.push_back( (*it).asString());
				if ((*it).isBool()) list.push_back( (*it).asBool());
				if ((*it).isInt()) list.push_back( (*it).asInt());
				if ((*it).isUInt()) list.push_back( (*it).asUInt());
				if ((*it).isDouble()) list.push_back( (*it).asDouble());
			}
		}
	} catch (const std::exception& error) {
                cout << "ERROR! Exception during JSON->Variant::Map conversion!" << endl;
                stringstream errorstring;
                errorstring << error.what();
		cout << "EXCEPTION: " << errorstring.str() << endl;
        }


	return list;
}
Пример #2
0
Manageable::status_t
SubmissionObject::GetJobSummaries ( Variant::List &jobs,
                            std::string &text )
{
	ClassAd *ad = NULL;
	MyString constraint;
	// id, timestamp (which?), command, args, ins, outs, state, message
	const char *ATTRS[] = {ATTR_CLUSTER_ID,
			ATTR_PROC_ID,
			ATTR_GLOBAL_JOB_ID,
			ATTR_Q_DATE,
			ATTR_ENTERED_CURRENT_STATUS,
			ATTR_JOB_STATUS,
			ATTR_JOB_CMD,
			ATTR_JOB_ARGUMENTS1,
			ATTR_JOB_ARGUMENTS2,
			ATTR_RELEASE_REASON,
			ATTR_HOLD_REASON,
			NULL
			};

	constraint.sprintf("%s == \"%s\"",
					   ATTR_JOB_SUBMISSION, this->m_name.c_str());

	dprintf(D_FULLDEBUG,"GetJobSummaries for submission: %s\n",constraint.Value());

	Variant::Map job;
	int init_scan = 1;
	while (NULL != (ad = GetNextJobByConstraint(constraint.Value(), init_scan))) {

		// debug
//		if (IsFulldebug(D_FULLDEBUG)) {
//			ad->dPrint(D_FULLDEBUG|D_NOHEADER);
//		}

		for (int i = 0; NULL != ATTRS[i]; i++) {
			if (!AddAttribute(*ad, ATTRS[i], job)) {
				dprintf(D_FULLDEBUG,"Warning: %s attribute not found for job of %s\n",ATTRS[i],constraint.Value());
			}
		}

		jobs.push_back(job);
		init_scan = 0;

		// debug
//		if (IsFulldebug(D_FULLDEBUG)) {
//			std::ostringstream oss;
//			oss << jobs;
//			dprintf(D_FULLDEBUG|D_NOHEADER, "%s\n",oss.str().c_str());
//		}

		FreeJobAd(ad);
		ad = NULL;
	}

	return STATUS_OK;
}
Пример #3
0
CoreClass::CoreClass(ManagementAgent* _agent, string _name) : name(_name), agent(_agent)
{
    static uint64_t persistId = 0x111222333444555LL;
    mgmtObject = new _qmf::Parent(agent, this, name);

    agent->addObject(mgmtObject);
    mgmtObject->set_state("IDLE");

    Variant::Map args;
    Variant::Map subMap;
    args["first"] = "String data";
    args["second"] = 34;
    subMap["string-data"] = "Text";
    subMap["numeric-data"] = 10000;
    args["map-data"] = subMap;
    mgmtObject->set_args(args);

    Variant::List list;
    list.push_back(20000);
    list.push_back("string-item");
    mgmtObject->set_list(list);
}
Пример #4
0
Manageable::status_t
SubmissionObject::GetJobSummaries ( Variant::List &jobs,
                            std::string &text )
{

    // id, timestamp (which?), command, args, ins, outs, state, message
    // id, time queued, time entered current state, state, command, args, hold reason, release reason

	ClassAd ad;
	Variant::Map job;

    // find all the jobs in their various states...

    //1) Idle
    for ( SubmissionObject::JobSet::const_iterator i = GetIdle().begin();
            GetIdle().end() != i; i++ )
    {
	    (*i)->GetSummary(ad);
	if ( !PopulateVariantMapFromAd ( ad, job ) )
        {
            text = "Error retrieving attributes for Idle job";
            return STATUS_USER + 1;
        }

        jobs.push_back(job);
    }

    //2) Running
    for ( SubmissionObject::JobSet::const_iterator i = GetRunning().begin();
            GetRunning().end() != i;
            i++ )
    {
	    (*i)->GetSummary(ad);
	if ( !PopulateVariantMapFromAd ( ad, job ) )
        {
            text = "Error retrieving attributes for Running job";
            return STATUS_USER + 1;
        }

        jobs.push_back(job);
    }

    //3) Removed
    for ( SubmissionObject::JobSet::const_iterator i = GetRemoved().begin();
            GetRemoved().end() != i; i++ )
    {
	    (*i)->GetSummary(ad);
	if ( !PopulateVariantMapFromAd ( ad, job ) )
        {
            text = "Error retrieving attributes for Removed job";
            return STATUS_USER + 1;
        }

        jobs.push_back(job);
    }

    //4) Completed
    for ( SubmissionObject::JobSet::const_iterator i = GetCompleted().begin();
            GetCompleted().end() != i; i++ )
    {
	    (*i)->GetSummary(ad);
	if ( !PopulateVariantMapFromAd ( ad, job ) )
        {
            text = "Error retrieving attributes for Completed job";
            return STATUS_USER + 1;
        }

        jobs.push_back(job);
    }


    //5) Held
    for ( SubmissionObject::JobSet::const_iterator i = GetHeld().begin();
            GetHeld().end() != i; i++ )
    {
	    (*i)->GetSummary(ad);
	if ( !PopulateVariantMapFromAd ( ad, job ) )
        {
            text = "Error retrieving attributes for Held job";
            return STATUS_USER + 1;
        }

        jobs.push_back(job);
    }

    //6) Transferring Output
    for ( SubmissionObject::JobSet::const_iterator i = GetTransferringOutput().begin();
            GetTransferringOutput().end() != i; i++ )
    {
	    (*i)->GetSummary(ad);
	if ( !PopulateVariantMapFromAd ( ad, job ) )
        {
            text = "Error retrieving attributes for TransferringOutput job";
            return STATUS_USER + 1;
        }

        jobs.push_back(job);
    }

    //7) Suspended
    for ( SubmissionObject::JobSet::const_iterator i = GetSuspended().begin();
            GetSuspended().end() != i; i++ )
    {
	    (*i)->GetSummary(ad);
	if ( !PopulateVariantMapFromAd ( ad, job ) )
        {
            text = "Error retrieving attributes for Suspended job";
            return STATUS_USER + 1;
        }

        jobs.push_back(job);
    }

    return STATUS_OK;
}