当前位置: 首页>>代码示例>>Java>>正文


Java AlarmSeverity类代码示例

本文整理汇总了Java中monasca.common.model.alarm.AlarmSeverity的典型用法代码示例。如果您正苦于以下问题:Java AlarmSeverity类的具体用法?Java AlarmSeverity怎么用?Java AlarmSeverity使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


AlarmSeverity类属于monasca.common.model.alarm包,在下文中一共展示了AlarmSeverity类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: parseAndValidateSeverity

import monasca.common.model.alarm.AlarmSeverity; //导入依赖的package包/类
public static List<AlarmSeverity> parseAndValidateSeverity(String severityStr) {
  List<AlarmSeverity> severityList = null;
  if (severityStr != null && !severityStr.isEmpty()) {
    severityList = new ArrayList<>();
    List<String> severities = Lists.newArrayList(VERTICAL_BAR_SPLITTER.split(severityStr));
    for (String severity : severities) {
      AlarmSeverity s = AlarmSeverity.fromString(severity);
      if (s != null) {
        severityList.add(s);
      } else {
        throw Exceptions.unprocessableEntity(String.format("Invalid severity %s",
                                                           severity));
      }
    }
  }
  return severityList;
}
 
开发者ID:openstack,项目名称:monasca-api,代码行数:18,代码来源:Validation.java

示例2: shouldFilterBySeverity

import monasca.common.model.alarm.AlarmSeverity; //导入依赖的package包/类
@Test(groups = "orm")
public void shouldFilterBySeverity() {

  checkUnsortedList(repo.find(TENANT_ID, null, null, null, null, Lists.newArrayList(AlarmSeverity.LOW), null, null, null, null, null, 1, false),
      alarm1, alarm2, alarm3);

  checkUnsortedList(repo.find(TENANT_ID, null, null, null, null, Lists.newArrayList(AlarmSeverity.HIGH), null, null, null, null, null, 1, false),
      compoundAlarm);

  checkUnsortedList(repo.find(TENANT_ID, null, null, null, null, Lists.newArrayList(AlarmSeverity.LOW, AlarmSeverity.HIGH), null, null, null, null, null, 1, false),
      alarm1, alarm2, compoundAlarm, alarm3);

  // no alarms for those severities
  checkUnsortedList(repo.find(TENANT_ID, null, null, null, null, Lists.newArrayList(AlarmSeverity.CRITICAL), null, null, null, null, null, 1, false));
  checkUnsortedList(repo.find(TENANT_ID, null, null, null, null, Lists.newArrayList(AlarmSeverity.MEDIUM), null, null, null, null, null, 1, false));
  checkUnsortedList(repo.find(TENANT_ID, null, null, null, null, Lists.newArrayList(AlarmSeverity.CRITICAL, AlarmSeverity.MEDIUM), null, null, null, null, null, 1, false));
}
 
开发者ID:openstack,项目名称:monasca-api,代码行数:18,代码来源:AlarmSqlRepositoryImplTest.java

示例3: AlarmDefinitionDb

import monasca.common.model.alarm.AlarmSeverity; //导入依赖的package包/类
public AlarmDefinitionDb(String id,
                         String tenantId,
                         String name,
                         String description,
                         String expression,
                         AlarmSeverity severity,
                         String matchBy,
                         boolean actionsEnabled,
                         DateTime created_at,
                         DateTime updated_at,
                         DateTime deletedAt) {
  super(id, created_at, updated_at);
  this.id = id;
  this.tenantId = tenantId;
  this.name = name;
  this.description = description;
  this.expression = expression;
  this.severity = severity;
  this.matchBy = matchBy;
  this.actionsEnabled = actionsEnabled;
  this.setDeletedAt(deletedAt);
}
 
开发者ID:openstack,项目名称:monasca-common,代码行数:23,代码来源:AlarmDefinitionDb.java

示例4: list

