01: /**
02: * Sequoia: Database clustering technology.
03: * Copyright (C) 2006 Continuent, Inc.
04: * Contact: sequoia@continuent.org
05: *
06: * Licensed under the Apache License, Version 2.0 (the "License");
07: * you may not use this file except in compliance with the License.
08: * You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing, software
13: * distributed under the License is distributed on an "AS IS" BASIS,
14: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15: * See the License for the specific language governing permissions and
16: * limitations under the License.
17: *
18: * Initial developer(s): Emmanuel Cecchet.
19: * Contributor(s): ______________________.
20: */package org.continuent.sequoia.controller.virtualdatabase.protocol;
21:
22: import java.io.Serializable;
23: import java.sql.SQLException;
24:
25: import org.continuent.sequoia.common.exceptions.VirtualDatabaseException;
26: import org.continuent.sequoia.controller.requestmanager.distributed.DistributedRequestManager;
27: import org.continuent.sequoia.controller.requests.AbstractRequest;
28:
29: /**
30: * This class defines a inconsistency notification command that is sent to
31: * controllers that reported a result that is inconsistent with other
32: * controllers. As a consequence, all backends of the inconsistent controllers
33: * are disabled.
34: *
35: * @author <a href="mailto:Emmanuel.Cecchet@inria.fr">Emmanuel Cecchet </a>
36: * @version 1.0
37: */
38: public class NotifyInconsistency extends DistributedRequest {
39: private static final long serialVersionUID = -5744767614853747783L;
40:
41: /**
42: * Creates a new <code>NotifyInconsistency</code> object
43: *
44: * @param request the request that generated the inconsistency
45: */
46: public NotifyInconsistency(AbstractRequest request) {
47: super (request);
48: }
49:
50: /**
51: * @see org.continuent.sequoia.controller.virtualdatabase.protocol.DistributedRequest#scheduleRequest(org.continuent.sequoia.controller.requestmanager.distributed.DistributedRequestManager)
52: */
53: public final Object scheduleRequest(DistributedRequestManager drm)
54: throws SQLException {
55: return null;
56: }
57:
58: /**
59: * @see org.continuent.sequoia.controller.virtualdatabase.protocol.DistributedRequest#executeScheduledRequest(org.continuent.sequoia.controller.requestmanager.distributed.DistributedRequestManager)
60: */
61: public final Serializable executeScheduledRequest(
62: DistributedRequestManager drm) throws SQLException {
63: try {
64: drm.getLogger().warn(
65: "Disabling all backends after an inconsistency was detected for request "
66: + request.getId()
67: + (request.isAutoCommit() ? "" : " "
68: + request.getTransactionId()) + " "
69: + request);
70: drm.getVirtualDatabase().disableAllBackends(true);
71: } catch (VirtualDatabaseException e) {
72: drm
73: .getLogger()
74: .error(
75: "An error occured while disabling all backends after an inconsistency was detected for request "
76: + request.getId()
77: + (request.isAutoCommit() ? ""
78: : " "
79: + request
80: .getTransactionId())
81: + " " + request, e);
82: }
83: return null;
84: }
85:
86: }
|