public void setBlob(Resource payload) { stObj.setBlob(payload); }
@Override public boolean get(TileObject stObj) throws StorageException { stObj.setBlob(new FileResource(imageTile)); stObj.setCreated((new Date()).getTime()); stObj.setBlobSize(1000); return true; } });
@Override public boolean get(TileObject obj) throws StorageException { final String key = keyBuilder.forTile(obj); final S3Object object = s3Ops.getObject(key); if (object == null) { return false; } try (S3ObjectInputStream in = object.getObjectContent()) { byte[] bytes = ByteStreams.toByteArray(in); obj.setBlobSize(bytes.length); obj.setBlob(new ByteArrayResource(bytes)); obj.setCreated(object.getObjectMetadata().getLastModified().getTime()); } catch (IOException e) { throw new StorageException("Error getting " + key, e); } return true; }
public boolean getTransient(TileObject tile) { String key = TransientCache.computeTransientKey(tile); Resource resource; synchronized (transientCache) { resource = transientCache.get(key); } tile.setBlob(resource); return resource != null; }
@Override public boolean get(TileObject obj) throws StorageException { final String key = keyBuilder.forTile(obj); final S3Object object = s3Ops.getObject(key); if (object == null) { return false; } try (S3ObjectInputStream in = object.getObjectContent()) { byte[] bytes = ByteStreams.toByteArray(in); obj.setBlobSize(bytes.length); obj.setBlob(new ByteArrayResource(bytes)); obj.setCreated(object.getObjectMetadata().getLastModified().getTime()); } catch (IOException e) { throw new StorageException("Error getting " + key, e); } return true; }
public Boolean answer() throws Throwable { TileObject tile = (TileObject) EasyMock.getCurrentArguments()[0]; if (puts.contains(TransientCache.computeTransientKey(tile))) { tile.setBlob(new ByteArrayResource(fakeWMSResponse)); storageGetCounter.incrementAndGet(); return true; } else { return false; } } })
/** * Set the blob property of a TileObject. * * @param stObj the tile to load. Its setBlob() method will be called. * @return true if successful, false otherwise */ public boolean get(TileObject stObj) throws StorageException { File fh = getFileHandleTile(stObj, false); if (!fh.exists()) { stObj.setStatus(Status.MISS); return false; } else { Resource resource = readFile(fh); stObj.setBlob(resource); stObj.setCreated(resource.getLastModified()); stObj.setBlobSize((int) resource.getSize()); return true; } }
private TileObject put( long x, long y, int z, String layerName, String gridset, String formatExtension, Map<String, String> parameters) throws StorageException { byte[] bytes = new byte[256]; Arrays.fill(bytes, (byte) 0xaf); TileObject tile = queryTile(layerName, gridset, formatExtension, x, y, z, parameters); tile.setBlob(new ByteArrayResource(bytes)); blobStore.put(tile); return tile; }
obj.setBlob(resource); obj.setCreated(resource.getLastModified()); obj.setBlobSize((int) resource.getSize());
public Boolean answer() throws Throwable { TileObject tile = (TileObject) EasyMock.getCurrentArguments()[0]; String key = TransientCache.computeTransientKey(tile); Resource resource; synchronized (transientCache) { resource = transientCache.get(key); } if (resource != null) { cacheHits.incrementAndGet(); } else { cacheMisses.incrementAndGet(); } tile.setBlob(resource); return resource != null; } })
final File imageTile = new File(getClass().getResource("/image.png").toURI()); stObj.setBlob(new FileResource(imageTile)); stObj.setCreated((new Date()).getTime()); stObj.setBlobSize(1000);
bytes = gtTile.getData(); tile.setBlob(Utils.byteArrayToResource(bytes));
bytes = gtTile.getData(); tile.setBlob(Utils.byteArrayToResource(bytes));
Arrays.fill(bytes, (byte) 0xaf); TileObject tile = queryTile(20, 30, 12); tile.setBlob(new ByteArrayResource(bytes));
@Test public void testPutGetBlobIsNotByteArrayResource() throws MimeException, IOException { File tileFile = File.createTempFile("tile", ".png"); Files.write(new byte[1024], tileFile); Resource blob = new FileResource(tileFile); TileObject tile = queryTile(20, 30, 12); tile.setBlob(blob); blobStore.put(tile); TileObject queryTile = queryTile(20, 30, 12); boolean found = blobStore.get(queryTile); assertTrue(found); Resource resource = queryTile.getBlob(); assertNotNull(resource); assertEquals(1024, resource.getSize()); }
@Test public void testDeleteLayer() throws Exception { byte[] bytes = new byte[1024]; Arrays.fill(bytes, (byte) 0xaf); TileObject tile = queryTile(20, 30, 12); tile.setBlob(new ByteArrayResource(bytes)); blobStore.put(tile); tile.getXYZ()[0] = 21; blobStore.put(tile); tile.getXYZ()[0] = 22; blobStore.put(tile); BlobStoreListener listener = mock(BlobStoreListener.class); blobStore.addListener(listener); String layerName = tile.getLayerName(); blobStore.delete(layerName); blobStore.destroy(); Thread.sleep(10000); // blobStore.delete(layerName); // verify(listener, Mockito.atLeastOnce()).layerDeleted(eq(layerName)); }
@Test public void testPutGet() throws MimeException, StorageException { byte[] bytes = new byte[1024]; Arrays.fill(bytes, (byte) 0xaf); TileObject tile = queryTile(20, 30, 12); tile.setBlob(new ByteArrayResource(bytes)); blobStore.put(tile); TileObject queryTile = queryTile(20, 30, 12); boolean found = blobStore.get(queryTile); assertTrue(found); Resource resource = queryTile.getBlob(); assertNotNull(resource); assertEquals(bytes.length, resource.getSize()); }