Search in sources :

Example 1 with Decorator

use of com.ctrip.xpipe.redis.console.alert.decorator.Decorator in project x-pipe by ctripcorp.

the class DecoratorManager method generateTitleAndContent.

public Pair<String, String> generateTitleAndContent(Map<ALERT_TYPE, Set<AlertEntity>> alerts) {
    Decorator decorator = decorators.get(ScheduledAlertMessageDecorator.ID);
    ScheduledAlertMessageDecorator scheduledDecorator = (ScheduledAlertMessageDecorator) decorator;
    String content = scheduledDecorator.generateBody(alerts);
    String title = scheduledDecorator.generateTitle();
    return new Pair<>(title, content);
}
Also used : Decorator(com.ctrip.xpipe.redis.console.alert.decorator.Decorator) RecoverMessageDecorator(com.ctrip.xpipe.redis.console.alert.decorator.RecoverMessageDecorator) ScheduledAlertMessageDecorator(com.ctrip.xpipe.redis.console.alert.decorator.ScheduledAlertMessageDecorator) AlertMessageDecorator(com.ctrip.xpipe.redis.console.alert.decorator.AlertMessageDecorator) ScheduledAlertMessageDecorator(com.ctrip.xpipe.redis.console.alert.decorator.ScheduledAlertMessageDecorator) Pair(com.ctrip.xpipe.tuple.Pair)

Example 2 with Decorator

use of com.ctrip.xpipe.redis.console.alert.decorator.Decorator in project x-pipe by ctripcorp.

the class DecoratorManager method generateTitleAndContent.

/* There's another option to generate content for recover message
    So the @param isAlertMessage is the pivot to switch between two phases
    */
public Pair<String, String> generateTitleAndContent(AlertEntity alert, boolean isAlertMessage) {
    Decorator decorator = getDecorator(isAlertMessage);
    String content = decorator.generateContent(alert);
    String title = decorator.generateTitle(alert);
    return new Pair<>(title, content);
}
Also used : Decorator(com.ctrip.xpipe.redis.console.alert.decorator.Decorator) RecoverMessageDecorator(com.ctrip.xpipe.redis.console.alert.decorator.RecoverMessageDecorator) ScheduledAlertMessageDecorator(com.ctrip.xpipe.redis.console.alert.decorator.ScheduledAlertMessageDecorator) AlertMessageDecorator(com.ctrip.xpipe.redis.console.alert.decorator.AlertMessageDecorator) Pair(com.ctrip.xpipe.tuple.Pair)

Aggregations

AlertMessageDecorator (com.ctrip.xpipe.redis.console.alert.decorator.AlertMessageDecorator)2 Decorator (com.ctrip.xpipe.redis.console.alert.decorator.Decorator)2 RecoverMessageDecorator (com.ctrip.xpipe.redis.console.alert.decorator.RecoverMessageDecorator)2 ScheduledAlertMessageDecorator (com.ctrip.xpipe.redis.console.alert.decorator.ScheduledAlertMessageDecorator)2 Pair (com.ctrip.xpipe.tuple.Pair)2