예제 #1
0
void RobustnessTestProvider::methodWithDelayedResponse(
        const std::int32_t& delayArg,
        std::function<void(const std::string& stringOut)> onSuccess,
        std::function<void(const joynr::exceptions::ProviderRuntimeException& exception)> onError)
{
    JOYNR_LOG_WARN(logger(), "methodWithDelayedResponse - START");

    std::this_thread::sleep_for(std::chrono::milliseconds(delayArg));

    JOYNR_LOG_WARN(logger(), "methodWithDelayedResponse - OK");
    onSuccess("done");
}
예제 #2
0
void RobustnessTestProvider::methodToFireBroadcastWithSingleStringParameter(
        std::function<void()> onSuccess,
        std::function<void(const joynr::exceptions::ProviderRuntimeException& exception)> onError)
{
    std::ignore = onError;
    JOYNR_LOG_WARN(
            logger(), "**********************************************************************");
    JOYNR_LOG_WARN(logger(),
                   "* RobustnessProvider::methodToFireBroadcastWithSingleStringParameter called");
    JOYNR_LOG_WARN(
            logger(), "**********************************************************************");
    std::string stringOut = "boom";
    fireBroadcastWithSingleStringParameter(stringOut);
    onSuccess();
}
예제 #3
0
void ParticipantIdStorage::loadEntriesFromFile()
{
    if (!joynr::util::fileExists(fileName)) {
        return;
    }

    JOYNR_LOG_TRACE(logger(), "Attempting to load ParticipantIdStorage from: {}", fileName);

    boost::property_tree::ptree pt;
    WriteLocker lockAccessToStorage(storageMutex);
    try {
        boost::property_tree::ini_parser::read_ini(fileName, pt);
        for (boost::property_tree::ptree::const_iterator it = pt.begin(); it != pt.end(); ++it) {
            StorageItem item{it->first, it->second.data()};
            auto retVal = storage.insert(std::move(item));
            assert(retVal.second);
        }
    } catch (const std::exception& ex) {
        JOYNR_LOG_WARN(logger(),
                       "Cannot read participantId storage file {}. Removing file. Exception: {}",
                       fileName,
                       ex.what());
        std::remove(fileName.c_str());
    }

    // set entriesWrittenToDisk to the size of the storage
    entriesWrittenToDisk = storage.get<participantIdStorageTags::write>().size();
    JOYNR_LOG_TRACE(logger(), "Loaded {} entries.", entriesWrittenToDisk);
}
types::DiscoveryEntryWithMetaInfo QosArbitrationStrategyFunction::select(
        const std::map<std::string, types::CustomParameter> customParameters,
        const std::vector<types::DiscoveryEntryWithMetaInfo>& discoveryEntries) const
{
    std::ignore = customParameters;
    auto selectedDiscoveryEntryIt = discoveryEntries.cend();
    std::int64_t highestPriority = types::ProviderQos().getPriority(); // get default value

    for (auto it = discoveryEntries.cbegin(); it != discoveryEntries.cend(); ++it) {
        const types::ProviderQos& providerQos = it->getQos();
        JOYNR_LOG_TRACE(logger(), "Looping over discoveryEntry: {}", it->toString());

        if (providerQos.getPriority() >= highestPriority) {
            selectedDiscoveryEntryIt = it;
            JOYNR_LOG_TRACE(logger(),
                            "setting selectedParticipantId to {}",
                            selectedDiscoveryEntryIt->getParticipantId());
            highestPriority = providerQos.getPriority();
        }
    }

    if (selectedDiscoveryEntryIt == discoveryEntries.cend()) {
        std::stringstream errorMsg;
        errorMsg << "There was more than one entry in capabilitiesEntries, but none of the "
                    "compatible entries had a priority >= " << types::ProviderQos().getPriority();
        JOYNR_LOG_WARN(logger(), errorMsg.str());
        throw exceptions::DiscoveryException(errorMsg.str());
    }

    return *selectedDiscoveryEntryIt;
}
예제 #5
0
HttpRequest* HttpRequestBuilder::build()
{
    if (built) {
        JOYNR_LOG_WARN(logger,
                       "The method build of HttpBuilder may be called only once on a specific "
                       "instance. Throwing an Exception from worker thread.");
        throw exceptions::JoynrRuntimeException(
                "The method build of HttpBuilder may be called only once on a specific instance");
    }
    built = true;
    return new DefaultHttpRequest(handle, content, headers);
}