OPENBUS-3050 Novo parâmetro para tamanho máximo das caches LRU

O valor padrão continua sendo o valor do campo maxsize da classe loop.collection.LRUCache
parent e51332e8
......@@ -44,6 +44,7 @@ interface Configuration {
* + Nome de pacotes de validação de login e suas configurações
* (ex: ldap_patterns, ldap_servers).
* + Número máximo de canais de comunicação do OiL.
* + Tamanho máximo das caches LRU.
* + Níveis de log (busservices e OiL).
*/
void reloadConfigsFile()
......@@ -97,6 +98,8 @@ interface Configuration {
/**
* \brief Redefine o número máximo de canais de comunicação do OiL.
*
* \param maxchannels Novo máximo de canais.
*/
void setMaxChannels(in long maxchannels)
raises (UnauthorizedOperation, ServiceFailure);
......@@ -109,6 +112,24 @@ interface Configuration {
long getMaxChannels()
raises (ServiceFailure);
/**
* \brief Redefine o tamanho máximo das caches LRU do barramento (profiles
* IOR, sessões de entrada e sessões de saída).
*
* \param maxCacheSize Novo tamanho máximo das caches LRU.
*/
void setMaxCacheSize(in long maxCacheSize)
raises (UnauthorizedOperation, ServiceFailure);
/**
* \brief Retorna o tamanho máximo das caches LRU do barramento (profiles
* IOR, sessões de entrada e sessões de saída).
*
* \return Tamanho máximo das caches LRU.
*/
long getMaxCacheSize()
raises (ServiceFailure);
/**
* \brief Redefine o nível de log do barramento.
*/
......
......@@ -209,6 +209,10 @@ return function(...)
--set-max-channels=<integer>
* Mostra o número máximo de canais de comunicação do OiL:
--get-max-channels
* Redefine o tamnho máximo de caches LRU:
--set-max-cachesize=<integer>
* Mostra o tamanho máximo de caches LRU:
--get-max-cachesize
* Redefine o nível de log do barramento:
--set-log-level=<integer>
* Mostra o nível de log do barramento:
......@@ -393,6 +397,12 @@ return function(...)
["get-max-channels"] = {
{n = 0, params = {}},
};
["set-max-cachesize"] = {
{n = 1, params = {}},
};
["get-max-cachesize"] = {
{n = 0, params = {}},
};
["set-log-level"] = {
{n = 1, params = {}},
};
......@@ -1457,6 +1467,14 @@ return function(...)
return handleConfigurationGetCall(cmd, "getMaxChannels", "maxchannels")
end
handlers["set-max-cachesize"] = function(cmd)
return handleConfigurationCall(cmd, "setMaxCacheSize", "number")
end
handlers["get-max-cachesize"] = function(cmd)
return handleConfigurationGetCall(cmd, "getMaxCacheSize", "maxcachesize")
end
handlers["set-log-level"] = function(cmd)
return handleConfigurationCall(cmd, "setLogLevel", "number")
end
......
......@@ -27,6 +27,8 @@ local table = require "loop.table"
local copy = table.copy
local memoize = table.memoize
local LRUCache = require "loop.collection.LRUCache"
local cothread = require "cothread"
local running = cothread.running
......@@ -80,12 +82,14 @@ return function(...)
InvalidMaximumChannelLimit = 16,
UnableToConvertLegacyDatabase = 17,
WrongAlternateAddress = 18,
InvalidMaximumCacheSize = 19,
}
local reloadConfigs = {
admin = {},
validator = {},
maxchannels = 1000,
maxcachesize = LRUCache.maxsize,
loglevel = 3,
oilloglevel = 0,
}
......@@ -235,6 +239,14 @@ return function(...)
return true
end
local function validateMaxCacheSize(maxsize)
if maxsize < 0 then
log:misconfig(msg.InvalidMaximumCacheSize:tag{value=maxsize})
return false, errcode.InvalidMaximumCacheSize
end
return true
end
local function loadConfigs()
local path = getenv("OPENBUS_CONFIG")
if path == nil then
......@@ -276,6 +288,7 @@ Options:
-badpasswordrate <number> frequncia mxima de autenticaes com senha incoreta (autenticao/segundo)
-maxchannels <number> nmero mximo de canais de comunicao com os sistemas
-maxcachesize <number> tamanho mximo das caches LRU de profiles IOR, sesses de entrada e de sada
-admin <user> usurio com privilgio de administrao
-validator <name> nome de pacote de validao de login
......@@ -381,11 +394,17 @@ Options:
return errcode.InvalidPasswordValidationRate
end
-- validate max channels and cache size
do
local res, errcode = validateMaxChannels(Configs.maxchannels)
if not res then return errcode end
end
do
local res, errcode = validateMaxCacheSize(Configs.maxcachesize)
if not res then return errcode end
end
-- load private key
local prvkey, errmsg = readprivatekey(Configs.privatekey)
if prvkey == nil then
......@@ -500,6 +519,7 @@ Options:
prvkey = prvkey,
orb = orb,
legacy = legacy,
maxcachesize = Configs.maxcachesize,
}
orb:setinterceptor(iceptor, "corba")
loadidl(orb)
......@@ -541,6 +561,7 @@ Options:
access:setGrantedUsers(self.__type, "addValidator", admins)
access:setGrantedUsers(self.__type, "delValidator", admins)
access:setGrantedUsers(self.__type, "setMaxChannels", admins)
access:setGrantedUsers(self.__type, "setMaxCacheSize", admins)
access:setGrantedUsers(self.__type, "setLogLevel", admins)
access:setGrantedUsers(self.__type, "setOilLogLevel", admins)
end
......@@ -619,6 +640,7 @@ Options:
setLogLevel("core", Configs.loglevel)
setLogLevel("oil", Configs.oilloglevel)
resetMaxChannels(orb, Configs.maxchannels)
self:setMaxCacheSize(Configs.maxcachesize)
resetAdminUsers(admins)
unloadValidators(validators)
loadValidators(validators)
......@@ -676,6 +698,20 @@ Options:
return orb.ResourceManager.inuse.maxsize
end
function Configuration:setMaxCacheSize(maxsize)
if not validateMaxCacheSize(maxsize) then
ServiceFailure{
message = msg.InvalidMaximumCacheSize:tag{value=maxsize}
}
end
self.access:maxCacheSize(maxsize)
log:admin(msg.MaximumCacheSize:tag{value=maxsize})
end
function Configuration:getMaxCacheSize()
return self.access:maxCacheSize()
end
function Configuration:setLogLevel(loglevel)
return updateLogLevel("core", loglevel)
end
......@@ -725,6 +761,7 @@ Options:
log:config(msg.BadPasswordTotalLimit:tag{value=Configs.badpasswordlimit})
log:config(msg.BadPasswordMaxRate:tag{value=Configs.badpasswordrate})
log:config(msg.MaximumChannelLimit:tag{value=Configs.maxchannels})
log:config(msg.MaximumCacheSize:tag{value=Configs.maxcachesize})
if not params.enforceAuth then
log:config(msg.OfferAuthorizationDisabled)
end
......
......@@ -109,6 +109,7 @@ assert(execute("--del-entity=ENT04"))
assert(execute("--del-category=CTG02"))
-- reconfigurao dinmica
assert(execute("--set-max-cachesize=1024"))
assert(execute("--set-max-channels=100"))
assert(execute("--set-log-level=5"))
assert(execute("--set-oil-log-level=5"))
......
Markdown is supported
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