import monasca.common.model.alarm.AlarmSeverity; //导入依赖的package包/类
@GET
@Timed
@Produces(MediaType.APPLICATION_JSON)
public Object list(@Context UriInfo uriInfo,
    @HeaderParam("X-Tenant-Id") String tenantId, @QueryParam("name") String name,
    @QueryParam("dimensions") String dimensionsStr,
    @QueryParam("severity") String severityStr,
    @QueryParam("sort_by") String sortByStr,
    @QueryParam("offset") String offset,
    @QueryParam("limit") String limit) throws UnsupportedEncodingException {
  Map<String, String> dimensions =
      Strings.isNullOrEmpty(dimensionsStr) ? null : Validation
          .parseAndValidateDimensions(dimensionsStr);

  List<String> sortByList = Validation.parseAndValidateSortBy(sortByStr, ALLOWED_SORT_BY);
  if (!Strings.isNullOrEmpty(offset)) {
    Validation.parseAndValidateNumber(offset, "offset");
  }

  List<AlarmSeverity> severityList = Validation.parseAndValidateSeverity(severityStr);

  final int paging_limit = this.persistUtils.getLimit(limit);
  final List<AlarmDefinition> resources = repo.find(tenantId,
                                                    name,
                                                    dimensions,
                                                    severityList,
                                                    sortByList,
                                                    offset,
                                                    paging_limit
  );
  return Links.paginateAlarming(paging_limit, Links.hydrate(resources, uriInfo), uriInfo);
}
 
开发者ID:openstack,项目名称:monasca-api,代码行数:33,代码来源:AlarmDefinitionResource.java

示例5: updateAlarmDefinition

import monasca.common.model.alarm.AlarmSeverity; //导入依赖的package包/类
private AlarmDefinitionDb updateAlarmDefinition(final String tenantId,
                                                final String id,
                                                final String name,
                                                final String description,
                                                final String expression,
                                                final List<String> matchBy,
                                                final String severity,
                                                final boolean actionsEnabled,
                                                final Session session) {
  final AlarmDefinitionDb alarmDefinitionDb = (AlarmDefinitionDb) session
      .getNamedQuery(AlarmDefinitionDb.Queries.FIND_BY_TENANT_ID_AND_ID)
      .setString("tenantId", tenantId)
      .setString("id", id)
      .uniqueResult();

  alarmDefinitionDb.setName(name);
  alarmDefinitionDb.setDescription(description);
  alarmDefinitionDb.setExpression(expression);
  alarmDefinitionDb.setMatchBy(matchBy == null || Iterables.isEmpty(matchBy) ? null : COMMA_JOINER.join(matchBy));
  alarmDefinitionDb.setSeverity(AlarmSeverity.valueOf(severity));
  alarmDefinitionDb.setActionsEnabled(actionsEnabled);
  alarmDefinitionDb.setUpdatedAt(this.getUTCNow());

  session.saveOrUpdate(alarmDefinitionDb);

  return alarmDefinitionDb;
}
 
开发者ID:openstack,项目名称:monasca-api,代码行数:28,代码来源:AlarmDefinitionSqlRepoImpl.java

示例6: getAlarmsCount

import monasca.common.model.alarm.AlarmSeverity; //导入依赖的package包/类
@Override
public AlarmCount getAlarmsCount(String tenantId, String alarmDefId, String metricName,
                                 Map<String, String> metricDimensions, AlarmState state,
                                 List<AlarmSeverity> severities, String lifecycleState, String link,
                                 DateTime stateUpdatedStart, List<String> groupBy,
                                 String offset, int limit) {
  // Not Implemented
  return null;
}
 
开发者ID:openstack,项目名称:monasca-api,代码行数:10,代码来源:AlarmSqlRepoImpl.java

示例7: buildSeverityAndClause

import monasca.common.model.alarm.AlarmSeverity; //导入依赖的package包/类
public static String buildSeverityAndClause(List<AlarmSeverity> severities) {
  StringBuilder sbWhere = new StringBuilder();
  if (severities != null && !severities.isEmpty()) {
    sbWhere.append(" and (");
    for (int i = 0; i < severities.size(); i++) {
      sbWhere.append("ad.severity = :severity").append(i);
      if (i < severities.size() - 1) {
        sbWhere.append(" or ");
      }
    }
    sbWhere.append(") ");
  }
  return sbWhere.toString();
}
 
