/** * Try to read a chunk footer. * * @param end the end of the chunk * @return the chunk, or null if not successful */ private Chunk readChunkFooter(long end) { // the following can fail for various reasons try { // read the chunk footer of the last block of the file ByteBuffer lastBlock = fileStore.readFully( end - Chunk.FOOTER_LENGTH, Chunk.FOOTER_LENGTH); byte[] buff = new byte[Chunk.FOOTER_LENGTH]; lastBlock.get(buff); HashMap<String, String> m = DataUtils.parseChecksummedMap(buff); if (m != null) { int chunk = DataUtils.readHexInt(m, "chunk", 0); Chunk c = new Chunk(chunk); c.version = DataUtils.readHexLong(m, "version", 0); c.block = DataUtils.readHexLong(m, "block", 0); return c; } } catch (Exception e) { // ignore } return null; }
HashMap<String, String> m = DataUtils.parseChecksummedMap(buff); if (m == null) { continue;
/** * Try to read a chunk footer. * * @param end the end of the chunk * @return the chunk, or null if not successful */ private Chunk readChunkFooter(long end) { // the following can fail for various reasons try { // read the chunk footer of the last block of the file ByteBuffer lastBlock = fileStore.readFully( end - Chunk.FOOTER_LENGTH, Chunk.FOOTER_LENGTH); byte[] buff = new byte[Chunk.FOOTER_LENGTH]; lastBlock.get(buff); HashMap<String, String> m = DataUtils.parseChecksummedMap(buff); if (m != null) { int chunk = DataUtils.readHexInt(m, "chunk", 0); Chunk c = new Chunk(chunk); c.version = DataUtils.readHexLong(m, "version", 0); c.block = DataUtils.readHexLong(m, "block", 0); return c; } } catch (Exception e) { // ignore } return null; }
HashMap<String, String> m = DataUtils.parseChecksummedMap(buff); if (m == null) { continue;