Commit 6c08d438 authored by Amadeu Andrade Barbosa Junior's avatar Amadeu Andrade Barbosa Junior
Browse files

OPENBUS-3050 Novo método para definir tamanho máximo de caches LRU

Essa mudança afeta a openbus.core.Access.Interceptor que é usada pela
implementação do busservices. Mas também afeta Connection que herda de
parent 05caf37b
......@@ -217,17 +217,36 @@ local Interceptor = class()
-- login : information about the login used to access the bus
-- Optional field that may be provided to configure the interceptor:
-- prvkey: private key associated to the key registered to the login
-- legacy: ACS facet of OpenBus 1.5 to validate legacy invocations
-- prvkey : private key associated to the key registered to the login
-- legacy : ACS facet of OpenBus 1.5 to validate legacy invocations
-- maxcachesize: max size for LRUCache objects
function Interceptor:__init()
self.maxcachesize = self.maxcachesize or LRUCache.maxsize
function Interceptor:maxCacheSize(newsize)
if not newsize then
return self.maxcachesize
self.maxcachesize = newsize
self.profile2login.maxsize = newsize
self.outgoingSessions.maxsize = newsize
self.incomingSessions.maxsize = newsize
local function newLRU(self, data)
local data = data or {}
data.maxsize = self.maxcachesize
return LRUCache(data)
function Interceptor:resetCaches()
self.profile2login = LRUCache() -- [iop_profile] = loginid
self.outgoingSessions = LRUCache()
self.incomingSessions = LRUCache{
self.profile2login = newLRU(self) -- [iop_profile] = loginid
self.outgoingSessions = newLRU(self)
self.incomingSessions = newLRU(self,{
retrieve = function(id)
return {
id = id,
......@@ -235,7 +254,7 @@ function Interceptor:resetCaches()
tickets = tickets(),
function Interceptor:unmarshalSignedChain(chain, busid)
......@@ -45,6 +45,17 @@ local orb = openbus.initORB()
local OpenBusContext = orb.OpenBusContext
assert(OpenBusContext.orb == orb)
do log:TEST("Make changes on LRU max cache size")
local default = require("loop.collection.LRUCache").maxsize
local conn = OpenBusContext:createConnection(bushost, busport, connprops)
assert(conn:maxCacheSize() == default)
assert(conn:maxCacheSize() == 1024)
-- TODO: exercise more calls than default initial value could perform
assert(conn:maxCacheSize() == default)
do log:TEST("Two threads logging in")
local conn = OpenBusContext:createConnection(bushost, busport, connprops)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment