コード例 #1
0
ファイル: ThreadMemory.cpp プロジェクト: CodaFi/swift-lldb
bool
ThreadMemory::CalculateStopInfo ()
{
    if (m_backing_thread_sp)
    {
        lldb::StopInfoSP backing_stop_info_sp (m_backing_thread_sp->GetPrivateStopInfo());
        if (backing_stop_info_sp && backing_stop_info_sp->IsValidForOperatingSystemThread(*this))
        {
            backing_stop_info_sp->SetThread (shared_from_this());
            SetStopInfo (backing_stop_info_sp);
            return true;
        }
    }
    else
    {
        ProcessSP process_sp (GetProcess());

        if (process_sp)
        {
            OperatingSystem *os = process_sp->GetOperatingSystem ();
            if (os)
            {
                SetStopInfo (os->CreateThreadStopReason (this));
                return true;
            }
        }
    }
    return false;
}
コード例 #2
0
Experiment_Result Experiment::copyback_map_experiment(vector<Thread*> (*experiment)(int highest_lba), int cb_map_min, int cb_map_max, int cb_map_inc, int used_space, string data_folder, string name, int IO_limit) {
    Experiment_Result experiment_result(name, data_folder, "", "Max copyback map size");
    experiment_result.start_experiment();

    const int num_pages = NUMBER_OF_ADDRESSABLE_BLOCKS() * BLOCK_SIZE;
    for (int copyback_map_size = cb_map_min; copyback_map_size <= cb_map_max; copyback_map_size += cb_map_inc) {
		int highest_lba = (int) ((double) num_pages * used_space / 100);
		printf("-------------------------------------------------------\n");
		printf("Experiment with %d copybacks allowed in copyback map.  \n", copyback_map_size);
		printf("-------------------------------------------------------\n");

		MAX_ITEMS_IN_COPY_BACK_MAP = copyback_map_size;

		// Run experiment
		vector<Thread*> threads = experiment(highest_lba);
		OperatingSystem* os = new OperatingSystem();
		os->set_threads(threads);
		os->set_num_writes_to_stop_after(IO_limit);
		os->run();

		// Collect statistics from this experiment iteration (save in csv files)
		experiment_result.collect_stats(copyback_map_size);

		StatisticsGatherer::get_global_instance()->print();
		if (PRINT_LEVEL >= 1) {
			StateVisualiser::print_page_status();
			StateVisualiser::print_block_ages();
		}

		delete os;
	}

	experiment_result.end_experiment();
	return experiment_result;
}
コード例 #3
0
CIMObjectPath
OperatingSystemProvider::_fill_reference(const CIMNamespaceName &nameSpace,
				         const CIMName &className)
{
    Array<CIMKeyBinding> keys;
    OperatingSystem os;
    String csName;
    String name;

    if (!os.getCSName(csName))
    {
        throw CIMOperationFailedException("OperatingSystemProvider "
                  "can't determine name of computer system");
    }

    if (!os.getName(name))
    {
        throw CIMOperationFailedException("OperatingSystemProvider "
                  "can't determine name of Operating System");
    }

    keys.append(CIMKeyBinding("CSCreationClassName",
 	                   CSCREATIONCLASSNAME.getString(),
			   CIMKeyBinding::STRING));
    keys.append(CIMKeyBinding("CSName", csName, CIMKeyBinding::STRING));
    keys.append(CIMKeyBinding("CreationClassName",
                              STANDARDOPERATINGSYSTEMCLASS.getString(),
                              CIMKeyBinding::STRING));
    keys.append(CIMKeyBinding("Name", name, CIMKeyBinding::STRING));

    return CIMObjectPath(csName, nameSpace, className, keys);
}
コード例 #4
0
ファイル: Submitter.hpp プロジェクト: frarteaga/tcframe
    Verdict executeOnTestCase(string testCaseName) {
        string testCaseInputFilename = generator->getTestCasesDir() + "/" + testCaseName + ".in";

        os->limitExecutionTime(generator->getTimeLimit());
        os->limitExecutionMemory(generator->getMemoryLimit());
        ExecutionResult result = os->execute(testCaseName + "-submission-evaluation", submissionCommand, testCaseInputFilename, "_submission.out", "_error.out");
        os->limitExecutionTime(0);
        os->limitExecutionMemory(0);

        if (result.exitStatus == 0) {
            return Verdict::unknown();
        }

        vector<Failure> failures;

        if (result.exitStatus & (1<<7)) {
            int signal = WTERMSIG(result.exitStatus);

            if (signal == SIGXCPU) {
                return Verdict::timeLimitExceeded();
            }

            failures.push_back(Failure("Execution of submission failed:", 0));
            failures.push_back(Failure(string(strsignal(signal)), 1));
        } else {
            failures.push_back(Failure("Execution of submission failed:", 0));
            failures.push_back(Failure("Exit code: " + Util::toString(result.exitStatus), 1));
            failures.push_back(Failure("Standard error: " + string(istreambuf_iterator<char>(*result.errorStream), istreambuf_iterator<char>()), 1));
        }
        return Verdict::runtimeError(failures);
    }
