Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FileCopy based bootstrap] Added changes for filestore implementation #2990

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/**
* Copyright 2025 LinkedIn Corp. All rights reserved.
*
* Licensed 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.
*/

package com.github.ambry.clustermap;

/**
* Custom exception class for FileStore-related errors.
* Extends RuntimeException to allow unchecked exception handling.
* Includes specific error codes for different failure scenarios.
*/
public class FileStoreException extends RuntimeException {

// Ensures proper serialization across JVM versions
private static final long serialVersionUID = 1L;

// Stores the specific error code associated with this exception
private final FileStoreErrorCode error;

/**
* Creates a new FileStoreException with a message and error code.
*
* @param s The error message describing what went wrong
* @param error The specific error code categorizing the failure
*/
public FileStoreException(String s, FileStoreErrorCode error) {
super(s);
this.error = error;
}

/**
* Creates a new FileStoreException with a message, error code, and cause.
*
* @param s The error message describing what went wrong
* @param error The specific error code categorizing the failure
* @param throwable The underlying cause of this exception
*/
public FileStoreException(String s, FileStoreErrorCode error, Throwable throwable) {
super(s, throwable);
this.error = error;
}

/**
* Enumeration of possible FileStore error codes.
* Each code represents a specific category of failure.
*/
public enum FileStoreErrorCode {
/**
* Indicates that the FileStore service is not in running state
* when an operation was attempted.
*/
FileStoreRunningFailure
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
/**
* Copyright 2025 LinkedIn Corp. All rights reserved.
*
* Licensed 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.
*/

package com.github.ambry.config;

/**
* Configuration parameters for file copy operations in Ambry.
* This class manages settings related to:
* - Parallel processing
* - Thread management
* - Timeouts
* - Data flushing
* - Metadata file naming
*/
public class FileCopyConfig {

/**
* Number of partitions that can be hydrated in parallel per disk.
* Higher values increase parallelism but also resource usage.
*/
public static final String PARALLEL_PARTITION_HYDRATION_COUNT_PER_DISK = "parallel.partition.hydration.count.per.disk";
@Config(PARALLEL_PARTITION_HYDRATION_COUNT_PER_DISK)
public final int parallelPartitionHydrationCountPerDisk;

/**
* Number of threads dedicated to file copy operations.
* Controls the level of concurrent file transfers.
*/
public static final String NUMBER_OF_FILE_COPY_THREADS = "number.of.file.copy.threads";
@Config(NUMBER_OF_FILE_COPY_THREADS)
public final int numberOfFileCopyThreads;

/**
* Timeout duration for file chunk operations in minutes.
* After this duration, incomplete chunk operations are considered failed.
*/
public static final String FILE_CHUNK_TIMEOUT_IN_MINUTES = "file.chunk.timeout.in.minutes";
@Config(FILE_CHUNK_TIMEOUT_IN_MINUTES)
public final long fileChunkTimeoutInMins;

/**
* The frequency at which data gets flushed to disk in megabytes.
* Lower values increase durability but may impact performance.
* Default: 1000MB
*/
public static final String STORE_DATA_FLUSH_INTERVAL_IN_MBS = "store.data.flush.interval.In.MBs";
@Config(STORE_DATA_FLUSH_INTERVAL_IN_MBS)
@Default("1000")
public final long storeDataFlushIntervalInMbs;

/**
* Name of the metadata file used for file copy operations.
* This file stores information about sealed logs and their associated metadata.
* Default: "sealed_logs_metadata_file"
*/
public static final String FILE_COPY_META_DATA_FILE_NAME = "file.copy.meta.data.file.name";
@Config(FILE_COPY_META_DATA_FILE_NAME)
@Default("sealed_logs_metadata_file")
public final String fileCopyMetaDataFileName;

/**
* Creates a new FileCopyConfig with the provided properties.
*
* @param verifiableProperties Properties containing configuration values
* If a property is not specified, default values are used:
* - parallelPartitionHydrationCountPerDisk: 1
* - numberOfFileCopyThreads: 4
* - fileChunkTimeoutInMins: 5
* - storeDataFlushIntervalInMbs: 1000
* - fileCopyMetaDataFileName: "sealed_logs_metadata_file"
*/
public FileCopyConfig(VerifiableProperties verifiableProperties) {
fileCopyMetaDataFileName = verifiableProperties.getString(FILE_COPY_META_DATA_FILE_NAME, "sealed_logs_metadata_file");
parallelPartitionHydrationCountPerDisk = verifiableProperties.getInt(PARALLEL_PARTITION_HYDRATION_COUNT_PER_DISK, 1);
numberOfFileCopyThreads = verifiableProperties.getInt(NUMBER_OF_FILE_COPY_THREADS, 4);
fileChunkTimeoutInMins = verifiableProperties.getInt(FILE_CHUNK_TIMEOUT_IN_MINUTES, 5);
storeDataFlushIntervalInMbs = verifiableProperties.getLong(STORE_DATA_FLUSH_INTERVAL_IN_MBS, 1000);
}
}
72 changes: 72 additions & 0 deletions ambry-api/src/main/java/com/github/ambry/store/FileInfo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/**
* Copyright 2025 LinkedIn Corp. All rights reserved.
*
* Licensed 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.
*/

package com.github.ambry.store;

/**
* Represents metadata about a file in the Ambry storage system.
* Contains basic file information like name and size.
* Used for tracking file details during copy operations and metadata management.
*/
public class FileInfo {
// Name of the file, including any path components
private String fileName;

// Size of the file in bytes
// Marked final as size shouldn't change after creation
private final long fileSize;

/**
* Creates a new FileInfo instance.
*
* @param fileName Name or path of the file
* @param fileSize Size of the file in bytes
*/
public FileInfo(String fileName, Long fileSize) {
this.fileName = fileName;
this.fileSize = fileSize;
}

/**
* Gets the name of the file.
*
* @return The file name or path
*/
public String getFileName() {
return fileName;
}

/**
* Gets the size of the file in bytes.
*
* @return The file size
*/
public Long getFileSize() {
return fileSize;
}

/**
* Returns a string representation of the FileInfo object.
* Useful for logging and debugging.
*
* @return String containing file name and size
*/
@Override
public String toString() {
return "FileInfo{" +
"fileName='" + fileName + '\'' +
", fileSize=" + fileSize +
'}';
}
}
119 changes: 119 additions & 0 deletions ambry-api/src/main/java/com/github/ambry/store/LogInfo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
/**
* Copyright 2025 LinkedIn Corp. All rights reserved.
*
* Licensed 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.
*/

package com.github.ambry.store;

import java.util.List;

/**
* Represents information about a log segment and its associated metadata files.
* Contains details about:
* - The sealed log segment
* - Associated index segments
* - Bloom filters for efficient lookups
*/
public class LogInfo {
// The sealed log segment containing the actual data
FileInfo sealedSegment;

// List of index segments associated with this log
// Each index segment provides lookup capabilities for a portion of the log
List<FileInfo> indexSegments;

// List of bloom filters for efficient key lookups
// Each bloom filter corresponds to an index segment
List<FileInfo> bloomFilters;

/**
* Creates a new LogInfo instance with the specified components.
*
* @param sealedSegment The sealed log segment file information
* @param indexSegments List of index segment file information
* @param bloomFilters List of bloom filter file information
*/
public LogInfo(FileInfo sealedSegment, List<FileInfo> indexSegments, List<FileInfo> bloomFilters) {
this.sealedSegment = sealedSegment;
this.indexSegments = indexSegments;
this.bloomFilters = bloomFilters;
}

/**
* Gets the sealed log segment information.
*
* @return FileInfo for the sealed log segment
*/
public FileInfo getSealedSegment() {
return sealedSegment;
}

/**
* Sets the sealed log segment information.
*
* @param sealedSegments New sealed segment information
*/
public void setSealedSegments(FileInfo sealedSegments) {
this.sealedSegment = sealedSegments;
}

/**
* Gets the list of index segment information.
*
* @return List of FileInfo objects for index segments
*/
public List<FileInfo> getIndexSegments() {
return indexSegments;
}

/**
* Sets the list of index segment information.
*
* @param indexSegments New list of index segment information
*/
public void setIndexSegments(List<FileInfo> indexSegments) {
this.indexSegments = indexSegments;
}

/**
* Gets the list of bloom filter information.
*
* @return List of FileInfo objects for bloom filters
*/
public List<FileInfo> getBloomFilters() {
return bloomFilters;
}

/**
* Sets the list of bloom filter information.
*
* @param bloomFilters New list of bloom filter information
*/
public void setBloomFilters(List<FileInfo> bloomFilters) {
this.bloomFilters = bloomFilters;
}

/**
* Returns a string representation of the LogInfo object.
* Useful for logging and debugging.
*
* @return String containing details of sealed segment, index segments, and bloom filters
*/
@Override
public String toString() {
return "LogInfo{" +
"sealedSegment=" + sealedSegment +
", indexSegments=" + indexSegments +
", bloomFilters=" + bloomFilters +
'}';
}
}
Loading
Loading