001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package org.netbeans.modules.cnd.repository.testbench;
043:
044: import org.netbeans.modules.cnd.repository.spi.Key;
045:
046: /**
047: *
048: * @author Sergey Grinev
049: */
050: public class Stats {
051:
052: private Stats() {
053: }
054:
055: public static int debugPut = 0;
056: public static int debugGot = 0;
057: public static int debugReadFromFile = 0;
058: public static int debugNotFound = 0;
059: public static int debugGotFromHardCache = 0;
060: public static int nullDataTriggered = 0;
061:
062: public static final boolean monitorRemovedKeys = getBoolean(
063: "cnd.repository.monitor.removed.keys", false); //NOI18N
064:
065: public static final boolean isDebug = getBoolean(
066: "cnd.repository.use.dev", false); //NOI18N
067: public static final boolean verbosePut = getBoolean(
068: "cnd.repository.verbose.put", false); //NOI18N
069: public static final boolean validatePut = getBoolean(
070: "cnd.repository.validate.put", false); //NOI18N
071: public static final boolean validateKeys = getBoolean(
072: "cnd.repository.validate.keys", false); //NOI18N
073: public static final boolean rememberKeys = getBoolean(
074: "cnd.repository.remember.keys", false); //NOI18N
075: public static final boolean useNullWorkaround = getBoolean(
076: "cnd.repository.workaround.nulldata", false); //NOI18N
077:
078: public static final boolean useHardRefRepository = getBoolean(
079: "cnd.repository.hardrefs", false); //NOI18N
080: public static final boolean queueTiming = getBoolean(
081: "cnd.repository.queue.timing", false); //NOI18N
082: public static final boolean queueTrace = getBoolean(
083: "cnd.repository.queue.trace", false); //NOI18N
084: public static final boolean queueUseTicking = getBoolean(
085: "cnd.repository.queue.ticking", true); //NOI18N
086:
087: public static final int fileStatisticsLevel = getInteger(
088: "cnd.repository.file.stat", 0); //NOI18N
089: public static final int fileStatisticsRanges = getInteger(
090: "cnd.repository.file.stat.ranges", 10); //NOI18N
091:
092: public static final boolean writeStatistics = getBoolean(
093: "cnd.repository.write.stat", false); //NOI18N
094:
095: public static final boolean dumoFileOnExit = getBoolean(
096: "cnd.repository.dump.on.exit", false); //NOI18N
097: public static final int maintenanceInterval = getInteger(
098: "cnd.repository.queue.maintenance", 500); //NOI18N
099: public static final boolean allowMaintenance = getBoolean(
100: "cnd.repository.defragm", true); //NOI18N
101:
102: public static final int fileRWAccess = getInteger(
103: "cnd.repository.rw", 0); //NOI18N
104: public static final int bufSize = getInteger(
105: "cnd.repository.bufsize", -1); //NOI18N
106: public static final boolean useCompactIndex = getBoolean(
107: "cnd.repository.compact.index", true); //NOI18N
108:
109: public static final String traceKeyName = System
110: .getProperty("cnd.repository.trace.key"); //NOI18N
111: public static final boolean traceKey = (traceKeyName != null); //NOI18N
112:
113: public static final boolean traceDefragmentation = getBoolean(
114: "cnd.repository.trace.defragm", false); //NOI18N
115:
116: public static final boolean hardFickle = getBoolean(
117: "cnd.repository.hard.fickle", false); //NOI18N
118: public static final int defragmentationThreashold = getInteger(
119: "cnd.repository.defragm.threshold", 50); //NOI18N
120:
121: public final static String ENCODING = System
122: .getProperty("file.encoding"); // NOI18N
123:
124: public final static boolean TRACE_REPOSITORY_TRANSLATOR = getBoolean(
125: "cnd.repository.trace.translator", false); //NOI18N
126: public final static boolean TRACE_UNIT_DELETION = getBoolean(
127: "cnd.repository.trace.unit.deletion", false); //I18N
128:
129: public static final boolean isTraceKey(Key key) {
130: if (traceKey) {
131: if (key != null) {
132: for (int i = 0; i < key.getDepth(); i++) {
133: if (traceKeyName.equals(key.getAt(i))) {
134: return true;
135: }
136: }
137: }
138: }
139: return false;
140: }
141:
142: public static boolean getBoolean(String name, boolean result) {
143: String text = System.getProperty(name);
144: if (text != null) {
145: result = Boolean.parseBoolean(text);
146: }
147: return result;
148: }
149:
150: public static int getInteger(String name, int result) {
151: String text = System.getProperty(name);
152: if (text != null) {
153: result = Integer.parseInt(text);
154: }
155: return result;
156: }
157:
158: public static void report(String st) {
159: log("Put: " + debugPut + //NOI18N
160: "; Got: " + debugGot + //NOI18N
161: "; Read: " + debugReadFromFile + //NOI18N
162: "; N/A: " + debugNotFound //NOI18N
163: + "; Hard: " + debugGotFromHardCache //NOI18N
164: + st);
165: }
166:
167: public static void report() {
168: report("");
169: }
170:
171: public static void report(int hard, int soft) {
172: report("; in Hard cache: " + hard + "; in Soft cache <" + soft); // NOI18N
173: }
174:
175: public static void log(String st) {
176: if (useNullWorkaround) {
177: st += "; NULL: " + nullDataTriggered; //NOI18N
178: }
179: if (isDebug)
180: System.err.println("DEBUG [Repository] " + st); //NOI18N
181: }
182:
183: }
|