KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > continuent > sequoia > controller > backend > BackendStateListener


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

22
23 package org.continuent.sequoia.controller.backend;
24
25 import java.sql.SQLException JavaDoc;
26
27 import org.continuent.sequoia.common.log.Trace;
28 import org.continuent.sequoia.controller.recoverylog.BackendRecoveryInfo;
29 import org.continuent.sequoia.controller.recoverylog.RecoveryLog;
30
31 /**
32  * This class defines a BackendStateListener
33  *
34  * @author <a HREF="mailto:Nicolas.Modrzyk@inrialpes.fr">Nicolas Modrzyk </a>
35  * @version 1.0
36  */

37 public class BackendStateListener
38 {
39
40   Trace logger = Trace.getLogger(BackendStateListener.class
41                                  .getName());
42   private String JavaDoc virtualDatabaseName;
43   private RecoveryLog recoveryLog;
44
45   /**
46    * Creates a new <code>BackendStateListener</code> object
47    *
48    * @param vdbName virtual database name
49    * @param recoveryLog recovery log
50    */

51   public BackendStateListener(String JavaDoc vdbName, RecoveryLog recoveryLog)
52   {
53     this.virtualDatabaseName = vdbName;
54     this.recoveryLog = recoveryLog;
55   }
56
57   /**
58    * Update the persistent state of the backend in the recovery log
59    * when the state of the backend instance has been changed
60    *
61    * @param backend the backend to update information from
62    */

63   public synchronized void stateChanged(DatabaseBackend backend)
64   {
65     try
66     {
67       recoveryLog.storeBackendRecoveryInfo(virtualDatabaseName,
68           new BackendRecoveryInfo(backend.getName(), backend
69               .getLastKnownCheckpoint(), backend.getStateValue(),
70               virtualDatabaseName));
71     }
72     catch (SQLException JavaDoc e)
73     {
74       logger.error("Could not store information for backend: "
75           + backend.getName(), e);
76     }
77   }
78 }
Popular Tags