method2testcases
stringlengths
118
6.63k
### Question: HandlerRemovingChannelPool implements SdkChannelPool { @Override public Future<Void> release(Channel channel) { removePerRequestHandlers(channel); return delegate.release(channel); } HandlerRemovingChannelPool(SdkChannelPool delegate); @Override Future<Channel> acquire(); @Override Future<Channel> acquire...
### Question: OldConnectionReaperHandler extends ChannelDuplexHandler { @Override public void handlerAdded(ChannelHandlerContext ctx) throws Exception { initialize(ctx); super.handlerAdded(ctx); } OldConnectionReaperHandler(int connectionTtlMillis); @Override void handlerAdded(ChannelHandlerContext ctx); @Override void...
### Question: HealthCheckedChannelPool implements SdkChannelPool { @Override public Future<Channel> acquire() { return acquire(eventLoopGroup.next().newPromise()); } HealthCheckedChannelPool(EventLoopGroup eventLoopGroup, NettyConfiguration configuration, ...
### Question: OneTimeReadTimeoutHandler extends ReadTimeoutHandler { @Override public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { ctx.pipeline().remove(this); super.channelRead(ctx, msg); } OneTimeReadTimeoutHandler(Duration timeout); @Override void channelRead(ChannelHandlerContext ctx, ...
### Question: SharedSdkEventLoopGroup { @SdkTestInternalApi static synchronized int referenceCount() { return referenceCount; } private SharedSdkEventLoopGroup(); @SdkInternalApi static synchronized SdkEventLoopGroup get(); }### Answer: @Test public void referenceCountIsInitiallyZero() { assertThat(SharedSdkEventLoop...
### Question: SharedSdkEventLoopGroup { @SdkInternalApi public static synchronized SdkEventLoopGroup get() { if (sharedSdkEventLoopGroup == null) { sharedSdkEventLoopGroup = SdkEventLoopGroup.builder().build(); } referenceCount++; return SdkEventLoopGroup.create(new ReferenceCountingEventLoopGroup(sharedSdkEventLoopGro...
### Question: ProxyTunnelInitHandler extends ChannelDuplexHandler { @Override public void handlerAdded(ChannelHandlerContext ctx) { ChannelPipeline pipeline = ctx.pipeline(); pipeline.addBefore(ctx.name(), null, httpCodecSupplier.get()); HttpRequest connectRequest = connectRequest(); ctx.channel().writeAndFlush(connect...
### Question: ProxyTunnelInitHandler extends ChannelDuplexHandler { @Override public void channelRead(ChannelHandlerContext ctx, Object msg) { if (msg instanceof HttpResponse) { HttpResponse response = (HttpResponse) msg; if (response.status().code() == 200) { ctx.pipeline().remove(this); initPromise.setSuccess(ctx.cha...
### Question: ProxyTunnelInitHandler extends ChannelDuplexHandler { @Override public void handlerRemoved(ChannelHandlerContext ctx) { if (ctx.pipeline().get(HttpClientCodec.class) != null) { ctx.pipeline().remove(HttpClientCodec.class); } } ProxyTunnelInitHandler(ChannelPool sourcePool, URI remoteHost, Promise<Channel>...
### Question: BetterFixedChannelPool implements SdkChannelPool { public CompletableFuture<Void> collectChannelPoolMetrics(MetricCollector metrics) { CompletableFuture<Void> delegateMetricResult = delegateChannelPool.collectChannelPoolMetrics(metrics); CompletableFuture<Void> result = new CompletableFuture<>(); doInEven...
### Question: NettyUtils { public static <T> AttributeKey<T> getOrCreateAttributeKey(String attr) { if (AttributeKey.exists(attr)) { return AttributeKey.valueOf(attr); } return AttributeKey.newInstance(attr); } private NettyUtils(); static BiConsumer<SuccessT, ? super Throwable> promiseNotifyingBiConsumer( Fun...
### Question: ChannelUtils { public static <T> Optional<T> getAttribute(Channel channel, AttributeKey<T> key) { return Optional.ofNullable(channel.attr(key)) .map(Attribute::get); } private ChannelUtils(); @SafeVarargs static void removeIfExists(ChannelPipeline pipeline, Class<? extends ChannelHandler>... handlers); s...
### Question: ChannelUtils { @SafeVarargs public static void removeIfExists(ChannelPipeline pipeline, Class<? extends ChannelHandler>... handlers) { for (Class<? extends ChannelHandler> handler : handlers) { if (pipeline.get(handler) != null) { try { pipeline.remove(handler); } catch (NoSuchElementException exception) ...
### Question: SocketChannelResolver { @SuppressWarnings("unchecked") public static ChannelFactory<? extends Channel> resolveSocketChannelFactory(EventLoopGroup eventLoopGroup) { if (eventLoopGroup instanceof DelegatingEventLoopGroup) { return resolveSocketChannelFactory(((DelegatingEventLoopGroup) eventLoopGroup).getDe...
### Question: ExceptionHandlingUtils { public static void tryCatch(Runnable executable, Consumer<Throwable> errorNotifier) { try { executable.run(); } catch (Throwable throwable) { errorNotifier.accept(throwable); } } private ExceptionHandlingUtils(); static void tryCatch(Runnable executable, Consumer<Throwable> error...
### Question: ExceptionHandlingUtils { public static <T> T tryCatchFinally(Callable<T> executable, Consumer<Throwable> errorNotifier, Runnable cleanupExecutable) { try { return executable.call(); } catch (Throwable throwable) { errorNotifier.accept(throwable); } finally { cleanupExecutable.run(); } return null; } priva...
### Question: Http2GoAwayEventListener extends Http2ConnectionAdapter { @Override public void onGoAwayReceived(int lastStreamId, long errorCode, ByteBuf debugData) { Http2MultiplexedChannelPool channelPool = parentChannel.attr(ChannelAttributeKey.HTTP2_MULTIPLEXED_CHANNEL_POOL).get(); GoAwayException exception = new Go...
### Question: Http2MultiplexedChannelPool implements SdkChannelPool { @Override public Future<Channel> acquire() { return acquire(eventLoopGroup.next().newPromise()); } Http2MultiplexedChannelPool(ChannelPool connectionPool, EventLoopGroup eventLoopGroup, ...
### Question: Http2PingHandler extends SimpleChannelInboundHandler<Http2PingFrame> { @Override public void channelInactive(ChannelHandlerContext ctx) { stop(); ctx.fireChannelInactive(); } Http2PingHandler(int pingTimeoutMillis); @Override void handlerAdded(ChannelHandlerContext ctx); @Override void handlerRemoved(Chan...
### Question: Http2SettingsFrameHandler extends SimpleChannelInboundHandler<Http2SettingsFrame> { @Override protected void channelRead0(ChannelHandlerContext ctx, Http2SettingsFrame msg) { Long serverMaxStreams = Optional.ofNullable(msg.settings().maxConcurrentStreams()).orElse(Long.MAX_VALUE); channel.attr(MAX_CONCURR...
### Question: Http2SettingsFrameHandler extends SimpleChannelInboundHandler<Http2SettingsFrame> { @Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { channelError(cause, channel, ctx); } Http2SettingsFrameHandler(Channel channel, long clientMaxStreams, AtomicReference<ChannelPool> channe...
### Question: Http2SettingsFrameHandler extends SimpleChannelInboundHandler<Http2SettingsFrame> { @Override public void channelUnregistered(ChannelHandlerContext ctx) { if (!channel.attr(PROTOCOL_FUTURE).get().isDone()) { channelError(new IOException("The channel was closed before the protocol could be determined."), c...
### Question: HttpToHttp2OutboundAdapter extends ChannelOutboundHandlerAdapter { @Override public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) { if (!(msg instanceof HttpMessage || msg instanceof HttpContent)) { ctx.write(msg, promise); return; } boolean release = true; SimpleChannelPromise...
### Question: MultiplexedChannelRecord { boolean acquireStream(Promise<Channel> promise) { if (claimStream()) { releaseClaimOnFailure(promise); acquireClaimedStream(promise); return true; } return false; } MultiplexedChannelRecord(Channel connection, long maxConcurrencyPerConnection, Duration allowedIdleConnectionTime)...
### Question: HttpOrHttp2ChannelPool implements SdkChannelPool { @Override public void close() { doInEventLoop(eventLoop, this::close0); } HttpOrHttp2ChannelPool(ChannelPool delegatePool, EventLoopGroup group, int maxConcurrency, ...
### Question: Http2StreamExceptionHandler extends ChannelInboundHandlerAdapter { @Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { if (isIoError(cause) && ctx.channel().parent() != null) { Channel parent = ctx.channel().parent(); log.debug(() -> "An I/O error occurred on an Http2 strea...
### Question: LastHttpContentHandler extends ChannelInboundHandlerAdapter { @Override public void channelRead(ChannelHandlerContext ctx, Object msg) { if (msg instanceof LastHttpContent) { logger.debug(() -> "Received LastHttpContent " + ctx.channel()); ctx.channel().attr(LAST_HTTP_CONTENT_RECEIVED_KEY).set(true); } ct...
### Question: HonorCloseOnReleaseChannelPool implements ChannelPool { @Override public Future<Void> release(Channel channel) { return release(channel, channel.eventLoop().newPromise()); } HonorCloseOnReleaseChannelPool(ChannelPool delegatePool); @Override Future<Channel> acquire(); @Override Future<Channel> acquire(Pro...
### Question: ChannelPipelineInitializer extends AbstractChannelPoolHandler { @Override public void channelCreated(Channel ch) { ch.attr(PROTOCOL_FUTURE).set(new CompletableFuture<>()); ChannelPipeline pipeline = ch.pipeline(); if (sslCtx != null) { SslHandler sslHandler = sslCtx.newHandler(ch.alloc(), poolKey.getHost(...
### Question: StaticKeyManagerFactorySpi extends KeyManagerFactorySpi { @Override protected KeyManager[] engineGetKeyManagers() { return keyManagers; } StaticKeyManagerFactorySpi(KeyManager[] keyManagers); }### Answer: @Test public void constructorCreatesArrayCopy() { KeyManager[] keyManagers = IntStream.range(0,8) ....
### Question: StaticKeyManagerFactorySpi extends KeyManagerFactorySpi { @Override protected void engineInit(KeyStore ks, char[] password) { throw new UnsupportedOperationException("engineInit not supported by this KeyManagerFactory"); } StaticKeyManagerFactorySpi(KeyManager[] keyManagers); }### Answer: @Test(expected...
### Question: LastHttpContentSwallower extends SimpleChannelInboundHandler<HttpObject> { @Override protected void channelRead0(ChannelHandlerContext ctx, HttpObject obj) { if (obj instanceof LastHttpContent) { ctx.read(); } else { ctx.fireChannelRead(obj); } ctx.pipeline().remove(this); } private LastHttpContentSwallo...
### Question: S3BucketResource implements S3Resource, ToCopyableBuilder<S3BucketResource.Builder, S3BucketResource> { @Override public Builder toBuilder() { return builder() .partition(partition) .region(region) .accountId(accountId) .bucketName(bucketName); } private S3BucketResource(Builder b); static Builder builde...
### Question: BootstrapProvider { public Bootstrap createBootstrap(String host, int port) { Bootstrap bootstrap = new Bootstrap() .group(sdkEventLoopGroup.eventLoopGroup()) .channelFactory(sdkEventLoopGroup.channelFactory()) .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, nettyConfiguration.connectTimeoutMillis()) .remot...
### Question: StaticKeyManagerFactory extends KeyManagerFactory { public static StaticKeyManagerFactory create(KeyManager[] keyManagers) { return new StaticKeyManagerFactory(keyManagers); } private StaticKeyManagerFactory(KeyManager[] keyManagers); static StaticKeyManagerFactory create(KeyManager[] keyManagers); }###...
### Question: SdkChannelOptions { public Map<ChannelOption, Object> channelOptions() { return Collections.unmodifiableMap(options); } SdkChannelOptions(); SdkChannelOptions putOption(ChannelOption<T> channelOption, T channelOptionValue); Map<ChannelOption, Object> channelOptions(); }### Answer: @Test public void defau...
### Question: SdkEventLoopGroup { public static SdkEventLoopGroup create(EventLoopGroup eventLoopGroup, ChannelFactory<? extends Channel> channelFactory) { return new SdkEventLoopGroup(eventLoopGroup, channelFactory); } SdkEventLoopGroup(EventLoopGroup eventLoopGroup, ChannelFactory<? extends Channel> channelFactory); ...
### Question: ProxyConfiguration implements ToCopyableBuilder<ProxyConfiguration.Builder, ProxyConfiguration> { @Override public Builder toBuilder() { return new BuilderImpl(this); } private ProxyConfiguration(BuilderImpl builder); String scheme(); String host(); int port(); String username(); String password(); @Over...
### Question: S3BucketResource implements S3Resource, ToCopyableBuilder<S3BucketResource.Builder, S3BucketResource> { public static Builder builder() { return new Builder(); } private S3BucketResource(Builder b); static Builder builder(); @Override String type(); @Override Optional<String> partition(); @Override Optio...
### Question: ApacheHttpClient implements SdkHttpClient { public static Builder builder() { return new DefaultBuilder(); } @SdkTestInternalApi ApacheHttpClient(ConnectionManagerAwareHttpClient httpClient, ApacheHttpRequestConfig requestConfig, AttributeMap resolvedOptions); pr...
### Question: IdleConnectionReaper { public synchronized boolean registerConnectionManager(HttpClientConnectionManager manager, long maxIdleTime) { boolean notPreviouslyRegistered = connectionManagers.put(manager, maxIdleTime) == null; setupExecutorIfNecessary(); return notPreviouslyRegistered; } private IdleConnectio...
### Question: SdkTlsSocketFactory extends SSLConnectionSocketFactory { @Override protected final void prepareSocket(final SSLSocket socket) { String[] supported = socket.getSupportedProtocols(); String[] enabled = socket.getEnabledProtocols(); log.debug(() -> String.format("socket.getSupportedProtocols(): %s, socket.ge...
### Question: ClientConnectionManagerFactory { public static HttpClientConnectionManager wrap(HttpClientConnectionManager orig) { if (orig instanceof Wrapped) { throw new IllegalArgumentException(); } Class<?>[] interfaces; if (orig instanceof ConnPoolControl) { interfaces = new Class<?>[]{ HttpClientConnectionManager....
### Question: ProfileUseArnRegionProvider implements UseArnRegionProvider { @Override public Optional<Boolean> resolveUseArnRegion() { return profileFile.get() .profile(profileName) .map(p -> p.properties().get(AWS_USE_ARN_REGION)) .map(StringUtils::safeStringToBoolean); } private ProfileUseArnRegionProvider(Supplier<...
### Question: ApacheHttpRequestFactory { public HttpRequestBase create(final HttpExecuteRequest request, final ApacheHttpRequestConfig requestConfig) { HttpRequestBase base = createApacheRequest(request, sanitizeUri(request.httpRequest())); addHeadersToRequest(base, request.httpRequest()); addRequestConfig(base, reques...
### Question: ProfileUseArnRegionProvider implements UseArnRegionProvider { public static ProfileUseArnRegionProvider create() { return new ProfileUseArnRegionProvider(ProfileFile::defaultProfileFile, ProfileFileSystemSetting.AWS_PROFILE.getStringValueOrThrow()); } private ProfileUseArnRegionProvider(Supplier<ProfileF...
### Question: FormService { public ResponseEntity<?> handleKillThreadPost(Map<String, String> form, TileLayer tl) { String id = form.get("thread_id"); StringBuilder doc = new StringBuilder(); makeHeader(doc); if (seeder.terminateGWCTask(Long.parseLong(id))) { doc.append("<ul><li>Requested to terminate task " + id + ".<...
### Question: FileManager { File getFile(TileObject tile) { if (tile.getParametersId() == null && tile.getParameters() != null) { tile.setParametersId(ParametersUtils.getId(tile.getParameters())); } return getFile( tile.getParametersId(), tile.getXYZ(), tile.getLayerName(), tile.getGridSetId(), tile.getBlobFormat(), ti...
### Question: MbtilesBlobStore extends SqliteBlobStore { @Override public boolean deleteByGridsetId(String layerName, String gridSetId) throws StorageException { boolean deleted = deleteFiles(fileManager.getFiles(layerName, gridSetId)); listeners.sendGridSubsetDeleted(layerName, gridSetId); return deleted; } MbtilesBlo...
### Question: MbtilesBlobStore extends SqliteBlobStore { @Override public boolean layerExists(String layerName) { return !fileManager.getFiles(layerName).isEmpty(); } MbtilesBlobStore(MbtilesInfo configuration); MbtilesBlobStore(MbtilesInfo configuration, SqliteConnectionManager connectionManager); @Override void put(...
### Question: MbtilesBlobStore extends SqliteBlobStore { @Override public boolean rename(String oldLayerName, String newLayerName) throws StorageException { List<File> files = fileManager.getFiles(oldLayerName); if (files.isEmpty()) { return false; } for (File currentFile : files) { String normalizedLayerName = FileMan...
### Question: SwiftTile { public Payload getPayload() { Payload payload = new ByteArrayPayload(data); payload.setContentMetadata(getMetadata()); return payload; } SwiftTile(final TileObject tile); Payload getPayload(); void setExisted(long oldSize); void notifyListeners(BlobStoreListenerList listeners); String toString...
### Question: SwiftTile { public void notifyListeners(BlobStoreListenerList listeners) { boolean hasListeners = !listeners.isEmpty(); if (hasListeners && existed) { listeners.sendTileUpdated( layerName, gridSetId, blobFormat, parametersId, x, y, z, outputLength, oldSize); } else if (hasListeners) { listeners.sendTileSt...
### Question: SwiftBlobStore implements BlobStore { @Override public void destroy() { try { this.shutDown = true; this.swiftApi.close(); this.blobStoreContext.close(); } catch (IOException e) { log.error("Error closing connection."); log.error(e); } } SwiftBlobStore(SwiftBlobStoreInfo config, TileLayerDispatcher layers...
### Question: SwiftBlobStore implements BlobStore { @Override public void addListener(BlobStoreListener listener) { listeners.addListener(listener); } SwiftBlobStore(SwiftBlobStoreInfo config, TileLayerDispatcher layers); @Override void destroy(); @Override void addListener(BlobStoreListener listener); @Override boolea...
### Question: SwiftBlobStore implements BlobStore { @Override public boolean removeListener(BlobStoreListener listener) { return listeners.removeListener(listener); } SwiftBlobStore(SwiftBlobStoreInfo config, TileLayerDispatcher layers); @Override void destroy(); @Override void addListener(BlobStoreListener listener); ...
### Question: SwiftBlobStore implements BlobStore { @Override public void put(TileObject obj) throws StorageException { try { final SwiftTile tile = new SwiftTile(obj); final String key = keyBuilder.forTile(obj); executor.execute(new SwiftUploadTask(key, tile, listeners, objectApi)); log.debug("Added request to upload ...
### Question: SwiftBlobStore implements BlobStore { @Override public boolean get(TileObject obj) throws StorageException { final String key = keyBuilder.forTile(obj); SwiftObject object = this.objectApi.get(key); if (object == null) { return false; } try (Payload in = object.getPayload()) { try (InputStream inStream = ...
### Question: SwiftBlobStore implements BlobStore { @Override public boolean deleteByGridsetId(final String layerName, final String gridSetId) { checkNotNull(layerName, "layerName"); checkNotNull(gridSetId, "gridSetId"); final String gridsetPrefix = keyBuilder.forGridset(layerName, gridSetId); boolean deletedSuccessful...
### Question: SwiftBlobStore implements BlobStore { @Override public boolean rename(String oldLayerName, String newLayerName) { log.debug("No need to rename layers, SwiftBlobStore uses layer id as key root"); if (objectApi.get(oldLayerName) != null) { listeners.sendLayerRenamed(oldLayerName, newLayerName); } return tru...
### Question: SwiftBlobStore implements BlobStore { @Override public void clear() { throw new UnsupportedOperationException("clear() should not be called"); } SwiftBlobStore(SwiftBlobStoreInfo config, TileLayerDispatcher layers); @Override void destroy(); @Override void addListener(BlobStoreListener listener); @Overrid...
### Question: SwiftBlobStore implements BlobStore { @Nullable @Override public String getLayerMetadata(String layerName, String key) { SwiftObject layer = this.objectApi.get(layerName); if (layer == null) { return null; } if (layer.getMetadata() == null) { return null; } else { return layer.getMetadata().get(key); } } ...
### Question: SwiftBlobStore implements BlobStore { @Override public void putLayerMetadata(String layerName, String key, String value) { SwiftObject layer = this.objectApi.get(layerName); Map<String, String> metaData; if (layer == null) { return; } metaData = layer.getMetadata(); if (metaData == null) { metaData = new ...
### Question: SwiftBlobStore implements BlobStore { @Override public boolean layerExists(String layerName) { return this.objectApi.get(layerName) != null; } SwiftBlobStore(SwiftBlobStoreInfo config, TileLayerDispatcher layers); @Override void destroy(); @Override void addListener(BlobStoreListener listener); @Override ...
### Question: SwiftBlobStore implements BlobStore { @Override public Map<String, Optional<Map<String, String>>> getParametersMapping(String layerName) { String prefix = keyBuilder.parametersMetadataPrefix(layerName); ListContainerOptions options = new ListContainerOptions(); options.prefix(prefix); Map<String, Optional...
### Question: SwiftBlobStore implements BlobStore { @Override public boolean deleteByParametersId(String layerName, String parametersId) { checkNotNull(layerName, "layerName"); checkNotNull(parametersId, "parametersId"); boolean deletionSuccessful = keyBuilder .forParameters(layerName, parametersId) .stream() .map(path...
### Question: S3BlobStoreConfigProvider implements XMLConfigurationProvider { @Override public XStream getConfiguredXStream(XStream xs) { xs.alias("S3BlobStore", S3BlobStoreInfo.class); xs.registerLocalConverter( S3BlobStoreInfo.class, "maxConnections", EnvironmentNullableIntConverter); xs.registerLocalConverter( S3Blo...
### Question: WMSTileFuser { protected void writeResponse(HttpServletResponse response, RuntimeStats stats) throws IOException, OutsideCoverageException, GeoWebCacheException, Exception { determineSourceResolution(); determineCanvasLayout(); createCanvas(); renderCanvas(); scaleRaster(); @SuppressWarnings("PMD.CloseRes...
### Question: JDBCQuotaStore implements QuotaStore { public void renameLayer(final String oldLayerName, final String newLayerName) throws InterruptedException { tt.execute( new TransactionCallbackWithoutResult() { @Override protected void doInTransactionWithoutResult(TransactionStatus status) { String sql = dialect.get...
### Question: JDBCQuotaStore implements QuotaStore { public void deleteLayer(final String layerName) { tt.execute( new TransactionCallbackWithoutResult() { @Override protected void doInTransactionWithoutResult(TransactionStatus status) { deleteLayerInternal(layerName); } }); } JDBCQuotaStore(DefaultStorageFinder finder...
### Question: JDBCQuotaStore implements QuotaStore { public TileSet getTileSetById(String tileSetId) throws InterruptedException { TileSet result = getTileSetByIdInternal(tileSetId); if (result == null) { throw new IllegalArgumentException("Could not find a tile set with id: " + tileSetId); } return result; } JDBCQuota...
### Question: JDBCQuotaStore implements QuotaStore { public Quota getUsedQuotaByLayerName(String layerName) { String sql = dialect.getUsedQuotaByLayerName(schema, "layerName"); return nonNullQuota( jt.queryForOptionalObject( sql, new DiskQuotaMapper(), Collections.singletonMap("layerName", layerName))); } JDBCQuotaStor...
### Question: JDBCQuotaStore implements QuotaStore { public Quota getUsedQuotaByTileSetId(String tileSetId) { return nonNullQuota(getUsedQuotaByTileSetIdInternal(tileSetId)); } JDBCQuotaStore(DefaultStorageFinder finder, TilePageCalculator tilePageCalculator); SQLDialect getDialect(); void setDialect(SQLDialect dialect...
### Question: AzureBlobStoreConfigProvider implements XMLConfigurationProvider { @Override public XStream getConfiguredXStream(XStream xs) { Class<AzureBlobStoreInfo> clazz = AzureBlobStoreInfo.class; xs.alias("AzureBlobStore", clazz); xs.aliasField("id", clazz, "name"); return xs; } @Override XStream getConfiguredXSt...
### Question: JDBCQuotaStore implements QuotaStore { public Quota getGloballyUsedQuota() throws InterruptedException { return nonNullQuota(getUsedQuotaByTileSetIdInternal(GLOBAL_QUOTA_NAME)); } JDBCQuotaStore(DefaultStorageFinder finder, TilePageCalculator tilePageCalculator); SQLDialect getDialect(); void setDialect(S...
### Question: JDBCQuotaStore implements QuotaStore { public PageStats setTruncated(final TilePage page) throws InterruptedException { return (PageStats) tt.execute( new TransactionCallback<Object>() { public Object doInTransaction(TransactionStatus status) { if (log.isDebugEnabled()) { log.info("Truncating page " + pag...
### Question: JDBCQuotaStore implements QuotaStore { public TilePage getLeastFrequentlyUsedPage(Set<String> layerNames) throws InterruptedException { return getSinglePage(layerNames, true); } JDBCQuotaStore(DefaultStorageFinder finder, TilePageCalculator tilePageCalculator); SQLDialect getDialect(); void setDialect(SQL...
### Question: JDBCQuotaStore implements QuotaStore { public TilePage getLeastRecentlyUsedPage(Set<String> layerNames) throws InterruptedException { return getSinglePage(layerNames, false); } JDBCQuotaStore(DefaultStorageFinder finder, TilePageCalculator tilePageCalculator); SQLDialect getDialect(); void setDialect(SQLD...
### Question: JDBCQuotaStore implements QuotaStore { public long[][] getTilesForPage(TilePage page) throws InterruptedException { TileSet tileSet = getTileSetById(page.getTileSetId()); long[][] gridCoverage = calculator.toGridCoverage(tileSet, page); return gridCoverage; } JDBCQuotaStore(DefaultStorageFinder finder, Ti...
### Question: FileUtils { public static boolean renameFile(File src, File dst) { boolean renamed = false; boolean win = System.getProperty("os.name").startsWith("Windows"); if (win && dst.exists()) { if (!dst.delete()) { throw new RuntimeException("Could not delete: " + dst.getPath()); } } Path srcPath = Paths.get(src....
### Question: ImageMime extends MimeType { public ImageWriter getImageWriter(RenderedImage image) { Iterator<ImageWriter> it = javax.imageio.ImageIO.getImageWritersByFormatName(internalName); ImageWriter writer = it.next(); if (this.internalName.equals(ImageMime.png.internalName) || this.internalName.equals(ImageMime.p...
### Question: RegexParameterFilter extends CaseNormalizingParameterFilter { @Override public void setNormalize(CaseNormalizer normalize) { super.setNormalize(normalize); this.pat = compile(this.regex, getNormalize().getCase()); } RegexParameterFilter(); synchronized Matcher getMatcher(String value); @Override String ap...
### Question: ParametersUtils { public static String getKvp(Map<String, String> parameters) { return parameters .entrySet() .stream() .sorted(derivedComparator(Entry::getKey)) .map(e -> String.join("=", encUTF8(e.getKey()), encUTF8(e.getValue()))) .collect(Collectors.joining("&")); } static String getLegacyParametersK...
### Question: ParametersUtils { public static Map<String, String> getMap(String kvp) { return Arrays.stream(kvp.split("&")) .filter(((Predicate<String>) String::isEmpty).negate()) .map(pair -> pair.split("=", 2)) .collect(Collectors.toMap(p -> decUTF8(p[0]), p -> decUTF8(p[1]))); } static String getLegacyParametersKvp...
### Question: LegendInfoBuilder { public LegendInfoBuilder withUrl(String url) { this.url = url; return this; } LegendInfoBuilder withLayerName(String layerName); LegendInfoBuilder withLayerUrl(String layerUrl); LegendInfoBuilder withDefaultWidth(Integer defaultWidth); LegendInfoBuilder withDefaultHeight(Integer defau...
### Question: LegendInfoBuilder { public LegendInfoBuilder withCompleteUrl(String completeUrl) { this.completeUrl = completeUrl; return this; } LegendInfoBuilder withLayerName(String layerName); LegendInfoBuilder withLayerUrl(String layerUrl); LegendInfoBuilder withDefaultWidth(Integer defaultWidth); LegendInfoBuilder...
### Question: ListenerCollection { public synchronized void safeForEach(HandlerMethod<Listener> method) throws GeoWebCacheException, IOException { LinkedList<Exception> exceptions = listeners .stream() .map( l -> { try { method.callOn(l); return Optional.<Exception>empty(); } catch (Exception ex) { return Optional.of(e...
### Question: ListenerCollection { public synchronized void remove(Listener listener) { listeners.remove(listener); } synchronized void add(Listener listener); synchronized void remove(Listener listener); synchronized void safeForEach(HandlerMethod<Listener> method); }### Answer: @Test public void testRemove() throws...
### Question: XMLConfiguration implements TileLayerConfiguration, InitializingBean, DefaultingConfiguration, ServerConfiguration, BlobStoreConfiguration, GridSetConfiguration { public boolean canSave(TileLayer tl) { if (tl.isTransientLayer(...
### Question: XMLConfiguration implements TileLayerConfiguration, InitializingBean, DefaultingConfiguration, ServerConfiguration, BlobStoreConfiguration, GridSetConfiguration { @Override public List<BlobStoreInfo> getBlobStores() { return C...
### Question: CompositeBlobStore implements BlobStore, BlobStoreConfigurationListener { public static StoreSuitabilityCheck getStoreSuitabilityCheck() { return storeSuitability.get(); } CompositeBlobStore( TileLayerDispatcher layers, DefaultStorageFinder defaultStorageFinder, ServerC...
### Question: GeoWebCacheExtensions implements ApplicationContextAware, ApplicationListener { @SuppressFBWarnings("ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD") public void setApplicationContext(ApplicationContext context) throws BeansException { GeoWebCacheExtensions.context = context; extensionsCache.clear(); } @Suppres...
### Question: GeoWebCacheExtensions implements ApplicationContextAware, ApplicationListener { @SuppressWarnings("unchecked") public static final <T> List<T> extensions( Class<T> extensionPoint, ApplicationContext context) { String[] names; if (GeoWebCacheExtensions.context == context) { names = extensionsCache.get(exte...
### Question: GeoWebCacheExtensions implements ApplicationContextAware, ApplicationListener { public static String getProperty(String propertyName) { return getProperty(propertyName, context); } @SuppressFBWarnings("ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD") void setApplicationContext(ApplicationContext context); @Supp...
### Question: GridSetBroker implements ConfigurationAggregator<GridSetConfiguration>, ApplicationContextAware, InitializingBean { public @Nullable GridSet get(String gridSetId) { return getGridSet(gridSetId).orElse(null); } GridSetBroker(); GridSetBroker(List<GridSetConfiguration> confi...
### Question: GridSetBroker implements ConfigurationAggregator<GridSetConfiguration>, ApplicationContextAware, InitializingBean { protected Optional<GridSet> getGridSet(String name) { for (GridSetConfiguration c : getConfigurations()) { Optional<GridSet> gridSet = c.getGridSet(name); if ...
### Question: GridSetBroker implements ConfigurationAggregator<GridSetConfiguration>, ApplicationContextAware, InitializingBean { public void addGridSet(GridSet gridSet) { log.debug("Adding " + gridSet.getName()); getConfigurations() .stream() .filter(c -> c.canSave(gridSet)) .findFirst(...
### Question: GridSetBroker implements ConfigurationAggregator<GridSetConfiguration>, ApplicationContextAware, InitializingBean { public synchronized void removeGridSet(final String gridSetName) { getConfigurations() .stream() .filter(c -> c.getGridSet(gridSetName).isPresent()) .forEach(...
### Question: GridSubset { public long[][] getCoverageIntersections(BoundingBox reqBounds) { final int zoomStart = getZoomStart(); final int zoomStop = getZoomStop(); long[][] ret = new long[1 + zoomStop - zoomStart][5]; for (int level = zoomStart; level <= zoomStop; level++) { ret[level - zoomStart] = getCoverageInter...
### Question: GridSet implements Info { public BoundingBox boundsFromIndex(long[] tileIndex) { final int tileZ = (int) tileIndex[2]; Grid grid = getGrid(tileZ); final long tileX = tileIndex[0]; final long tileY; if (yBaseToggle) { tileY = tileIndex[1] - grid.getNumTilesHigh(); } else { tileY = tileIndex[1]; } double wi...