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: * Contact: sequoia@continuent.org
007: *
008: * Licensed under the Apache License, Version 2.0 (the "License");
009: * you may not use this file except in compliance with the License.
010: * You may obtain a copy of the License at
011: *
012: * http://www.apache.org/licenses/LICENSE-2.0
013: *
014: * Unless required by applicable law or agreed to in writing, software
015: * distributed under the License is distributed on an "AS IS" BASIS,
016: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017: * See the License for the specific language governing permissions and
018: * limitations under the License.
019: *
020: * Initial developer(s): Emmanuel Cecchet.
021: * Contributor(s): ______________________.
022: */package org.continuent.sequoia.controller.virtualdatabase.protocol;
023:
024: import java.io.Serializable;
025: import java.sql.SQLException;
026:
027: import org.continuent.sequoia.controller.requestmanager.distributed.DistributedRequestManager;
028: import org.continuent.sequoia.controller.requests.AbstractRequest;
029:
030: /**
031: * This class defines a NotifyCompletion command that is sent to controllers
032: * that have either failed (AllBackendsFailedException) or did not execute the
033: * query (NoMoreBackendException) to notify of the success or failure of the
034: * request execution.
035: *
036: * @author <a href="mailto:Emmanuel.Cecchet@inria.fr">Emmanuel Cecchet </a>
037: * @version 1.0
038: */
039: public class NotifyCompletion extends DistributedRequest {
040: private static final long serialVersionUID = 7558772103262086995L;
041:
042: private boolean success;
043: private boolean disableBackendOnSuccess;
044: private int updateCount = -1;
045:
046: /**
047: * Creates a new <code>NotifyCompletion</code> object without update count
048: * information
049: *
050: * @param request the request that completed
051: * @param success true if completion is successful, false if it is a failure
052: * @param disableBackendOnSuccess disable all local backends if query was
053: * successful (but failed locally). Usually set to true in case of
054: * AllBackendsFailedException and false for NoMoreBackendException.
055: */
056: public NotifyCompletion(AbstractRequest request, boolean success,
057: boolean disableBackendOnSuccess) {
058: super (request);
059: this .success = success;
060: this .disableBackendOnSuccess = disableBackendOnSuccess;
061: }
062:
063: /**
064: * Creates a new <code>NotifyCompletion</code> object with update count
065: * information
066: *
067: * @param request the request that completed
068: * @param success true if completion is successful, false if it is a failure
069: * @param disableBackendOnSuccess disable all local backends if query was
070: * successful (but failed locally). Usually set to true in case of
071: * AllBackendsFailedException and false for NoMoreBackendException.
072: * @param requestUpdateCount update count if the query was executed using
073: * Statement.executeUpdate()
074: */
075: public NotifyCompletion(AbstractRequest request, boolean success,
076: boolean disableBackendOnSuccess, int requestUpdateCount) {
077: this (request, success, disableBackendOnSuccess);
078: updateCount = requestUpdateCount;
079: }
080:
081: /**
082: * @see org.continuent.sequoia.controller.virtualdatabase.protocol.DistributedRequest#scheduleRequest(org.continuent.sequoia.controller.requestmanager.distributed.DistributedRequestManager)
083: */
084: public final Object scheduleRequest(DistributedRequestManager drm)
085: throws SQLException {
086: return null;
087: }
088:
089: /**
090: * @see org.continuent.sequoia.controller.virtualdatabase.protocol.DistributedRequest#executeScheduledRequest(org.continuent.sequoia.controller.requestmanager.distributed.DistributedRequestManager)
091: */
092: public final Serializable executeScheduledRequest(
093: DistributedRequestManager drm) throws SQLException {
094: drm.completeFailedOnAllBackends(request, success,
095: disableBackendOnSuccess, updateCount);
096: return null;
097: }
098:
099: /**
100: * @see java.lang.Object#toString()
101: */
102: public String toString() {
103: if (success) {
104: return "Notify success of request: " + request;
105: } else {
106: return "Notify failure of request: " + request;
107: }
108: }
109: }
|