diff options
author | dolphin <dolphin@lindenlab.com> | 2013-08-21 15:43:09 -0700 |
---|---|---|
committer | dolphin <dolphin@lindenlab.com> | 2013-08-21 15:43:09 -0700 |
commit | 257110c11e5546f0a5a07b087694cfc9059367b4 (patch) | |
tree | 2fdd2a90fd32a17a950a055068d9eb39686ba96f /indra/llmessage | |
parent | 98628066eb27d4f2616479538ae20a07bf92cd98 (diff) |
Added new fields to the experience cache.
Experience profile moved to it's own floater, will probalby be moving again.
XP profile displays most data, though the presentation is not final
Fixed a bug with the XP selection combobox in the script editor
Diffstat (limited to 'indra/llmessage')
-rw-r--r-- | indra/llmessage/llexperiencecache.cpp | 61 | ||||
-rw-r--r-- | indra/llmessage/llexperiencecache.h | 17 |
2 files changed, 55 insertions, 23 deletions
diff --git a/indra/llmessage/llexperiencecache.cpp b/indra/llmessage/llexperiencecache.cpp index 219e68b51c..2e260ecdef 100644 --- a/indra/llmessage/llexperiencecache.cpp +++ b/indra/llmessage/llexperiencecache.cpp @@ -37,11 +37,10 @@ namespace LLExperienceCache { - typedef std::map<LLUUID, LLUUID> PrivateKeyMap; - PrivateKeyMap experinceKeyMap; - - void mapPrivateKeys(const LLSD& legacyKeys); + typedef std::map<LLUUID, LLUUID> KeyMap; + KeyMap privateToPublicKeyMap; + void mapKeys(const LLSD& legacyKeys); std::string sLookupURL; @@ -66,6 +65,7 @@ namespace LLExperienceCache signal_map_t sSignalMap; + bool max_age_from_cache_control(const std::string& cache_control, S32 *max_age); void eraseExpired(); @@ -89,6 +89,17 @@ namespace LLExperienceCache sPendingQueue.erase(row[OWNER_ID].asUUID()); } + if(!row.has(OWNER_ID)) + { + if(row.has(AGENT_ID) && row[AGENT_ID].asUUID().notNull()) + { + row[OWNER_ID]=row[AGENT_ID]; + } + else + { + row[OWNER_ID]=row[GROUP_ID]; + } + } //signal signal_map_t::iterator sig_it = sSignalMap.find(public_key); @@ -119,7 +130,7 @@ namespace LLExperienceCache void bootstrap(const LLSD& legacyKeys, int initialExpiration) { - mapPrivateKeys(legacyKeys); + mapKeys(legacyKeys); LLSD::array_const_iterator it = legacyKeys.beginArray(); for(/**/; it != legacyKeys.endArray(); ++it) { @@ -302,7 +313,8 @@ namespace LLExperienceCache exp[EXPIRES]=DEFAULT_EXPIRATION; exp[EXPERIENCE_ID] = id; exp[PROPERTIES]=PROPERTY_INVALID; - exp["DoesNotExist"]=true; + exp[MISSING]=true; + exp[QUOTA] = DEFAULT_QUOTA; processExperience(id, exp); LL_INFOS("ExperienceCache") << "Error result for " << id << LL_ENDL ; @@ -324,14 +336,22 @@ namespace LLExperienceCache ask_queue_t::const_iterator it = mKeys.begin(); for ( ; it != mKeys.end(); ++it) { + LLSD exp; + //leave the properties alone if we already have a cache entry for this xp + if(!get(it->first, exp)) + { + exp[PROPERTIES]=PROPERTY_INVALID; + } exp[EXPIRES]=retry_timestamp; exp[EXPERIENCE_ID] = it->first; exp["key_type"] = it->second; exp["uuid"] = it->first; exp["error"] = (LLSD::Integer)status; - exp[PROPERTIES]=PROPERTY_INVALID; + exp[QUOTA] = DEFAULT_QUOTA; + LLExperienceCache::processExperience(it->first, exp); + LL_INFOS("ExperienceCache") << "Error result for " << it->first << LL_ENDL ; } } @@ -514,22 +534,25 @@ namespace LLExperienceCache cache_t::iterator cur = it; LLSD& exp = cur->second; ++it; + if(exp.has(EXPIRES) && exp[EXPIRES].asReal() < now) { - if(exp.has(EXPERIENCE_ID)) + if(!exp.has(EXPERIENCE_ID)) { - LLUUID id = exp[EXPERIENCE_ID].asUUID(); - S32 properties = PROPERTY_INVALID; - if(exp.has(PROPERTIES)) - { - properties = exp[PROPERTIES].asInteger(); + LL_INFOS("ExperienceCache") << "Removing experience with no id " << LL_ENDL ; + sCache.erase(cur); } - if(id.notNull() && ((properties & PROPERTY_INVALID) == 0)) + else + { + LLUUID id = exp[EXPERIENCE_ID].asUUID(); + LLUUID private_key = exp.has(LLExperienceCache::PRIVATE_KEY) ? exp[LLExperienceCache::PRIVATE_KEY].asUUID():LLUUID::null; + if(private_key.notNull() || !exp.has("DoesNotExist")) { fetch(id, true); } else { + LL_INFOS("ExperienceCache") << "Removing invalid experience " << id << LL_ENDL ; sCache.erase(cur); } } @@ -616,15 +639,14 @@ namespace LLExperienceCache } - -void LLExperienceCache::mapPrivateKeys( const LLSD& legacyKeys ) +void LLExperienceCache::mapKeys( const LLSD& legacyKeys ) { LLSD::array_const_iterator exp = legacyKeys.beginArray(); for(/**/ ; exp != legacyKeys.endArray() ; ++exp) { if(exp->has(LLExperienceCache::EXPERIENCE_ID) && exp->has(LLExperienceCache::PRIVATE_KEY)) { - experinceKeyMap[(*exp)[LLExperienceCache::PRIVATE_KEY].asUUID()]=(*exp)[LLExperienceCache::EXPERIENCE_ID].asUUID(); + privateToPublicKeyMap[(*exp)[LLExperienceCache::PRIVATE_KEY].asUUID()]=(*exp)[LLExperienceCache::EXPERIENCE_ID].asUUID(); } } } @@ -635,9 +657,8 @@ LLUUID LLExperienceCache::getExperienceId(const LLUUID& private_key, bool null_i if (private_key.isNull()) return LLUUID::null; - - PrivateKeyMap::const_iterator it=experinceKeyMap.find(private_key); - if(it == experinceKeyMap.end()) + KeyMap::const_iterator it=privateToPublicKeyMap.find(private_key); + if(it == privateToPublicKeyMap.end()) { if(null_if_not_found) { diff --git a/indra/llmessage/llexperiencecache.h b/indra/llmessage/llexperiencecache.h index fb00ea31f0..8b3443e5a9 100644 --- a/indra/llmessage/llexperiencecache.h +++ b/indra/llmessage/llexperiencecache.h @@ -40,13 +40,21 @@ class LLUUID; namespace LLExperienceCache { const std::string PRIVATE_KEY = "private_id"; + const std::string MISSING = "DoesNotExist"; + const std::string AGENT_ID = "agent_id"; + const std::string GROUP_ID = "group_id"; const std::string EXPERIENCE_ID = "public_id"; const std::string OWNER_ID = "owner_id"; const std::string NAME = "name"; const std::string PROPERTIES = "properties"; const std::string EXPIRES = "expiration"; - const std::string DESCRIPTION = "description"; + const std::string DESCRIPTION = "description"; + const std::string QUOTA = "quota"; + const std::string MATURITY = "maturity"; + const std::string METADATA = "extended_metadata"; + const std::string SLURL = "slurl"; + // should be in sync with experience-api/experiences/models.py const int PROPERTY_INVALID = 1 << 0; @@ -54,10 +62,12 @@ namespace LLExperienceCache const int PROPERTY_GRID = 1 << 4; const int PROPERTY_PRIVATE = 1 << 5; const int PROPERTY_DISABLED = 1 << 6; - const int PROPERTY_SUSPENDED = 1 << 7; + const int PROPERTY_SUSPENDED = 1 << 7; + // default values const static F64 DEFAULT_EXPIRATION = 600.0; + const static S32 DEFAULT_QUOTA = 128; // this is megabytes // Callback types for get() below typedef boost::signals2::signal<void (const LLSD& experience)> @@ -79,7 +89,7 @@ namespace LLExperienceCache void erase(const LLUUID& key); bool fetch(const LLUUID& key, bool refresh=false); - void insert(LLSD& experience_data); + void insert(const LLSD& experience_data); bool get(const LLUUID& key, LLSD& experience_data); // If name information is in cache, callback will be called immediately. @@ -87,6 +97,7 @@ namespace LLExperienceCache const cache_t& getCached(); + // maps an experience private key to the experience id LLUUID getExperienceId(const LLUUID& private_key, bool null_if_not_found=false); }; |