bbotella commented on code in PR #147: URL: https://github.com/apache/cassandra-sidecar/pull/147#discussion_r1850864966
########## server/src/main/java/org/apache/cassandra/sidecar/routes/cdc/ListCDCDirHandler.java: ########## @@ -0,0 +1,145 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.cassandra.sidecar.routes.cdc; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.nio.file.attribute.BasicFileAttributes; +import java.util.Arrays; +import java.util.LinkedList; +import java.util.Set; +import java.util.stream.Collectors; +import org.apache.commons.lang3.tuple.Pair; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import com.google.inject.Inject; +import com.google.inject.Singleton; +import io.netty.handler.codec.http.HttpResponseStatus; +import io.vertx.core.http.HttpServerRequest; +import io.vertx.core.json.Json; +import io.vertx.core.net.SocketAddress; +import io.vertx.ext.web.RoutingContext; +import org.apache.cassandra.sidecar.common.response.ListCDCSegmentResponse; +import org.apache.cassandra.sidecar.concurrent.ExecutorPools; +import org.apache.cassandra.sidecar.config.ServiceConfiguration; +import org.apache.cassandra.sidecar.config.SidecarConfiguration; +import org.apache.cassandra.sidecar.routes.AbstractHandler; +import org.apache.cassandra.sidecar.utils.CDCUtil; +import org.apache.cassandra.sidecar.utils.CassandraInputValidator; +import org.apache.cassandra.sidecar.utils.InstanceMetadataFetcher; + +import static org.apache.cassandra.sidecar.utils.CDCUtil.getIdxFileName; +import static org.apache.cassandra.sidecar.utils.CDCUtil.getLogFilePrefix; +import static org.apache.cassandra.sidecar.utils.CDCUtil.isIndexFile; +import static org.apache.cassandra.sidecar.utils.CDCUtil.parseIndexFile; + +/** + * Provides REST endpoint for listing commit logs in CDC directory. + */ +@Singleton +public class ListCDCDirHandler extends AbstractHandler<Void> +{ + private static final Logger LOGGER = LoggerFactory.getLogger(ListCDCDirHandler.class); + private final ServiceConfiguration config; + + @Inject + public ListCDCDirHandler(InstanceMetadataFetcher metadataFetcher, + SidecarConfiguration config, + ExecutorPools executorPools, + CassandraInputValidator validator) + { + super(metadataFetcher, executorPools, validator); + this.config = config.serviceConfiguration(); + } + + @Override + protected void handleInternal(RoutingContext context, + HttpServerRequest httpRequest, + String host, + SocketAddress remoteAddress, + Void request) + { + String cdcDir = metadataFetcher.instance(host).cdcDir(); + ListCDCSegmentResponse listCDCSegmentResponse = new ListCDCSegmentResponse(config.host(), + config.port(), + new LinkedList<>()); + try + { + addResources(cdcDir, listCDCSegmentResponse); Review Comment: Synced with @frankgh offline about this question. Now I understand that, from the client point of view, it still keeps waiting for the response. It is just the server side deciding to execute it in another resource pool. It makes sense to send the request to the internal executor pool. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: pr-unsubscr...@cassandra.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: pr-unsubscr...@cassandra.apache.org For additional commands, e-mail: pr-h...@cassandra.apache.org