KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > continuent > sequoia > controller > virtualdatabase > protocol > NotifyCompletion


1 /**
2  * Sequoia: Database clustering technology.
3  * Copyright (C) 2002-2004 French National Institute For Research In Computer
4  * Science And Control (INRIA).
5  * Copyright (C) 2005 AmicoSoft, Inc. dba Emic Networks
6  * Contact: sequoia@continuent.org
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *
20  * Initial developer(s): Emmanuel Cecchet.
21  * Contributor(s): ______________________.
22  */

23
24 package org.continuent.sequoia.controller.virtualdatabase.protocol;
25
26 import java.io.Serializable JavaDoc;
27 import java.sql.SQLException JavaDoc;
28
29 import org.continuent.sequoia.controller.requestmanager.distributed.DistributedRequestManager;
30 import org.continuent.sequoia.controller.requests.AbstractRequest;
31
32 /**
33  * This class defines a NotifyCompletion command that is sent to controllers
34  * that have either failed (AllBackendsFailedException) or did not execute the
35  * query (NoMoreBackendException) to notify of the success or failure of the
36  * request execution.
37  *
38  * @author <a HREF="mailto:Emmanuel.Cecchet@inria.fr">Emmanuel Cecchet </a>
39  * @version 1.0
40  */

41 public class NotifyCompletion extends DistributedRequest
42 {
43   private static final long serialVersionUID = 7558772103262086995L;
44
45   private boolean success;
46   private boolean disableBackendOnSuccess;
47   private int updateCount = -1;
48
49   /**
50    * Creates a new <code>NotifyCompletion</code> object without update count
51    * information
52    *
53    * @param request the request that completed
54    * @param success true if completion is successful, false if it is a failure
55    * @param disableBackendOnSuccess disable all local backends if query was
56    * successful (but failed locally). Usually set to true in case of
57    * AllBackendsFailedException and false for NoMoreBackendException.
58    */

59   public NotifyCompletion(AbstractRequest request, boolean success,
60       boolean disableBackendOnSuccess)
61   {
62     super(request);
63     this.success = success;
64     this.disableBackendOnSuccess = disableBackendOnSuccess;
65   }
66
67   /**
68    * Creates a new <code>NotifyCompletion</code> object with update count
69    * information
70    *
71    * @param request the request that completed
72    * @param success true if completion is successful, false if it is a failure
73    * @param disableBackendOnSuccess disable all local backends if query was
74    * successful (but failed locally). Usually set to true in case of
75    * AllBackendsFailedException and false for NoMoreBackendException.
76    * @param requestUpdateCount update count if the query was executed using
77    * Statement.executeUpdate()
78    */

79   public NotifyCompletion(AbstractRequest request, boolean success,
80       boolean disableBackendOnSuccess, int requestUpdateCount)
81   {
82     this(request, success, disableBackendOnSuccess);
83     updateCount = requestUpdateCount;
84   }
85
86   /**
87    * @see org.continuent.sequoia.controller.virtualdatabase.protocol.DistributedRequest#scheduleRequest(org.continuent.sequoia.controller.requestmanager.distributed.DistributedRequestManager)
88    */

89   public final Object JavaDoc scheduleRequest(DistributedRequestManager drm)
90       throws SQLException JavaDoc
91   {
92     return null;
93   }
94
95   /**
96    * @see org.continuent.sequoia.controller.virtualdatabase.protocol.DistributedRequest#executeScheduledRequest(org.continuent.sequoia.controller.requestmanager.distributed.DistributedRequestManager)
97    */

98   public final Serializable JavaDoc executeScheduledRequest(
99       DistributedRequestManager drm) throws SQLException JavaDoc
100   {
101     drm.completeFailedOnAllBackends(request, success, disableBackendOnSuccess,
102         updateCount);
103     return null;
104   }
105
106   /**
107    * @see java.lang.Object#toString()
108    */

109   public String JavaDoc toString()
110   {
111     if (success)
112     {
113       return "Notify success of request: " + request;
114     }
115     else
116     {
117       return "Notify failure of request: " + request;
118     }
119   }
120 }
121
Popular Tags