コード例 #5
0
ファイル: ThreadMemory.cpp プロジェクト: ztianjin/lldb
lldb::StopInfoSP
ThreadMemory::GetPrivateStopReason ()
{
    ProcessSP process_sp (GetProcess());

    if (process_sp)
    {
        const uint32_t process_stop_id = process_sp->GetStopID();
        if (m_thread_stop_reason_stop_id != process_stop_id ||
            (m_actual_stop_info_sp && !m_actual_stop_info_sp->IsValid()))
        {
            // If GetGDBProcess().SetThreadStopInfo() doesn't find a stop reason
            // for this thread, then m_actual_stop_info_sp will not ever contain
            // a valid stop reason and the "m_actual_stop_info_sp->IsValid() == false"
            // check will never be able to tell us if we have the correct stop info
            // for this thread and we will continually send qThreadStopInfo packets
            // down to the remote GDB server, so we need to keep our own notion
            // of the stop ID that m_actual_stop_info_sp is valid for (even if it
            // contains nothing). We use m_thread_stop_reason_stop_id for this below.
            m_thread_stop_reason_stop_id = process_stop_id;
            m_actual_stop_info_sp.reset();
            
            OperatingSystem *os = process_sp->GetOperatingSystem ();
            if (os)
                m_actual_stop_info_sp = os->CreateThreadStopReason (this);
        }
    }
    return m_actual_stop_info_sp;
    
}
コード例 #6
0
Experiment_Result Experiment::copyback_experiment(vector<Thread*> (*experiment)(int highest_lba), int used_space, int max_copybacks, string data_folder, string name, int IO_limit) {
    Experiment_Result experiment_result(name, data_folder, "", "CopyBacks allowed before ECC check");
    experiment_result.start_experiment();

    const int num_pages = NUMBER_OF_ADDRESSABLE_BLOCKS() * BLOCK_SIZE;
    for (int copybacks_allowed = 0; copybacks_allowed <= max_copybacks; copybacks_allowed += 1) {
		int highest_lba = (int) ((double) num_pages * used_space / 100);
		printf("---------------------------------------\n");
		printf("Experiment with %d copybacks allowed.\n", copybacks_allowed);
		printf("---------------------------------------\n");

		MAX_REPEATED_COPY_BACKS_ALLOWED = copybacks_allowed;

		// Run experiment
		vector<Thread*> threads = experiment(highest_lba);
		OperatingSystem* os = new OperatingSystem();
		os->set_threads(threads);
		os->set_num_writes_to_stop_after(IO_limit);
		os->run();

		// Collect statistics from this experiment iteration (save in csv files)
		experiment_result.collect_stats(copybacks_allowed);

		StatisticsGatherer::get_global_instance()->print();
		if (PRINT_LEVEL >= 1) {
			StateVisualiser::print_page_status();
			StateVisualiser::print_block_ages();
		}

		delete os;
	}

	experiment_result.end_experiment();
	return experiment_result;
}
コード例 #7
0
void Experiment::simple_experiment_double(string name, T* var, T min, T max, T inc) {
	string data_folder = base_folder + name + "/";
	mkdir(data_folder.c_str(), 0755);
	Experiment_Result global_result(name, data_folder, "Global/", variable_name);
	global_result.start_experiment();
	T& variable = *var;
	for (variable = min; variable <= max; variable += inc) {
		printf("----------------------------------------------------------------------------------------------------------\n");
		printf("%s :  %s \n", name.c_str(), to_string(variable).c_str());
		printf("----------------------------------------------------------------------------------------------------------\n");

		string point_folder_name = data_folder + to_string(variable) + "/";
		mkdir(point_folder_name.c_str(), 0755);
		if (generate_trace_file) {
			VisualTracer::init(data_folder);
		} else {
			VisualTracer::init();
		}
		write_config_file(point_folder_name);
		Queue_Length_Statistics::init();
		Free_Space_Meter::init();
		Free_Space_Per_LUN_Meter::init();

		OperatingSystem* os;
		if (calibrate_for_each_point && calibration_workload != NULL) {
			string calib_file_name = "calib-" + to_string(variable) + ".txt";
			Experiment::calibrate_and_save(calibration_workload, calib_file_name);
			os = load_state(calib_file_name);
		} else if (!calibration_file.empty()) {
			os = load_state(calibration_file);
		} else {
			os = new OperatingSystem();
		}

		if (workload != NULL) {
			vector<Thread*> experiment_threads = workload->generate_instance();
			os->set_threads(experiment_threads);
		}
		os->set_num_writes_to_stop_after(io_limit);
		os->run();
		StatisticsGatherer::get_global_instance()->print();
		Utilization_Meter::print();
		Queue_Length_Statistics::print_avg();
		Free_Space_Meter::print();
		Free_Space_Per_LUN_Meter::print();
		global_result.collect_stats(variable, StatisticsGatherer::get_global_instance());
		write_results_file(point_folder_name);
		delete os;
	}
	global_result.end_experiment();
	vector<Experiment_Result> result;
	result.push_back(global_result);
	results.push_back(result);
}
コード例 #8
0
void Experiment::run_single_point(string name) {
	string data_folder = base_folder + name + "/";
	mkdir(data_folder.c_str(), 0755);
	StatisticsGatherer::set_record_statistics(true);
	Thread::set_record_internal_statistics(true);
	Experiment_Result global_result(name, data_folder, "Global/", "");
	Individual_Threads_Statistics::init();
	global_result.start_experiment();
	Free_Space_Meter::init();
	Free_Space_Per_LUN_Meter::init();

	if (generate_trace_file) {
		VisualTracer::init(data_folder);
	} else {
		VisualTracer::init();
	}

	write_config_file(data_folder);
	Queue_Length_Statistics::init();

	OperatingSystem* os = calibration_file.empty() ? new OperatingSystem() : load_state(calibration_file);
	os->set_progress_meter_granularity(20);
	if (workload != NULL) {
		vector<Thread*> experiment_threads = workload->generate_instance();
		os->set_threads(experiment_threads);
	}
	os->set_num_writes_to_stop_after(io_limit);
	os->run();

	StatisticsGatherer::get_global_instance()->print();
	StatisticsGatherer::get_global_instance()->print_mapping_info();
	//StatisticsGatherer::get_global_instance()->print_gc_info();
	Utilization_Meter::print();
	//Individual_Threads_Statistics::print();
	//Queue_Length_Statistics::print_distribution();
	//Queue_Length_Statistics::print_avg();
	Free_Space_Meter::print();
	Free_Space_Per_LUN_Meter::print();

	global_result.collect_stats(0, StatisticsGatherer::get_global_instance());
	write_results_file(data_folder);
	if (!alternate_location_for_results_file.compare("") == 0) {
		printf("writing results in %s\n", alternate_location_for_results_file.c_str());
		write_results_file(alternate_location_for_results_file);
	}

	global_result.end_experiment();
	vector<Experiment_Result> result;
	result.push_back(global_result);
	results.push_back(result);
	delete os;
}
コード例 #9
0
ファイル: ThreadMemory.cpp プロジェクト: ztianjin/lldb
RegisterContextSP
ThreadMemory::GetRegisterContext ()
{
    if (!m_reg_context_sp)
    {
        ProcessSP process_sp (GetProcess());
        if (process_sp)
        {
            OperatingSystem *os = process_sp->GetOperatingSystem ();
            if (os)
                m_reg_context_sp = os->CreateRegisterContextForThread (this);
        }
    }
    return m_reg_context_sp;
}
コード例 #10
0
OperatingSystem* Experiment::load_state(string name) {
	string file_name = base_folder + name;
	printf("loading calibration file:  %s\n", file_name.c_str());
	std::ifstream file(file_name.c_str());
	boost::archive::text_iarchive ia(file);
	ia.register_type<FtlImpl_Page>( );
	ia.register_type<Block_manager_parallel>();
	ia.register_type<Sequential_Locality_BM>( );
	ia.register_type<File_Manager>( );
	ia.register_type<Simple_Thread>( );
	ia.register_type<Random_IO_Pattern>( );
	ia.register_type<Sequential_IO_Pattern>( );
	ia.register_type<WRITES>( );
	ia.register_type<TRIMS>( );
	ia.register_type<READS>( );
	ia.register_type<READS_OR_WRITES>();
	ia.register_type<Asynchronous_Random_Writer>();
	ia.register_type<Asynchronous_Random_Reader>();

	ia.register_type<MTRand>();
	ia.register_type<MTRand_closed>();
	ia.register_type<MTRand_open>();
	ia.register_type<MTRand53>();

	OperatingSystem* os;
	ia >> os;
	vector<Thread*> threads;
	ia >> threads;
	Individual_Threads_Statistics::init();
	for (auto t : threads) {
		//Individual_Threads_Statistics::register_thread(t, "");
	}
	os->set_threads(threads);
	//os->init_threads();
	IOScheduler* scheduler = os->get_ssd()->get_scheduler();
	scheduler->init();
	Block_manager_parent* bm = Block_manager_parent::get_new_instance();
	bm->copy_state(scheduler->get_bm());
	delete scheduler->get_bm();
	scheduler->set_block_manager(bm);
	Migrator* m = scheduler->get_migrator();
	m->set_block_manager(bm);
	Garbage_Collector* gc = m->get_garbage_collector();
	gc->set_block_manager(bm);

	return os;
}
コード例 #11
0
void cacic_hardware::iniciaColeta()
{
#ifdef Q_OS_WIN
    this->coletaHardware = coletaWin();
#elif defined(Q_OS_LINUX)
    OperatingSystem operatingSystem;


    // Como criaremos pacotes agora, todas essas verificações podiam só
    // ser incluídas como dependências.

    // se o shell retorna erro ao tentar utilizar o lshw ou o dmidecode, instala o mesmo
    if( console("lshw").contains("/bin/sh:") ){
        QLogger::QLog_Info("Gercols (hardware)", "lshw nao estava instalado.");
        if(operatingSystem.getIdOs() == OperatingSystem::LINUX_ARCH)
            console("pacman -S --needed --noconfirm lshw");
        else if(operatingSystem.getIdOs() == OperatingSystem::LINUX_DEBIAN ||
               operatingSystem.getIdOs() == OperatingSystem::LINUX_UBUNTU )
            console("apt-get -y install lshw");
    }

    if( console("dmidecode").contains("/bin/sh:") ){
        QLogger::QLog_Info("Gercols (hardware)", "dmidecode nao estava instalado");
        if(operatingSystem.getIdOs() == OperatingSystem::LINUX_ARCH)
            console("pacman -S --needed --noconfirm dmidecode");
        else if(operatingSystem.getIdOs() == OperatingSystem::LINUX_DEBIAN ||
               operatingSystem.getIdOs() == OperatingSystem::LINUX_UBUNTU )
            console("apt-get -y install dmidecode");
    }

    this->coletaHardware = coletaLinux();
#endif
}
コード例 #12
0
ファイル: Submitter.hpp プロジェクト: frarteaga/tcframe
    Verdict scoreOnTestCase(string testCaseName) {
        string testCaseOutputFilename = generator->getTestCasesDir() + "/" + testCaseName + ".out";

        string diffCommand = "diff --unchanged-line-format=' %.2dn    %L' --old-line-format='(expected) [line %.2dn]    %L' --new-line-format='(received) [line %.2dn]    %L' " + testCaseOutputFilename + " _submission.out | head -n 10";
        ExecutionResult result = os->execute(testCaseName + "-submission-scoring", diffCommand, "", "_diff.out", "");

        string briefDiffCommand = "diff --brief _submission.out " + testCaseOutputFilename;
        ExecutionResult briefResult = os->execute(testCaseName + "-submission-scoring-brief", briefDiffCommand, "", "", "");

        if (briefResult.exitStatus == 0) {
            return Verdict::accepted();
        } else {
            string diff = string(istreambuf_iterator<char>(*result.outputStream), istreambuf_iterator<char>());
            return Verdict::wrongAnswer({
                Failure("Diff:\n" + diff, 0)
            });
        }
    }
