nvharikrishna commented on code in PR #309: URL: https://github.com/apache/cassandra-sidecar/pull/309#discussion_r2813455683
########## client-common/src/main/java/org/apache/cassandra/sidecar/common/request/LiveMigrationFileDigestRequest.java: ########## @@ -0,0 +1,76 @@ +/* + * 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.common.request; + +import java.util.Objects; + +import io.netty.handler.codec.http.HttpMethod; +import org.apache.cassandra.sidecar.common.response.DigestResponse; + +/** + * Represents a request to retrieve file digest for validation during live migration. + * Supports configurable digest algorithms and optional seed values for verification. + */ +public class LiveMigrationFileDigestRequest extends JsonRequest<DigestResponse> +{ + public static final String DIGEST_ALGORITHM_PARAM = "digestAlgorithm"; + public static final String SEED_PARAM = "seed"; + + /** + * Private constructor for internal use by the factory method + * + * @param fullRequestURI the complete URI with query parameters + */ + private LiveMigrationFileDigestRequest(String fullRequestURI) + { + super(fullRequestURI); + } + + /** + * Creates a live migration file digest request with validation + * + * @param requestURI the base URI of the request + * @param digestAlgorithm the digest algorithm to use (e.g., "MD5", "SHA-256") + * @param seed optional seed value for digest verification, may be null + * @return a new LiveMigrationFileDigestRequest instance + * @throws NullPointerException if requestURI or digestAlgorithm is null + * @throws IllegalArgumentException if digestAlgorithm is empty + */ + public static LiveMigrationFileDigestRequest create(String requestURI, String digestAlgorithm, Integer seed) + { + Objects.requireNonNull(requestURI, "requestURI cannot be null"); + Objects.requireNonNull(digestAlgorithm, "digestAlgorithm cannot be null"); + if (digestAlgorithm.isEmpty()) + { + throw new IllegalArgumentException("digestAlgorithm cannot be empty"); + } + + String fullURI = seed != null + ? String.format("%s?%s=%s&%s=%d", requestURI, DIGEST_ALGORITHM_PARAM, digestAlgorithm, SEED_PARAM, seed) Review Comment: I agree with the code complexity and simplifying code suggestions. I can remove the support for seed for live migration. -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]

