String dataString = baseString + i;
byte[] data = dataString.getBytes("UTF-8");
ClientCHKBlock b;
b = ClientCHKBlock.encode(data, false, false, (short)-1, 0, COMPRESSOR_TYPE.DEFAULT_COMPRESSORDESCRIPTOR, false);
CHKBlock block = b.getBlock();
ClientCHK chk = b.getClientKey();
byte[] encData = block.getData();
byte[] encHeaders = block.getHeaders();
ClientCHKBlock newBlock = new ClientCHKBlock(encData, encHeaders, chk, true);
keys[i] = chk;
Logger.minor(RealNodeRequestInsertTest.class, "Decoded: "+new String(newBlock.memoryDecode(), "UTF-8"));
Logger.normal(RealNodeRequestInsertTest.class,"CHK: "+chk.getURI());
Logger.minor(RealNodeRequestInsertTest.class,"Headers: "+HexUtil.bytesToHex(block.getHeaders()));
// Insert it.
try {
randomNode.clientCore.realPut(block, false, FORK_ON_CACHEABLE, false, false, REAL_TIME_FLAG);
Logger.error(RealNodeRequestInsertTest.class, "Inserted to "+node1);
Logger.minor(RealNodeRequestInsertTest.class, "Data: "+Fields.hashCode(encData)+", Headers: "+Fields.hashCode(encHeaders));
} catch (freenet.node.LowLevelPutException putEx) {
Logger.error(RealNodeRequestInsertTest.class, "Insert failed: "+ putEx);
System.err.println("Insert failed: "+ putEx);
System.exit(EXIT_INSERT_FAILED);
}
}
// Now queue requests for each key on every node.
for(int i=0;i<INSERT_KEYS;i++) {
ClientCHK key = keys[i];
System.err.println("Queueing requests for "+i+" of "+INSERT_KEYS);
for(int j=0;j<nodes.length;j++) {
clients[j].prefetch(key.getURI(), DAYS.toMillis(1), 32768, null);
}
long totalRunningRequests = 0;
for(int j=0;j<nodes.length;j++) {
totalRunningRequests += nodes[j].clientCore.countQueuedRequests();
}