Source Code Cross Referenced for RpcDispatcherMultiplexerTest.java in  » Net » JGroups-2.4.1-sp3 » org » jgroups » tests » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Net » JGroups 2.4.1 sp3 » org.jgroups.tests 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.jgroups.tests;
002:
003:        import org.jgroups.*;
004:        import org.jgroups.blocks.GroupRequest;
005:        import org.jgroups.blocks.RequestHandler;
006:        import org.jgroups.blocks.RpcDispatcher;
007:        import org.jgroups.util.RspList;
008:
009:        import java.util.Vector;
010:
011:        /**
012:         * Tests cluster method invocations on disconnected and connected services
013:         * @author Bela Ban
014:         * @version $Id: RpcDispatcherMultiplexerTest.java,v 1.5 2006/09/01 07:44:16 belaban Exp $
015:         */
016:        public class RpcDispatcherMultiplexerTest implements 
017:                MembershipListener, RequestHandler, ChannelListener {
018:            Channel channel;
019:            JChannelFactory factory = null;
020:            RpcDispatcher disp;
021:            String props = null;
022:            boolean spurious_channel_created = false;
023:
024:            public static void main(String[] args) throws Exception {
025:                String props = null;
026:                for (int i = 0; i < args.length; i++) {
027:                    String arg = args[i];
028:                    if (arg.equals("-props")) {
029:                        props = args[++i];
030:                        continue;
031:                    }
032:                    help();
033:                    return;
034:                }
035:                new RpcDispatcherMultiplexerTest().start(props);
036:            }
037:
038:            private void start(String props) throws Exception {
039:                if (factory == null)
040:                    factory = new JChannelFactory();
041:                if (props == null)
042:                    this .props = "stacks.xml";
043:                else
044:                    this .props = props;
045:                factory.setMultiplexerConfig(this .props);
046:                channel = factory.createMultiplexerChannel("udp", "MyId");
047:
048:                if (!spurious_channel_created) {
049:                    // create one additional channel so that we don't close the JGroups channel when disconnecting from MuxChannel !
050:                    Channel tmp = factory.createMultiplexerChannel("udp",
051:                            "tempChannel");
052:                    tmp.connect("bla");
053:                    spurious_channel_created = true;
054:                }
055:
056:                channel.addChannelListener(this );
057:                channel.setOpt(Channel.AUTO_RECONNECT, Boolean.TRUE);
058:                disp = new RpcDispatcher(channel, null, this , this , false, // deadlock detection is disabled
059:                        true); // concurrent processing is enabled
060:                channel.connect("MessageDispatcherTestGroup");
061:                mainLoop();
062:            }
063:
064:            private void stop() {
065:                disp.stop();
066:                channel.close();
067:            }
068:
069:            private void mainLoop() throws Exception {
070:                while (true) {
071:                    int c;
072:                    System.in.skip(System.in.available());
073:                    System.out
074:                            .println("\n[1] Send [2] Start service [3] Stop service [4] Print view [q] Quit");
075:                    c = System.in.read();
076:                    switch (c) {
077:                    case -1:
078:                        break;
079:                    case '1':
080:                        invokeGroupMethod();
081:                        break;
082:                    case '2':
083:                        start(this .props);
084:                        break;
085:                    case '3':
086:                        stop();
087:                        break;
088:                    case '4':
089:                        View v = channel.getView();
090:                        System.out.println("View: " + v);
091:                        break;
092:                    case 'q':
093:                        channel.close();
094:                        return;
095:                    default:
096:                        break;
097:                    }
098:                }
099:            }
100:
101:            public Object helloWorld() {
102:                System.out.println("method helloWorld() was called");
103:                return "same to you";
104:            }
105:
106:            private void invokeGroupMethod() {
107:                RspList rsp_list;
108:                View v = channel.getView();
109:                if (v == null)
110:                    return;
111:                Vector members = new Vector(v.getMembers());
112:                System.out.println("sending to " + members);
113:                rsp_list = disp.callRemoteMethods(members, "helloWorld", null,
114:                        (String[]) null, GroupRequest.GET_ALL, 0);
115:                System.out.println("responses:\n" + rsp_list);
116:            }
117:
118:            private static void help() {
119:                System.out
120:                        .println("MessageDispatcherShunTest [-help] [-props <props>]");
121:            }
122:
123:            public Object handle(Message msg) {
124:                return "same to you";
125:            }
126:
127:            public void viewAccepted(View new_view) {
128:                System.out.println("-- view: " + new_view);
129:            }
130:
131:            public void suspect(Address suspected_mbr) {
132:            }
133:
134:            public void block() {
135:            }
136:
137:            public void channelConnected(Channel channel) {
138:                // System.out.println("-- channel connected");
139:            }
140:
141:            public void channelDisconnected(Channel channel) {
142:                // System.out.println("-- channel disconnected");
143:            }
144:
145:            public void channelClosed(Channel channel) {
146:                // System.out.println("-- channel closed");
147:            }
148:
149:            public void channelShunned() {
150:                // System.out.println("-- channel shunned");
151:            }
152:
153:            public void channelReconnected(Address addr) {
154:                // System.out.println("-- channel reconnected");
155:            }
156:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.