use of info.xiancloud.core.Unit in project xian by happyyangyuan.
the class CountLatchEntity method getUnitCollection.
@Override
public Collection<Unit> getUnitCollection() {
// 读取配置文件,获取要监控的unit
String[] unitArray = XianConfig.getStringArray(MONITOR_UNIT_LIST);
try {
if (unitArray != null && unitArray.length > 0) {
List<String> unitList = Arrays.asList(unitArray);
return new HashSet<Unit>() {
{
// 配置文件内指定的监控集
unitList.forEach(unitFullName -> {
// 配置文件格式 groupName.unitName
Pair<String, String> pair = Unit.parseFullName(unitFullName);
String groupName = pair.fst;
String unitName = pair.snd;
Unit unit = LocalUnitsManager.getLocalUnit(groupName, unitName);
if (unit != null) {
add(unit);
// 初始化对应的计数器并设置为0
countLatches.put(unitFullName, new CountLatchEntity());
}
});
LocalUnitsManager.searchUnitMap(searchUnitMap -> {
// unit自定义的监控集
for (Unit unit : searchUnitMap.values()) {
if (unit.getMeta().isMonitorEnabled()) {
add(unit);
countLatches.put(Unit.fullName(unit), new CountLatchEntity());
}
}
});
}
};
}
} catch (Exception e) {
LOG.error("unit调用频率监控AOP 从配置文件中加载要监控的unit出错", e);
}
return null;
}
use of info.xiancloud.core.Unit in project xian by happyyangyuan.
the class TransactionalUnitAop method getUnitCollection.
@Override
public Collection<Unit> getUnitCollection() {
Set<Unit> collection = new HashSet<>();
LocalUnitsManager.unitMap(unitMap -> {
for (String groupName : unitMap.keySet()) {
for (Unit unit : unitMap.get(groupName)) {
if (unit.getMeta().isTransactional()) {
collection.add(unit);
}
}
}
});
return collection;
}
Aggregations