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

Add changes to Point in time segments API service layer #4105

Merged
merged 18 commits into from
Aug 23, 2022

Conversation

bharath-techie
Copy link
Contributor

@bharath-techie bharath-techie commented Aug 3, 2022

Signed-off-by: Bharathwaj G bharath78910@gmail.com

Description

This contains service layer changes for retrieving segments information of PITs which provides information about disk utilization of PIT

Issues Resolved

#1147

Check List

  • New functionality includes testing.
    • All tests pass
  • New functionality has been documented.
    • New functionality has javadoc added
  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@bharath-techie bharath-techie requested review from a team and reta as code owners August 3, 2022 09:46
@github-actions
Copy link
Contributor

github-actions bot commented Aug 3, 2022

Gradle Check (Jenkins) Run Completed with:

Signed-off-by: Bharathwaj G <bharath78910@gmail.com>
@github-actions
Copy link
Contributor

github-actions bot commented Aug 3, 2022

Gradle Check (Jenkins) Run Completed with:

return pitIds;
}

public void setPitIds(Collection<String> pitIds) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Any reason for having setter. We can have it initialised during construction.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah in transport layer, if no pit ids are passed, we get all PITs and set it in request.


}

public Collection<String> getPitIds() {
Copy link
Contributor

@pranikum pranikum Aug 3, 2022

Choose a reason for hiding this comment

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

UnmodifiableList ? Also i don't see anywhere we are using it apart from List type. We can use List itself.

*/
public class PitSegmentsRequest extends BroadcastRequest<PitSegmentsRequest> {

protected boolean verbose = false;
Copy link
Contributor

@pranikum pranikum Aug 3, 2022

Choose a reason for hiding this comment

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

Why protected if we already have setter and getter public methods.
Since default value is false. So don't need to mention it specifically.

* Sets the <code>verbose</code> option.
* @see #verbose()
*/
public void verbose(boolean v) {
Copy link
Contributor

@pranikum pranikum Aug 3, 2022

Choose a reason for hiding this comment

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

setVerbose ?

* <code>true</code> if detailed information about each segment should be returned,
* <code>false</code> otherwise.
*/
public boolean verbose() {
Copy link
Contributor

@pranikum pranikum Aug 3, 2022

Choose a reason for hiding this comment

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

isVerbose for clarity?

@github-actions
Copy link
Contributor

github-actions bot commented Aug 3, 2022

Gradle Check (Jenkins) Run Completed with:

Signed-off-by: Bharathwaj G <bharath78910@gmail.com>
@bharath-techie bharath-techie force-pushed the pitsegments branch 4 times, most recently from c29f252 to cd5263f Compare August 4, 2022 05:54
@github-actions
Copy link
Contributor

github-actions bot commented Aug 4, 2022

Gradle Check (Jenkins) Run Completed with:

@github-actions
Copy link
Contributor

github-actions bot commented Aug 4, 2022

Gradle Check (Jenkins) Run Completed with:

@github-actions
Copy link
Contributor

github-actions bot commented Aug 4, 2022

Gradle Check (Jenkins) Run Completed with:

}

public List<Segment> getSegments() {
return segments;
Copy link
Contributor

Choose a reason for hiding this comment

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

Collection.unmodifiable

IndicesSegmentResponse indicesSegmentResponse = client.execute(PitSegmentsAction.INSTANCE, new PitSegmentsRequest()).actionGet();
assertTrue(indicesSegmentResponse.getShardFailures() == null || indicesSegmentResponse.getShardFailures().length == 0);
if (isEmpty) {
assertTrue(indicesSegmentResponse.getIndices().size() == 0);
Copy link
Contributor

Choose a reason for hiding this comment

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

we can use assertEquals(indicesSegmentResponse.getIndices().isEmpty(), isEmpty); and avoid if/else block

@github-actions
Copy link
Contributor

github-actions bot commented Aug 4, 2022

Gradle Check (Jenkins) Run Completed with:

* Transport request for retrieving PITs segment information
*/
public class PitSegmentsRequest extends BroadcastRequest<PitSegmentsRequest> {
boolean verbose = false;
Copy link
Contributor

@pranikum pranikum Aug 4, 2022

Choose a reason for hiding this comment

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

we can simply write private boolean verbose;. Since default initialisation is false for boolean. No need to give package access to variable as we already have public setter.

Signed-off-by: Bharathwaj G <bharath78910@gmail.com>
@github-actions
Copy link
Contributor

github-actions bot commented Aug 4, 2022

Gradle Check (Jenkins) Run Completed with:

Signed-off-by: Bharathwaj G <bharath78910@gmail.com>
@sachinpkale
Copy link
Member

The build is failing, please fix it.

Signed-off-by: Bharathwaj G <bharath78910@gmail.com>
@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

*/
@Override
protected ShardSegments shardOperation(PitSegmentsRequest request, ShardRouting shardRouting) {
if (shardRouting instanceof PitAwareShardRouting) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this be an assertion instead of an if condition

.get(shardRouting.shardId());
PitReaderContext pitReaderContext = searchService.getPitReaderContext(searchContextIdForNode.getSearchContextId());
if (pitReaderContext == null) {
return new ShardSegments(shardRouting, new ArrayList<>());
Copy link
Collaborator

Choose a reason for hiding this comment

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

Collections.emptyList() instead?

Comment on lines 202 to 204
} else {
throw new IllegalArgumentException("Shard routing is not of PitAwareShardRouting type");
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

lets remove and replace with assertion?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure

@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

Signed-off-by: Bharathwaj G <bharath78910@gmail.com>
@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

@bharath-techie
Copy link
Contributor Author

@reta @Bukhtawar I've addressed comments, if changes look good can you please approve / merge.

Comment on lines +143 to +146
@Override
protected ClusterBlockException checkGlobalBlock(ClusterState state, PitSegmentsRequest request) {
return state.blocks().globalBlockedException(ClusterBlockLevel.METADATA_READ);
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

should this be READ instead of METADATA_READ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

METADATA_READ is used in index segments as well. Read is used in operations like search, multisearch etc.

Copy link
Collaborator

@Bukhtawar Bukhtawar left a comment

Choose a reason for hiding this comment

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

Left a couple of minor comments. Please review them

@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

Signed-off-by: Bharathwaj G <bharath78910@gmail.com>
@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

@bharath-techie
Copy link
Contributor Author

@reta @Bukhtawar can we please merge this ?

@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants