This project has retired. For details please refer to its Attic page.
EntryPoitMultiNode xref
View Javadoc
1   /*
2    * Copyright 2015 The Apache Software Foundation.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.apache.juddi.samples;
17  
18  import java.util.List;
19  import org.apache.juddi.api_v3.Node;
20  import org.apache.juddi.v3.client.UDDIConstants;
21  import org.apache.juddi.v3.client.config.UDDIClient;
22  import org.uddi.api_v3.BusinessList;
23  import org.uddi.api_v3.FindBusiness;
24  import org.uddi.api_v3.FindQualifiers;
25  import org.uddi.api_v3.FindService;
26  import org.uddi.api_v3.FindTModel;
27  import org.uddi.api_v3.Name;
28  import org.uddi.api_v3.ServiceList;
29  import org.uddi.api_v3.TModelList;
30  import org.uddi.v3_service.UDDIInquiryPortType;
31  
32  /**
33   *
34   * @author alex
35   */
36  public class EntryPoitMultiNode {
37  
38          static void goMultiNode() throws Exception {
39                 
40                  UDDIClient clerkManager = new UDDIClient("META-INF/simple-publish-uddi.xml");
41  
42                 
43                  String input = null;
44                  do {
45                          System.out.println("1) Sets undirected replication two instances of jUDDI");
46                          System.out.println("2) Sets undirected replication 3 instances of jUDDI");
47                          System.out.println("3) Sets directed replication between 3 instances of jUDDI");
48                          System.out.println("4) Prints the replication status for all nodes");
49                          System.out.println("5) Prints the business, service, and tmodels counts");
50                          System.out.println("6) Ping all nodes");
51  
52                          System.out.println("q) quit");
53                          System.out.print("Selection: ");
54                          input = System.console().readLine();
55  
56                          processInput(input, clerkManager);
57  
58                  } while (!input.equalsIgnoreCase("q"));
59          }
60  
61          private static void processInput(String input, UDDIClient clerkManager) throws Exception {
62                  if (input.equals("1")) {
63  
64                          new JuddiAdminService(clerkManager, null).autoMagic();
65                          List<Node> uddiNodeList = clerkManager.getClientConfig().getUDDINodeList();
66                          for (int i = 0; i < uddiNodeList.size(); i++) {
67                                  new UddiCreatebulk(uddiNodeList.get(i).getName()).publishBusiness(null, 1, 1, "root@" + uddiNodeList.get(i).getName());
68                          }
69                          //new UddiCreatebulk("uddi:another.juddi.apache.org:node2").publishBusiness(null, 1, 1);
70                  } else if (input.equals("2")) {
71  
72                          new JuddiAdminService(clerkManager, null).autoMagic3();
73                          List<Node> uddiNodeList = clerkManager.getClientConfig().getUDDINodeList();
74                          for (int i = 0; i < uddiNodeList.size(); i++) {
75                                  new UddiCreatebulk(uddiNodeList.get(i).getName()).publishBusiness(null, 1, 1, "root@" + uddiNodeList.get(i).getName());
76                          }
77                          //new UddiCreatebulk("uddi:another.juddi.apache.org:node2").publishBusiness(null, 1, 1);
78                  } else if (input.equals("3")) {
79                          new JuddiAdminService(clerkManager, null).autoMagicDirected();
80  
81                          List<Node> uddiNodeList = clerkManager.getClientConfig().getUDDINodeList();
82                          for (int i = 0; i < uddiNodeList.size(); i++) {
83                                  new UddiCreatebulk(uddiNodeList.get(i).getName()).publishBusiness(null, 1, 1, "root@" + uddiNodeList.get(i).getName());
84                          }
85                  } else if (input.equals("4")) {
86                          new JuddiAdminService(clerkManager, null).printStatus();
87                  } else if (input.equals("5")) {
88                          List<Node> uddiNodeList = clerkManager.getClientConfig().getUDDINodeList();
89                          for (Node n : uddiNodeList) {
90                                  UDDIInquiryPortType uddiInquiryService = clerkManager.getTransport(n.getName()).getUDDIInquiryService();
91  
92                                  FindBusiness fb = new FindBusiness();
93  
94                                  fb.getName().add(new Name(UDDIConstants.WILDCARD, null));
95                                  fb.setFindQualifiers(new FindQualifiers());
96                                  fb.getFindQualifiers().getFindQualifier().add(UDDIConstants.APPROXIMATE_MATCH);
97                                  fb.setMaxRows(1);
98                                  fb.setListHead(0);
99                                  BusinessList findBusiness = uddiInquiryService.findBusiness(fb);
100                                 System.out.println(n.getName() + " business count "
101                                         + findBusiness.getListDescription().getActualCount());
102                                 FindService fs = new FindService();
103 
104                                 fs.getName().add(new Name(UDDIConstants.WILDCARD, null));
105                                 fs.setFindQualifiers(new FindQualifiers());
106                                 fs.getFindQualifiers().getFindQualifier().add(UDDIConstants.APPROXIMATE_MATCH);
107                                 fs.setMaxRows(1);
108                                 fs.setListHead(0);
109                                 ServiceList findService = uddiInquiryService.findService(fs);
110                                 System.out.println(n.getName() + " service count "
111                                         + findService.getListDescription().getActualCount());
112 
113                                 FindTModel ft = new FindTModel();
114                                 ft.setName(new Name(UDDIConstants.WILDCARD, null));
115                                 ft.setFindQualifiers(new FindQualifiers());
116                                 ft.getFindQualifiers().getFindQualifier().add(UDDIConstants.APPROXIMATE_MATCH);
117                                 ft.setMaxRows(1);
118                                 ft.setListHead(0);
119                                 TModelList findTModel = uddiInquiryService.findTModel(ft);
120                                 System.out.println(n.getName() + " tModel count "
121                                         + findTModel.getListDescription().getActualCount());
122 
123                         }
124                         System.out.println();
125                 } else if (input.equals("6")) {
126                         new JuddiAdminService(clerkManager, null).pingAll();
127                 }
128 
129         }
130 
131 }