コード例 #13
0
void
RegisterContextThreadMemory::UpdateRegisterContext ()
{
    ThreadSP thread_sp (m_thread_wp.lock());
    if (thread_sp)
    {
        ProcessSP process_sp (thread_sp->GetProcess());

        if (process_sp)
        {
            const uint32_t stop_id = process_sp->GetModID().GetStopID();
            if (m_stop_id != stop_id)
            {
                m_stop_id = stop_id;
                m_reg_ctx_sp.reset();
            }
            if (!m_reg_ctx_sp)
            {
                ThreadSP backing_thread_sp (thread_sp->GetBackingThread());
                if (backing_thread_sp)
                {
                    m_reg_ctx_sp = backing_thread_sp->GetRegisterContext();
                }
                else
                {
                    OperatingSystem *os = process_sp->GetOperatingSystem ();
                    if (os->IsOperatingSystemPluginThread (thread_sp))
                        m_reg_ctx_sp = os->CreateRegisterContextForThread (thread_sp.get(), LLDB_INVALID_ADDRESS);
                }                
            }
        }
        else
        {
            m_reg_ctx_sp.reset();
        }
    }
    else
    {
        m_reg_ctx_sp.reset();
    }
}
コード例 #14
0
// currently, this method checks if there if a file already exists, and if so, assumes it is valid.
// ideally, a check should be made to ensure the saved SSD state matches with the state of the current global parameters
void Experiment::calibrate_and_save(Workload_Definition* workload, string name, int num_IOs, bool force) {
	//string file_name = base_folder + "calibrated_state.txt";
	string file_name = base_folder + name;
	std::ifstream ifile(file_name.c_str());
	if (ifile && !force) {
		return; // file exists
	}
	StatisticsGatherer::set_record_statistics(false);
	//StatisticsGatherer::get_global_instance()->init();
	Thread::set_record_internal_statistics(false);
	VisualTracer::init();
	//Free_Space_Meter::init();
	//Free_Space_Per_LUN_Meter::init();
	printf("Creating calibrated SSD state.\n");
	OperatingSystem* os = new OperatingSystem();
	os->set_num_writes_to_stop_after(num_IOs);
	vector<Thread*> init_threads = workload->generate_instance();
	os->set_threads(init_threads);
	os->set_progress_meter_granularity(1000);

	os->run();
	os->get_ssd()->execute_all_remaining_events();
	save_state(os, file_name);
	//StatisticsGatherer::get_global_instance()->print();
	//Free_Space_Meter::print();
	//Free_Space_Per_LUN_Meter::print();
	delete os;
}
コード例 #15
0
ファイル: Submitter.hpp プロジェクト: frarteaga/tcframe
    Verdict submitOnTestCase(string testCaseName) {

        if (!brief) {
            logger->logTestCaseIntroduction(testCaseName);
        }

        Verdict verdict = gradeOnTestCase(testCaseName);
        os->removeFile("_submission.out");
        os->removeFile("_diff.out");

        if (!brief) {
            logger->logTestCaseVerdict(verdict);
        }

        if (!verdict.isAccepted()) {
            if (!brief) {
                logger->logFailures(verdict.getFailures());
            }
        }

        return verdict;
    }
