Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#253 #254

Merged
merged 1 commit into from
Feb 11, 2025
Merged

#253 #254

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions config/objects/nInput_Init.js
Original file line number Diff line number Diff line change
Expand Up @@ -558,8 +558,8 @@ var nInput_Init = function(aMap) {
parent._entryRetries[init.name][ikey].set(0)
} else {
if (isDef(_tries) && _tries > 0) {
parent._entryRetries[init.name][i].inc()
log("nInputInit | Graceful retries before destroy for (" + init.name + ") #" + i + " (" + parent._entryRetries[init.name][i].get() + "/" + _tries + ")")
parent._entryRetries[init.name][ikey].inc()
log("nInputInit | Graceful retries before destroy for (" + init.name + ") #" + ikey + " (" + parent._entryRetries[init.name][ikey].get() + "/" + _tries + ")")
} else {
init.recycle(parent.fns, ikey, _res.select(), iskube)
}
Expand Down
78 changes: 59 additions & 19 deletions config/objects/nInput_RAIDLookups.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,15 @@
* You can create an input to get a list of existing RAID lookups with a map composed of:\
* - keys (a key string or an array of keys for an AF object)\
* - chKeys (a channel name for the keys of AF objects)\
* - excludeUnloaded (exclude Unloaded lk from output, defaults to false)\
* - include (array of lookup names to include)\
* - exclude (array of lookup names to exclude)\
* - includeRE (array of lookup names' reg exp to include)\
* - excludeRE (array of lookup names' reg exp to exclude)\
* \
* </odoc>
*/
var nInput_RAIDLookups = function(aMap) {
var nInput_RAIDLookups = function(aMap) {
if (isUnDef(getOPackPath("OpenCli"))) {
throw "OpenCli opack not installed.";
}
Expand All @@ -32,6 +37,12 @@
}

this.attrTemplate = aMap.attrTemplate;
this.include = aMap.include
this.exclude = aMap.exclude
this.includeRE = aMap.includeRE
this.excludeRE = aMap.excludeRE

this.excludeUnloaded = _$(aMap.excludeUnloaded, "excludeUnloaded").isBoolean().default(false);

ow.loadWAF();
nInput.call(this, this.input);
Expand All @@ -45,9 +56,10 @@ nInput_RAIDLookups.prototype.input = function(scope, args) {
if (isDef(this.chKeys)) this.keys = $stream($ch(this.chKeys).getKeys()).map("key").toArray();

var convertRAIDDates = aRAIDDate => {
if (isUnDef(aRAIDDate)) return __
return ow.format.fromWeDoDateToDate(aRAIDDate);
};

for (var i in this.keys) {
var arr = [];
var aKey = this.keys[i];
Expand All @@ -57,23 +69,51 @@ nInput_RAIDLookups.prototype.input = function(scope, args) {
try {
listOfLKs = ow.waf.dp.listLookups(aAF);

if (this.excludeUnloaded) {
listOfLKs = $from(listOfLKs).notEquals("extraMetadata.report.status", "UNLOADED").select();
}

listOfLKs.forEach(lk => {
var elk = ow.waf.dp.getLookup(aAF, lk.shortname);

arr.push({
Name : aKey,
Lookup : lk.shortname,
Status : lk.extraMetadata.report.status,
InUse : (isDef(elk.resourceInfo) ? elk.resourceInfo.InUse : false),
Count : (isDef(elk.resourceInfo) ? elk.resourceInfo.RecordCount : __),
LastUsedTime : (isDef(elk.resourceInfo) ? convertRAIDDates(elk.resourceInfo.LastUsedTime) : __),
LoadTime : (isDef(elk.resourceInfo) ? convertRAIDDates(elk.resourceInfo.LoadTime) : __),
TotalLoadTimeMs : (isDef(elk.resourceInfo) ? elk.resourceInfo.TotalLoadTime : __),
LoadedVersion : (isDef(elk.resourceInfo) ? elk.resourceInfo.LoadedLookupVersion : __),
IndexMemoryBytes : (isDef(elk.resourceInfo) ? ow.format.fromBytesAbbreviation(elk.resourceInfo.IdxMemoryUsage) : __),
ValuesMemoryBytes : (isDef(elk.resourceInfo) ? ow.format.fromBytesAbbreviation(elk.resourceInfo.ValMemoryUsage) : __),
TotalMemoryBytes : (isDef(elk.resourceInfo) ? ow.format.fromBytesAbbreviation(elk.resourceInfo.TotalMemoryUsage) : __)
});
var doIt = true

// Handle include, exclude, includeRE and excludeRE
if (isDef(this.include) && isArray(this.include) && this.include.indexOf(lk.shortname) < 0) doIt = false
if (isDef(this.exclude) && isArray(this.exclude) && this.exclude.indexOf(lk.shortname) >= 0) doIt = false
if (isDef(this.includeRE) && isArray(this.includeRE)) {
doIt = false
for(var irei in this.includeRE) {
if (lk.shortname.match(this.includeRE[irei])) doIt = true
}
}
if (isDef(this.excludeRE) && isArray(this.excludeRE)) {
doIt = true
for(var erei in this.excludeRE) {
if (lk.shortname.match(this.excludeRE[erei])) doIt = false
}
}

if (doIt) {
try {
var elk = ow.waf.dp.getLookup(aAF, lk.shortname);

arr.push({
Name : aKey,
Lookup : lk.shortname,
Status : lk.extraMetadata.report.status,
InUse : isDef(elk.resourceInfo) ? elk.resourceInfo.InUse : __,
Count : isDef(elk.resourceInfo) ? elk.resourceInfo.RecordCount : __,
LastUsedTime : isDef(elk.resourceInfo) ? convertRAIDDates(elk.resourceInfo.LastUsedTime) : __,
LoadTime : isDef(elk.resourceInfo) ? convertRAIDDates(elk.resourceInfo.LoadTime) : __,
TotalLoadTimeMs : isDef(elk.resourceInfo) ? elk.resourceInfo.TotalLoadTime : __,
LoadedVersion : isDef(elk.resourceInfo) ? elk.resourceInfo.LoadedLookupVersion : __,
IndexMemoryBytes : isDef(elk.resourceInfo) ? ow.format.fromBytesAbbreviation(elk.resourceInfo.IdxMemoryUsage) : __,
ValuesMemoryBytes : isDef(elk.resourceInfo) ? ow.format.fromBytesAbbreviation(elk.resourceInfo.ValMemoryUsage) : __,
TotalMemoryBytes : isDef(elk.resourceInfo) ? ow.format.fromBytesAbbreviation(elk.resourceInfo.TotalMemoryUsage) : __
});
} catch(lke1) {
logErr("nInput_RAIDLookups | " + lk.shortname + " | " + lke1)
}
}
});
} catch(e) {
logErr("nInput_RAIDLookups | " + String(e));
Expand All @@ -86,4 +126,4 @@ nInput_RAIDLookups.prototype.input = function(scope, args) {
}

return res;
};
};