本文整理匯總了Java中monasca.common.model.alarm.AlarmOperator.fromJson方法的典型用法代碼示例。如果您正苦於以下問題:Java AlarmOperator.fromJson方法的具體用法?Java AlarmOperator.fromJson怎麽用?Java AlarmOperator.fromJson使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類monasca.common.model.alarm.AlarmOperator
的用法示例。
在下文中一共展示了AlarmOperator.fromJson方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: findSubExpressions
import monasca.common.model.alarm.AlarmOperator; //導入方法依賴的package包/類
private List<SubExpression> findSubExpressions(Handle h, String alarmDefId) {
List<Map<String, Object>> rows =
h.createQuery(SUB_ALARM_SQL).bind("alarmDefId", alarmDefId).list();
final List<SubExpression> subExpressions = new ArrayList<>(rows.size());
int index = 0;
while (index < rows.size()) {
Map<String, Object> row = rows.get(index);
String id = (String) row.get("id");
AggregateFunction function = AggregateFunction.fromJson((String) row.get("function"));
String metricName = (String) row.get("metric_name");
AlarmOperator operator = AlarmOperator.fromJson((String) row.get("operator"));
Double threshold = (Double) row.get("threshold");
// MySQL connector returns an Integer, Drizzle returns a Long for period and periods.
// Need to convert the results appropriately based on type.
Integer period = Conversions.variantToInteger(row.get("period"));
Integer periods = Conversions.variantToInteger(row.get("periods"));
Boolean deterministic = BOOLEAN_MAPPER_FUNCTION.apply(row.get("is_deterministic"));
Map<String, String> dimensions = new HashMap<>();
while (addedDimension(dimensions, id, rows, index)) {
index++;
}
subExpressions.add(
new SubExpression(id,
new AlarmSubExpression(
function,
new MetricDefinition(metricName, dimensions),
operator,
threshold,
period,
periods,
deterministic
)
)
);
}
return subExpressions;
}
示例2: findSubExpressions
import monasca.common.model.alarm.AlarmOperator; //導入方法依賴的package包/類
@Override
public Map<String, AlarmSubExpression> findSubExpressions(String alarmDefId) {
try (Handle h = db.open()) {
List<Map<String, Object>> rows =
h.createQuery(SUB_ALARM_SQL).bind("alarmDefId", alarmDefId).list();
Map<String, AlarmSubExpression> subExpressions = new HashMap<>();
for (Map<String, Object> row : rows) {
String id = (String) row.get("id");
AggregateFunction function = AggregateFunction.fromJson((String) row.get("function"));
String metricName = (String) row.get("metric_name");
AlarmOperator operator = AlarmOperator.fromJson((String) row.get("operator"));
Double threshold = (Double) row.get("threshold");
// MySQL connector returns an Integer, Drizzle returns a Long for period and periods.
// Need to convert the results appropriately based on type.
Integer period = Conversions.variantToInteger(row.get("period"));
Integer periods = Conversions.variantToInteger(row.get("periods"));
Boolean isDeterministic = Conversions.variantToBoolean(row.get("is_deterministic"));
Map<String, String> dimensions =
DimensionQueries.dimensionsFor((String) row.get("dimensions"));
subExpressions.put(
id,
new AlarmSubExpression(
function,
new MetricDefinition(metricName, dimensions),
operator,
threshold,
period,
periods,
isDeterministic
)
);
}
return subExpressions;
}
}
示例3: findSubExpressions
import monasca.common.model.alarm.AlarmOperator; //導入方法依賴的package包/類
@Override
@SuppressWarnings("unchecked")
public Map<String, AlarmSubExpression> findSubExpressions(String alarmDefId) {
logger.trace(ORM_LOG_MARKER, "findSubExpressions(...) entering...");
Session session = null;
Map<String, AlarmSubExpression> subExpressions = Maps.newHashMap();
try {
session = sessionFactory.openSession();
List<SubAlarmDefinitionDb> subAlarmDefList = session
.getNamedQuery(SubAlarmDefinitionDb.Queries.BY_ALARMDEFINITION_ID)
.setString("id", alarmDefId)
.list();
Query querySybAlarmDefDimension = session
.getNamedQuery(SubAlarmDefinitionDb.Queries.BY_ALARMDEFINITIONDIMENSION_SUBEXPRESSION_ID)
.setString("id", alarmDefId);
List<SubAlarmDefinitionDimensionDb> subAlarmDefDimensionList = querySybAlarmDefDimension.list();
Map<String, Map<String, String>> subAlarmDefDimensionMapExpression = mapAlarmDefDimensionExpression(subAlarmDefDimensionList);
for (SubAlarmDefinitionDb subAlarmDef : subAlarmDefList) {
String id = subAlarmDef.getId();
AggregateFunction function = AggregateFunction.fromJson(subAlarmDef.getFunction());
String metricName = subAlarmDef.getMetricName();
AlarmOperator operator = AlarmOperator.fromJson(subAlarmDef.getOperator());
double threshold = subAlarmDef.getThreshold();
int period = subAlarmDef.getPeriod();
int periods = subAlarmDef.getPeriods();
boolean isDeterministic = subAlarmDef.isDeterministic();
Map<String, String> dimensions = Collections.emptyMap();
if (subAlarmDefDimensionMapExpression.containsKey(id)) {
dimensions = subAlarmDefDimensionMapExpression.get(id);
}
subExpressions.put(id,
new AlarmSubExpression(
function,
new MetricDefinition(metricName, dimensions),
operator,
threshold,
period,
periods,
isDeterministic
)
);
}
return subExpressions;
} finally {
if (session != null) {
session.close();
}
}
}