コード例 #16
0
    EvaluationResult evaluate(
            const string& inputFilename,
            const string& outputFilename,
            const EvaluatorConfig& config) {

        ExecutionRequestBuilder request = ExecutionRequestBuilder()
                .setCommand(config.solutionCommand())
                .setInputFilename(inputFilename)
                .setOutputFilename(outputFilename)
                .setErrorFilename("_error.out");

        if (config.timeLimit()) {
            request.setTimeLimit(config.timeLimit().value());
        }
        if (config.memoryLimit()) {
            request.setMemoryLimit(config.memoryLimit().value());
        }

        ExecutionResult executionResult = os_->execute(request.build());
        return createResult(executionResult);
    }
コード例 #17
0
vector<Experiment_Result> Experiment::random_writes_on_the_side_experiment(Workload_Definition* workload, int write_threads_min, int write_threads_max, int write_threads_inc, string name, int IO_limit, double used_space, int random_writes_min_lba, int random_writes_max_lba) {
	string data_folder = base_folder + name;
	mkdir(data_folder.c_str(), 0755);
	Experiment_Result global_result       (name, data_folder, "Global/",             "Number of concurrent random write threads");
    Experiment_Result experiment_result   (name, data_folder, "Experiment_Threads/", "Number of concurrent random write threads");
    Experiment_Result write_threads_result(name, data_folder, "Noise_Threads/",      "Number of concurrent random write threads");

    global_result.start_experiment();
    experiment_result.start_experiment();
    write_threads_result.start_experiment();

    for (int random_write_threads = write_threads_min; random_write_threads <= write_threads_max; random_write_threads += write_threads_inc) {
		printf("----------------------------------------------------------------------------------------------------------\n");
		printf("%s : Experiment with max %d concurrent random writes threads.\n", name.c_str(), random_write_threads);
		printf("----------------------------------------------------------------------------------------------------------\n");

		StatisticsGatherer* experiment_statistics_gatherer = new StatisticsGatherer();
		StatisticsGatherer* random_writes_statics_gatherer = new StatisticsGatherer();
		Thread* initial_write    = new Asynchronous_Sequential_Writer(0, used_space);
		if (workload != NULL) {
			vector<Thread*> experiment_threads = workload->generate_instance();
			unify_under_one_statistics_gatherer(experiment_threads, experiment_statistics_gatherer);
			initial_write->add_follow_up_threads(experiment_threads);
		}
		for (int i = 0; i < random_write_threads; i++) {
			ulong randseed = (i*3)+537;
			Simple_Thread* random_writes = new Synchronous_Random_Writer(random_writes_min_lba, random_writes_max_lba, randseed);
			Simple_Thread* random_reads = new Synchronous_Random_Reader(random_writes_min_lba, random_writes_max_lba, randseed+461);
			/*if (workload == NULL) {
				random_writes->set_experiment_thread(true);
				random_reads->set_experiment_thread(true);
			}*/
			random_writes->set_num_ios(INFINITE);
			random_reads->set_num_ios(INFINITE);
			random_writes->set_statistics_gatherer(random_writes_statics_gatherer);
			random_reads->set_statistics_gatherer(random_writes_statics_gatherer);
			initial_write->add_follow_up_thread(random_writes);
			initial_write->add_follow_up_thread(random_reads);
		}

		vector<Thread*> threads;
		threads.push_back(initial_write);
		OperatingSystem* os = new OperatingSystem();
		os->set_threads(threads);
		os->set_num_writes_to_stop_after(IO_limit);
		os->run();

			// Collect statistics from this experiment iteration (save in csv files)
		global_result.collect_stats       (random_write_threads, StatisticsGatherer::get_global_instance());
		experiment_result.collect_stats   (random_write_threads, experiment_statistics_gatherer);
		write_threads_result.collect_stats(random_write_threads, random_writes_statics_gatherer);

		if (workload == NULL) {
			StatisticsGatherer::get_global_instance()->print();
		} else {
			experiment_statistics_gatherer->print();
		}

		//StatisticsGatherer::get_global_instance()->print();
		//random_writes_statics_gatherer->print();
		if (PRINT_LEVEL >= 1) {
			StateVisualiser::print_page_status();
			StateVisualiser::print_block_ages();
		}
		delete os;
		delete experiment_statistics_gatherer;
		delete random_writes_statics_gatherer;
	}
    global_result.end_experiment();
    experiment_result.end_experiment();
    write_threads_result.end_experiment();

    vector<Experiment_Result> results;
    results.push_back(global_result);
    results.push_back(experiment_result);
    results.push_back(write_threads_result);
    if (workload != NULL)
    	delete workload;
    return results;
}
コード例 #18
0
void
OperatingSystemProvider::getInstance(const OperationContext& context,
				     const CIMObjectPath& ref,
				     const Boolean includeQualifiers,
				     const Boolean includeClassOrigin,
				     const CIMPropertyList& propertyList,
				     InstanceResponseHandler &handler)
{
    Array<CIMKeyBinding> keys;
    CIMInstance instance;
    OperatingSystem os;
    CIMName className;
    String csName;
    String name;


    //-- make sure we're working on the right class
    className = ref.getClassName();
    if (!(className.equal (STANDARDOPERATINGSYSTEMCLASS)) &&
        !(className.equal (EXTENDEDOPERATINGSYSTEMCLASS)))
        throw CIMNotSupportedException("OperatingSystemProvider does not support class " + className.getString());

    //-- make sure we're the right instance
    int keyCount;
    CIMName keyName;

    keyCount = 4;
    keys = ref.getKeyBindings();

    if ((unsigned int)keys.size() != (unsigned int)keyCount)
        throw CIMInvalidParameterException("Wrong number of keys");

    // doesn't seem as though this code will handle duplicate keys,
    // but it appears as though the CIMOM strips those out for us.
    // Despite test cases, don't get invoked with 2 keys of the same
    // name.

    if (!os.getCSName(csName))
    {
        throw CIMOperationFailedException("OperatingSystemProvider "
                       "Can't determine name of computer system");
    }

    if (!os.getName(name))
    {
        throw CIMOperationFailedException("OperatingSystemProvider "
                       "Can't determine name of Operating System");
    }

    for (unsigned int ii = 0; ii < keys.size(); ii++)
    {
         keyName = keys[ii].getName();

         if ((keyName.equal ("CSCreationClassName")) &&
       	    String::equalNoCase(keys[ii].getValue(),
                                CSCREATIONCLASSNAME.getString()))
         {
              keyCount--;
         }
         else if ((keyName.equal ("CSName")) &&
  	         String::equalNoCase(keys[ii].getValue(), csName))
         {
              keyCount--;
         }
         else if ((keyName.equal ("CreationClassName")) &&
 	         String::equalNoCase(keys[ii].getValue(),
                                     STANDARDOPERATINGSYSTEMCLASS.getString()))
         {
              keyCount--;
         }
         else if ((keyName.equal ("Name")) &&
 	         String::equalNoCase(keys[ii].getValue(), name))
         {
              keyCount--;
         }
         else
         {
              throw CIMInvalidParameterException("OperatingSystemProvider"
                             " unrecognized key " + keyName.getString());
         }
     }

     if (keyCount)
     {
        throw CIMInvalidParameterException("Wrong keys");
     }

    OSP_DEBUG("losp-> getInstance got the right keys");

    handler.processing();

    //-- fill 'er up...
    instance = _build_instance(ref);
    instance.setPath(ref);

    OSP_DEBUG("losp-> getInstance built an instance");

    handler.deliver(instance);
    handler.complete();

    OSP_DEBUG("losp-> getInstance done");
    return;
}
コード例 #19
0
CIMInstance
OperatingSystemProvider::_build_instance(const CIMObjectPath& objectReference)
{
    CIMInstance instance(objectReference.getClassName());
    OperatingSystem os;
    CIMName className;
    String stringValue;
    Uint16 uint16Value;
    CIMDateTime cimDateTimeValue;
    Sint16 sint16Value;
    Uint32 uint32Value;
    Uint64 uint64Value;
    Boolean booleanValue;

    className = objectReference.getClassName();

    //-- fill in all the blanks
    instance.addProperty(CIMProperty("CSCreationClassName",
 	                 (CSCREATIONCLASSNAME.getString())));

    if (os.getCSName(stringValue))
    {
        instance.addProperty(CIMProperty("CSName", stringValue));
    }

    instance.addProperty(CIMProperty("CreationClassName",
 	                 (STANDARDOPERATINGSYSTEMCLASS.getString())));

    if (os.getName(stringValue))
    {
        instance.addProperty(CIMProperty("Name", stringValue));
    }

    if (os.getCaption(stringValue))
    {
        instance.addProperty(CIMProperty("Caption", stringValue));
    }

    if (os.getDescription(stringValue))
    {
        instance.addProperty(CIMProperty("Description", stringValue));
    }

    if (os.getInstallDate(cimDateTimeValue))
    {
        instance.addProperty(CIMProperty("InstallDate", cimDateTimeValue));
    }

    if (os.getStatus(stringValue))
    {
        instance.addProperty(CIMProperty("Status", stringValue));
    }

    if (os.getOSType(uint16Value))
    {
        instance.addProperty(CIMProperty("OSType", uint16Value));
    }

    if (os.getOtherTypeDescription(stringValue))
    {
        instance.addProperty(CIMProperty("OtherTypeDescription", stringValue));
    }

    if (os.getVersion(stringValue))
    {
        instance.addProperty(CIMProperty("Version", stringValue));
    }

    if (os.getLastBootUpTime(cimDateTimeValue))
    {
        instance.addProperty(CIMProperty("LastBootUpTime", cimDateTimeValue));
    }

    if (os.getLocalDateTime(cimDateTimeValue))
    {
        instance.addProperty(CIMProperty("LocalDateTime", cimDateTimeValue));
    }

    if (os.getCurrentTimeZone(sint16Value))
    {
        instance.addProperty(CIMProperty("CurrentTimeZone", sint16Value));
    }

    if (os.getNumberOfLicensedUsers(uint32Value))
    {
        instance.addProperty(CIMProperty("NumberOfLicensedUsers",uint32Value));
    }

    if (os.getNumberOfUsers(uint32Value))
    {
        instance.addProperty(CIMProperty("NumberOfUsers", uint32Value));
    }

    if (os.getNumberOfProcesses(uint32Value))
    {
        instance.addProperty(CIMProperty("NumberOfProcesses", uint32Value));
    }

    if (os.getMaxNumberOfProcesses(uint32Value))
    {
        instance.addProperty(CIMProperty("MaxNumberOfProcesses", uint32Value));
    }

    if (os.getTotalSwapSpaceSize(uint64Value))
    {
        instance.addProperty(CIMProperty("TotalSwapSpaceSize", uint64Value));
    }

    if (os.getTotalVirtualMemorySize(uint64Value))
    {
        instance.addProperty(CIMProperty("TotalVirtualMemorySize", uint64Value));
    }

    if (os.getFreeVirtualMemory(uint64Value))
    {
        instance.addProperty(CIMProperty("FreeVirtualMemory", uint64Value));
    }

    if (os.getFreePhysicalMemory(uint64Value))
    {
       instance.addProperty(CIMProperty("FreePhysicalMemory", uint64Value));
    }

    if (os.getTotalVisibleMemorySize(uint64Value))
    {
       instance.addProperty(CIMProperty("TotalVisibleMemorySize", uint64Value));
    }

    if (os.getSizeStoredInPagingFiles(uint64Value))
    {
        instance.addProperty(CIMProperty("SizeStoredInPagingFiles", uint64Value));
    }

    if (os.getFreeSpaceInPagingFiles(uint64Value))
    {
        instance.addProperty(CIMProperty("FreeSpaceInPagingFiles", uint64Value));
    }

    if (os.getMaxProcessMemorySize(uint64Value))
    {
        instance.addProperty(CIMProperty("MaxProcessMemorySize", uint64Value));
    }

    if (os.getDistributed(booleanValue))
    {
        instance.addProperty(CIMProperty("Distributed", booleanValue));
    }

    if (os.getMaxProcsPerUser(uint32Value))
    {
        instance.addProperty(CIMProperty("MaxProcessesPerUser", uint32Value));
    }

    if (className.equal (EXTENDEDOPERATINGSYSTEMCLASS))
    {
        if (os.getSystemUpTime(uint64Value))
        {
            instance.addProperty(CIMProperty("SystemUpTime",uint64Value ));
        }

        if (os.getOperatingSystemCapability(stringValue))
        {
            instance.addProperty(CIMProperty("OperatingSystemCapability",
                                              stringValue));
        }
    }
    return instance;
}