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

Bootstrap Performance Improvement[PR3] : Adding File Store And Related Interfaces #2976

Merged
merged 5 commits into from
Dec 20, 2024
Merged
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
17 changes: 17 additions & 0 deletions ambry-api/src/main/java/com/github/ambry/server/StoreManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import com.github.ambry.store.Store;
import com.github.ambry.store.StoreException;
import java.io.IOException;
import java.nio.file.FileStore;
import java.util.Collection;
import java.util.List;

Expand All @@ -34,6 +35,13 @@ public interface StoreManager {
*/
boolean addBlobStore(ReplicaId replica);

/**
* Add a new FileStore with given {@link ReplicaId}.
* @param replicaId the {@link ReplicaId} of the {@link FileStore} which would be added.
* @return {@code true} if adding FileStore was successful. {@code false} if not.
*/
boolean addFileStore(ReplicaId replicaId);

/**
* Remove store from storage manager.
* @param id the {@link PartitionId} associated with store
Expand Down Expand Up @@ -62,6 +70,15 @@ public interface StoreManager {
*/
Store getStore(PartitionId id);


/**
*
* @param id the {@link PartitionId} to find the store for.
* @return the {@link FileStore} corresponding to the given {@link PartitionId}, or {@code null} if no store was found for
* that partition, or that store was not started.
*/
FileStore getFileStore(PartitionId id);

/**
* Get replicaId on current node by partition name. (There should be at most one replica belonging to specific
* partition on single node)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.github.ambry.server.ServerErrorCode;
import com.github.ambry.server.StoreManager;
import com.github.ambry.store.Store;
import java.nio.file.FileStore;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
Expand Down Expand Up @@ -57,6 +58,16 @@ public boolean addBlobStore(ReplicaId replica) {
return createAndStartBlobStoreIfAbsent(replica.getPartitionId()) != null;
}

/**
* Returning false because this will not be used as part of CloudStorageManager Implementation.
* Implementation will be added if needed.
*/
@Override
public boolean addFileStore(ReplicaId replicaId) {
return false;

}

@Override
public boolean shutdownBlobStore(PartitionId id) {
try {
Expand All @@ -71,6 +82,10 @@ public boolean shutdownBlobStore(PartitionId id) {
return false;
}

/**
* Returning null because this will not be used as part of CloudStorageManager Implementation.
* Implementation will be added if needed.
*/
@Override
public Store getStore(PartitionId id) {
try {
Expand All @@ -84,6 +99,11 @@ public Store getStore(PartitionId id) {
return createAndStartBlobStoreIfAbsent(id);
}

@Override
public FileStore getFileStore(PartitionId id) {
aga9900 marked this conversation as resolved.
Show resolved Hide resolved
return null;
}

@Override
public boolean scheduleNextForCompaction(PartitionId id) {
throw new UnsupportedOperationException("Method not supported");
Expand Down
46 changes: 46 additions & 0 deletions ambry-store/src/main/java/com/github/ambry/store/FileStore.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/**
* Copyright 2024 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.nio.channels.FileChannel;
import java.util.concurrent.ConcurrentHashMap;


/**
* This class is responsible for interactions with Disk as Part Of File Copy Protocol.
* It is responsible for reading and writing chunks and metadata to disk.
*/
class FileStore {
private boolean isRunning = false;
private ConcurrentHashMap<String, FileChannel> fileNameToFileChannelMap;

public FileStore(String dataDir){
fileNameToFileChannelMap = new ConcurrentHashMap<>();
isRunning = false;
}

void start() {
if(!isRunning) {
//Start the FileStore
isRunning = true;
}
}
void stop() {
//TODO: Implement shutdown Hook.
isRunning = false;
}
boolean isRunning() {
return isRunning;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import com.github.ambry.utils.Utils;
import java.io.File;
import java.io.IOException;
import java.nio.file.FileStore;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
Expand Down Expand Up @@ -353,6 +354,12 @@ public Store getStore(PartitionId id) {
return getStore(id, false);
}

@Override
public FileStore getFileStore(PartitionId id) {
//TODO: Implementation To Be added.
return null;
}

/**
* @param id the {@link PartitionId} to find the store for.
* @param skipStateCheck whether to skip checking state of the store. if true, it also returns store that is not started yet.
Expand Down Expand Up @@ -534,6 +541,12 @@ public boolean addBlobStore(ReplicaId replica) {
return true;
}

@Override
public boolean addFileStore(ReplicaId replicaId) {
//TODO: Implementation To Be added.
return false;
aga9900 marked this conversation as resolved.
Show resolved Hide resolved
}

/**
* If a bootstrap replica fails, try to remove all the files and directories associated with it.
* @param replica The failed bootstrap {@link ReplicaId}.
Expand Down
Loading