开发者ID:openstack,项目名称:monasca-api,代码行数:15,代码来源:MySQLUtils.java

示例8: bindSeverityToQuery

import monasca.common.model.alarm.AlarmSeverity; //导入依赖的package包/类
public static void bindSeverityToQuery(Query query, List<AlarmSeverity> severities) {
  if (severities != null && !severities.isEmpty()) {
    for (int i = 0; i < severities.size(); i++) {
      query.bind("severity" + String.valueOf(i), severities.get(i).name());
    }
  }
}
 
开发者ID:openstack,项目名称:monasca-api,代码行数:8,代码来源:MySQLUtils.java

示例9: shouldList

import monasca.common.model.alarm.AlarmSeverity; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public void shouldList() {


  Map<String, Object> lhm = (Map<String, Object>) client().resource("/v2.0/alarm-definitions").header("X-Tenant-Id", "abc")
      .get(Paged.class).elements.get(0);

  AlarmDefinition ad = new AlarmDefinition((String) lhm.get("id"), (String) lhm.get("name"),
                                           (String) lhm.get("description"),
                                           (String) lhm.get("severity"),
                                           (String) lhm.get("expression"),
                                           (List<String>) lhm.get("match_by"),
                                           (boolean) lhm.get("actions_enabled"),
                                           (List<String>) lhm.get("alarm_actions"),
                                           (List<String>) lhm.get("ok_actions"),
                                           (List<String>) lhm.get("undetermined_actions"));


  List<Map<String, String>> links = (List<Map<String, String>>) lhm.get("links");
  List<Link> linksList = Arrays.asList(new Link(links.get(0).get("rel"), links.get(0).get("href")));

  ad.setLinks(linksList);

  List<AlarmDefinition> alarms = Arrays.asList(ad);

  assertEquals(alarms, Arrays.asList(alarmItem));

  verify(repo).find(eq("abc"), anyString(), (Map<String, String>) anyMap(), anyListOf(AlarmSeverity.class),
                    (List<String>) anyList(),
                    anyString(), anyInt());
}
 
开发者ID:openstack,项目名称:monasca-api,代码行数:32,代码来源:AlarmDefinitionResourceTest.java

示例10: shouldListByName

import monasca.common.model.alarm.AlarmSeverity; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public void shouldListByName() throws Exception {
  Map<String, Object>
      lhm =
      (Map<String, Object>) client()
          .resource("/v2.0/alarm-definitions?name=" + URLEncoder.encode("foo bar baz", "UTF-8"))
          .header("X-Tenant-Id", "abc").get(Paged.class).elements.get(0);

  AlarmDefinition
      ad =
      new AlarmDefinition((String) lhm.get("id"), (String) lhm.get("name"),
                          (String) lhm.get("description"), (String) lhm.get("severity"),
                          (String) lhm.get("expression"), (List<String>) lhm.get("match_by"),
                          (boolean) lhm.get("actions_enabled"),
                          (List<String>) lhm.get("alarm_actions"),
                          (List<String>) lhm.get("ok_actions"),
                          (List<String>) lhm.get("undetermined_actions"));

  List<Map<String, String>> links = (List<Map<String, String>>) lhm.get("links");
  List<Link>
      linksList =
      Arrays.asList(new Link(links.get(0).get("rel"), links.get(0).get("href")));

  ad.setLinks(linksList);

  List<AlarmDefinition> alarms = Arrays.asList(ad);

  assertEquals(alarms, Arrays.asList(alarmItem));
  verify(repo).find(eq("abc"), eq("foo bar baz"), (Map<String, String>) anyMap(), anyListOf(AlarmSeverity.class), (List<String>) anyList(),
                    anyString(), anyInt());
}
 
开发者ID:openstack,项目名称:monasca-api,代码行数:32,代码来源:AlarmDefinitionResourceTest.java

示例11: should500OnInternalException

import monasca.common.model.alarm.AlarmSeverity; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public void should500OnInternalException() {
  doThrow(new RuntimeException("")).when(repo).find(anyString(), anyString(),

      (Map<String, String>) anyObject(), anyListOf(AlarmSeverity.class), (List<String>) anyList(), anyString(), anyInt());

  try {
    client().resource("/v2.0/alarm-definitions").header("X-Tenant-Id", "abc").get(List.class);
    fail();
  } catch (Exception e) {
    assertTrue(e.getMessage().contains("500"), e.getMessage());
  }
}
 
开发者ID:openstack,项目名称:monasca-api,代码行数:14,代码来源:AlarmDefinitionResourceTest.java

示例12: newAlarmDefinition

import monasca.common.model.alarm.AlarmSeverity; //导入依赖的package包/类
private AlarmDefinitionDb newAlarmDefinition(final Session session,
                                             final String id,
                                             final String tenantId,
                                             final String name,
                                             final String expression,
                                             final AlarmSeverity severity,
                                             final String matchBy,
                                             final boolean actionEnabled) {
  final DateTime now = DateTime.now();
  final AlarmDefinitionDb db = new AlarmDefinitionDb(id, tenantId, name, null, expression, severity, matchBy, actionEnabled, now, now, null);
  session.save(db);
  return db;
}
 
开发者ID:openstack,项目名称:monasca-api,代码行数:14,代码来源:AlarmSqlRepositoryImplTest.java

示例13: newAlarmDefinition

import monasca.common.model.alarm.AlarmSeverity; //导入依赖的package包/类
private AlarmDefinitionDb newAlarmDefinition(final Session session,
                                             final String id,
                                             final String tenantId) {
  final String str = "AlarmDefinition" + 1;
  final DateTime now = DateTime.now();
  final AlarmDefinitionDb definition = new AlarmDefinitionDb(id, tenantId, ALARM_DEF_NAME, str, ALARM_DEF_EXPRESSION, AlarmSeverity.LOW, ALARM_MATCH_BY, true, now, now, null);
  session.save(definition);
  return definition;
}
 
开发者ID:openstack,项目名称:monasca-api,代码行数:10,代码来源:AlarmHibernateUtilsTest.java

示例14: shouldFilterBySeverity

import monasca.common.model.alarm.AlarmSeverity; //导入依赖的package包/类
public void shouldFilterBySeverity() {
  checkList(repo.find("bob", null, null, Lists.newArrayList(AlarmSeverity.HIGH), null, null, 1),
      this.alarmDef_123);
  checkList(repo.find("bob", null, null, Lists.newArrayList(AlarmSeverity.LOW), null, null, 1),
      this.alarmDef_234);
  checkList(repo.find("bob", null, null, Lists.newArrayList(AlarmSeverity.HIGH, AlarmSeverity.LOW), null, null, 1),
      this.alarmDef_123, this.alarmDef_234);
}
 
开发者ID:openstack,项目名称:monasca-api,代码行数:9,代码来源:AlarmDefinitionSqlRepositoryImplTest.java

示例15: shouldFindBySeverity

import monasca.common.model.alarm.AlarmSeverity; //导入依赖的package包/类
public void shouldFindBySeverity() {
  assertEquals(Arrays.asList(alarmDef_234), repo.find("bob", null, null, Lists.newArrayList(AlarmSeverity.HIGH), null, null, 1));

  assertEquals(0, repo.find("bob", null, null, Lists.newArrayList(AlarmSeverity.CRITICAL), null, null, 1).size());

  assertEquals(Arrays.asList(alarmDef_234, alarmDef_345),
               repo.find("bob", null, null, Lists.newArrayList(AlarmSeverity.HIGH, AlarmSeverity.CRITICAL),
                         null, null, 2));
}
 
开发者ID:openstack,项目名称:monasca-api,代码行数:10,代码来源:AlarmDefinitionMySqlRepositoryImplTest.java


注:本文中的monasca.common.model.alarm.AlarmSeverity类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。