Source Code Cross Referenced for BackendTransfer.java in  » Database-JDBC-Connection-Pool » sequoia-2.10.9 » org » continuent » sequoia » controller » virtualdatabase » protocol » 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 » Database JDBC Connection Pool » sequoia 2.10.9 » org.continuent.sequoia.controller.virtualdatabase.protocol 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * Sequoia: Database clustering technology.
003:         * Copyright (C) 2002-2004 French National Institute For Research In Computer
004:         * Science And Control (INRIA).
005:         * Copyright (C) 2005 AmicoSoft, Inc. dba Emic Networks
006:         * Copyright (C) 2006 Continuent, Inc.
007:         * Contact: sequoia@continuent.org
008:         * 
009:         * Licensed under the Apache License, Version 2.0 (the "License");
010:         * you may not use this file except in compliance with the License.
011:         * You may obtain a copy of the License at
012:         * 
013:         * http://www.apache.org/licenses/LICENSE-2.0
014:         * 
015:         * Unless required by applicable law or agreed to in writing, software
016:         * distributed under the License is distributed on an "AS IS" BASIS,
017:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
018:         * See the License for the specific language governing permissions and
019:         * limitations under the License. 
020:         *
021:         * Initial developer(s): Nicolas Modrzyk.
022:         * Contributor(s): Emmanuel Cecchet.
023:         */package org.continuent.sequoia.controller.virtualdatabase.protocol;
024:
025:        import java.io.Serializable;
026:        import java.util.LinkedList;
027:
028:        import org.continuent.hedera.common.Member;
029:        import org.continuent.sequoia.common.exceptions.VirtualDatabaseException;
030:        import org.continuent.sequoia.common.i18n.Translate;
031:        import org.continuent.sequoia.common.jmx.management.BackendInfo;
032:        import org.continuent.sequoia.common.log.Trace;
033:        import org.continuent.sequoia.controller.backend.DatabaseBackend;
034:        import org.continuent.sequoia.controller.virtualdatabase.DistributedVirtualDatabase;
035:
036:        /**
037:         * This class defines a BackendTransfer message used to transfer the backend
038:         * information and re-enable the backend on the remote controller (checkpoint
039:         * transfer have already been taken care of).
040:         * 
041:         * @author <a href="mailto:Nicolas.Modrzyk@inrialpes.fr">Nicolas Modrzyk </a>
042:         * @author <a href="mailto:emmanuel.cecchet@continuent.com">Emmanuel Cecchet</a>
043:         * @version 1.0
044:         */
045:        public class BackendTransfer extends DistributedVirtualDatabaseMessage {
046:            private static final long serialVersionUID = 520265407391630486L;
047:
048:            private BackendInfo info;
049:            private String controllerDest;
050:            private String checkpointName;
051:
052:            private transient LinkedList totalOrderQueue;
053:
054:            /**
055:             * Creates a new <code>BackendTransfer</code> object
056:             * 
057:             * @param info the info on the backend to transfer
058:             * @param controllerDest the JMX name of the target controller
059:             * @param checkpointName the name of the ckeckpoint from which to restore
060:             */
061:            public BackendTransfer(String controllerDest,
062:                    String checkpointName, BackendInfo info) {
063:                this .info = info;
064:                this .controllerDest = controllerDest;
065:                this .checkpointName = checkpointName;
066:            }
067:
068:            /**
069:             * Returns the controllerDest value.
070:             * 
071:             * @return Returns the controllerDest.
072:             */
073:            public String getControllerDest() {
074:                return controllerDest;
075:            }
076:
077:            /**
078:             * Returns the info value.
079:             * 
080:             * @return Returns the info.
081:             */
082:            public BackendInfo getInfo() {
083:                return info;
084:            }
085:
086:            /**
087:             * Returns the checkpointName value.
088:             * 
089:             * @return Returns the checkpointName.
090:             */
091:            public String getCheckpointName() {
092:                return checkpointName;
093:            }
094:
095:            /**
096:             * @see org.continuent.sequoia.controller.virtualdatabase.protocol.DistributedVirtualDatabaseMessage#handleMessageSingleThreaded(org.continuent.sequoia.controller.virtualdatabase.DistributedVirtualDatabase,
097:             *      org.continuent.hedera.common.Member)
098:             */
099:            public Object handleMessageSingleThreaded(
100:                    DistributedVirtualDatabase dvdb, Member sender) {
101:                totalOrderQueue = dvdb.getTotalOrderQueue();
102:                if (totalOrderQueue == null)
103:                    return new VirtualDatabaseException(Translate.get(
104:                            "virtualdatabase.no.total.order.queue", dvdb
105:                                    .getVirtualDatabaseName()));
106:
107:                synchronized (totalOrderQueue) {
108:                    totalOrderQueue.addLast(this );
109:                    return this ;
110:                }
111:            }
112:
113:            /**
114:             * @see org.continuent.sequoia.controller.virtualdatabase.protocol.DistributedVirtualDatabaseMessage#handleMessageMultiThreaded(org.continuent.sequoia.controller.virtualdatabase.DistributedVirtualDatabase,
115:             *      org.continuent.hedera.common.Member, java.lang.Object)
116:             */
117:            public Serializable handleMessageMultiThreaded(
118:                    DistributedVirtualDatabase dvdb, Member sender,
119:                    Object handleMessageSingleThreadedResult) {
120:                Trace logger = dvdb.getLogger();
121:
122:                // Wait for our turn to execute
123:                if (!dvdb.waitForTotalOrder(handleMessageSingleThreadedResult,
124:                        false))
125:                    logger
126:                            .error("BackendTransfer was not found in total order queue, posting out of order ("
127:                                    + checkpointName + ")");
128:                else
129:                    synchronized (totalOrderQueue) {
130:                        totalOrderQueue.removeFirst();
131:                        totalOrderQueue.notifyAll();
132:                    }
133:
134:                if (logger.isInfoEnabled())
135:                    logger.info(dvdb.getControllerName()
136:                            + ": Received transfer command. Checkpoint: "
137:                            + getCheckpointName());
138:                DatabaseBackend backend = new DatabaseBackend(info);
139:
140:                try {
141:                    dvdb.addBackend(backend);
142:                } catch (VirtualDatabaseException e) {
143:                    // No cleanup expected there (if addBackend() behaves). The backend does
144:                    // not exist here, and still exists (though disabled) on the originating
145:                    // vdb peer (controller). Just return the exception.
146:                    return e;
147:                }
148:
149:                try {
150:                    if (logger.isInfoEnabled())
151:                        logger.info(dvdb.getControllerName()
152:                                + ": Enable backend from " + checkpointName);
153:                    dvdb.enableBackendFromCheckpoint(backend.getName(),
154:                            getCheckpointName());
155:                } catch (VirtualDatabaseException e) {
156:                    // The backend was added, but could not be enabled. Remove it from this
157:                    // vdb peer, since it remains (in a disabled state) on the originating
158:                    // peer.
159:                    cleanup(dvdb, backend);
160:                    return e;
161:                }
162:                return Boolean.TRUE;
163:            }
164:
165:            void cleanup(DistributedVirtualDatabase dvdb,
166:                    DatabaseBackend backend) {
167:                try {
168:                    dvdb.removeBackend(backend);
169:                } catch (VirtualDatabaseException e) {
170:                    dvdb
171:                            .getLogger()
172:                            .error(
173:                                    "Could not cleanup vdb after transfer backend failure",
174:                                    e);
175:                }
176:            }
177:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.