Initial commit for ServiceHandler
[transportpce.git] / stubrenderer / src / main / java / org / opendaylight / transportpce / stubrenderer / SendingRendererRPCs.java
1 /*
2  * Copyright © 2017 Orange, Inc. and others.  All rights reserved.
3  *
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
7  */
8
9 package org.opendaylight.transportpce.stubrenderer;
10
11 import java.util.ArrayList;
12 import java.util.List;
13
14 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service.TopologyBuilder;
15 import org.opendaylight.yang.gen.v1.http.org.openroadm.topology.rev161014.topology.AToZ;
16 import org.opendaylight.yang.gen.v1.http.org.openroadm.topology.rev161014.topology.ZToA;
17 import org.slf4j.Logger;
18 import org.slf4j.LoggerFactory;
19
20 /*
21  *Class for Sending
22  * Renderer requests :
23  * - Service-implementation-request
24  * - Service-delete-request.
25  * @author Martial Coulibaly ( martial.coulibaly@gfi.com ) on behalf of Orange
26  *
27  */
28 public class SendingRendererRPCs {
29     /* Logging. */
30     private static final Logger LOG = LoggerFactory.getLogger(SendingRendererRPCs.class);
31     /* define procedure success (or not ). */
32     private Boolean success;
33     /* define type of request<br>
34      * <code>true</code> pathcomputation <br>
35      * <code>false</code> cancelresourcereserve. */
36     private TopologyBuilder topology;
37     private List<AToZ> atoz;
38     private List<ZToA> ztoa;
39
40     public SendingRendererRPCs() {
41         success = true;
42         setTopology(null);
43     }
44
45     private void buildAtoZ() {
46         atoz = new ArrayList<AToZ>();
47     }
48
49     private void buildZtoA() {
50         ztoa = new ArrayList<ZToA>();
51     }
52
53     public void serviceDelete() {
54         LOG.info("Wait for 10s til beginning the Renderer ServiceDelete request");
55         try {
56             Thread.sleep(10000); //sleep for 10s
57         } catch (InterruptedException e) {
58             LOG.error(e.toString());
59         }
60         LOG.info("ServiceDelete ...");
61     }
62
63     public void serviceImplementation() {
64         LOG.info("Wait for 10s til beginning the Renderer serviceImplementation request");
65         try {
66             Thread.sleep(10000); //sleep for 10s
67         } catch (InterruptedException e) {
68             LOG.error(e.toString());
69         }
70         LOG.info("serviceImplementation ...");
71         buildAtoZ();
72         buildZtoA();
73
74         setTopology(new TopologyBuilder()
75             .setAToZ(atoz)
76             .setZToA(ztoa));
77     }
78
79     public Boolean getSuccess() {
80         return success;
81     }
82
83     public void setSuccess(Boolean success) {
84         this.success = success;
85     }
86
87     public TopologyBuilder getTopology() {
88         return topology;
89     }
90
91     public void setTopology(TopologyBuilder topo) {
92         this.topology = topo;
93     }
94 }