@Override public boolean executeOperation(BlobStore store, Object... objs) throws StorageException { if (objs == null || objs.length < 1 || !(objs[0] instanceof TileObject)) { return false; } return store.get((TileObject) objs[0]); } },
public boolean get(TileObject tileObj) throws StorageException { return blobStore.get(tileObj); }
@Override public boolean get(TileObject obj) throws StorageException { // Check if the blobstore has already been configured if (configured.get()) { // Increment the number of current operations // This behavior is used in order to wait // the end of all the operations after setting // the configured parameter to false actualOperations.incrementAndGet(); try { // Get a TileObject return delegate.get(obj); } finally { // Decrement the number of current operations. actualOperations.decrementAndGet(); } } return false; }
@Override public boolean get(TileObject obj) throws StorageException { return readFunctionUnsafe(() -> store(obj.getLayerName()).get(obj)); }
@Test public void getTileDefaultsToDefaultBlobStore() throws Exception { store = create(); LiveStore liveStore = store.blobStores.get(CompositeBlobStore.DEFAULT_STORE_DEFAULT_ID); liveStore.liveInstance = spy(liveStore.liveInstance); when(defaultLayer.getBlobStoreId()).thenReturn(null); TileObject tile = queryTile(0, 0, 0); store.get(tile); verify(liveStore.liveInstance).get(tile); }
@Test public void testEmpty() throws Exception { TileObject fromCache = TileObject.createQueryTileObject( "testLayer", new long[] {0L, 0L, 0L}, "testGridSet", "image/png", null); assertThat(store.get(fromCache), equalTo(false)); // assertThat(fromCache, hasProperty("status", is(Status.MISS))); }
"layer", tile, "grid", "image/png", null); try { fileBlobStore.get(mbtile); } catch (Exception exception) { throw Utils.exception(
protected void assertNoTile( String layerName, long x, long y, int z, String gridSetId, String format, Map<String, String> parameters) throws StorageException { TileObject to = TileObject.createQueryTileObject( layerName, new long[] {x, y, z}, gridSetId, format, parameters); assertThat(store.get(to), describedAs("don't get a tile", is(false))); assertThat(to, hasProperty("blob", nullValue())); assertThat(to, hasProperty("blobSize", is(0))); }
protected void assertTile( String layerName, long x, long y, int z, String gridSetId, String format, Map<String, String> parameters, String content) throws StorageException { TileObject to = TileObject.createQueryTileObject( layerName, new long[] {x, y, z}, gridSetId, format, parameters); assertThat(store.get(to), describedAs("get a tile", is(true))); assertThat( to, hasProperty( "blob", resource(new ByteArrayResource(content.getBytes(StandardCharsets.UTF_8))))); }
public void testTileDelete() throws Exception { fbs = setup(); Map<String, String> parameters = new HashMap<String, String>(); parameters.put("a", "x"); parameters.put("b", "ø"); Resource bytes = new ByteArrayResource("1 2 3 4 5 6 test".getBytes()); long[] xyz = {5L, 6L, 7L}; TileObject to = TileObject.createCompleteTileObject( "test:123123 112", xyz, "EPSG:4326", "image/jpeg", parameters, bytes); fbs.put(to); TileObject to2 = TileObject.createQueryTileObject( "test:123123 112", xyz, "EPSG:4326", "image/jpeg", parameters); fbs.get(to2); try (InputStream is = to2.getBlob().getInputStream(); InputStream is2 = bytes.getInputStream()) { assertTrue(IOUtils.contentEquals(is, is2)); } TileObject to3 = TileObject.createQueryTileObject( "test:123123 112", xyz, "EPSG:4326", "image/jpeg", parameters); fbs.delete(to3); TileObject to4 = TileObject.createQueryTileObject( "test:123123 112", xyz, "EPSG:4326", "image/jpeg", parameters); assertFalse(fbs.get(to4)); }
public void testTile() throws Exception { fbs = setup(); Resource bytes = new ByteArrayResource("1 2 3 4 5 6 test".getBytes()); long[] xyz = {1L, 2L, 3L}; Map<String, String> parameters = new HashMap<String, String>(); parameters.put("a", "x"); parameters.put("b", "ø"); TileObject to = TileObject.createCompleteTileObject( "test:123123 112", xyz, "EPSG:4326", "image/jpeg", parameters, bytes); fbs.put(to); TileObject to2 = TileObject.createQueryTileObject( "test:123123 112", xyz, "EPSG:4326", "image/jpeg", parameters); fbs.get(to2); assertEquals(to.getBlobFormat(), to2.getBlobFormat()); try (InputStream is = to.getBlob().getInputStream(); InputStream is2 = to2.getBlob().getInputStream()) { assertTrue(IOUtils.contentEquals(is, is2)); } }
assertThat(store.get(fromCache2_1), is(false)); store.put(toCache2); assertThat(store.get(fromCache1_1), is(true)); assertThat(fromCache1_1, hasProperty("blobSize", is((int) size1))); assertThat( new ByteArrayResource( "1,2,4,5,6 test".getBytes(StandardCharsets.UTF_8))))); assertThat(store.get(fromCache2_2), is(true)); assertThat(fromCache2_2, hasProperty("blobSize", is((int) size2))); assertThat( "7,8,9,10 test".getBytes(StandardCharsets.UTF_8))))); store.deleteByGridsetId("testLayer", "testGridSet1"); assertThat(store.get(fromCache1_2), is(false)); assertThat(fromCache1_2, hasProperty("blobSize", is(0))); assertThat(store.get(fromCache2_3), is(true)); assertThat(fromCache2_3, hasProperty("blobSize", is((int) size2))); assertThat(
store.put(toCache2); store.deleteByParametersId("testLayer", paramID1); assertThat(store.get(fromCache2_3), is(true)); assertThat(fromCache2_3, hasProperty("blobSize", is((int) size2))); assertThat(
assertThat(store.deleteByGridsetId("testLayer", "testGridSet1"), is(true)); EasyMock.verify(listener); assertThat(store.get(fromCache1_2), is(false)); assertThat(fromCache1_2, hasProperty("blobSize", is(0)));
assertThat(store.get(fromCache), is(true));
assertThat(store.get(fromCache2_1), is(false)); store.put(toCache2); EasyMock.verify(listener); assertThat(store.get(fromCache1_1), is(true)); assertThat(fromCache1_1, hasProperty("blobSize", is((int) size1))); assertThat( new ByteArrayResource( "1,2,4,5,6 test".getBytes(StandardCharsets.UTF_8))))); assertThat(store.get(fromCache2_2), is(true)); assertThat(fromCache2_2, hasProperty("blobSize", is((int) size2))); assertThat( store.deleteByParametersId("testLayer", paramID1); EasyMock.verify(listener); assertThat(store.get(fromCache1_2), is(false)); assertThat(fromCache1_2, hasProperty("blobSize", is(0)));
assertThat(store.get(fromCache2_1), is(false)); assertThat(fromCache2_1, hasProperty("blobSize", is(0))); EasyMock.verify(listener); assertThat(store.get(fromCache1), is(true)); assertThat(fromCache1, hasProperty("blobSize", is((int) size1))); assertThat( new ByteArrayResource( "1,2,4,5,6 test".getBytes(StandardCharsets.UTF_8))))); assertThat(store.get(fromCache2_2), is(true)); assertThat(fromCache2_2, hasProperty("blobSize", is((int) size2))); assertThat(
TileObject.createQueryTileObject( layerName, tos[0].xyz, srs.toString(), mime.getFormat(), parameters); fbs.get(firstTO); try (InputStream is = firstTO.getBlob().getInputStream(); InputStream is2 = bytes.getInputStream(); ) { mime.getFormat(), parameters); fbs.get(lastTO); try (InputStream is = lastTO.getBlob().getInputStream(); InputStream is2 = bytes.getInputStream()) { mime.getFormat(), parameters); fbs.get(midTO); Resource res = midTO.getBlob();
store.delete(remove); EasyMock.verify(listener); assertThat(store.get(fromCache), is(false)); assertThat(fromCache, hasProperty("blobSize", is(0)));
store.put(toCache2); EasyMock.verify(listener); assertThat(store.get(fromCache), is(true)); assertThat(fromCache, hasProperty("blobSize", is((int) size2))); assertThat(