01: /**
02: * Sequoia: Database clustering technology.
03: * Copyright (C) 2006 Continuent
04: * Contact: sequoia@continuent.org
05: *
06: * Licensed under the Apache License, Version 2.0 (the "License");
07: * you may not use this file except in compliance with the License.
08: * You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing, software
13: * distributed under the License is distributed on an "AS IS" BASIS,
14: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15: * See the License for the specific language governing permissions and
16: * limitations under the License.
17: *
18: */package org.continuent.sequoia.common.jmx.management;
19:
20: import java.util.Date;
21:
22: import javax.management.openmbean.CompositeData;
23: import javax.management.openmbean.CompositeDataSupport;
24: import javax.management.openmbean.CompositeType;
25: import javax.management.openmbean.OpenDataException;
26: import javax.management.openmbean.OpenType;
27: import javax.management.openmbean.SimpleType;
28: import javax.management.openmbean.TabularData;
29: import javax.management.openmbean.TabularDataSupport;
30: import javax.management.openmbean.TabularType;
31:
32: import org.continuent.sequoia.common.log.Trace;
33:
34: public class DumpInfoSupport {
35:
36: protected static Trace logger = Trace
37: .getLogger(DumpInfoSupport.class.getName());
38:
39: private final static CompositeType DUMP_INFO_COMPOSITE_TYPE;
40: private final static TabularType DUMP_INFO_TABULAR_TYPE;
41:
42: public static final String[] NAMES = new String[] { "dumpName",
43: "dumpDate", "dumpPath", "dumpFormat", "checkpointName",
44: "backendName", "tables" };
45: private static final OpenType[] TYPES = new OpenType[] {
46: SimpleType.STRING, SimpleType.DATE, SimpleType.STRING,
47: SimpleType.STRING, SimpleType.STRING, SimpleType.STRING,
48: SimpleType.STRING };
49:
50: static {
51: try {
52: DUMP_INFO_COMPOSITE_TYPE = new CompositeType("dump_info",
53: "dump information", NAMES, NAMES, TYPES);
54: // a table of dumps is indexed by dumpName
55: DUMP_INFO_TABULAR_TYPE = new TabularType("dump_info_list",
56: "table of dump informations",
57: DUMP_INFO_COMPOSITE_TYPE,
58: new String[] { "dumpName" });
59: } catch (OpenDataException e) {
60: throw new ExceptionInInitializerError(e);
61: }
62: }
63:
64: public static CompositeData newCompositeData(DumpInfo info)
65: throws OpenDataException {
66: Date dumpDate = new java.util.Date(info.getDumpDate().getTime());
67: Object[] values = new Object[] { info.getDumpName(), dumpDate,
68: info.getDumpPath(), info.getDumpFormat(),
69: info.getCheckpointName(), info.getBackendName(),
70: info.getTables() };
71: return new CompositeDataSupport(DUMP_INFO_COMPOSITE_TYPE,
72: NAMES, values);
73: }
74:
75: public static TabularData newTabularData() throws Exception {
76: TabularData data = new TabularDataSupport(
77: DUMP_INFO_TABULAR_TYPE);
78: return data;
79: }
80: }
|