author | phh |
Sat, 30 Nov 2019 14:33:05 -0800 | |
changeset 59330 | 5b96c12f909d |
parent 49958 | cc29d7717e3a |
permissions | -rw-r--r-- |
49958
cc29d7717e3a
8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff
changeset
|
1 |
/* |
cc29d7717e3a
8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff
changeset
|
2 |
* Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved. |
cc29d7717e3a
8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
cc29d7717e3a
8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff
changeset
|
4 |
* |
cc29d7717e3a
8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
cc29d7717e3a
8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
cc29d7717e3a
8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
cc29d7717e3a
8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff
changeset
|
8 |
* |
cc29d7717e3a
8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
cc29d7717e3a
8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
cc29d7717e3a
8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
cc29d7717e3a
8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
cc29d7717e3a
8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff
changeset
|
13 |
* accompanied this code). |
cc29d7717e3a
8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff
changeset
|
14 |
* |
cc29d7717e3a
8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
cc29d7717e3a
8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
cc29d7717e3a
8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
cc29d7717e3a
8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff
changeset
|
18 |
* |
cc29d7717e3a
8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
cc29d7717e3a
8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
cc29d7717e3a
8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff
changeset
|
21 |
* questions. |
cc29d7717e3a
8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff
changeset
|
22 |
*/ |
cc29d7717e3a
8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff
changeset
|
23 |
|
cc29d7717e3a
8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff
changeset
|
24 |
package nsk.monitoring.share; |
cc29d7717e3a
8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff
changeset
|
25 |
|
cc29d7717e3a
8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff
changeset
|
26 |
import nsk.share.log.*; |
cc29d7717e3a
8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff
changeset
|
27 |
|
cc29d7717e3a
8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff
changeset
|
28 |
/** |
cc29d7717e3a
8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff
changeset
|
29 |
* An abstract base class for operating VM state. The follow methods must |
cc29d7717e3a
8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff
changeset
|
30 |
* be implemented by its subclasses: |
cc29d7717e3a
8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff
changeset
|
31 |
* <ul> |
cc29d7717e3a
8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff
changeset
|
32 |
* <li><code>run()</code> -- brings VM into defined state. |
cc29d7717e3a
8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff
changeset
|
33 |
* <li><code>reset()</code> -- tries to reclaim VM into initial state. |
cc29d7717e3a
8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff
changeset
|
34 |
* </ul> |
cc29d7717e3a
8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff
changeset
|
35 |
*/ |
cc29d7717e3a
8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff
changeset
|
36 |
public abstract class StateControllerBase implements LogAware { |
cc29d7717e3a
8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff
changeset
|
37 |
protected Log log; |
cc29d7717e3a
8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff
changeset
|
38 |
|
cc29d7717e3a
8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff
changeset
|
39 |
public StateControllerBase(Log log) { |
cc29d7717e3a
8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff
changeset
|
40 |
this.log = log; |
cc29d7717e3a
8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff
changeset
|
41 |
} |
cc29d7717e3a
8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff
changeset
|
42 |
|
cc29d7717e3a
8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff
changeset
|
43 |
/** |
cc29d7717e3a
8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff
changeset
|
44 |
* Brings VM into defined state. |
cc29d7717e3a
8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff
changeset
|
45 |
*/ |
cc29d7717e3a
8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff
changeset
|
46 |
public abstract void run(); |
cc29d7717e3a
8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff
changeset
|
47 |
|
cc29d7717e3a
8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff
changeset
|
48 |
/** |
cc29d7717e3a
8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff
changeset
|
49 |
* Tries to reclaim VM into initial state |
cc29d7717e3a
8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff
changeset
|
50 |
*/ |
cc29d7717e3a
8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff
changeset
|
51 |
public abstract void reset(); |
cc29d7717e3a
8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff
changeset
|
52 |
|
cc29d7717e3a
8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff
changeset
|
53 |
/** |
cc29d7717e3a
8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff
changeset
|
54 |
* Defines {@link Log <code>Log.Logger</code>} object. |
cc29d7717e3a
8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff
changeset
|
55 |
*/ |
cc29d7717e3a
8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff
changeset
|
56 |
public final void setLog(Log log) { |
cc29d7717e3a
8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff
changeset
|
57 |
this.log = log; |
cc29d7717e3a
8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff
changeset
|
58 |
} |
cc29d7717e3a
8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff
changeset
|
59 |
|
cc29d7717e3a
8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff
changeset
|
60 |
/** |
cc29d7717e3a
8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff
changeset
|
61 |
* Converts an integer to string. |
cc29d7717e3a
8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff
changeset
|
62 |
* |
cc29d7717e3a
8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff
changeset
|
63 |
* @param i an integer to convert. |
cc29d7717e3a
8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff
changeset
|
64 |
* @return a string that represents the int value. |
cc29d7717e3a
8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff
changeset
|
65 |
*/ |
cc29d7717e3a
8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff
changeset
|
66 |
protected String int2Str(int i) { |
cc29d7717e3a
8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff
changeset
|
67 |
String tmp = ""; |
cc29d7717e3a
8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff
changeset
|
68 |
|
cc29d7717e3a
8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff
changeset
|
69 |
if (i < 10) { |
cc29d7717e3a
8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff
changeset
|
70 |
tmp = "00"; |
cc29d7717e3a
8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff
changeset
|
71 |
} else if (i >= 10 && i < 100) { |
cc29d7717e3a
8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff
changeset
|
72 |
tmp = "0"; |
cc29d7717e3a
8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff
changeset
|
73 |
} |
cc29d7717e3a
8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff
changeset
|
74 |
return tmp + String.valueOf(i); |
cc29d7717e3a
8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff
changeset
|
75 |
} |
cc29d7717e3a
8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff
changeset
|
76 |
} |