1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
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  * ProcessDataModel.java
26  */
27 
28 package com.sun.wbem.solarisprovider.srm;
29 
30 import javax.wbem.cim.*;
31 
32 import java.util.*;
33 
34 
35 /**
36  * Data model of Process Utilization. It encapsulates a CIM instance of
37  * a Solaris_ProcessStatisticalInformation class.
38  * @author Sun Microsystems
39  */
40 public class ProcessDataModel extends SRMProviderDataModel
41 	implements SRMProviderProperties,
42 	    Solaris_ProcessStatisticalInformationProperties {
43 
44     /**
45      * Object path to the Solaris_Process instance
46      */
47     protected CIMObjectPath   opForProc;
48     int pid;
49 
50 
ProcessDataModel()51     public ProcessDataModel() {
52     	super();
53     }
54 
55 
ProcessDataModel(int pid)56     public ProcessDataModel(int pid) {
57     	this.pid = pid;
58     }
59 
60 
61     /**
62      * Get a CIM object path to a Solaris_Process object.
63      * @returns object path to the Solaris_Process instance.
64      */
getCIMObjectPathForProc()65     public CIMObjectPath getCIMObjectPathForProc() {
66         if (opForProc == null) {
67 
68             opForProc = new CIMObjectPath(SOLARIS_PROCESS);
69 	    opForProc.setNameSpace(NAMESPACE);
70 
71             Vector properties = new Vector(5);
72 
73             properties.add(
74 		new CIMProperty(CSCREATIONCLASSNAME,
75 		  new CIMValue(SOLARIS_COMPUTERSYSTEM)));
76 
77 	    properties.add(
78 		new CIMProperty(CSNAME,
79 		  new CIMValue(csName)));
80 
81 	    properties.add(
82 		new CIMProperty(OSCREATIONCLASSNAME,
83 		  new CIMValue(SOLARIS_OPERATINGSYSTEM)));
84 
85 	    properties.add(
86 		new CIMProperty(OSNAME,
87 		  new CIMValue(osName)));
88 
89 	    properties.add(
90 		new CIMProperty(HANDLE,
91 		  new CIMValue(Long.toString(pid))));
92 
93 	    opForProc.setKeys(properties);
94         }
95         return opForProc;
96     }
97 
98 
toString()99     public String toString() {
100 
101     	return "Name    " + pid + "\n" + super.toString();
102     }
103 
104 
setOpPropertiesVector()105     protected void setOpPropertiesVector() {
106 
107         opProperties.add(
108 	    	new CIMProperty(CSCREATIONCLASSNAME,
109 		new CIMValue(SOLARIS_COMPUTERSYSTEM)));
110 
111         opProperties.add(
112 		new CIMProperty(CSNAME,
113 		new CIMValue(csName)));
114 
115         opProperties.add(
116 	    	new CIMProperty(OSCREATIONCLASSNAME,
117 	  	new CIMValue(SOLARIS_OPERATINGSYSTEM)));
118 
119         opProperties.add(
120 	    	new CIMProperty(OSNAME,
121 		new CIMValue(osName)));
122 
123         opProperties.add(
124 	    	new CIMProperty(NAME,
125 		new CIMValue(Long.toString(pid))));
126     }
127 
128 
setCIMInstance(boolean newInstance)129     protected void setCIMInstance(boolean newInstance) {
130 
131         setStrProp(newInstance,
132 		  	SYSTEMCREATIONCLASSNAME,
133 		  	SOLARIS_COMPUTERSYSTEM);
134 
135         setStrProp(newInstance,
136 			  SYSTEMNAME,
137 			  csName);
138 
139         setStrProp(newInstance,
140 			  CREATIONCLASSNAME,
141 			  SOLARIS_PROCESSSTATISTICALINFORMATION);
142 
143         setStrProp(newInstance,
144 			  CAPTION,
145 			  "");
146 
147         setStrProp(newInstance,
148 			  DESCRIPTION,
149 			  "");
150 
151         setStrProp(newInstance,
152 			  NAME,
153 			  Long.toString(pid));
154     }
155 
156 
initKeyValTable()157     protected void initKeyValTable() {
158     	keyValTab = new LinkedHashMap(30);
159 
160 	keyValTab.put(WAITCPUTIME_KEY,
161 	    new SetReal64Prop(WAITCPUTIME));
162 	keyValTab.put(USERMODETIME_KEY,
163 	    new SetReal64Prop(USERMODETIME));
164 	keyValTab.put(SYSTEMMODETIME_KEY,
165 	    new SetReal64Prop(SYSTEMMODETIME));
166 	keyValTab.put(SYSTEMTRAPTIME_KEY,
167 	    new SetReal64Prop(SYSTEMTRAPTIME));
168 	keyValTab.put(TEXTPAGEFAULTSLEEPTIME_KEY,
169 	    new SetReal64Prop(TEXTPAGEFAULTSLEEPTIME));
170 	keyValTab.put(DATAPAGEFAULTSLEEPTIME_KEY,
171 	    new SetReal64Prop(DATAPAGEFAULTSLEEPTIME));
172 	keyValTab.put(SYSTEMPAGEFAULTSLEEPTIME_KEY,
173 	    new SetReal64Prop(SYSTEMPAGEFAULTSLEEPTIME));
174 	keyValTab.put(USERLOCKWAITSLEEPTIME_KEY,
175 	    new SetReal64Prop(USERLOCKWAITSLEEPTIME));
176 	keyValTab.put(OTHERSLEEPTIME_KEY,
177 	    new SetReal64Prop(OTHERSLEEPTIME));
178 	keyValTab.put(STOPPEDTIME_KEY,
179 	    new SetReal64Prop(STOPPEDTIME));
180 	keyValTab.put(MINORPAGEFAULTS_KEY,
181 	    new SetUI64Prop(MINORPAGEFAULTS));
182 	keyValTab.put(MAJORPAGEFAULTS_KEY,
183 	    new SetUI64Prop(MAJORPAGEFAULTS));
184 	keyValTab.put(SWAPOPERATIONS_KEY,
185 	    new SetUI64Prop(SWAPOPERATIONS));
186 	keyValTab.put(BLOCKSREAD_KEY,
187 	    new SetUI64Prop(BLOCKSREAD));
188 	keyValTab.put(BLOCKSWRITTEN_KEY,
189 	    new SetUI64Prop(BLOCKSWRITTEN));
190 	keyValTab.put(MESSAGESSENT_KEY,
191 	    new SetUI64Prop(MESSAGESSENT));
192 	keyValTab.put(MESSAGESRECEIVED_KEY,
193 	    new SetUI64Prop(MESSAGESRECEIVED));
194 	keyValTab.put(SIGNALSRECEIVED_KEY,
195 	    new SetUI64Prop(SIGNALSRECEIVED));
196 	keyValTab.put(VOLUNTARYCONTEXTSWITCHES_KEY,
197 	    new SetUI64Prop(VOLUNTARYCONTEXTSWITCHES));
198 	keyValTab.put(INVOLUNTARYCONTEXTSWITCHES_KEY,
199 	    new SetUI64Prop(INVOLUNTARYCONTEXTSWITCHES));
200 	keyValTab.put(SYSTEMCALLSMADE_KEY,
201 	    new SetUI64Prop(SYSTEMCALLSMADE));
202 	keyValTab.put(CHARACTERIOUSAGE_KEY,
203 	    new SetUI64Prop(CHARACTERIOUSAGE));
204 	keyValTab.put(PROCESSHEAPSIZE_KEY,
205 	    new SetUI64Prop(PROCESSHEAPSIZE));
206 	keyValTab.put(PROCESSVMSIZE_KEY,
207 	    new SetUI64Prop(PROCESSVMSIZE));
208 	keyValTab.put(PROCESSRESIDENTSETSIZE_KEY,
209 	    new SetUI64Prop(PROCESSRESIDENTSETSIZE));
210 	keyValTab.put(PERCENTCPUTIME_KEY,
211 	    new SetReal32Prop(PERCENTCPUTIME));
212 	keyValTab.put(PERCENTMEMORYSIZE_KEY,
213 	    new SetReal32Prop(PERCENTMEMORYSIZE));
214 	keyValTab.put(USERSYSTEMMODETIME_KEY,
215 	    new SetUI64Prop(USERSYSTEMMODETIME));
216 	keyValTab.put(NUMTHREADS_KEY,
217 	    new SetUI64Prop(NUMTHREADS));
218 	keyValTab.put(TIMESTAMP_KEY,
219 	    new SetUI64Prop(TIMESTAMP));
220     }
221 }
222