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.v3.client.cli;
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                  String input = null;
43                  do {
44                          System.out.println("1) Sets undirected replication two instances of jUDDI");
45                          System.out.println("2) Sets undirected replication 3 instances of jUDDI");
46                          System.out.println("3) Sets directed replication between 3 instances of jUDDI");
47                          System.out.println("4) Prints the replication status for all nodes");
48                          System.out.println("5) Prints the business, service, and tmodels counts");
49                          System.out.println("6) Ping all nodes");
50  
51                          System.out.println("q) quit");
52                          System.out.print("Selection: ");
53                          input = System.console().readLine();
54  
55                          processInput(input, clerkManager);
56  
57                  } while (!input.equalsIgnoreCase("q"));
58          }
59  
60          private static void processInput(String input, UDDIClient clerkManager) throws Exception {
61                  if (input.equals("1")) {
62                          new JuddiAdminService(clerkManager, null).autoMagic();
63                  } else if (input.equals("2")) {
64                          new JuddiAdminService(clerkManager, null).autoMagic3();
65                  } else if (input.equals("3")) {
66                          new JuddiAdminService(clerkManager, null).autoMagicDirected();
67                  } else if (input.equals("4")) {
68                          new JuddiAdminService(clerkManager, null).printStatus();
69                  } else if (input.equals("5")) {
70                          List<Node> uddiNodeList = clerkManager.getClientConfig().getUDDINodeList();
71                          for (Node n : uddiNodeList) {
72                                  UDDIInquiryPortType uddiInquiryService = clerkManager.getTransport(n.getName()).getUDDIInquiryService();
73  
74                                  FindBusiness fb = new FindBusiness();
75  
76                                  fb.getName().add(new Name(UDDIConstants.WILDCARD, null));
77                                  fb.setFindQualifiers(new FindQualifiers());
78                                  fb.getFindQualifiers().getFindQualifier().add(UDDIConstants.APPROXIMATE_MATCH);
79                                  fb.setMaxRows(1);
80                                  fb.setListHead(0);
81                                  BusinessList findBusiness = uddiInquiryService.findBusiness(fb);
82                                  System.out.println(n.getName() + " business count "
83                                          + findBusiness.getListDescription().getActualCount());
84                                  FindService fs = new FindService();
85  
86                                  fs.getName().add(new Name(UDDIConstants.WILDCARD, null));
87                                  fs.setFindQualifiers(new FindQualifiers());
88                                  fs.getFindQualifiers().getFindQualifier().add(UDDIConstants.APPROXIMATE_MATCH);
89                                  fs.setMaxRows(1);
90                                  fs.setListHead(0);
91                                  ServiceList findService = uddiInquiryService.findService(fs);
92                                  System.out.println(n.getName() + " service count "
93                                          + findService.getListDescription().getActualCount());
94  
95                                  FindTModel ft = new FindTModel();
96                                  ft.setName(new Name(UDDIConstants.WILDCARD, null));
97                                  ft.setFindQualifiers(new FindQualifiers());
98                                  ft.getFindQualifiers().getFindQualifier().add(UDDIConstants.APPROXIMATE_MATCH);
99                                  ft.setMaxRows(1);
100                                 ft.setListHead(0);
101                                 TModelList findTModel = uddiInquiryService.findTModel(ft);
102                                 System.out.println(n.getName() + " tModel count "
103                                         + findTModel.getListDescription().getActualCount());
104 
105                         }
106                         System.out.println();
107                 } else if (input.equals("6")) {
108                         new JuddiAdminService(clerkManager, null).pingAll();
109                 }
110 
111         }
112 
113 }