KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > continuent > sequoia > controller > loadbalancer > tasks > KillThreadTask


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) 2006 Continuent, Inc.
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): Julie Marguerite.
22  */

23
24 package org.continuent.sequoia.controller.loadbalancer.tasks;
25
26 import java.sql.SQLException JavaDoc;
27
28 import org.continuent.sequoia.controller.loadbalancer.BackendWorkerThread;
29 import org.continuent.sequoia.controller.requests.AbstractRequest;
30
31 /**
32  * This task is used to kill backend worker threads.
33  *
34  * @author <a HREF="mailto:Emmanuel.Cecchet@inria.fr">Emmanuel Cecchet</a>
35  * @author <a HREF="mailto:Julie.Marguerite@inria.fr">Julie Marguerite</a>
36  * @version 1.0
37  */

38 public class KillThreadTask extends AbstractTask
39 {
40
41   /**
42    * Creates a new <code>KillThreadTask</code> instance that must be executed
43    * by <code>nbToComplete</code> backend threads
44    *
45    * @param nbToComplete number of threads that must succeed before returning
46    * @param totalNb total number of threads
47    */

48   public KillThreadTask(int nbToComplete, int totalNb)
49   {
50     super(nbToComplete, totalNb, false, 0);
51   }
52
53   /**
54    * This function call the backendThread kill function and notifies the task
55    * completion success.
56    *
57    * @param backendThread the backend thread that will execute the task
58    * @throws SQLException if an error occurs
59    */

60   public void executeTask(BackendWorkerThread backendThread)
61       throws SQLException JavaDoc
62   {
63     backendThread.killWithoutDisablingBackend();
64     notifySuccess(backendThread);
65   }
66
67   /**
68    * @see org.continuent.sequoia.controller.loadbalancer.tasks.AbstractTask#getRequest()
69    */

70   public AbstractRequest getRequest()
71   {
72     return null;
73   }
74
75   /**
76    * @see org.continuent.sequoia.controller.loadbalancer.tasks.AbstractTask#getTransactionId()
77    */

78   public long getTransactionId()
79   {
80     return 0;
81   }
82
83   /**
84    * @see org.continuent.sequoia.controller.loadbalancer.tasks.AbstractTask#isAutoCommit()
85    */

86   public boolean isAutoCommit()
87   {
88     return true;
89   }
90
91   /**
92    * @see java.lang.Object#toString()
93    */

94   public String JavaDoc toString()
95   {
96     return "KillThreadTask";
97   }
98 }
Popular Tags