-
Notifications
You must be signed in to change notification settings - Fork 275
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] GetMetadata Api #2991
Conversation
ambry-network/src/main/java/com/github/ambry/network/LocalRequestResponseChannel.java
Outdated
Show resolved
Hide resolved
ambry-server/src/main/java/com/github/ambry/server/AmbryRequests.java
Outdated
Show resolved
Hide resolved
ambry-server/src/main/java/com/github/ambry/server/AmbryRequests.java
Outdated
Show resolved
Hide resolved
ambry-server/src/main/java/com/github/ambry/server/AmbryServer.java
Outdated
Show resolved
Hide resolved
ambry-server/src/test/java/com/github/ambry/server/AmbryServerRequestsTest.java
Outdated
Show resolved
Hide resolved
ambry-server/src/test/java/com/github/ambry/server/AmbryServerRequestsTest.java
Outdated
Show resolved
Hide resolved
ambry-store/src/main/java/com/github/ambry/store/BlobStore.java
Outdated
Show resolved
Hide resolved
ambry-store/src/main/java/com/github/ambry/store/BlobStore.java
Outdated
Show resolved
Hide resolved
ambry-store/src/main/java/com/github/ambry/store/DiskManager.java
Outdated
Show resolved
Hide resolved
ambry-protocol/src/main/java/com/github/ambry/protocol/FileCopyGetMetaDataRequest.java
Show resolved
Hide resolved
return sb.toString(); | ||
} | ||
|
||
@Override | ||
public void accept(RequestVisitor visitor) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are we using this for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is used in a generic infra defined in RequestMetricsUpdater
This powers some common metrics like qps for a particular request type defined here.
public List<LogInfo> getLogInfos() { | ||
return logInfos; | ||
return Collections.unmodifiableList(logInfos); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need this to be unmodifiableList?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This ensures that the list cannot be modified from outside the class and helps in maintaining the immutability of the list and prevents accidental or intentional modifications.
Checked the demo master branch and this works well there too with FileCopyHandler caller code.
ambry-protocol/src/main/java/com/github/ambry/protocol/LogInfo.java
Outdated
Show resolved
Hide resolved
ambry-protocol/src/main/java/com/github/ambry/protocol/RequestVisitor.java
Outdated
Show resolved
Hide resolved
null, null, totalTimeSpent)); | ||
} | ||
|
||
private List<LogInfo> convertStoreToProtocolLogInfo(List<com.github.ambry.store.LogInfo> logSegments) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use one LogInfo class so we don't need to do this conversion. Maybe we can put the LogInfo to ambry-api package.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Request handler for this api is in ambry-server
module.
Protocol class is required to have network stream SerDe (alongwith readFrom, prepareBuffer etc) same as any other protocol request/response classes in ambry-protocol
module.
BlobStore/FileStore need their Pojos (LogInfo, FileInfo) in ambry-store
module as it doesn't have a dependency on Protocol module (and vice-versa)
Eventually, we need similar constructs in ambry-store
and ambry-protocol
modules.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This pattern is same in some other apis where Store and Protocol class conversion is happening.
fe, check this BatchDelete Api code
List<BlobDeleteStatus> blobDeleteStatuses = new ArrayList<>();
for (StoreKey storeKey : batchDeletePartitionRequestInfo.getBlobIds()){
blobDeleteStatuses.add(new BlobDeleteStatus((BlobId)storeKey, ServerErrorCode.Unknown_Error));
}
BlobDeleteStatus is a protocol class while StoreKey is a Store class and we are converting from Store to Protocol class. Just that in my case, I have named both classes same (LogInfo) and created a private converter util.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can put these classes under ambry-api modules. Just like FindToken. This way, you don't need two identical classes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ty for pointing this out @justinlin-linkedin
PTAL at the latest diff.
Changelog :-
Fixes the consolidation of pojos. Protocol/pojos no longer exist.
New interfaces are in common place api-module and Store, Protocol classes implement it.
ambry-server/src/main/java/com/github/ambry/server/AmbryRequests.java
Outdated
Show resolved
Hide resolved
ambry-store/src/main/java/com/github/ambry/store/DiskManager.java
Outdated
Show resolved
Hide resolved
ambry-store/src/main/java/com/github/ambry/store/StorageManager.java
Outdated
Show resolved
Hide resolved
ambry-store/src/main/java/com/github/ambry/store/BlobStore.java
Outdated
Show resolved
Hide resolved
ambry-protocol/src/main/java/com/github/ambry/protocol/LogInfo.java
Outdated
Show resolved
Hide resolved
* @param buf The output stream. | ||
*/ | ||
public void writeTo(@Nonnull ByteBuf buf){ | ||
Objects.requireNonNull(buf, "buf should not be null"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The @nonnull annotation will already be doing this check. We should remove this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nonnull works as a static warning. Shows up as red line in the calling code if null is passed but it doesn't give a compilation error. I tried the same. From tests, I was able to pass null. Hence, I added a requireNonNull check.
ambry-protocol/src/test/java/com/github/ambry/protocol/RequestResponseTest.java
Show resolved
Hide resolved
ambry-protocol/src/test/java/com/github/ambry/protocol/RequestResponseTest.java
Show resolved
Hide resolved
|
||
RequestMetricsUpdater metricsUpdater = new RequestMetricsUpdater( | ||
requestQueueTime, processingTime, 0, 0, false); | ||
if (null != fileCopyGetMetaDataRequest) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: fileCopyGetMetaDataRequest != null
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ambry-server/src/test/java/com/github/ambry/server/AmbryServerRequestsTest.java
Outdated
Show resolved
Hide resolved
*/ | ||
public class FileInfo { | ||
/** | ||
* Name of the file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you remove redundant comments
* @param includeActiveLogSegment | ||
* @return | ||
*/ | ||
List<LogInfo> getLogSegmentMetadataFiles(boolean includeActiveLogSegment); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have a default access modifier
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default access modifier would be public in an interface.
the default
keyword would mean that a default impl exists for this method (which btw, doesn't).
Can you pls elaborate what could be the default access modifier here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes , i meant public modifier
ambry-protocol/src/main/java/com/github/ambry/protocol/FileCopyGetMetaDataRequest.java
Show resolved
Hide resolved
ambry-protocol/src/main/java/com/github/ambry/protocol/LogInfo.java
Outdated
Show resolved
Hide resolved
ambry-protocol/src/main/java/com/github/ambry/protocol/LogInfo.java
Outdated
Show resolved
Hide resolved
StringBuilder sb = new StringBuilder(); | ||
sb.append("LogInfo["); | ||
sb.append("FileName=").append(fileName).append(", FileSizeInBytes=").append(fileSizeInBytes).append(","); | ||
for(FileInfo fileInfo : indexFiles) { | ||
sb.append(fileInfo.toString()); | ||
sb.append("FileName=").append(fileName).append(", FileSizeInBytes=").append(fileSizeInBytes); | ||
|
||
if(!indexFiles.isEmpty()) { | ||
sb.append(", IndexFiles=["); | ||
for (FileInfo fileInfo : indexFiles) { | ||
sb.append(fileInfo.toString()); | ||
} | ||
sb.append("]"); | ||
if(!bloomFilters.isEmpty()) { | ||
sb.append(", "); | ||
} | ||
} | ||
for(FileInfo fileInfo: bloomFilters){ | ||
sb.append(fileInfo.toString()); | ||
if(!bloomFilters.isEmpty()){ | ||
sb.append(" BloomFilters=["); | ||
for(FileInfo fileInfo: bloomFilters){ | ||
sb.append(fileInfo.toString()); | ||
} | ||
sb.append("]"); | ||
} | ||
sb.append("]"); | ||
return sb.toString(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not this?
{
return "LogInfo{" +
"fileName='" + fileName + '\'' +
", fileSizeInBytes=" + fileSizeInBytes +
", indexFiles=" + indexFiles +
", bloomFilters=" + bloomFilters +
'}';
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I vaguely remember this.
iirc, it should have worked but It was not recursively printing indexFiles and bloomFilters.
Indexfiles and bloomfiles are of type List<FileInfo>
and List wont get strigified as is. So, I needed to iterate over these values and then delegate to indexfile/bloomfile-toString()
Ticket
BUG=AMBRY-13007
Summary
Adds GetMetadata Api required for bootstrap replication improvements using file copy based protocol.
Testing Done
Test logs :-