@Override protected void mark(BlockId blockId) throws Exception { Connection con = this.ch.getRWConnection(); PreparedStatement prep = null; try { if (minLastModified == 0) { return; } String id = StringUtils.convertBytesToHex(blockId.getDigest()); prep = con.prepareStatement("update " + this.tnMeta + " set LASTMOD = ? where ID = ? and LASTMOD < ?"); prep.setLong(1, System.currentTimeMillis()); prep.setString(2, id); prep.setLong(3, minLastModified); prep.executeUpdate(); prep.close(); } finally { closeStatement(prep); con.commit(); this.ch.closeConnection(con); } }
@Override protected void mark(BlockId blockId) throws Exception { Connection con = this.ch.getRWConnection(); PreparedStatement prep = null; try { if (minLastModified == 0) { return; } String id = StringUtils.convertBytesToHex(blockId.getDigest()); prep = con.prepareStatement("update " + this.tnMeta + " set LASTMOD = ? where ID = ? and LASTMOD < ?"); prep.setLong(1, System.currentTimeMillis()); prep.setString(2, id); prep.setLong(3, minLastModified); prep.executeUpdate(); prep.close(); } finally { closeStatement(prep); con.commit(); this.ch.closeConnection(con); } }
@Override protected void mark(BlockId blockId) throws Exception { if (minLastModified == 0) { return; } String id = StringUtils.convertBytesToHex(blockId.getDigest()); Bson query = getBlobQuery(id, minLastModified); Bson update = new BasicDBObject("$set", new BasicDBObject(MongoBlob.KEY_LAST_MOD, System.currentTimeMillis())); getBlobCollection().updateOne(query, update); }
@Override protected byte[] readBlockFromBackend(BlockId blockId) throws Exception { String id = StringUtils.convertBytesToHex(blockId.getDigest()); byte[] data = cache.get(id);
@Override protected byte[] readBlockFromBackend(BlockId blockId) throws Exception { String id = StringUtils.convertBytesToHex(blockId.getDigest()); byte[] data = cache.get(id);
Preconditions.checkNotNull(context); String id = StringUtils.convertBytesToHex(blockId.getDigest()); byte[] data = cache.get(id); if (data == null) {
Preconditions.checkNotNull(context); String id = StringUtils.convertBytesToHex(blockId.getDigest()); byte[] data = cache.get(id); if (data == null) {
Preconditions.checkNotNull(context); String id = StringUtils.convertBytesToHex(blockId.getDigest()); byte[] data = cache.get(id); if (data == null) {
@Override protected byte[] readBlockFromBackend(BlockId blockId) throws Exception { String id = StringUtils.convertBytesToHex(blockId.getDigest()); byte[] data = cache.get(id); if (data == null) { long start = System.nanoTime(); MongoBlob blobMongo = getBlob(id, 0); if (blobMongo == null) { String message = "Did not find block " + id; LOG.error(message); throw new IOException(message); } data = blobMongo.getData(); getStatsCollector().downloaded(id, System.nanoTime() - start, TimeUnit.NANOSECONDS, data.length); cache.put(id, data); } if (blockId.getPos() == 0) { return data; } int len = (int) (data.length - blockId.getPos()); if (len < 0) { return new byte[0]; } byte[] d2 = new byte[len]; System.arraycopy(data, (int) blockId.getPos(), d2, 0, len); return d2; }
@Override protected byte[] readBlockFromBackend(BlockId blockId) throws Exception { String id = StringUtils.convertBytesToHex(blockId.getDigest()); byte[] data = cache.get(id); if (data == null) { long start = System.nanoTime(); MongoBlob blobMongo = getBlob(id, 0); if (blobMongo == null) { String message = "Did not find block " + id; LOG.error(message); throw new IOException(message); } data = blobMongo.getData(); getStatsCollector().downloaded(id, System.nanoTime() - start, TimeUnit.NANOSECONDS, data.length); cache.put(id, data); } if (blockId.getPos() == 0) { return data; } int len = (int) (data.length - blockId.getPos()); if (len < 0) { return new byte[0]; } byte[] d2 = new byte[len]; System.arraycopy(data, (int) blockId.getPos(), d2, 0, len); return d2; }
@Override protected String computeNext() { if (iter.hasNext()) { BlockId blockId = iter.next(); if (blockId != null) { return StringUtils.convertBytesToHex(blockId.getDigest()); } } return endOfData(); } };
@Override protected String computeNext() { if (iter.hasNext()) { BlockId blockId = iter.next(); if (blockId != null) { return StringUtils.convertBytesToHex(blockId.getDigest()); } } return endOfData(); } };
@Override protected void mark(BlockId blockId) throws Exception { if (minLastModified == 0) { return; } String id = StringUtils.convertBytesToHex(blockId.getDigest()); Bson query = getBlobQuery(id, minLastModified); Bson update = new BasicDBObject("$set", new BasicDBObject(MongoBlob.KEY_LAST_MOD, System.currentTimeMillis())); getBlobCollection().updateOne(query, update); }
@Override protected byte[] readBlockFromBackend(BlockId id) { Integer length = map.get(StringUtils.convertBytesToHex(id.getDigest())); if (length != null) { return new byte[length]; } else { return super.readBlockFromBackend(id); } } }
@Override protected String computeNext() { if (iter.hasNext()) { BlockId blockId = iter.next(); if (blockId != null) { return StringUtils.convertBytesToHex(blockId.getDigest()); } } return endOfData(); } };