use of org.h2.message.Trace in project h2database by h2database.
the class TestAll method testEverything.
/**
* Run all tests in all possible combinations.
*/
private void testEverything() throws SQLException {
for (int c = 0; c < 2; c++) {
if (c == 0) {
cipher = null;
} else {
cipher = "AES";
}
for (int a = 0; a < 64; a++) {
smallLog = (a & 1) != 0;
big = (a & 2) != 0;
networked = (a & 4) != 0;
memory = (a & 8) != 0;
ssl = (a & 16) != 0;
diskResult = (a & 32) != 0;
for (int trace = 0; trace < 3; trace++) {
traceLevelFile = trace;
test();
}
}
}
}
use of org.h2.message.Trace in project h2database by h2database.
the class TestBenchmark method testConcurrency.
private void testConcurrency(String fileName, int concurrency, final int count) throws Exception {
Thread.sleep(1000);
final MVStore store = new MVStore.Builder().cacheSize(256).cacheConcurrency(concurrency).fileName(fileName).open();
int threadCount = 128;
final CountDownLatch wait = new CountDownLatch(1);
final AtomicInteger counter = new AtomicInteger();
final AtomicBoolean stopped = new AtomicBoolean();
Task[] tasks = new Task[threadCount];
// Profiler prof = new Profiler().startCollecting();
for (int i = 0; i < threadCount; i++) {
final int x = i;
Task t = new Task() {
@Override
public void call() throws Exception {
MVMap<Integer, byte[]> map = store.openMap("test");
Random random = new Random(x);
wait.await();
while (!stopped.get()) {
int key = random.nextInt(count);
byte[] data = map.get(key);
if (data.length > 1) {
counter.incrementAndGet();
}
}
}
};
t.execute("t" + i);
tasks[i] = t;
}
wait.countDown();
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
e.printStackTrace();
}
stopped.set(true);
for (Task t : tasks) {
t.get();
}
// System.out.println(prof.getTop(5));
String msg = "concurrency " + concurrency + " threads " + threadCount + " requests: " + counter;
System.out.println(msg);
trace(msg);
store.close();
}
use of org.h2.message.Trace in project h2database by h2database.
the class TestMVStore method testLargerThan2G.
private void testLargerThan2G() {
if (!config.big) {
return;
}
String fileName = getBaseDir() + "/" + getTestName();
FileUtils.delete(fileName);
MVStore store = new MVStore.Builder().cacheSize(16).fileName(fileName).open();
try {
MVMap<Integer, String> map = store.openMap("test");
long last = System.nanoTime();
String data = new String(new char[2500]).replace((char) 0, 'x');
for (int i = 0; ; i++) {
map.put(i, data);
if (i % 10000 == 0) {
store.commit();
long time = System.nanoTime();
if (time - last > TimeUnit.SECONDS.toNanos(2)) {
long mb = store.getFileStore().size() / 1024 / 1024;
trace(mb + "/4500");
if (mb > 4500) {
break;
}
last = time;
}
}
}
store.commit();
store.close();
} finally {
store.closeImmediately();
}
FileUtils.delete(fileName);
}
use of org.h2.message.Trace in project h2database by h2database.
the class Recover method dumpPageBtreeNode.
private void dumpPageBtreeNode(PrintWriter writer, Data s, long pageId, boolean positionOnly) {
int rowCount = s.readInt();
int entryCount = s.readShortInt();
int[] children = new int[entryCount + 1];
int[] offsets = new int[entryCount];
children[entryCount] = s.readInt();
checkParent(writer, pageId, children, entryCount);
int empty = Integer.MAX_VALUE;
for (int i = 0; i < entryCount; i++) {
children[i] = s.readInt();
checkParent(writer, pageId, children, i);
int off = s.readShortInt();
empty = Math.min(off, empty);
offsets[i] = off;
}
empty = empty - s.length();
if (!trace) {
return;
}
writer.println("-- empty: " + empty);
for (int i = 0; i < entryCount; i++) {
int off = offsets[i];
s.setPos(off);
long key = s.readVarLong();
Value data;
if (positionOnly) {
data = ValueLong.get(key);
} else {
try {
data = s.readValue();
} catch (Throwable e) {
writeDataError(writer, "exception " + e, s.getBytes());
continue;
}
}
writer.println("-- [" + i + "] child: " + children[i] + " key: " + key + " data: " + data);
}
writer.println("-- [" + entryCount + "] child: " + children[entryCount] + " rowCount: " + rowCount);
}
use of org.h2.message.Trace in project h2database by h2database.
the class FtpServer method startTask.
/**
* Start a task.
*
* @param path the name of the task file
*/
void startTask(String path) throws IOException {
stopTask(path);
if (path.endsWith(".zip.task")) {
trace("expand: " + path);
Process p = Runtime.getRuntime().exec("jar -xf " + path, null, new File(root));
new StreamRedirect(path, p.getInputStream(), null).start();
return;
}
Properties prop = SortedProperties.loadProperties(path);
String command = prop.getProperty("command");
String outFile = path.substring(0, path.length() - TASK_SUFFIX.length());
String errorFile = root + "/" + prop.getProperty("error", outFile + ".err.txt");
String outputFile = root + "/" + prop.getProperty("output", outFile + ".out.txt");
trace("start process: " + path + " / " + command);
Process p = Runtime.getRuntime().exec(command, null, new File(root));
new StreamRedirect(path, p.getErrorStream(), errorFile).start();
new StreamRedirect(path, p.getInputStream(), outputFile).start();
tasks.put(path, p);
}
Aggregations