Merge "Version update to 1.6 of the service-path model"
[transportpce.git] / tests / 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 Renderer requests :
22  * - Service-implementation-request
23  * - Service-delete-request.
24  * @author Martial Coulibaly ( martial.coulibaly@gfi.com ) on behalf of Orange
25  *
26  */
27 public class SendingRendererRPCs {
28     /* Logging. */
29     private static final Logger LOG = LoggerFactory.getLogger(SendingRendererRPCs.class);
30     /* define procedure success (or not ). */
31     private Boolean success;
32     /* define type of request<br>
33      * <code>true</code> pathcomputation <br>
34      * <code>false</code> cancelresourcereserve. */
35     private TopologyBuilder topology;
36     private List<AToZ> atoz;
37     private List<ZToA> ztoa;
38
39     public SendingRendererRPCs() {
40         success = true;
41         setTopology(null);
42     }
43
44     private void buildAtoZ() {
45         atoz = new ArrayList<AToZ>();
46     }
47
48     private void buildZtoA() {
49         ztoa = new ArrayList<ZToA>();
50     }
51
52     public void serviceDelete() {
53         LOG.info("Wait for 10s til beginning the Renderer ServiceDelete request");
54         try {
55             Thread.sleep(10000); //sleep for 10s
56         } catch (InterruptedException e) {
57             LOG.error(e.toString());
58         }
59         LOG.info("ServiceDelete ...");
60     }
61
62     public void serviceImplementation() {
63         LOG.info("Wait for 10s til beginning the Renderer serviceImplementation request");
64         try {
65             Thread.sleep(10000); //sleep for 10s
66         } catch (InterruptedException e) {
67             LOG.error(e.toString());
68         }
69         LOG.info("serviceImplementation ...");
70         buildAtoZ();
71         buildZtoA();
72
73         setTopology(new TopologyBuilder()
74             .setAToZ(atoz)
75             .setZToA(ztoa));
76     }
77
78     public Boolean getSuccess() {
79         return success;
80     }
81
82     public void setSuccess(Boolean success) {
83         this.success = success;
84     }
85
86     public TopologyBuilder getTopology() {
87         return topology;
88     }
89
90     public void setTopology(TopologyBuilder topo) {
91         this.topology = topo;
92     }
93 }