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) 2005 AmicoSoft, Inc. dba Emic Networks
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): Nicolas Modrzyk.
21: * Contributor(s): Emmanuel Cecchet.
22: */package org.continuent.sequoia.controller.virtualdatabase;
23:
24: import org.continuent.sequoia.common.log.Trace;
25: import org.continuent.sequoia.common.sql.metadata.MetadataContainer;
26: import org.continuent.sequoia.controller.backend.DatabaseBackend;
27:
28: /**
29: * Class gathering the static metadata related to the database. We collect
30: * information from the underlying driver and keep this object for further
31: * usage.
32: *
33: * @author <a href="mailto:Nicolas.Modrzyk@inria.fr">Nicolas Modrzyk </a>
34: * @author <a href="mailto:Emmanuel.Cecchet@inria.fr">Emmanuel Cecchet </a>
35: * @version 1.0
36: */
37: public class VirtualDatabaseStaticMetaData {
38: private String vdbName;
39: private Trace logger;
40: private MetadataContainer metadataContainer = null;
41:
42: /**
43: * Reference the database for this metadata. Do not fetch any data at this
44: * time
45: *
46: * @param database to link this metadata to
47: */
48: public VirtualDatabaseStaticMetaData(VirtualDatabase database) {
49: this .vdbName = database.getVirtualDatabaseName();
50: this .logger = Trace
51: .getLogger("org.continuent.sequoia.controller.virtualdatabase.VirtualDatabaseWorkerThread."
52: + vdbName + ".metadata");
53: }
54:
55: /**
56: * Save the driver metadata of the backend if this is the first one to be
57: * collected. If not display a warning for each incompatible value.
58: *
59: * @param backend the new backend to get metadata from
60: */
61: public void gatherStaticMetadata(DatabaseBackend backend) {
62: MetadataContainer newContainer = backend
63: .getDatabaseStaticMetadata();
64: if (logger.isDebugEnabled())
65: logger.debug("fetching static metadata for backend:"
66: + backend.getName());
67: if (metadataContainer == null)
68: metadataContainer = newContainer;
69: else {
70: boolean isCompatible = metadataContainer.isCompatible(
71: newContainer, logger);
72: if (logger.isDebugEnabled())
73: logger
74: .debug("Backend static metadata is compatible with current ones:"
75: + isCompatible);
76: }
77: }
78:
79: /**
80: * Returns the ("getXXX(Y,Z,...)", value) hash table holding metadata queries.
81: *
82: * @return the metadataContainer.
83: */
84: public MetadataContainer getMetadataContainer() {
85: return metadataContainer;
86: }
87:
88: /**
89: * Sets the ("getXXX(Y,Z,...)", value) hash table holding metadata queries.
90: *
91: * @param container the metadata container.
92: */
93: public void setMetadataContainer(MetadataContainer container) {
94: this.metadataContainer = container;
95: }
96: }
|