@Override public boolean executeOperation(BlobStore store, Object... objs) throws StorageException { if (objs == null || objs.length < 1 || !(objs[0] instanceof TileObject)) { return false; } store.put((TileObject) objs[0]); return true; } },
public boolean put(TileObject tileObj) throws StorageException { blobStore.put(tileObj); return true; }
@Override public void put(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 { // Put the TileObject delegate.put(obj); } finally { // Decrement the number of current operations. actualOperations.decrementAndGet(); } } }
@Override public void put(TileObject obj) throws StorageException { readActionUnsafe(() -> store(obj.getLayerName()).put(obj)); }
protected void cacheTile( String layerName, long x, long y, int z, String gridSetId, String format, Map<String, String> parameters, String content) throws StorageException { TileObject to = TileObject.createCompleteTileObject( layerName, new long[] {x, y, z}, gridSetId, format, parameters, new ByteArrayResource(content.getBytes(StandardCharsets.UTF_8))); store.put(to); }
tiles[i][1] = tile.y; tiles[i][2] = tile.z; fileBlobStore.put( TileObject.createCompleteTileObject( "layer",
@SuppressWarnings("unchecked") @Test public void testParameterList() throws Exception { Map<String, String> params1 = Collections.singletonMap("testKey", "testValue1"); Map<String, String> params2 = Collections.singletonMap("testKey", "testValue2"); TileObject toCache1 = TileObject.createCompleteTileObject( "testLayer", new long[] {0L, 0L, 0L}, "testGridSet", "image/png", params1, new ByteArrayResource("1,2,4,5,6 test".getBytes(StandardCharsets.UTF_8))); TileObject toCache2 = TileObject.createCompleteTileObject( "testLayer", new long[] {0L, 0L, 0L}, "testGridSet", "image/png", params2, new ByteArrayResource("7,8,9,10 test".getBytes(StandardCharsets.UTF_8))); assertThat(store.getParameters("testLayer"), empty()); store.put(toCache1); assertThat(store.getParameters("testLayer"), containsInAnyOrder(params1)); store.put(toCache2); assertThat(store.getParameters("testLayer"), containsInAnyOrder(params1, params2)); }
@Test public void testParameterIDList() throws Exception { Map<String, String> params1 = Collections.singletonMap("testKey", "testValue1"); Map<String, String> params2 = Collections.singletonMap("testKey", "testValue2"); String params1Id = ParametersUtils.getId(params1); String params2Id = ParametersUtils.getId(params2); TileObject toCache1 = TileObject.createCompleteTileObject( "testLayer", new long[] {0L, 0L, 0L}, "testGridSet", "image/png", params1, new ByteArrayResource("1,2,4,5,6 test".getBytes(StandardCharsets.UTF_8))); TileObject toCache2 = TileObject.createCompleteTileObject( "testLayer", new long[] {0L, 0L, 0L}, "testGridSet", "image/png", params2, new ByteArrayResource("7,8,9,10 test".getBytes(StandardCharsets.UTF_8))); assertThat(store.getParameterIds("testLayer"), empty()); store.put(toCache1); assertThat(store.getParameterIds("testLayer"), containsInAnyOrder(params1Id)); store.put(toCache2); assertThat(store.getParameterIds("testLayer"), containsInAnyOrder(params1Id, params2Id)); }
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)); } }
TileObject.createCompleteTileObject( layerName, xyz, srs.toString(), mime.getFormat(), parameters, bytes); fbs.put(tos[i]);
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)); }
store.put(toCache1); EasyMock.verify(listener); EasyMock.reset(listener);
store.put(toCache);
store.put(toCache); EasyMock.verify(listener); long storedSize = 0;
TileObject.createCompleteTileObject( layerName, xyz, srs.toString(), mime.getFormat(), parameters, bytes); fbs.put(tos[i]);