2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2018 Huawei Technologies Co., Ltd. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.ccsdk.sli.plugins.restconfdiscovery;
23 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
24 import org.onap.ccsdk.sli.core.sli.SvcLogicException;
25 import org.slf4j.Logger;
26 import org.slf4j.LoggerFactory;
30 import static org.onap.ccsdk.sli.plugins.prop.JsonParser.convertToProperties;
33 * Processes the events from event queue and executes callback DG.
35 class EventProcessor implements Runnable {
36 private static final Logger log = LoggerFactory.getLogger(EventProcessor.class);
37 private RestconfDiscoveryNode node;
39 private static final String EVENT_SUBSCRIPTION_ID = "ietf-notification:notification" +
40 ".ietf-yang-push:push-change-update" +
43 public EventProcessor(RestconfDiscoveryNode node) {
51 String payload = node.eventQueue().take();
52 Map<String, String> param = convertToProperties(payload);
53 String id = param.get(EVENT_SUBSCRIPTION_ID);
54 SubscriptionInfo info = node.subscriptionInfoMap().get(id);
56 SvcLogicContext ctx = new SvcLogicContext();
57 for (Map.Entry<String, String> entry : param.entrySet()) {
58 ctx.setAttribute(entry.getKey(), entry.getValue());
60 SvcLogicGraphInfo callbackDG = info.callBackDG();
61 callbackDG.executeGraph(ctx);
63 } catch (InterruptedException | SvcLogicException e) {
64 log.error(e.getMessage());
65 throw new RuntimeException(e.getMessage());