2 * Copyright © 2024 Orange, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.transportpce.renderer.rpcs;
10 import static java.util.Objects.requireNonNull;
12 import com.google.common.util.concurrent.ListenableFuture;
13 import java.util.concurrent.ExecutionException;
14 import org.opendaylight.transportpce.renderer.ModelMappingUtils;
15 import org.opendaylight.transportpce.renderer.provisiondevice.RendererServiceOperations;
16 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915.ServiceImplementationRequest;
17 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915.ServiceImplementationRequestInput;
18 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915.ServiceImplementationRequestOutput;
19 import org.opendaylight.yangtools.yang.common.RpcResult;
20 import org.slf4j.Logger;
21 import org.slf4j.LoggerFactory;
24 public class ServiceImplementationRequestImpl implements ServiceImplementationRequest {
25 private static final Logger LOG = LoggerFactory.getLogger(ServiceImplementationRequestImpl.class);
26 private final RendererServiceOperations rendererServiceOperations;
28 public ServiceImplementationRequestImpl(final RendererServiceOperations rendererServiceOperations) {
29 this.rendererServiceOperations = requireNonNull(rendererServiceOperations);
33 public ListenableFuture<RpcResult<ServiceImplementationRequestOutput>> invoke(
34 ServiceImplementationRequestInput input) {
35 String serviceName = input.getServiceName();
36 LOG.info("Calling RPC service impl request {}", serviceName);
37 ServiceImplementationRequestOutput output = null;
39 output = this.rendererServiceOperations.serviceImplementation(input, false).get();
40 } catch (InterruptedException | ExecutionException e) {
41 LOG.error("RPC service implementation failed !", e);
42 Thread.currentThread().interrupt();
44 return ModelMappingUtils.createServiceImplementationRpcResponse(output);