All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.opendaylight.openflowplugin.applications.southboundcli.alarm.NodeReconciliationAlarm Maven / Gradle / Ivy

The newest version!
/*
 * Copyright (c) 2018 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
 * and is available at http://www.eclipse.org/legal/epl-v10.html
 */
package org.opendaylight.openflowplugin.applications.southboundcli.alarm;

import com.google.common.collect.ImmutableList;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicLong;
import javax.management.AttributeChangeNotification;
import javax.management.NotificationBroadcasterSupport;

public final class NodeReconciliationAlarm extends NotificationBroadcasterSupport
        implements NodeReconciliationAlarmMBean {
    private final AtomicLong sequenceNumber = new AtomicLong(1);

    private volatile List raiseAlarmObject = new ArrayList<>();
    private volatile List clearAlarmObject = new ArrayList<>();

    @Override
    public void setRaiseAlarmObject(final List raiseAlarmObject) {
        this.raiseAlarmObject = raiseAlarmObject;

        sendRaiseAlarmNotification(this.raiseAlarmObject);
    }

    private void sendRaiseAlarmNotification(final List alarmObject) {
        sendNotification(new AttributeChangeNotification(this, sequenceNumber.getAndIncrement(),
                System.currentTimeMillis(), "raise alarm object notified ", "raiseAlarmObject", "ArrayList", "",
                alarmObject));
    }

    @Override
    public List getRaiseAlarmObject() {
        return raiseAlarmObject;
    }

    @Override
    public void setClearAlarmObject(final List clearAlarmObject) {
        this.clearAlarmObject = clearAlarmObject;
        sendClearAlarmNotification(this.clearAlarmObject);
    }

    private void sendClearAlarmNotification(final List alarmObject) {
        sendNotification(new AttributeChangeNotification(this, sequenceNumber.getAndIncrement(),
                System.currentTimeMillis(), "clear alarm object notified ", "clearAlarmObject", "ArrayList", "",
                alarmObject));
    }

    @Override
    public List getClearAlarmObject() {
        return clearAlarmObject;
    }

    @Override
    public void raiseAlarm(final String alarmName, final String additionalText, final String source) {
        sendRaiseAlarmNotification(ImmutableList.of(alarmName, additionalText, source));
    }

    @Override
    public void clearAlarm(final String alarmName, final String additionalText, final String source) {
        sendClearAlarmNotification(ImmutableList.of(alarmName, additionalText, source));
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy