void ConfigurationPersistenceManager::onConfigurationUpdated(const KaaRootConfiguration& configuration) { if (ignoreConfigurationUpdate_) { ignoreConfigurationUpdate_ = false; return; } KAA_LOG_INFO("Configuration updated."); AvroByteArrayConverter<KaaRootConfiguration> converter; SharedDataBuffer buffer = converter.toByteArray(configuration); KAA_LOG_INFO(boost::format("Going to store configuration using configuration storage %1%") % storage_); KAA_MUTEX_LOCKING("confPersistenceGuard_"); KAA_MUTEX_UNIQUE_DECLARE(confPersistenceGuardLock, confPersistenceGuard_); KAA_MUTEX_LOCKED("confPersistenceGuard_"); if (storage_) { storage_->saveConfiguration(std::vector<std::uint8_t>(buffer.first.get(), buffer.first.get() + buffer.second)); } KAA_MUTEX_UNLOCKING("confPersistenceGuard_"); KAA_UNLOCK(confPersistenceGuardLock); KAA_MUTEX_UNLOCKED("confPersistenceGuard_"); configurationHash_ = EndpointObjectHash(buffer); KAA_LOG_INFO(boost::format("Calculated configuration hash: %1%") % LoggingUtils::ByteArrayToString(configurationHash_.getHashDigest())); }
void ConfigurationManager::updateConfiguration(const std::uint8_t* data, const std::uint32_t dataSize) { static AvroByteArrayConverter<KaaRootConfiguration> converter; converter.fromByteArray(data, dataSize, configuration_); configurationHash_ = EndpointObjectHash(data, dataSize); KAA_LOG_TRACE(boost::format("Calculated configuration hash: %1%") % LoggingUtils::ByteArrayToString(configurationHash_.getHashDigest())); }
static Notification createNotification(const std::int64_t topicId) { KaaNotification originalNotification; AvroByteArrayConverter<KaaNotification> serializer; Notification notification; notification.topicId = topicId; notification.seqNumber.set_int(rand()); serializer.toByteArray(originalNotification, notification.body); notification.type = NotificationType::CUSTOM; notification.uid.set_null(); return notification; }
/** * Retrieves serialized profile * * @return byte array with serialized profile * */ SharedDataBuffer getSerializedProfile() { static AvroByteArrayConverter<KaaProfile> avroConverter; if (profileContainer_) { return avroConverter.toByteArray(profileContainer_->getProfile()); } #if KAA_PROFILE_SCHEMA_VERSION > 0 else { throw KaaException("Profile container is not set!"); } #endif return avroConverter.toByteArray(KaaProfile()); }