2 * Copyright 2017 ZTE Corporation.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package org.onap.holmes.engine.dmaap;
18 import static jdk.nashorn.internal.runtime.regexp.joni.Config.log;
20 import java.util.ArrayList;
21 import java.util.List;
22 import lombok.extern.slf4j.Slf4j;
23 import org.onap.holmes.common.api.stat.VesAlarm;
24 import org.onap.holmes.common.exception.CorrelationException;
25 import org.onap.holmes.dsa.dmaappolling.Subscriber;
26 import org.onap.holmes.engine.manager.DroolsEngine;
29 public class DMaaPAlarmPolling implements Runnable {
31 private Subscriber subscriber;
32 private DroolsEngine droolsEngine;
33 private volatile boolean isAlive = true;
35 public DMaaPAlarmPolling(Subscriber subscriber, DroolsEngine droolsEngine) {
36 this.subscriber = subscriber;
37 this.droolsEngine = droolsEngine;
42 List<VesAlarm> vesAlarmList = new ArrayList<>();
44 vesAlarmList = subscriber.subscribe();
45 vesAlarmList.forEach(vesAlarm -> droolsEngine.putRaisedIntoStream(vesAlarm));
46 } catch (CorrelationException e) {
47 log.error("Failed to process alarms. Sleep for 60 seconds to restart.", e);
50 } catch (InterruptedException e1) {
51 log.info("Thread is still active.", e);
53 } catch (Exception e) {
54 log.error("An error occurred while processing alarm. Sleep for 60 seconds to restart.", e);
57 } catch (InterruptedException e1) {
58 log.info("Thread is still active.", e);
64 public void stopTask() {