本文整理汇总了Java中monasca.common.model.event.AlarmStateTransitionedEvent类的典型用法代码示例。如果您正苦于以下问题:Java AlarmStateTransitionedEvent类的具体用法?Java AlarmStateTransitionedEvent怎么用?Java AlarmStateTransitionedEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AlarmStateTransitionedEvent类属于monasca.common.model.event包,在下文中一共展示了AlarmStateTransitionedEvent类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: AlarmStateTransitionHandler
import monasca.common.model.event.AlarmStateTransitionedEvent; //导入依赖的package包/类
@Inject
public AlarmStateTransitionHandler(Repo<AlarmStateTransitionedEvent> alarmRepo,
Environment environment,
@Assisted PipelineConfig configuration,
@Assisted("threadId") String threadId,
@Assisted("batchSize") int batchSize) {
super(configuration, environment, threadId, batchSize);
this.alarmRepo = alarmRepo;
this.alarmStateTransitionCounter =
environment.metrics()
.counter(this.handlerName + "." + "alarm-state-transitions-added-to-batch-counter");
}
示例2: addToBatch
import monasca.common.model.event.AlarmStateTransitionedEvent; //导入依赖的package包/类
public void addToBatch(AlarmStateTransitionedEvent message, String id) {
String metricsString = getSerializedString(message.metrics, id);
// Validate metricsString does not exceed a sufficient maximum upper bound
if (metricsString.length() * MAX_BYTES_PER_CHAR >= MAX_LENGTH_VARCHAR) {
metricsString = "[]";
logger.warn("length of metricsString for alarm ID {} exceeds max length of {}", message.alarmId,
MAX_LENGTH_VARCHAR);
}
String subAlarmsString = getSerializedString(message.subAlarms, id);
if (subAlarmsString.length() * MAX_BYTES_PER_CHAR >= MAX_LENGTH_VARCHAR) {
subAlarmsString = "[]";
logger.warn("length of subAlarmsString for alarm ID {} exceeds max length of {}", message.alarmId,
MAX_LENGTH_VARCHAR);
}
queue.offerLast(cluster.getAlarmHistoryInsertStmt().bind(retention, metricsString, message.oldState.name(),
message.newState.name(), subAlarmsString, message.stateChangeReason, EMPTY_REASON_DATA,
message.tenantId, message.alarmId, new Timestamp(message.timestamp)));
}
示例3: getAlarmStateHistoryPipeline
import monasca.common.model.event.AlarmStateTransitionedEvent; //导入依赖的package包/类
public ManagedPipeline<AlarmStateTransitionedEvent> getAlarmStateHistoryPipeline(
PersisterConfig configuration,
String threadId,
Injector injector) {
logger.debug("Creating alarm state history pipeline [{}]...", threadId);
int batchSize = configuration.getAlarmHistoryConfiguration().getBatchSize();
logger.debug("Batch size for each AlarmStateHistoryPipeline [{}]", batchSize);
AlarmStateTransitionHandlerFactory alarmHistoryEventHandlerFactory =
injector.getInstance(AlarmStateTransitionHandlerFactory.class);
ManagedPipelineFactory<AlarmStateTransitionedEvent> alarmStateTransitionPipelineFactory =
injector.getInstance(new Key<ManagedPipelineFactory<AlarmStateTransitionedEvent>>(){});
ManagedPipeline<AlarmStateTransitionedEvent> pipeline =
alarmStateTransitionPipelineFactory.create(alarmHistoryEventHandlerFactory.create(
configuration.getAlarmHistoryConfiguration(), threadId, batchSize), threadId);
logger.debug("Instance of alarm state history pipeline [{}] fully created", threadId);
return pipeline;
}
示例4: addToBatch
import monasca.common.model.event.AlarmStateTransitionedEvent; //导入依赖的package包/类
public void addToBatch(AlarmStateTransitionedEvent message, String id) {
String metricsString = getSerializedString(message.metrics, id);
// Validate metricsString does not exceed a sufficient maximum upper bound
if (metricsString.length()*MAX_BYTES_PER_CHAR >= MAX_LENGTH_VARCHAR) {
metricsString = "[]";
logger.warn("length of metricsString for alarm ID {} exceeds max length of {}", message.alarmId, MAX_LENGTH_VARCHAR);
}
String subAlarmsString = getSerializedString(message.subAlarms, id);
// Validate subAlarmsString does not exceed a sufficient maximum upper bound
if (subAlarmsString.length()*MAX_BYTES_PER_CHAR >= MAX_LENGTH_VARCHAR) {
subAlarmsString = "[]";
logger.warn("length of subAlarmsString for alarm ID {} exceeds max length of {}", message.alarmId, MAX_LENGTH_VARCHAR);
}
String timeStamp = simpleDateFormat.format(new Date(message.timestamp));
batch.add()
.bind("tenant_id", message.tenantId)
.bind("alarm_id", message.alarmId)
.bind("metrics", metricsString)
.bind("old_state", message.oldState.name())
.bind("new_state", message.newState.name())
.bind("sub_alarms", subAlarmsString)
.bind("reason", message.stateChangeReason)
.bind("reason_data", "{}")
.bind("time_stamp", timeStamp);
this.msgCnt++;
}
示例5: changeAlarmState
import monasca.common.model.event.AlarmStateTransitionedEvent; //导入依赖的package包/类
private void changeAlarmState(Alarm alarm, AlarmState initialState, String stateChangeReason) {
final AlarmDefinition alarmDefinition = alarmDefinitions.get(alarm.getAlarmDefinitionId());
// If the Alarm Definition id does not exist, ignore updating this alarm
if (alarmDefinition == null) {
logger.warn("Failed to locate alarm definition for id {},"
+ " ignoring state update to alarm with id {}",
alarm.getAlarmDefinitionId(),
alarm.getId());
return;
}
long timestamp = getTimestamp();
alarmDAO.updateState(alarm.getId(), alarm.getState(), timestamp);
final List<MetricDefinition> alarmedMetrics = new ArrayList<>(alarm.getAlarmedMetrics().size());
for (final MetricDefinitionAndTenantId mdtid : alarm.getAlarmedMetrics()) {
alarmedMetrics.add(mdtid.metricDefinition);
}
logger.debug("Alarm {} transitioned from {} to {}", alarm, initialState, alarm.getState());
AlarmStateTransitionedEvent event =
new AlarmStateTransitionedEvent(alarmDefinition.getTenantId(), alarm.getId(),
alarmDefinition.getId(), alarmedMetrics, alarmDefinition.getName(),
alarmDefinition.getDescription(), initialState, alarm.getState(),
alarmDefinition.getSeverity(), alarm.getLink(), alarm.getLifecycleState(),
alarmDefinition.isActionsEnabled(), stateChangeReason,
alarm.getTransitionSubAlarms(), timestamp);
try {
alarmEventForwarder.send(Serialization.toJson(event));
} catch (Exception ignore) {
logger.error("Failure sending alarm", ignore);
}
}
示例6: process
import monasca.common.model.event.AlarmStateTransitionedEvent; //导入依赖的package包/类
@Override
protected int process(String msg) {
AlarmStateTransitionedEvent alarmStateTransitionedEvent;
try {
alarmStateTransitionedEvent =
this.objectMapper.readValue(msg, AlarmStateTransitionedEvent.class);
} catch (IOException e) {
logger.error("[{}]: failed to deserialize message {}", this.threadId, msg, e);
return 0;
}
logger.debug("[{}]: [{}:{}] {}",
this.threadId,
this.getBatchCount(),
this.getMsgCount(),
alarmStateTransitionedEvent);
this.alarmRepo.addToBatch(alarmStateTransitionedEvent, this.threadId);
this.alarmStateTransitionCounter.inc();
return 1;
}
示例7: addToBatch
import monasca.common.model.event.AlarmStateTransitionedEvent; //导入依赖的package包/类
@Override
public void addToBatch(AlarmStateTransitionedEvent alarmStateTransitionedEvent, String id) {
this.alarmStateTransitionedEventList.add(alarmStateTransitionedEvent);
this.alarmStateHistoryMeter.mark();
}