1 /*******************************************************************************
2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2019 Wipro Limited.
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=========================================================
20 *******************************************************************************/
22 package org.onap.dcaegen2.services.sonhms.child;
24 import java.util.ArrayList;
25 import java.util.List;
26 import java.util.UUID;
27 import java.util.concurrent.BlockingQueue;
29 import org.onap.dcaegen2.services.sonhms.Configuration;
30 import org.onap.dcaegen2.services.sonhms.exceptions.OofNotFoundException;
31 import org.onap.dcaegen2.services.sonhms.model.AnrInput;
32 import org.onap.dcaegen2.services.sonhms.restclient.OofRestClient;
33 import org.slf4j.Logger;
35 public class StateOof {
36 private static final Logger log = org.slf4j.LoggerFactory.getLogger(StateOof.class);
37 private BlockingQueue<List<String>> childStatusUpdate;
44 * Parameterized Constructor.
47 public StateOof(BlockingQueue<List<String>> childStatusUpdate) {
49 this.childStatusUpdate = childStatusUpdate;
53 * Triggers OOF for pci.
55 * @throws OofNotFoundException
56 * when trigger oof fails
58 public UUID triggerOof(List<String> cellidList, String networkId, List<AnrInput> anrInputList)
59 throws OofNotFoundException, InterruptedException {
61 log.info("Triggering oof");
63 log.debug("the cells triggering the oof are {}", cellidList);
65 UUID transactionId = UUID.randomUUID();
67 Configuration config = Configuration.getInstance();
68 int numSolutions = config.getNumSolutions();
69 List<String> pciOptimizerList = new ArrayList<>();
70 List<String> pciAnrOptimizerList = new ArrayList<>();
72 pciOptimizerList.add(config.getPciOptimizer());
73 pciAnrOptimizerList.add(config.getPciAnrOptimizer());
75 String oofResponse = null;
76 if (!anrInputList.isEmpty()) {
77 oofResponse = OofRestClient.queryOof(numSolutions, transactionId.toString(), "create", cellidList,
78 networkId, pciAnrOptimizerList, anrInputList);
80 oofResponse = OofRestClient.queryOof(numSolutions, transactionId.toString(), "create", cellidList,
81 networkId, pciOptimizerList, anrInputList);
83 log.info("Synchronous Response {}", oofResponse);
85 List<String> childStatus = new ArrayList<>();
86 childStatus.add(Long.toString(Thread.currentThread().getId()));
87 childStatus.add("triggeredOof");
89 childStatusUpdate.put(childStatus);
90 } catch (InterruptedException e1) {
91 log.debug("Interrupted execption {}", e1);
92 Thread.currentThread().interrupt();