Is the below testLoop called multiple times? Try reusing your HBaseConfiguration rather than make a new one each time as you do below in the HTable construction. This should have you avert the issue J-D identifies. St.Ack
On Fri, Oct 9, 2009 at 7:53 AM, Julien Ruchaud <[email protected] > wrote: > Hi, > > I am a newbie on hbase. Currently I am testing hbase 0.20.0, but I don't > understand why my test don't run correctly sometimes : > > public void testLoop() throws Exception { > HTable hTable = new HTable(new HBaseConfiguration(), > Bytes.toBytes("Table")); > byte[] rowId = Bytes.toBytes("Test"); > > for (int j = 0; j < 10; j++) { > Put put = new Put(rowId); > put.add(Bytes.toBytes("data"), Bytes.toBytes("1:" + j), > Bytes.toBytes(j)); > hTable.put(put); > } > > for (int j = 0; j < 10; j++) { > Get get = new Get(rowId); > Result row = hTable.get(get); > if(row.getValue(Bytes.toBytes("data"), Bytes.toBytes("1:" + j)) > == null) { > throw new Exception("Error 1"); > } > } > > for (int j = 0; j < 10; j++) { > Delete delete = new Delete(rowId); > hTable.delete(delete); > } > > for (int j = 0; j < 10; j++) { > Put put = new Put(rowId); > put.add(Bytes.toBytes("data"), Bytes.toBytes("2:" + j), > Bytes.toBytes(j)); > hTable.put(put); > } > > for (int j = 0; j < 10; j++) { > Get get = new Get(rowId); > Result row = hTable.get(get); > if(row.getValue(Bytes.toBytes("data"), Bytes.toBytes("2:" + j)) > == null) { > throw new Exception("Error 2"); > } > } > } > > In fact I have got exception "Error 2" with a exception in hbase log : > > 2009-10-09 16:39:34,829 WARN org.apache.zookeeper.server.NIOServerCnxn: > Exception causing close of session 0x124393fc5390046 due to > java.io.IOException: Read error > 2009-10-09 16:39:34,829 DEBUG org.apache.zookeeper.server.NIOServerCnxn: > IOException stack trace > java.io.IOException: Read error > at > org.apache.zookeeper.server.NIOServerCnxn.doIO(NIOServerCnxn.java:366) > at > org.apache.zookeeper.server.NIOServerCnxn$Factory.run(NIOServerCnxn.java:220) > 2009-10-09 16:39:34,830 INFO org.apache.zookeeper.server.NIOServerCnxn: > closing session:0x124393fc5390046 NIOServerCnxn: > java.nio.channels.SocketChannel[connected local=/127.0.0.1:2181 remote=/ > 127.0.0.1:48870] > 2009-10-09 16:39:34,830 DEBUG org.apache.zookeeper.server.NIOServerCnxn: > ignoring exception during input shutdown > java.net.SocketException: Transport endpoint is not connected > at sun.nio.ch.SocketChannelImpl.shutdown(Native Method) > at > sun.nio.ch.SocketChannelImpl.shutdownInput(SocketChannelImpl.java:640) > at sun.nio.ch.SocketAdaptor.shutdownInput(SocketAdaptor.java:360) > at > org.apache.zookeeper.server.NIOServerCnxn.close(NIOServerCnxn.java:841) > at > org.apache.zookeeper.server.NIOServerCnxn.doIO(NIOServerCnxn.java:492) > at > > org.apache.zookeeper.server.NIOServerCnxn$Factory.run(NIOServerCnxn.java:220) > > Thanks in advance for your input > > Julien Ruchaud >
