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 Protocol] Bootstrap Controller #2974

Merged
merged 10 commits into from
Dec 20, 2024
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,11 @@ public enum StateModelListenerType {
* The partition state change listener owned by file copy manager. It takes actions when new replica is added (OFFLINE ->
* BOOTSTRAP)
*/
FileCopyManagerListener
FileCopyManagerListener,

/**
* The partition state change listener owned by Bootstrap Controller.
* It takes actions when Offline -> Bootstrap state transition is called for a partition.
*/
BootstrapControllerListener
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ public enum TransitionErrorCode {
/**
* If File Based Replication Protocol fails at some point for specific replica.
*/
FileCopyProtocolFailure
FileCopyProtocolFailure,

/**
* If Bootstap Controller fails in pre-filecopy steps for specific replica.
*/
BootstrapControllerFailure
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,7 @@ public class StoreConfig {
@Config("store.reshuffle.disks.on.reorder")
@Default("false")
public final boolean storeReshuffleDisksOnReorder;

public final static String storeReshuffleDisksOnReorderName = "store.reshuffle.disks.on.reorder";

/**
Expand Down Expand Up @@ -890,4 +891,4 @@ public StoreConfig(VerifiableProperties verifiableProperties) {
storeBootstrapInProgressFile = verifiableProperties.getString(STORE_BOOTSTRAP_IN_PROGRESS_FILE, "bootstrap_in_progress");
storeFileCopyCompletedFileName = verifiableProperties.getString(STORE_FILE_COPY_COMPLETED_FILE_NAME, "file_copy_completed");
}
}
}
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 @@ -13,6 +13,7 @@
*/
package com.github.ambry.server;

import com.github.ambry.clustermap.ClusterParticipant;
import com.github.ambry.clustermap.PartitionId;
import com.github.ambry.clustermap.ReplicaId;
import com.github.ambry.store.Store;
Expand All @@ -21,6 +22,7 @@
import java.nio.file.FileStore;
import java.util.Collection;
import java.util.List;
import java.util.regex.Pattern;


/**
Expand Down Expand Up @@ -123,4 +125,19 @@ public interface StoreManager {
* @return {@code true} if disabling was successful. {@code false} if not.
*/
boolean controlCompactionForBlobStore(PartitionId id, boolean enabled);

/**
* Check if a file exists in the store directory.
* @return {@code true} if the file exists, {@code false} otherwise.
*/
boolean isFileExists(PartitionId partitionId, String fileName);

/**
* Check if files exist for a given pattern in the store directory.
* @param partitionId
* @param pattern
* @return {@code true} if the files exist, {@code false} otherwise.
* @throws IOException
*/
boolean isFilesExistForPattern(PartitionId partitionId, Pattern pattern) throws IOException;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/**
* 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;

/**
* The types of hydration protocol transitions that can happen.
* The possible options are :- Blob based and File copy based hydration
*/
public enum ReplicationProtocolTransitionType {
/**
* Pre restart protocol: NA
* Bootstrap status: NA
* Post restart protocol: Blob based
*/
NEW_PARTITION_TO_BLOB_BASED_HYDRATION,

/**
* Pre restart protocol: NA
* Bootstrap status: NA
* Post restart protocol: File based
*/
NEW_PARTITION_TO_FILE_BASED_HYDRATION,

/**
* Pre restart protocol: Blob based
* Bootstrap status: Complete
* Post restart protocol: File based
*/
BLOB_BASED_HYDRATION_COMPLETE_TO_FILE_BASED_HYDRATION,

/**
* Pre restart protocol: File based
* Bootstrap status: Complete
* Post restart protocol: Blob based
*/
FILE_BASED_HYDRATION_COMPLETE_TO_BLOB_BASED_HYDRATION,

/**
* Pre restart protocol: Blob based
* Bootstrap status: Complete
* Post restart protocol: Blob based
*/
BLOB_BASED_HYDRATION_COMPLETE_TO_BLOB_BASED_HYDRATION,

/**
* Pre restart protocol: File based
* Bootstrap status: Complete
* Post restart protocol: File based
*/
FILE_BASED_HYDRATION_COMPLETE_TO_FILE_BASED_HYDRATION,

/**
* Pre restart protocol: Blob based
* Bootstrap status: InComplete
* Post restart protocol: Blob based
*/
BLOB_BASED_HYDRATION_INCOMPLETE_TO_BLOB_BASED_HYDRATION,

/**
* Pre restart protocol: File based
* Bootstrap status: InComplete
* Post restart protocol: File based
*/
FILE_BASED_HYDRATION_INCOMPLETE_TO_FILE_BASED_HYDRATION,

/**
* Pre restart protocol: Blob based
* Bootstrap status: InComplete
* Post restart protocol: File based
*/
BLOB_BASED_HYDRATION_INCOMPLETE_TO_FILE_BASED_HYDRATION,

/**
* Pre restart protocol: File based
* Bootstrap status: InComplete
* Post restart protocol: Blob based
*/
FILE_BASED_HYDRATION_INCOMPLETE_TO_BLOB_BASED_HYDRATION
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@
package com.github.ambry.cloud;

import com.github.ambry.clustermap.ClusterMap;
import com.github.ambry.clustermap.ClusterParticipant;
import com.github.ambry.clustermap.PartitionId;
import com.github.ambry.clustermap.PartitionStateChangeListener;
import com.github.ambry.clustermap.ReplicaId;
import com.github.ambry.clustermap.StateModelListenerType;
import com.github.ambry.config.VerifiableProperties;
import com.github.ambry.server.ServerErrorCode;
import com.github.ambry.server.StoreManager;
Expand All @@ -27,6 +30,7 @@
import java.util.Map;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import java.util.regex.Pattern;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -128,6 +132,16 @@ public boolean controlCompactionForBlobStore(PartitionId id, boolean enabled) {
throw new UnsupportedOperationException("Method not supported");
}

@Override
public boolean isFileExists(PartitionId partitionId, String fileName) {
throw new UnsupportedOperationException("Method not supported");
}
aga9900 marked this conversation as resolved.
Show resolved Hide resolved

@Override
public boolean isFilesExistForPattern(PartitionId partitionId, Pattern allLogSegmentFilesPattern) {
aga9900 marked this conversation as resolved.
Show resolved Hide resolved
throw new UnsupportedOperationException("Method not supported");
}

@Override
public List<PartitionId> setBlobStoreStoppedState(List<PartitionId> partitionIds, boolean markStop) {
throw new UnsupportedOperationException("Method not supported");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,6 @@
import static com.github.ambry.clustermap.TestUtils.*;
import static org.junit.Assert.*;


// Permits Replica to be constructed with a null Partition
class TestReplica extends Replica {
public TestReplica(HardwareLayout hardwareLayout, JSONObject jsonObject) throws JSONException {
super(hardwareLayout, null, jsonObject);
}

public TestReplica(TestHardwareLayout hardwareLayout, Disk disk) throws JSONException {
super(null, disk, hardwareLayout.clusterMapConfig);
}

@Override
public void validatePartition() {
// Null OK
}
}

/**
* Tests {@link Replica} class.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/**
* 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.clustermap;

import org.json.JSONException;
import org.json.JSONObject;


// Permits Replica to be constructed with a null Partition
public class TestReplica extends Replica {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Info] Needed this to be able to mock this from BootstrapController tests.

public TestReplica(HardwareLayout hardwareLayout, JSONObject jsonObject) throws JSONException {
super(hardwareLayout, null, jsonObject);
}

public TestReplica(TestUtils.TestHardwareLayout hardwareLayout, Disk disk) throws JSONException {
super(null, disk, hardwareLayout.clusterMapConfig);
}

@Override
public void validatePartition() {
// Null OK
}
}
Loading
Loading