-
Notifications
You must be signed in to change notification settings - Fork 275
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This change enables cloud find token and store find token to work together for two way replication. The main changes are 1. Since the tokens for a cloud replica and store replica are different, this change introduces replicatype to differentiate between the two. For now the determination about replica type is based on mount point (cloud replicas have a dummy mount point of /vcr/partitionId). 2. Implementation of a factoryfactory to get findtokenfactory based on an input stream (during deserialization) or based on replica type. 3. Implementation of cloud token factory. 4. Bug fixes in cloud find token. 5. Refactoring some common code used by both ambry-store, ambry-cloud and ambry-replication. 6. Change the replication code to recognize both cloud replicas and store replicas and serialize/deserialize their token accordingly. 7. Change tests where token factory was used.
- Loading branch information
1 parent
a1af48c
commit 9487e8b
Showing
60 changed files
with
1,024 additions
and
249 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
ambry-api/src/main/java/com.github.ambry/clustermap/ReplicaType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
* Copyright 2019 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; | ||
|
||
/** | ||
* The type of replica. | ||
*/ | ||
public enum ReplicaType { | ||
DISK_BACKED, CLOUD_BACKED | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
ambry-api/src/main/java/com.github.ambry/replication/FindTokenHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/** | ||
* Copyright 2019 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.replication; | ||
|
||
import com.github.ambry.clustermap.ReplicaType; | ||
import com.github.ambry.config.ReplicationConfig; | ||
import com.github.ambry.store.StoreKeyFactory; | ||
import com.github.ambry.utils.Utils; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
|
||
/** | ||
* Helper class to get findtoken based on replica type or input stream. | ||
*/ | ||
public class FindTokenHelper { | ||
private static final Logger logger = LoggerFactory.getLogger(FindTokenHelper.class); | ||
private final StoreKeyFactory storeKeyFactory; | ||
private final ReplicationConfig replicationConfig; | ||
private final Map<ReplicaType, FindTokenFactory> findTokenFactoryMap; | ||
|
||
public FindTokenHelper() { | ||
storeKeyFactory = null; | ||
replicationConfig = null; | ||
findTokenFactoryMap = null; | ||
} | ||
|
||
/** | ||
* Create a {@code FindTokenHelper} object. | ||
* @param storeKeyFactory | ||
* @param replicationConfig | ||
*/ | ||
public FindTokenHelper(StoreKeyFactory storeKeyFactory, ReplicationConfig replicationConfig) | ||
throws ReflectiveOperationException { | ||
this.storeKeyFactory = storeKeyFactory; | ||
this.replicationConfig = replicationConfig; | ||
findTokenFactoryMap = new HashMap<>(); | ||
findTokenFactoryMap.put(ReplicaType.DISK_BACKED, | ||
Utils.getObj(replicationConfig.replicationStoreTokenFactory, storeKeyFactory)); | ||
findTokenFactoryMap.put(ReplicaType.CLOUD_BACKED, Utils.getObj(replicationConfig.replicationCloudTokenFactory)); | ||
} | ||
|
||
/** | ||
* Get {@code FindTokenFactory} object based on {@code ReplicaType} | ||
* @param replicaType for which to get the {@code FindTokenFactory} object | ||
* @return {@code FindTokenFactory} object. | ||
* @throws ReflectiveOperationException | ||
*/ | ||
public FindTokenFactory getFindTokenFactoryFromReplicaType(ReplicaType replicaType) { | ||
if (!findTokenFactoryMap.containsKey(replicaType)) { | ||
throw new IllegalArgumentException("Invalid replica type " + replicaType.getClass()); | ||
} | ||
return findTokenFactoryMap.get(replicaType); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
ambry-api/src/main/java/com.github.ambry/replication/FindTokenType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/** | ||
* Copyright 2019 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.replication; | ||
|
||
/** | ||
* The type of replica token | ||
*/ | ||
public enum FindTokenType { | ||
Uninitialized, JournalBased, IndexBased, CloudBased; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.