use of org.h2.message.Trace in project h2database by h2database.
the class WebServer method readTranslations.
/**
* Read the translation for this language and save them in the 'text'
* property of this session.
*
* @param session the session
* @param language the language
*/
void readTranslations(WebSession session, String language) {
Properties text = new Properties();
try {
trace("translation: " + language);
byte[] trans = getFile("_text_" + language + ".prop");
trace(" " + new String(trans));
text = SortedProperties.fromLines(new String(trans, StandardCharsets.UTF_8));
// remove starting # (if not translated yet)
for (Entry<Object, Object> entry : text.entrySet()) {
String value = (String) entry.getValue();
if (value.startsWith("#")) {
entry.setValue(value.substring(1));
}
}
} catch (IOException e) {
DbException.traceThrowable(e);
}
session.put("text", new HashMap<>(text));
}
use of org.h2.message.Trace in project h2database by h2database.
the class WebServer method init.
@Override
public void init(String... args) {
// set the serverPropertiesDir, because it's used in loadProperties()
for (int i = 0; args != null && i < args.length; i++) {
if ("-properties".equals(args[i])) {
serverPropertiesDir = args[++i];
}
}
Properties prop = loadProperties();
port = SortedProperties.getIntProperty(prop, "webPort", Constants.DEFAULT_HTTP_PORT);
ssl = SortedProperties.getBooleanProperty(prop, "webSSL", false);
allowOthers = SortedProperties.getBooleanProperty(prop, "webAllowOthers", false);
commandHistoryString = prop.getProperty(COMMAND_HISTORY);
for (int i = 0; args != null && i < args.length; i++) {
String a = args[i];
if (Tool.isOption(a, "-webPort")) {
port = Integer.decode(args[++i]);
} else if (Tool.isOption(a, "-webSSL")) {
ssl = true;
} else if (Tool.isOption(a, "-webAllowOthers")) {
allowOthers = true;
} else if (Tool.isOption(a, "-webDaemon")) {
isDaemon = true;
} else if (Tool.isOption(a, "-baseDir")) {
String baseDir = args[++i];
SysProperties.setBaseDir(baseDir);
} else if (Tool.isOption(a, "-ifExists")) {
ifExists = true;
} else if (Tool.isOption(a, "-properties")) {
// already set
i++;
} else if (Tool.isOption(a, "-trace")) {
trace = true;
}
}
// }
for (String[] lang : LANGUAGES) {
languages.add(lang[0]);
}
updateURL();
}
use of org.h2.message.Trace in project h2database by h2database.
the class PgServer method listen.
@Override
public void listen() {
String threadName = Thread.currentThread().getName();
try {
while (!stop) {
Socket s = serverSocket.accept();
if (!allow(s)) {
trace("Connection not allowed");
s.close();
} else {
PgServerThread c = new PgServerThread(s, this);
running.add(c);
c.setProcessId(pid.incrementAndGet());
Thread thread = new Thread(c, threadName + " thread");
thread.setDaemon(isDaemon);
c.setThread(thread);
thread.start();
}
}
} catch (Exception e) {
if (!stop) {
e.printStackTrace();
}
}
}
use of org.h2.message.Trace in project h2database by h2database.
the class TestTraceSystem method testAdapter.
private void testAdapter() {
TraceSystem ts = new TraceSystem(null);
ts.setName("test");
ts.setLevelFile(TraceSystem.ADAPTER);
ts.getTrace("test").debug("test");
ts.getTrace("test").info("test");
ts.getTrace("test").error(new Exception(), "test");
// The used SLF4J-nop logger has all log levels disabled,
// so this should be reflected in the trace system.
assertFalse(ts.isEnabled(TraceSystem.INFO));
assertFalse(ts.getTrace("test").isInfoEnabled());
ts.close();
}
use of org.h2.message.Trace in project h2database by h2database.
the class TestValueMemory method testType.
private void testType(int type) throws SQLException {
System.gc();
System.gc();
long first = Utils.getMemoryUsed();
ArrayList<Value> list = new ArrayList<>();
long memory = 0;
while (memory < 1000000) {
Value v = create(type);
memory += v.getMemory() + Constants.MEMORY_POINTER;
list.add(v);
}
Object[] array = list.toArray();
IdentityHashMap<Object, Object> map = new IdentityHashMap<>();
for (Object a : array) {
map.put(a, a);
}
int size = map.size();
map.clear();
map = null;
list = null;
System.gc();
System.gc();
long used = Utils.getMemoryUsed() - first;
memory /= 1024;
if (config.traceTest || used > memory * 3) {
String msg = "Type: " + type + " Used memory: " + used + " calculated: " + memory + " length: " + array.length + " size: " + size;
if (config.traceTest) {
trace(msg);
}
if (used > memory * 3) {
fail(msg);
}
}
}
Aggregations