author | Mark J. Nelson <Mark.J.Nelson@Sun.COM> |
Wed, 06 Aug 2008 16:29:39 -0600 | |
changeset 7298 | b69e27387f74 |
parent 0 | 68f95e015346 |
permissions | -rw-r--r-- |
0 | 1 |
/* |
2 |
* CDDL HEADER START |
|
3 |
* |
|
4 |
* The contents of this file are subject to the terms of the |
|
7298
b69e27387f74
6733918 Teamware has retired, please welcome your new manager, Mercurial
Mark J. Nelson <Mark.J.Nelson@Sun.COM>
parents:
0
diff
changeset
|
5 |
* Common Development and Distribution License (the "License"). |
b69e27387f74
6733918 Teamware has retired, please welcome your new manager, Mercurial
Mark J. Nelson <Mark.J.Nelson@Sun.COM>
parents:
0
diff
changeset
|
6 |
* You may not use this file except in compliance with the License. |
0 | 7 |
* |
8 |
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE |
|
9 |
* or http://www.opensolaris.org/os/licensing. |
|
10 |
* See the License for the specific language governing permissions |
|
11 |
* and limitations under the License. |
|
12 |
* |
|
13 |
* When distributing Covered Code, include this CDDL HEADER in each |
|
14 |
* file and include the License file at usr/src/OPENSOLARIS.LICENSE. |
|
15 |
* If applicable, add the following below this CDDL HEADER, with the |
|
16 |
* fields enclosed by brackets "[]" replaced with your own identifying |
|
17 |
* information: Portions Copyright [yyyy] [name of copyright owner] |
|
18 |
* |
|
19 |
* CDDL HEADER END |
|
20 |
*/ |
|
21 |
/* |
|
22 |
* Copyright (c) 2001 by Sun Microsystems, Inc. |
|
23 |
* All rights reserved. |
|
24 |
* |
|
25 |
* Solaris_ActiveProjectProcessAggregateStatistics.java |
|
26 |
*/ |
|
27 |
||
28 |
||
29 |
package com.sun.wbem.solarisprovider.srm; |
|
30 |
||
31 |
import javax.wbem.cim.*; |
|
32 |
import javax.wbem.provider.*; |
|
33 |
||
34 |
import java.util.Enumeration; |
|
35 |
import java.util.Iterator; |
|
36 |
import java.util.Vector; |
|
37 |
||
38 |
||
39 |
/** |
|
40 |
* Provider of the Solaris_ActiveProjectProcessAggregateStatistics class. |
|
41 |
* This class represents a link between a Project active on a system and the |
|
42 |
* aggregated resource usage of its Process(es). |
|
43 |
* @author Sun Microsystems |
|
44 |
*/ |
|
45 |
public class Solaris_ActiveProjectProcessAggregateStatistics |
|
46 |
extends SRMProvider { |
|
47 |
||
48 |
/** |
|
49 |
* The name of the provider implemented by this class |
|
50 |
*/ |
|
51 |
protected String providerName = |
|
52 |
SOLARIS_ACTIVEPROJECTPROCESSAGGREGATESTATISTICS; |
|
53 |
||
54 |
||
55 |
/** |
|
56 |
* Get the name of the provider implemented by this class. |
|
57 |
* @returns String provider name |
|
58 |
*/ |
|
59 |
protected String getProviderName() { |
|
60 |
return providerName; |
|
61 |
} |
|
62 |
||
63 |
||
64 |
/** |
|
65 |
* Returns a specific CIMInstance. |
|
66 |
* @param op - the name of the instance to be retrieved. This must include |
|
67 |
* all of the keys and values for the instance. |
|
68 |
* @param localOnly - if true, only the local properties of the class are |
|
69 |
* returned, otherwise all properties are required |
|
70 |
* @param includeQualifiers - if true, the qualifiers are returned as part |
|
71 |
* of of the returned instancei, otherwise no qualifiers will be returned |
|
72 |
* @param includeClassOrigin - if true, the class origin of each property |
|
73 |
* will be returned |
|
74 |
* @param String[] - if null, all properties are returned, otherwise only |
|
75 |
* the properties specified will be returned. Any duplicate properties will |
|
76 |
* be ignored. |
|
77 |
* @param cc - the class reference |
|
78 |
* |
|
79 |
* @return CIMInstance the retrieved instance. |
|
80 |
* @exception CIMException - the method getInstance throws a CIMException |
|
81 |
* if the CIMObjectPath is incorrect or does not exist. |
|
82 |
*/ |
|
83 |
public synchronized CIMInstance getInstance(CIMObjectPath op, |
|
84 |
boolean localOnly, |
|
85 |
boolean includeQualifiers, |
|
86 |
boolean includeClassOrigin, |
|
87 |
String[] propList, |
|
88 |
CIMClass cc) |
|
89 |
throws CIMException { |
|
90 |
||
91 |
CIMObjectPath procaggreCOP = null; |
|
92 |
CIMObjectPath activeprojCOP = null; |
|
93 |
CIMInstance ci = null; |
|
94 |
CIMProperty cp; |
|
95 |
||
96 |
SRMDebug.trace(SRMDebug.METHOD_CALL, op.toString()); |
|
97 |
try { |
|
98 |
Enumeration e = op.getKeys().elements(); |
|
99 |
while (e.hasMoreElements()) { |
|
100 |
cp = (CIMProperty) e.nextElement(); |
|
101 |
if (cp.getName().equalsIgnoreCase(ELEMENT)) { |
|
102 |
activeprojCOP = (CIMObjectPath)((CIMValue)(cp.getValue())). |
|
103 |
getValue(); |
|
104 |
} |
|
105 |
if (cp.getName().equalsIgnoreCase(STATS)) { |
|
106 |
procaggreCOP = (CIMObjectPath)((CIMValue)(cp.getValue())). |
|
107 |
getValue(); |
|
108 |
} |
|
109 |
} |
|
110 |
||
111 |
ci = cc.newInstance(); |
|
112 |
ci.setProperty(ELEMENT, new CIMValue(activeprojCOP)); |
|
113 |
ci.setProperty(STATS, new CIMValue(procaggreCOP)); |
|
114 |
||
115 |
} catch (Exception e) { |
|
116 |
String msg = writeLog(LOGERROR, "SRM_1001"); |
|
117 |
writeLog(LOGERROR, e); |
|
118 |
msg += " (" + e.getClass().toString() + ")"; |
|
119 |
SRMDebug.trace1(providerName, e); |
|
120 |
throw new CIMException(CIMException.CIM_ERR_FAILED, msg); |
|
121 |
} |
|
122 |
SRMDebug.trace(SRMDebug.METHOD_RETV, ci.toString()); |
|
123 |
return ci; |
|
124 |
||
125 |
} // end getInstance |
|
126 |
||
127 |
||
128 |
/** |
|
129 |
* Enumerates all instances of Solaris_ActiveProjectAggregateStatistics. |
|
130 |
* @param op - the object path specifies the class to be enumerated |
|
131 |
* localOnly - if true, only the local properties of the class are returned, |
|
132 |
* otherwise all properties are required |
|
133 |
* @param includeQualifiers - if true, the qualifiers are returned as part |
|
134 |
* of of the returned instancei, otherwise no qualifiers will be returned |
|
135 |
* @param includeClassOrigin - if true, the class origin of each property |
|
136 |
* will be returned |
|
137 |
* @param String[] - if null, all properties are returned, otherwise only |
|
138 |
* the properties specified will be |
|
139 |
* returned. Any duplicate properties will be ignored. |
|
140 |
* @param cc - the class reference |
|
141 |
* @return An array of CIMInstance |
|
142 |
* @exception CIMException - if the CIMObjectPath is incorrect or does not |
|
143 |
* exist. |
|
144 |
*/ |
|
145 |
public synchronized CIMInstance[] enumerateInstances(CIMObjectPath op, |
|
146 |
boolean localOnly, |
|
147 |
boolean includeQualifiers, |
|
148 |
boolean includeClassOrigin, |
|
149 |
String[] propList, |
|
150 |
CIMClass cc) |
|
151 |
throws CIMException { |
|
152 |
||
153 |
Vector installedElements = new Vector(); |
|
154 |
ActiveProjectModel apm; |
|
155 |
CIMObjectPath procaggreCOP; |
|
156 |
CIMObjectPath activeprojCOP; |
|
157 |
CIMInstance ci; |
|
158 |
DataModel dm = null; |
|
159 |
||
160 |
SRMDebug.trace(SRMDebug.METHOD_CALL, op.toString()); |
|
161 |
try { |
|
162 |
dm = resourceMonitor.getDataModel(false); |
|
163 |
for (Iterator i = dm.getProjectIterator(); i.hasNext(); ) { |
|
164 |
apm = (ActiveProjectModel) i.next(); |
|
165 |
activeprojCOP = apm.getCIMObjectPath(SOLARIS_ACTIVEPROJECT); |
|
166 |
procaggreCOP = dm.getProjprocs(apm.name).getCIMObjectPath( |
|
167 |
SOLARIS_PROJECTPROCESSAGGREGATESTATISTICALINFORMATION); |
|
168 |
ci = cc.newInstance(); |
|
169 |
ci.setProperty(ELEMENT, new CIMValue(activeprojCOP)); |
|
170 |
ci.setProperty(STATS, new CIMValue(procaggreCOP)); |
|
171 |
installedElements.addElement(ci); |
|
172 |
} |
|
173 |
dm = resourceMonitor.releaseDataModel(dm); |
|
174 |
} catch (Exception e) { |
|
175 |
dm = resourceMonitor.releaseDataModel(dm); |
|
176 |
String msg = writeLog(LOGERROR, "SRM_1002"); |
|
177 |
writeLog(LOGERROR, e); |
|
178 |
msg += " (" + e.getClass().toString() + ")"; |
|
179 |
SRMDebug.trace1(providerName, e); |
|
180 |
throw new CIMException(CIMException.CIM_ERR_FAILED, msg); |
|
181 |
} |
|
182 |
CIMInstance[] ciArray = new CIMInstance[installedElements.size()]; |
|
183 |
installedElements.toArray(ciArray); |
|
184 |
SRMDebug.trace(SRMDebug.METHOD_RETV, "instance[0]: " |
|
185 |
+ ciArray[0].toString()); |
|
186 |
return ciArray; |
|
187 |
||
188 |
} // end enumerateInstances |
|
189 |
||
190 |
||
191 |
/** |
|
192 |
* Returns all object paths. |
|
193 |
* |
|
194 |
* @param op - the class name to enumerate the instances |
|
195 |
* @param cc - the class reference passed to the provider |
|
196 |
* @return an array of CIMObjectPath containing names of the enumerated |
|
197 |
* instances. |
|
198 |
* @exception CIMException - if the classname is null or does not exist. |
|
199 |
*/ |
|
200 |
public synchronized CIMObjectPath[] |
|
201 |
enumerateInstanceNames(CIMObjectPath op, CIMClass cc) |
|
202 |
throws CIMException { |
|
203 |
||
204 |
Vector installedElements = new Vector(); |
|
205 |
ActiveProjectModel apm; |
|
206 |
CIMObjectPath procaggreCOP; |
|
207 |
CIMObjectPath activeprojCOP; |
|
208 |
CIMObjectPath cop; |
|
209 |
DataModel dm = null; |
|
210 |
||
211 |
SRMDebug.trace(SRMDebug.METHOD_CALL, op.toString()); |
|
212 |
try { |
|
213 |
dm = resourceMonitor.getDataModel(false); |
|
214 |
Iterator i = dm.getProjectIterator(); |
|
215 |
while (i.hasNext()) { |
|
216 |
apm = (ActiveProjectModel) i.next(); |
|
217 |
activeprojCOP = apm.getCIMObjectPath(SOLARIS_ACTIVEPROJECT); |
|
218 |
procaggreCOP = dm.getProjprocs(apm.name).getCIMObjectPath( |
|
219 |
SOLARIS_PROJECTPROCESSAGGREGATESTATISTICALINFORMATION); |
|
220 |
cop = new CIMObjectPath(op.getObjectName(), |
|
221 |
op.getNameSpace()); |
|
222 |
cop.addKey(ELEMENT, new CIMValue(activeprojCOP)); |
|
223 |
cop.addKey(STATS, new CIMValue(procaggreCOP)); |
|
224 |
installedElements.add(cop); |
|
225 |
} |
|
226 |
dm = resourceMonitor.releaseDataModel(dm); |
|
227 |
} catch (Exception e) { |
|
228 |
dm = resourceMonitor.releaseDataModel(dm); |
|
229 |
String msg = writeLog(LOGERROR, "SRM_1003"); |
|
230 |
writeLog(LOGERROR, e); |
|
231 |
msg += " (" + e.getClass().toString() + ")"; |
|
232 |
SRMDebug.trace1(providerName, e); |
|
233 |
throw new CIMException(CIMException.CIM_ERR_FAILED, msg); |
|
234 |
} |
|
235 |
CIMObjectPath[] copArray = new CIMObjectPath[installedElements.size()]; |
|
236 |
installedElements.toArray(copArray); |
|
237 |
SRMDebug.trace(SRMDebug.METHOD_RETV, "instanceName[0]: " |
|
238 |
+ copArray[0].toString()); |
|
239 |
return copArray; |
|
240 |
} |
|
241 |
||
242 |
} // end class Solaris_ActiveProjectProcessAggregateStatistics |