Example #1
0
static void parse(PmuXML & pmuXml, const char * const xml)
{
    mxml_node_t *root = mxmlLoadString(NULL, xml, MXML_NO_CALLBACK);

    for (mxml_node_t *node = mxmlFindElement(root, root, TAG_PMU, NULL, NULL, MXML_DESCEND); node != NULL;
            node = mxmlFindElement(node, root, TAG_PMU, NULL, NULL, MXML_DESCEND)) {
        const char * const pmncName = mxmlElementGetAttr(node, ATTR_PMNC_NAME);
        const char * const cpuidStr = mxmlElementGetAttr(node, ATTR_CPUID);
        int cpuid;
        if (!stringToInt(&cpuid, cpuidStr, 0)) {
            logg.logError("The cpuid for '%s' in pmu XML is not an integer", pmncName);
            handleException();
        }
        const char * const coreName = mxmlElementGetAttr(node, ATTR_CORE_NAME);
        const char * const dtName = mxmlElementGetAttr(node, ATTR_DT_NAME);
        const char * const speName = mxmlElementGetAttr(node, ATTR_SPE_NAME);
        const char * const pmncCountersStr = mxmlElementGetAttr(node, ATTR_PMNC_COUNTERS);
        const char * const profileStr = mxmlElementGetAttr(node, AATR_PROFILE);
        int pmncCounters;
        if (!stringToInt(&pmncCounters, pmncCountersStr, 0)) {
            logg.logError("The pmnc_counters for '%s' in pmu XML is not an integer", pmncName);
            handleException();
        }
        if (pmncName == NULL || cpuid == 0 || coreName == NULL || pmncCounters == 0) {
            logg.logError("A pmu from the pmu XML is missing one or more of the required attributes (%s, %s, %s and %s)", ATTR_PMNC_NAME, ATTR_CPUID, ATTR_CORE_NAME, ATTR_PMNC_COUNTERS);
            handleException();
        }

        //Check whether the pmu is v8, needed when hardware is 64 bit but kernel is 32 bit.
        bool isV8 = false;
        if (profileStr != nullptr) {
            if (profileStr[0] == '8') {
                isV8 = true;
            }
        }

        logg.logMessage("Found <%s %s=\"%s\" %s=\"%s\" %s=\"0x%05x\" %s=\"%d\" />",
                        TAG_PMU,
                        ATTR_CORE_NAME, coreName,
                        ATTR_PMNC_NAME, pmncName,
                        ATTR_CPUID, cpuid,
                        ATTR_PMNC_COUNTERS, pmncCounters);

        pmuXml.cpus.emplace_back(strdup(coreName), strdup(pmncName), lib::strdup_null(dtName),
                                 lib::strdup_null(speName), cpuid, pmncCounters, isV8);
    }

    for (mxml_node_t *node = mxmlFindElement(root, root, TAG_UNCORE_PMU, NULL, NULL, MXML_DESCEND); node != NULL;
            node = mxmlFindElement(node, root, TAG_UNCORE_PMU, NULL, NULL, MXML_DESCEND)) {
        const char * const pmncName = mxmlElementGetAttr(node, ATTR_PMNC_NAME);
        const char * const coreName = mxmlElementGetAttr(node, ATTR_CORE_NAME);
        const char * const pmncCountersStr = mxmlElementGetAttr(node, ATTR_PMNC_COUNTERS);
        int pmncCounters;
        if (!stringToInt(&pmncCounters, pmncCountersStr, 0)) {
            logg.logError("The pmnc_counters for '%s' in pmu XML is not an integer", pmncName);
            handleException();
        }
        const char * const hasCyclesCounterStr = mxmlElementGetAttr(node, ATTR_HAS_CYCLES_COUNTER);
        const bool hasCyclesCounter = stringToBool(hasCyclesCounterStr, true);
        if (pmncName == NULL || coreName == NULL || pmncCounters == 0) {
            logg.logError("An uncore_pmu from the pmu XML is missing one or more of the required attributes (%s, %s and %s)", ATTR_PMNC_NAME, ATTR_CORE_NAME, ATTR_PMNC_COUNTERS);
            handleException();
        }

        // check if the path contains a wildcard
        if (strstr(pmncName, UNCORE_PMNC_NAME_WILDCARD) == nullptr)
        {
            // no - just add one item
            logg.logMessage("Found <%s %s=\"%s\" %s=\"%s\" %s=\"%s\" %s=\"%d\" />",
                            TAG_UNCORE_PMU,
                            ATTR_CORE_NAME, coreName,
                            ATTR_PMNC_NAME, pmncName,
                            ATTR_HAS_CYCLES_COUNTER, hasCyclesCounter ? "true" : "false",
                            ATTR_PMNC_COUNTERS, pmncCounters);

            pmuXml.uncores.emplace_back(strdup(coreName), strdup(pmncName), pmncCounters, hasCyclesCounter);
        }
        else
        {
            // yes - add actual matching items from filesystem
            bool matched = false;
            std::unique_ptr<DIR, int (*)(DIR*)> dir { opendir(PERF_DEVICES), closedir };
            if (dir != nullptr) {
                struct dirent * dirent;
                while ((dirent = readdir(dir.get())) != NULL) {
                    if (matchPMUName(pmncName, dirent->d_name)) {
                        // matched dirent
                        logg.logMessage("Found <%s %s=\"%s\" %s=\"%s\" %s=\"%s\" %s=\"%d\" />",
                                        TAG_UNCORE_PMU,
                                        ATTR_CORE_NAME, coreName,
                                        ATTR_PMNC_NAME, dirent->d_name,
                                        ATTR_HAS_CYCLES_COUNTER, hasCyclesCounter ? "true" : "false",
                                        ATTR_PMNC_COUNTERS, pmncCounters);
                        new UncorePmu(strdup(coreName), strdup(dirent->d_name), pmncCounters, hasCyclesCounter);
                        matched = true;
                    }
                }
            }

            if (!matched) {
                logg.logMessage("No matching devices for wildcard <%s %s=\"%s\" %s=\"%s\" %s=\"%s\" %s=\"%d\" />",
                                TAG_UNCORE_PMU,
                                ATTR_CORE_NAME, coreName,
                                ATTR_PMNC_NAME, pmncName,
                                ATTR_HAS_CYCLES_COUNTER, hasCyclesCounter ? "true" : "false",
                                ATTR_PMNC_COUNTERS, pmncCounters);
            }
        }
    }

    mxmlDelete(root);
}
Example #2
0
void TimeLapseWidget::startShooting()
{
    if (running) {
        return;
    }

    if( !curCam ) {
        try {

            curCam = new QCCamera( attachedCameras->currentIndex(),
                                   attachedCameras->currentText(),
                                   saveDirectory->text());

        } catch (std::runtime_error re) {

            handleException(&re, tr("Check that no other instances of the program are running, and that your camera is plugged in and turned on."));
            return;
        }
    } else {

        try {

            curCam->setSaveDir( saveDirectory->text());

        } catch (std::runtime_error re) {
            handleException(&re);
            return;
        }
    }

    imagesCreated.clear();
    shootingStarted();

    startButton->setEnabled( false );
    stopButton->setEnabled( true );
    directoryButton->setEnabled( false );
    intervalBox->setEnabled( false );
    lengthOfTimeBox->setEnabled( false );
    saveDirectory->setEnabled( false );
    attachedCameras->setEnabled( false );
    seconds->setEnabled( false );
    minutes->setEnabled( false );

    interval = intervalBox->value();

    numPics = 0;
    emit statusUpdate(tr("Pictures taken: %1").arg(numPics) );

    // Add 2 seconds to account for shutter delay and lag

    // TODO: Figure out exactly what timing we want.
    // For the short intervals I'm testing with, there are cases where I take a picture every 2 seconds, for 10 seconds, and it only takes 4 pictures.
    // Even for longer intervals and durations, the number of pictures has been one or two less than expected.
    // We need to figure out:
    //    Is it more important to take a specific number of pictures, or run for a certain amount of time?
    //    Does it even matter?
    //    Maybe we can specify a run time and a "movie time"?  Like "Take pictures for an hour and make a movie 60 seconds long"
    //       That doesn't solve the problem entirely, but doesn't emphasize the exact number of pictures so much
    // Also, should the first picture be taken immediately when the "Start" button is pressed, or should it wait for one interval first?
    stopTime = new QTime( QTime::currentTime().addSecs( ( lengthOfTimeBox->time().hour() * 60 * 60 ) + ( lengthOfTimeBox->time().minute() * 60 ) + lengthOfTimeBox->time().second() + 2) );

    if( seconds->isChecked() )
        timerId = startTimer( 1000 * interval );
    else
        timerId = startTimer( 1000 * (interval * 60) );

    running = true;
}
int main(int argc, char** argv) {

	UTIL_TIME_SCOPE("main");

	try {

		util::ProgramOptions::init(argc, argv);
		logger::LogManager::init();

		util::point<float, 3> resolution(
				optionResX,
				optionResY,
				optionResZ);
		util::point<float, 3> offset(
				optionOffsetX,
				optionOffsetY,
				optionOffsetZ);

		Crag* crag = new Crag();
		CragVolumes* volumes = new CragVolumes(*crag);
		Costs* mergeCosts = 0;

		CragImport import;

		bool alreadyDownsampled = false;

		if (optionMergeTree) {

			UTIL_TIME_SCOPE("read CRAG from mergetree");

			// get information about the image to read
			std::string mergeTreePath = optionMergeTree;

			if (boost::filesystem::is_directory(boost::filesystem::path(mergeTreePath))) {

				std::vector<std::string> files = getImageFiles(mergeTreePath);

				// process one image after another
				std::vector<std::unique_ptr<Crag>> crags(files.size());
				std::vector<std::unique_ptr<CragVolumes>> cragsVolumes;
				for (auto& c : crags) {
					c = std::unique_ptr<Crag>(new Crag);
					cragsVolumes.push_back(std::unique_ptr<CragVolumes>(new CragVolumes(*c)));
				}

				int i = 0;
				for (std::string file : files) {
					
					LOG_USER(logger::out) << "reading crag from " << file << std::endl;

					import.readCrag(file, *crags[i], *cragsVolumes[i], resolution, offset + util::point<float, 3>(0, 0, resolution.z()*i));
					i++;
				}

				if (optionDownsampleCrag) {

					UTIL_TIME_SCOPE("downsample CRAG");

					DownSampler downSampler(optionMinCandidateSize.as<int>());

					std::vector<std::unique_ptr<Crag>> downSampledCrags(crags.size());
					std::vector<std::unique_ptr<CragVolumes>> downSampledVolumes(crags.size());

					for (int i = 0; i < crags.size(); i++) {

						downSampledCrags[i]   = std::unique_ptr<Crag>(new Crag());
						downSampledVolumes[i] = std::unique_ptr<CragVolumes>(new CragVolumes(*downSampledCrags[i]));

						downSampler.process(*crags[i], *cragsVolumes[i], *downSampledCrags[i], *downSampledVolumes[i]);
					}

					std::swap(cragsVolumes, downSampledVolumes);
					std::swap(crags, downSampledCrags);

					// prevent another downsampling on the candidates added by 
					// the combiner
					alreadyDownsampled = true;
				}

				// combine crags
				CragStackCombiner combiner;
				combiner.combine(crags, cragsVolumes, *crag, *volumes);

			} else {

				import.readCrag(mergeTreePath, *crag, *volumes, resolution, offset);
			}

		} else if (optionSupervoxels.as<bool>() && (optionMergeHistory.as<bool>() || optionCandidateSegmentation.as<bool>())) {

			UTIL_TIME_SCOPE("read CRAG from merge history");

			if (optionMergeHistory) {

				std::string mergeHistoryPath = optionMergeHistory;

				if (boost::filesystem::is_directory(boost::filesystem::path(mergeHistoryPath))) {

					// get all merge-history files
					std::vector<std::string> mhFiles;
					for (boost::filesystem::directory_iterator i(mergeHistoryPath); i != boost::filesystem::directory_iterator(); i++)
						if (!boost::filesystem::is_directory(*i) && (
							i->path().extension() == ".txt" ||
							i->path().extension() == ".dat"
						))
							mhFiles.push_back(i->path().native());
					std::sort(mhFiles.begin(), mhFiles.end());

					// get all supervoxel files
					std::vector<std::string> svFiles = getImageFiles(optionSupervoxels);

					// process one image after another
					std::vector<std::unique_ptr<Crag>> crags(mhFiles.size());
					std::vector<std::unique_ptr<CragVolumes>> cragsVolumes;
					for (auto& c : crags) {
						c = std::unique_ptr<Crag>(new Crag);
						cragsVolumes.push_back(std::unique_ptr<CragVolumes>(new CragVolumes(*c)));
					}

					for (int i = 0; i < mhFiles.size(); i++) {
						
						LOG_USER(logger::out) << "reading crag from supervoxel file " << svFiles[i] << " and merge history " << mhFiles[i] << std::endl;

						Costs mergeCosts(*crags[i]);
						import.readCragFromMergeHistory(svFiles[i], mhFiles[i], *crags[i], *cragsVolumes[i], resolution, offset + util::point<float, 3>(0, 0, resolution.z()*i), mergeCosts);
					}

					if (optionDownsampleCrag) {

						UTIL_TIME_SCOPE("downsample CRAG");

						DownSampler downSampler(optionMinCandidateSize.as<int>());

						std::vector<std::unique_ptr<Crag>> downSampledCrags(crags.size());
						std::vector<std::unique_ptr<CragVolumes>> downSampledVolumes(crags.size());

						for (int i = 0; i < crags.size(); i++) {

							downSampledCrags[i]   = std::unique_ptr<Crag>(new Crag());
							downSampledVolumes[i] = std::unique_ptr<CragVolumes>(new CragVolumes(*downSampledCrags[i]));

							downSampler.process(*crags[i], *cragsVolumes[i], *downSampledCrags[i], *downSampledVolumes[i]);
						}

						std::swap(cragsVolumes, downSampledVolumes);
						std::swap(crags, downSampledCrags);

						// prevent another downsampling on the candidates added by 
						// the combiner
						alreadyDownsampled = true;
					}

					// combine crags
					CragStackCombiner combiner;
					combiner.combine(crags, cragsVolumes, *crag, *volumes);

				} else {

					mergeCosts = new Costs(*crag);
					import.readCragFromMergeHistory(optionSupervoxels, optionMergeHistory, *crag, *volumes, resolution, offset, *mergeCosts);

				}

			} else
				import.readCragFromCandidateSegmentation(optionSupervoxels, optionCandidateSegmentation, *crag, *volumes, resolution, offset);

		} else {

			LOG_ERROR(logger::out)
					<< "at least one of mergetree or (supervoxels && mergeHistory) "
					<< "have to be given to create a CRAG" << std::endl;

			return 1;
		}

		if (optionDownsampleCrag && !alreadyDownsampled) {

			UTIL_TIME_SCOPE("downsample CRAG");

			Crag* downSampled = new Crag();
			CragVolumes* downSampledVolumes = new CragVolumes(*downSampled);

			if (optionMinCandidateSize) {

				DownSampler downSampler(optionMinCandidateSize.as<int>());
				downSampler.process(*crag, *volumes, *downSampled, *downSampledVolumes);
			} else {

				DownSampler downSampler;
				downSampler.process(*crag, *volumes, *downSampled, *downSampledVolumes);
			}

			delete crag;
			delete volumes;
			if (mergeCosts) {
				delete mergeCosts;
				mergeCosts = 0;
			}
			crag = downSampled;
			volumes = downSampledVolumes;
		}

		{
			UTIL_TIME_SCOPE("find CRAG adjacencies");

			PlanarAdjacencyAnnotator annotator(PlanarAdjacencyAnnotator::Direct);
			annotator.annotate(*crag, *volumes);
		}

		// Statistics

		int numNodes = 0;
		int numRootNodes = 0;
		double sumSubsetDepth = 0;
		int maxSubsetDepth = 0;
		int minSubsetDepth = 1e6;

		for (Crag::NodeIt n(*crag); n != lemon::INVALID; ++n) {

			if (crag->isRootNode(n)) {

				int depth = crag->getLevel(n);

				sumSubsetDepth += depth;
				minSubsetDepth = std::min(minSubsetDepth, depth);
				maxSubsetDepth = std::max(maxSubsetDepth, depth);
				numRootNodes++;
			}

			numNodes++;
		}

		int numAdjEdges = 0;
		for (Crag::EdgeIt e(*crag); e != lemon::INVALID; ++e)
			numAdjEdges++;
		int numSubEdges = 0;
		for (Crag::SubsetArcIt e(*crag); e != lemon::INVALID; ++e)
			numSubEdges++;

		LOG_USER(logger::out) << "created CRAG" << std::endl;
		LOG_USER(logger::out) << "\t# nodes          : " << numNodes << std::endl;
		LOG_USER(logger::out) << "\t# root nodes     : " << numRootNodes << std::endl;
		LOG_USER(logger::out) << "\t# adjacencies    : " << numAdjEdges << std::endl;
		LOG_USER(logger::out) << "\t# subset edges   : " << numSubEdges << std::endl;
		LOG_USER(logger::out) << "\tmax subset depth : " << maxSubsetDepth << std::endl;
		LOG_USER(logger::out) << "\tmin subset depth : " << minSubsetDepth << std::endl;
		LOG_USER(logger::out) << "\tmean subset depth: " << sumSubsetDepth/numRootNodes << std::endl;

		// Store CRAG and volumes

		boost::filesystem::remove(optionProjectFile.as<std::string>());
		Hdf5CragStore store(optionProjectFile.as<std::string>());

		{
			UTIL_TIME_SCOPE("saving CRAG");

			store.saveCrag(*crag);
			store.saveVolumes(*volumes);
			if (mergeCosts)
				store.saveCosts(*crag, *mergeCosts, "merge-scores");
		}

		{
			UTIL_TIME_SCOPE("saving volumes");

			Hdf5VolumeStore volumeStore(optionProjectFile.as<std::string>());

			ExplicitVolume<float> intensities = readVolume<float>(getImageFiles(optionIntensities));
			intensities.setResolution(resolution);
			intensities.setOffset(offset);
			intensities.normalize();
			volumeStore.saveIntensities(intensities);

			if (optionGroundTruth) {

				ExplicitVolume<int> groundTruth = readVolume<int>(getImageFiles(optionGroundTruth));

				if (optionExtractGroundTruthLabels) {

					vigra::MultiArray<3, int> tmp(groundTruth.data().shape());
					vigra::labelMultiArrayWithBackground(
							groundTruth.data(),
							tmp);
					groundTruth.data() = tmp;
				}

				groundTruth.setResolution(resolution);
				groundTruth.setOffset(offset);
				volumeStore.saveGroundTruth(groundTruth);
			}

			if (optionBoundaries) {

				ExplicitVolume<float> boundaries = readVolume<float>(getImageFiles(optionBoundaries));
				boundaries.setResolution(resolution);
				boundaries.setOffset(offset);
				boundaries.normalize();
				volumeStore.saveBoundaries(boundaries);
			}

			bool atLeastOneAffinity = optionXAffinities || optionYAffinities || optionZAffinities;
			bool allAfinities = optionXAffinities && optionYAffinities && optionZAffinities;

			if (atLeastOneAffinity) {

				if (!allAfinities) {

					LOG_ERROR(logger::out)
							<< "One of the affinities was not provided. "
							<< "Affinities will be ignored." << std::endl;

				} else {

					ExplicitVolume<float> xAffinities = readVolume<float>(getImageFiles(optionXAffinities));
					ExplicitVolume<float> yAffinities = readVolume<float>(getImageFiles(optionYAffinities));
					ExplicitVolume<float> zAffinities = readVolume<float>(getImageFiles(optionZAffinities));

					volumeStore.saveAffinities( xAffinities, yAffinities, zAffinities);
				}
			}
		}

		delete crag;
		delete volumes;
		delete mergeCosts;

		if (optionImportTrainingResult) {

			LOG_USER(logger::out)
							<< "importing training results from "
							<< optionImportTrainingResult.as<std::string>()
							<< std::endl;

			Hdf5CragStore trainingStore(optionImportTrainingResult.as<std::string>());

			FeatureWeights weights;
			FeatureWeights min;
			FeatureWeights max;

			trainingStore.retrieveFeatureWeights(weights);
			trainingStore.retrieveFeaturesMin(min);
			trainingStore.retrieveFeaturesMax(max);

			store.saveFeatureWeights(weights);
			store.saveFeaturesMin(min);
			store.saveFeaturesMax(max);
		}

	} catch (Exception& e) {

		handleException(e, std::cerr);
	}
}
Example #4
0
bool StandardRequestHandler::operator()(const std::string& request_path, const std::string& full_request_path, const osc::ReceivedMessage& m, const IpEndpointName& remoteEndPoint)
{
    try
    {
        std::string path = osgDB::getFilePath(full_request_path);
        std::string last_elem = osgDB::getSimpleFileName(full_request_path);

        osg::ref_ptr<osgGA::Event> ea = getDevice()->getOrCreateUserDataEvent();
        osg::UserDataContainer* udc = ea->getOrCreateUserDataContainer();


        ea->setName(_treatFirstArgumentAsValueName ? full_request_path : path);
        udc->setName(ea->getName());

        if (m.ArgumentCount() == 0) {
            return true;
        }

        // if we have only one argument, get it and save it to the udc
        else if (m.ArgumentCount() == 1)
        {
            addArgumentToUdc(udc, last_elem, m.ArgumentsBegin());
            return true;
        }
        else
        {
            unsigned int i(0);
            osc::ReceivedMessageArgumentIterator start = m.ArgumentsBegin();
            if ((_treatFirstArgumentAsValueName) && (start->TypeTag() == osc::STRING_TYPE_TAG))
            {
                last_elem = start->AsString();
                ++start;
                // if we hav only 2 arguments, then save the value and return
                if (m.ArgumentCount() == 2)
                {
                    addArgumentToUdc(udc, last_elem, start);
                    return true;
                }
            }
            std::vector<float> float_vec;
            std::vector<double> double_vec;
            bool mixed_arguments(false);
            for(osc::ReceivedMessageArgumentIterator itr = start; itr != m.ArgumentsEnd(); ++itr, ++i)
            {
                if(itr->TypeTag() == osc::FLOAT_TYPE_TAG)
                {
                    float_vec.push_back(itr->AsFloat());
                }
                else if(itr->TypeTag() == osc::DOUBLE_TYPE_TAG)
                {
                    double_vec.push_back(itr->AsDouble());
                }
                else if(itr->TypeTag() == osc::INT32_TYPE_TAG)
                {
                    float_vec.push_back(itr->AsInt32());
                }
                else {
                    mixed_arguments = true;
                    break;
                }
            }
            if (!mixed_arguments)
            {
                unsigned int sum = float_vec.size() + double_vec.size();
                if (sum == float_vec.size())
                {
                    if (addNativeTypeFromVector(udc, last_elem, float_vec))
                        return true;
                }
                else if (sum == double_vec.size())
                {
                    if (addNativeTypeFromVector(udc, last_elem, double_vec))
                        return true;
                }
            }

            for(osc::ReceivedMessageArgumentIterator itr = start; itr != m.ArgumentsEnd(); ++itr, ++i)
            {
                std::ostringstream ss;
                ss << last_elem << "_" << i;
                addArgumentToUdc(udc, ss.str(), itr);
            }
        }
        return true;

    }
    catch(osc::Exception& e)
    {
        handleException(e);
        return false;
    }
    return false;
}
Example #5
0
void Sender::writeData(const char* data, int length, int type) {
	if (length < 0 || (data == NULL && length > 0)) {
		return;
	}

	// Multiple threads call writeData()
	if (pthread_mutex_lock(&mSendMutex) != 0) {
		logg->logError("pthread_mutex_lock failed");
		handleException();
	}

	// Send data over the socket connection
	if (mDataSocket) {
		// Start alarm
		const int alarmDuration = 8;
		alarm(alarmDuration);

		// Send data over the socket, sending the type and size first
		logg->logMessage("Sending data with length %d", length);
		if (type != RESPONSE_APC_DATA) {
			// type and length already added by the Collector for apc data
			unsigned char header[5];
			header[0] = type;
			Buffer::writeLEInt(header + 1, length);
			mDataSocket->send((char*)&header, sizeof(header));
		}

		// 100Kbits/sec * alarmDuration sec / 8 bits/byte
		const int chunkSize = 100*1000 * alarmDuration / 8;
		int pos = 0;
		while (true) {
			mDataSocket->send(data + pos, min(length - pos, chunkSize));
			pos += chunkSize;
			if (pos >= length) {
				break;
			}

			// Reset the alarm
			alarm(alarmDuration);
			logg->logMessage("Resetting the alarm");
		}

		// Stop alarm
		alarm(0);
	}

	// Write data to disk as long as it is not meta data
	if (mDataFile && type == RESPONSE_APC_DATA) {
		logg->logMessage("Writing data with length %d", length);
		// Send data to the data file
		if (fwrite(data, 1, length, mDataFile) != (unsigned int)length) {
			logg->logError("Failed writing binary file %s", mDataFileName);
			handleException();
		}
	}

	if (pthread_mutex_unlock(&mSendMutex) != 0) {
		logg->logError("pthread_mutex_unlock failed");
		handleException();
	}
}
void DriverSource::run() {
	// Get the initial pointer to the collect buffer
	char *collectBuffer = mFifo->start();
	int bytesCollected = 0;

	logg->logMessage("********** Profiling started **********");

	// Set the maximum backtrace depth
	if (writeReadDriver("/dev/gator/backtrace_depth", &gSessionData->mBacktraceDepth)) {
		logg->logError(__FILE__, __LINE__, "Unable to set the driver backtrace depth");
		handleException();
	}

	// open the buffer which calls userspace_buffer_open() in the driver
	mBufferFD = open("/dev/gator/buffer", O_RDONLY | O_CLOEXEC);
	if (mBufferFD < 0) {
		logg->logError(__FILE__, __LINE__, "The gator driver did not set up properly. Please view the linux console or dmesg log for more information on the failure.");
		handleException();
	}

	// set the tick rate of the profiling timer
	if (writeReadDriver("/dev/gator/tick", &gSessionData->mSampleRate) != 0) {
		logg->logError(__FILE__, __LINE__, "Unable to set the driver tick");
		handleException();
	}

	// notify the kernel of the response type
	int response_type = gSessionData->mLocalCapture ? 0 : RESPONSE_APC_DATA;
	if (writeDriver("/dev/gator/response_type", response_type)) {
		logg->logError(__FILE__, __LINE__, "Unable to write the response type");
		handleException();
	}

	// Set the live rate
	if (writeReadDriver("/dev/gator/live_rate", &gSessionData->mLiveRate)) {
		logg->logError(__FILE__, __LINE__, "Unable to set the driver live rate");
		handleException();
	}

	logg->logMessage("Start the driver");

	// This command makes the driver start profiling by calling gator_op_start() in the driver
	if (writeDriver("/dev/gator/enable", "1") != 0) {
		logg->logError(__FILE__, __LINE__, "The gator driver did not start properly. Please view the linux console or dmesg log for more information on the failure.");
		handleException();
	}

	lseek(mBufferFD, 0, SEEK_SET);

	sem_post(mStartProfile);

	pthread_t bootstrapThreadID;
	if (pthread_create(&bootstrapThreadID, NULL, bootstrapThreadStatic, this) != 0) {
		logg->logError(__FILE__, __LINE__, "Unable to start the gator_bootstrap thread");
		handleException();
	}

	// Collect Data
	do {
		// This command will stall until data is received from the driver
		// Calls event_buffer_read in the driver
		errno = 0;
		bytesCollected = read(mBufferFD, collectBuffer, mBufferSize);

		// If read() returned due to an interrupt signal, re-read to obtain the last bit of collected data
		if (bytesCollected == -1 && errno == EINTR) {
			bytesCollected = read(mBufferFD, collectBuffer, mBufferSize);
		}

		// return the total bytes written
		logg->logMessage("Driver read of %d bytes", bytesCollected);

		// In one shot mode, stop collection once all the buffers are filled
		if (gSessionData->mOneShot && gSessionData->mSessionIsActive) {
			if (bytesCollected == -1 || mFifo->willFill(bytesCollected)) {
				logg->logMessage("One shot");
				child->endSession();
			}
		}
		collectBuffer = mFifo->write(bytesCollected);
	} while (bytesCollected > 0);

	logg->logMessage("Exit collect data loop");

	pthread_join(bootstrapThreadID, NULL);
}
void ExternalSource::run() {
	int pipefd[2];

	prctl(PR_SET_NAME, (unsigned long)&"gatord-external", 0, 0, 0);

	if (pipe_cloexec(pipefd) != 0) {
		logg->logError(__FILE__, __LINE__, "pipe failed");
		handleException();
	}
	mInterruptFd = pipefd[1];

	if (!mMonitor.add(pipefd[0])) {
		logg->logError(__FILE__, __LINE__, "Monitor::add failed");
		handleException();
	}

	// Notify annotate clients to retry connecting to gatord
	gSessionData->annotateListener.signal();

	while (gSessionData->mSessionIsActive) {
		struct epoll_event events[16];
		// Clear any pending sem posts
		while (sem_trywait(&mBufferSem) == 0);
		int ready = mMonitor.wait(events, ARRAY_LENGTH(events), -1);
		if (ready < 0) {
			logg->logError(__FILE__, __LINE__, "Monitor::wait failed");
			handleException();
		}

		const uint64_t currTime = getTime();

		for (int i = 0; i < ready; ++i) {
			const int fd = events[i].data.fd;
			if (fd == mMveStartupUds.getFd()) {
				// Mali Video Engine says it's alive
				int client = mMveStartupUds.acceptConnection();
				// Don't read from this connection, establish a new connection to Mali-V500
				close(client);
				if (!connectMve()) {
					logg->logError(__FILE__, __LINE__, "Unable to configure incoming Mali video connection");
					handleException();
				}
			} else if (fd == mMaliStartupUds.getFd()) {
				// Mali Graphics says it's alive
				int client = mMaliStartupUds.acceptConnection();
				// Don't read from this connection, establish a new connection to Mali Graphics
				close(client);
				if (!connectMali()) {
					logg->logError(__FILE__, __LINE__, "Unable to configure incoming Mali graphics connection");
					handleException();
				}
			} else if (fd == mAnnotate.getFd()) {
				int client = mAnnotate.acceptConnection();
				if (!setNonblock(client) || !mMonitor.add(client)) {
					logg->logError(__FILE__, __LINE__, "Unable to set socket options on incoming annotation connection");
					handleException();
				}
			} else if (fd == pipefd[0]) {
				// Means interrupt has been called and mSessionIsActive should be reread
			} else {
				/* This can result in some starvation if there are multiple
				 * threads which are annotating heavily, but it is not
				 * recommended that threads annotate that much as it can also
				 * starve out the gator data.
				 */
				while (gSessionData->mSessionIsActive) {
					// Wait until there is enough room for the fd, two headers and two ints
					waitFor(7*Buffer::MAXSIZE_PACK32 + 2*sizeof(uint32_t));
					mBuffer.packInt(fd);
					const int contiguous = mBuffer.contiguousSpaceAvailable();
					const int bytes = read(fd, mBuffer.getWritePos(), contiguous);
					if (bytes < 0) {
						if (errno == EAGAIN) {
							// Nothing left to read
							mBuffer.commit(currTime);
							break;
						}
						// Something else failed, close the socket
						mBuffer.commit(currTime);
						mBuffer.packInt(-1);
						mBuffer.packInt(fd);
						mBuffer.commit(currTime);
						close(fd);
						break;
					} else if (bytes == 0) {
						// The other side is closed
						mBuffer.commit(currTime);
						mBuffer.packInt(-1);
						mBuffer.packInt(fd);
						mBuffer.commit(currTime);
						close(fd);
						break;
					}

					mBuffer.advanceWrite(bytes);
					mBuffer.commit(currTime);

					// Short reads also mean nothing is left to read
					if (bytes < contiguous) {
						break;
					}
				}
			}
		}
	}

	mBuffer.setDone();

	if (mMveUds >= 0) {
		gSessionData->maliVideo.stop(mMveUds);
	}

	mInterruptFd = -1;
	close(pipefd[0]);
	close(pipefd[1]);
}
Example #8
0
void Source::start() {
	if (pthread_create(&mThreadID, NULL, runStatic, this)) {
		logg->logError(__FILE__, __LINE__, "Failed to create source thread");
		handleException();
	}
}
Example #9
0
Omm::AvStream::Meta*
VlcTagger::tag(const std::string& uri)
{
    LOGNS(Omm::Av, upnpav, debug, "vlc tagger tagging: " + uri);

    VlcMeta* pMeta = new VlcMeta;

#if LIBVLC_VERSION_INT < 0x110
    _pVlcMedia = libvlc_media_new(_pVlcInstance, uri.c_str(), _pException);
#else
    _pVlcMedia = libvlc_media_new_location(_pVlcInstance, uri.c_str());
#endif
    handleException();

#if LIBVLC_VERSION_INT < 0x110
#else
    libvlc_media_parse(_pVlcMedia);
#endif

#if LIBVLC_VERSION_INT < 0x110
    char* pTitle = libvlc_media_get_meta(_pVlcMedia, libvlc_meta_Title, _pException);
#else
    char* pTitle = libvlc_media_get_meta(_pVlcMedia, libvlc_meta_Title);
#endif
    handleException();
    if (pTitle) {
        pMeta->setTag("title", std::string(pTitle));
    }

#if LIBVLC_VERSION_INT < 0x110
    char* pArtist = libvlc_media_get_meta(_pVlcMedia, libvlc_meta_Artist, _pException);
#else
    char* pArtist = libvlc_media_get_meta(_pVlcMedia, libvlc_meta_Artist);
#endif
    handleException();
    if (pArtist) {
        pMeta->setTag("artist", std::string(pArtist));
    }

#if LIBVLC_VERSION_INT < 0x110
    char* pAlbum = libvlc_media_get_meta(_pVlcMedia, libvlc_meta_Album, _pException);
#else
    char* pAlbum = libvlc_media_get_meta(_pVlcMedia, libvlc_meta_Album);
#endif
    handleException();
    if (pAlbum) {
        pMeta->setTag("album", std::string(pAlbum));
    }

#if LIBVLC_VERSION_INT < 0x110
    char* pTrack = libvlc_media_get_meta(_pVlcMedia, libvlc_meta_TrackNumber, _pException);
#else
    char* pTrack = libvlc_media_get_meta(_pVlcMedia, libvlc_meta_TrackNumber);
#endif
    handleException();
    if (pTrack) {
        pMeta->setTag("track", std::string(pTrack));
    }

#if LIBVLC_VERSION_INT < 0x110
    libvlc_time_t duration = libvlc_media_get_duration(_pVlcMedia, _pException);
#else
    libvlc_time_t duration = libvlc_media_get_duration(_pVlcMedia);
#endif
    handleException();
    if (duration) {
        pMeta->setTag("duration", Poco::NumberFormatter::format(duration));
    }

    libvlc_media_release(_pVlcMedia);

    // vlc libs need to play the data in order to analyse the streams
    // thus we make a simple filename based media type detection
    Poco::Path path(uri);
    // try to get a filename extension for type of media
    std::string extension = Poco::toLower(path.getExtension());
//    LOGNS(Omm::Av, upnpav, debug, "vlc tagger extension: " + extension);

    Omm::AvStream::Meta::ContainerFormat containerFormat = Omm::AvStream::Meta::CF_UNKNOWN;
    if (extension == "mp3") {
        pMeta->_mime = Omm::Av::Mime::AUDIO_MPEG;
        containerFormat = Omm::AvStream::Meta::CF_AUDIO;
    }
    else if (extension == "wma" || extension == "ogg" || extension == "wav") {
        pMeta->_mime = Omm::Av::Mime::TYPE_AUDIO;
        containerFormat = Omm::AvStream::Meta::CF_AUDIO;
    }
    else if (extension == "mp4" || extension == "mpeg" || extension == "mpg") {
        pMeta->_mime = Omm::Av::Mime::VIDEO_MPEG;
        containerFormat = Omm::AvStream::Meta::CF_VIDEO;
    }
    else if (extension == "avi" || extension == "wmv" || extension == "flv") {
        pMeta->_mime = Omm::Av::Mime::TYPE_VIDEO;
        containerFormat = Omm::AvStream::Meta::CF_VIDEO;
    }
    else if (extension == "jpg" || extension == "png" || extension == "gif") {
        pMeta->_mime = Omm::Av::Mime::TYPE_IMAGE;
        containerFormat = Omm::AvStream::Meta::CF_IMAGE;
    }
    else if (extension == "m3u") {
        pMeta->_mime = Omm::Av::Mime::PLAYLIST;
        containerFormat = Omm::AvStream::Meta::CF_PLAYLIST;
    }

    if (containerFormat == Omm::AvStream::Meta::CF_AUDIO) {
        pMeta->_isStillImage = false;
        VlcStreamInfo* pStreamInfo = new VlcStreamInfo;
        pStreamInfo->_isAudio = true;
        pStreamInfo->_isVideo = false;
        pMeta->addStream(pStreamInfo);
    }
    else if (containerFormat == Omm::AvStream::Meta::CF_VIDEO) {
        pMeta->_isStillImage = false;
        VlcStreamInfo* pStreamInfo = new VlcStreamInfo;
        pStreamInfo->_isAudio = false;
        pStreamInfo->_isVideo = true;
        pMeta->addStream(pStreamInfo);
    }
    else if (containerFormat == Omm::AvStream::Meta::CF_IMAGE) {
        pMeta->_isStillImage = true;
        VlcStreamInfo* pStreamInfo = new VlcStreamInfo;
        pStreamInfo->_isAudio = false;
        pStreamInfo->_isVideo = false;
        pMeta->addStream(pStreamInfo);
    }
    else if (containerFormat == Omm::AvStream::Meta::CF_PLAYLIST) {
        pMeta->setIsPlaylist(true);
    }

    return pMeta;
}
Example #10
0
mxml_node_t *EventsXML::getTree() {
#include "events_xml.h" // defines and initializes char events_xml[] and int events_xml_len
	char path[PATH_MAX];
	mxml_node_t *xml = NULL;
	FILE *fl;

	// Avoid unused variable warning
	(void)events_xml_len;

	// Load the provided or default events xml
	if (gSessionData->mEventsXMLPath) {
		strncpy(path, gSessionData->mEventsXMLPath, PATH_MAX);
		fl = fopen_cloexec(path, "r");
		if (fl) {
			xml = mxmlLoadFile(NULL, fl, MXML_NO_CALLBACK);
			fclose(fl);
		}
	}
	if (xml == NULL) {
		logg->logMessage("Unable to locate events.xml, using default");
		xml = mxmlLoadString(NULL, (const char *)events_xml, MXML_NO_CALLBACK);
	}

	// Append additional events XML
	if (gSessionData->mEventsXMLAppend) {
		fl = fopen_cloexec(gSessionData->mEventsXMLAppend, "r");
		if (fl == NULL) {
			logg->logError("Unable to open additional events XML %s", gSessionData->mEventsXMLAppend);
			handleException();
		}
		mxml_node_t *append = mxmlLoadFile(NULL, fl, MXML_NO_CALLBACK);
		fclose(fl);

		mxml_node_t *events = mxmlFindElement(xml, xml, "events", NULL, NULL, MXML_DESCEND);
		if (!events) {
			logg->logError("Unable to find <events> node in the events.xml, please ensure the first two lines of events XML starts with:\n"
				       "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
				       "<events>");
			handleException();
		}

		XMLList *categoryList = NULL;
		XMLList *eventList = NULL;
		{
			// Make list of all categories in xml
			mxml_node_t *node = xml;
			while (true) {
				node = mxmlFindElement(node, xml, "category", NULL, NULL, MXML_DESCEND);
				if (node == NULL) {
					break;
				}
				categoryList = new XMLList(categoryList, node);
			}

			// Make list of all events in xml
			node = xml;
			while (true) {
				node = mxmlFindElement(node, xml, "event", NULL, NULL, MXML_DESCEND);
				if (node == NULL) {
					break;
				}
				eventList = new XMLList(eventList, node);
			}
		}

		// Handle events
		for (mxml_node_t *node = mxmlFindElement(append, append, "event", NULL, NULL, MXML_DESCEND),
		       *next = mxmlFindElement(node, append, "event", NULL, NULL, MXML_DESCEND);
		     node != NULL;
		     node = next, next = mxmlFindElement(node, append, "event", NULL, NULL, MXML_DESCEND)) {
			const char *const category = mxmlElementGetAttr(mxmlGetParent(node), "name");
			const char *const title = mxmlElementGetAttr(node, "title");
			const char *const name = mxmlElementGetAttr(node, "name");
			if (category == NULL || title == NULL || name == NULL) {
				logg->logError("Not all event XML nodes have the required title and name and parent name attributes");
				handleException();
			}

			// Replace any duplicate events
			for (XMLList *event = eventList; event != NULL; event = event->getPrev()) {
				const char *const category2 = mxmlElementGetAttr(mxmlGetParent(event->getNode()), "name");
				const char *const title2 = mxmlElementGetAttr(event->getNode(), "title");
				const char *const name2 = mxmlElementGetAttr(event->getNode(), "name");
				if (category2 == NULL || title2 == NULL || name2 == NULL) {
					logg->logError("Not all event XML nodes have the required title and name and parent name attributes");
					handleException();
				}

				if (strcmp(category, category2) == 0 && strcmp(title, title2) == 0 && strcmp(name, name2) == 0) {
					logg->logMessage("Replacing counter %s %s: %s", category, title, name);
					mxml_node_t *parent = mxmlGetParent(event->getNode());
					mxmlDelete(event->getNode());
					mxmlAdd(parent, MXML_ADD_AFTER, MXML_ADD_TO_PARENT, node);
					event->setNode(node);
					break;
				}
			}
		}

		// Handle categories
		for (mxml_node_t *node = strcmp(mxmlGetElement(append), "category") == 0 ? append : mxmlFindElement(append, append, "category", NULL, NULL, MXML_DESCEND),
		       *next = mxmlFindElement(node, append, "category", NULL, NULL, MXML_DESCEND);
		     node != NULL;
		     node = next, next = mxmlFindElement(node, append, "category", NULL, NULL, MXML_DESCEND)) {
			// After replacing duplicate events, a category may be empty
			if (mxmlGetFirstChild(node) == NULL) {
				continue;
			}

			const char *const name = mxmlElementGetAttr(node, "name");
			if (name == NULL) {
				logg->logError("Not all event XML categories have the required name attribute");
				handleException();
			}

			// Merge identically named categories
			bool merged = false;
			for (XMLList *category = categoryList; category != NULL; category = category->getPrev()) {
				const char *const name2 = mxmlElementGetAttr(category->getNode(), "name");
				if (name2 == NULL) {
					logg->logError("Not all event XML categories have the required name attribute");
					handleException();
				}

				if (strcmp(name, name2) == 0) {
					logg->logMessage("Merging category %s", name);
					while (true) {
						mxml_node_t *child = mxmlGetFirstChild(node);
						if (child == NULL) {
							break;
						}
						mxmlAdd(category->getNode(), MXML_ADD_AFTER, mxmlGetLastChild(category->getNode()), child);
					}
					merged = true;
					break;
				}
			}

			if (merged) {
				continue;
			}

			// Add new categories
			logg->logMessage("Appending category %s", name);
			mxmlAdd(events, MXML_ADD_AFTER, mxmlGetLastChild(events), node);
		}

		XMLList::free(eventList);
		XMLList::free(categoryList);

		mxmlDelete(append);
	}

	return xml;
}
bool ScriptGlobalObject::set(ScriptState* scriptState, const char* name, const ScriptObject& value)
{
    JSLock lock(SilenceAssertionsOnly);
    scriptState->lexicalGlobalObject()->putDirect(scriptState->globalData(), Identifier(scriptState, name), value.jsObject());
    return handleException(scriptState);
}
bool ScriptGlobalObject::remove(ScriptState* scriptState, const char* name)
{
    JSLock lock(SilenceAssertionsOnly);
    scriptState->lexicalGlobalObject()->deleteProperty(scriptState, Identifier(scriptState, name));
    return handleException(scriptState);
}
Example #13
0
void CCNDriver::readEvents(mxml_node_t *const) {
	struct stat st;
	if (stat("/sys/bus/event_source/devices/ccn", &st) != 0) {
		// Not found
		return;
	}

	int type;
	if (DriverSource::readIntDriver("/sys/bus/event_source/devices/ccn/type", &type) != 0) {
		logg.logError("Unable to read CCN-5xx type");
		handleException();
	}

	// Detect number of xps
	struct perf_event_attr pea;
	memset(&pea, 0, sizeof(pea));
	pea.type = type;
	pea.size = sizeof(pea);

	mXpCount = 1;
	while (true) {
		pea.config = getConfig(0, 0x08, 1, 0, 1) | mXpCount;
		if (!perfPoll(&pea)) {
			break;
		}
		mXpCount *= 2;
	};
	{
		int lower = mXpCount/2 + 1;
		while (lower < mXpCount) {
			int mid = (lower + mXpCount)/2;
			pea.config = getConfig(0, 0x08, 1, 0, 1) | mid;
			if (perfPoll(&pea)) {
				lower = mid + 1;
			} else {
				mXpCount = mid;
			}
		}
	}

	mNodeTypes = new NodeType[2*mXpCount];

	// Detect node types
	for (int i = 0; i < 2*mXpCount; ++i) {
		pea.config = getConfig(0, 0x04, 1, 0, 0) | i;
		if (perfPoll(&pea)) {
			mNodeTypes[i] = NT_HNF;
			continue;
		}

		pea.config = getConfig(0, 0x16, 1, 0, 0) | i;
		if (perfPoll(&pea)) {
			mNodeTypes[i] = NT_RNI;
			continue;
		}

		pea.config = getConfig(0, 0x10, 1, 0, 0) | i;
		if (perfPoll(&pea)) {
			mNodeTypes[i] = NT_SBAS;
			continue;
		}

		mNodeTypes[i] = NT_UNKNOWN;
	}
}
Example #14
0
void ScriptMessageHandler::closeContext()
{
	if (m_engine->hasUncaughtException())
		handleException();
	m_engine->popContext();
}
int main(int argc, char** argv)
{
	try {
		// init command line parser
		util::ProgramOptions::init(argc, argv);

		int stack_id = optionStackId.as<int>();
		std::string comp_dir = optionComponentDir.as<std::string>();
		std::string pg_host = optionPGHost.as<std::string>();
		std::string pg_user = optionPGUser.as<std::string>();
		std::string pg_pass = optionPGPassword.as<std::string>();
		std::string pg_dbase = optionPGDatabase.as<std::string>();


		std::cout << "Testing PostgreSQL stores with stack ID " << stack_id << std::endl;

		// init logger
		logger::LogManager::init();
		logger::LogManager::setGlobalLogLevel(logger::Debug);

		// create new project configuration
		ProjectConfiguration pc;
		pc.setBackendType(ProjectConfiguration::PostgreSql);
		StackDescription stack;
		stack.id = stack_id;
		pc.setCatmaidStack(Raw, stack);
		pc.setComponentDirectory(comp_dir);
		pc.setPostgreSqlHost(pg_host);
		pc.setPostgreSqlUser(pg_user);
		pc.setPostgreSqlPassword(pg_pass);
		pc.setPostgreSqlDatabase(pg_dbase);

		PostgreSqlSliceStore sliceStore(pc, Membrane);

		// Add first set of slices
		boost::shared_ptr<Slice> slice1 = createSlice(10, 0);
		boost::shared_ptr<Slice> slice2 = createSlice(10, 1);
		boost::shared_ptr<Slice> slice3 = createSlice(10, 2);

		Slices slices = Slices();
		slices.add(slice1);
		slices.add(slice2);
		slices.add(slice3);

		Block block(0, 0, 0);
		sliceStore.associateSlicesToBlock(slices, block);

		Blocks blocks;
		blocks.add(block);
		Blocks missingBlocks;

		boost::shared_ptr<Slices> retrievedSlices =
				sliceStore.getSlicesByBlocks(blocks, missingBlocks);

		// Create conflict set where each slice
		ConflictSet conflictSet1;
		conflictSet1.addSlice(slice1->hashValue());
		conflictSet1.addSlice(slice2->hashValue());
		conflictSet1.addSlice(slice3->hashValue());

		ConflictSets conflictSets;
		conflictSets.add(conflictSet1);

		sliceStore.associateConflictSetsToBlock(conflictSets, block);
		boost::shared_ptr<ConflictSets> retrievedConflictSets =
				sliceStore.getConflictSetsByBlocks(blocks, missingBlocks);
		for (const ConflictSet& cs : *retrievedConflictSets) {
			std::cout << "ConflictSet hash: " << hash_value(cs);

			for (const SliceHash& sh : cs.getSlices()) {
				std::cout << " Slice hash: " << sh;
			}

			std::cout << std::endl;
		}

		PostgreSqlSegmentStore segmentStore(pc, Membrane);
		util::box<unsigned int, 2> segmentBounds(0, 0, 0, 0);
		std::vector<double> segmentFeatures;
		segmentFeatures.push_back(0.0);
		segmentFeatures.push_back(1.0);
		segmentFeatures.push_back(2.0);
		SegmentDescription segment(0, segmentBounds);
		segment.addLeftSlice(slice1->hashValue());
		segment.addRightSlice(slice2->hashValue());
		segment.setFeatures(segmentFeatures);

		boost::shared_ptr<SegmentDescriptions> segments = boost::make_shared<SegmentDescriptions>();
		segments->add(segment);

		segmentStore.associateSegmentsToBlock(*segments, block);

		boost::shared_ptr<SegmentDescriptions> retrievedSegments =
				segmentStore.getSegmentsByBlocks(blocks, missingBlocks, false);

	} catch (boost::exception& e) {

		handleException(e, std::cerr);
	}
}