01: /**
02: * Sequoia: Database clustering technology.
03: * Copyright (C) 2002-2004 French National Institute For Research In Computer
04: * Science And Control (INRIA).
05: * Copyright (C) 2006 Continuent, Inc.
06: * Contact: sequoia@continuent.org
07: *
08: * Licensed under the Apache License, Version 2.0 (the "License");
09: * 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: */package org.continuent.sequoia.controller.loadbalancer.tasks;
23:
24: import java.sql.SQLException;
25:
26: import org.continuent.sequoia.controller.loadbalancer.BackendWorkerThread;
27: import org.continuent.sequoia.controller.requests.AbstractRequest;
28:
29: /**
30: * This task is used to kill backend worker threads.
31: *
32: * @author <a href="mailto:Emmanuel.Cecchet@inria.fr">Emmanuel Cecchet</a>
33: * @author <a href="mailto:Julie.Marguerite@inria.fr">Julie Marguerite</a>
34: * @version 1.0
35: */
36: public class KillThreadTask extends AbstractTask {
37:
38: /**
39: * Creates a new <code>KillThreadTask</code> instance that must be executed
40: * by <code>nbToComplete</code> backend threads
41: *
42: * @param nbToComplete number of threads that must succeed before returning
43: * @param totalNb total number of threads
44: */
45: public KillThreadTask(int nbToComplete, int totalNb) {
46: super (nbToComplete, totalNb, false, 0);
47: }
48:
49: /**
50: * This function call the backendThread kill function and notifies the task
51: * completion success.
52: *
53: * @param backendThread the backend thread that will execute the task
54: * @throws SQLException if an error occurs
55: */
56: public void executeTask(BackendWorkerThread backendThread)
57: throws SQLException {
58: backendThread.killWithoutDisablingBackend();
59: notifySuccess(backendThread);
60: }
61:
62: /**
63: * @see org.continuent.sequoia.controller.loadbalancer.tasks.AbstractTask#getRequest()
64: */
65: public AbstractRequest getRequest() {
66: return null;
67: }
68:
69: /**
70: * @see org.continuent.sequoia.controller.loadbalancer.tasks.AbstractTask#getTransactionId()
71: */
72: public long getTransactionId() {
73: return 0;
74: }
75:
76: /**
77: * @see org.continuent.sequoia.controller.loadbalancer.tasks.AbstractTask#isAutoCommit()
78: */
79: public boolean isAutoCommit() {
80: return true;
81: }
82:
83: /**
84: * @see java.lang.Object#toString()
85: */
86: public String toString() {
87: return "KillThreadTask";
88: }
89: }
|