2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 - 2019 AT&T Intellectual Property. 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.vid.scheduler;
23 import org.onap.vid.aai.ExceptionWithRequestInfo;
24 import org.onap.vid.model.probes.ErrorMetadata;
25 import org.onap.vid.model.probes.ExternalComponentStatus;
26 import org.onap.vid.model.probes.HttpRequestMetadata;
27 import org.onap.vid.mso.RestObjectWithRequestInfo;
28 import org.onap.vid.services.ChangeManagementService;
29 import org.onap.vid.utils.Logging;
30 import org.springframework.beans.factory.annotation.Autowired;
32 public class SchedulerServiceImpl implements SchedulerService{
34 private final ChangeManagementService changeManagementService;
38 public SchedulerServiceImpl(ChangeManagementService changeManagementService) {
39 this.changeManagementService = changeManagementService;
43 public ExternalComponentStatus probeComponent() {
44 long startTime = System.currentTimeMillis();
46 RestObjectWithRequestInfo response = this.changeManagementService.getSchedulerChangeManagementsWithRequestInfo();
47 return new ExternalComponentStatus(
48 ExternalComponentStatus.Component.SCHEDULER,
50 new HttpRequestMetadata(response, "OK", startTime)
52 } catch (ExceptionWithRequestInfo e) {
53 long duration = System.currentTimeMillis() - startTime;
54 return new ExternalComponentStatus(ExternalComponentStatus.Component.SCHEDULER,
56 new HttpRequestMetadata(e, duration));
57 } catch (Exception e) {
58 long duration = System.currentTimeMillis() - startTime;
59 return new ExternalComponentStatus(ExternalComponentStatus.Component.SCHEDULER, false,
60 new ErrorMetadata(Logging.exceptionToDescription(e), duration));