-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding stats for unreferenced files cleanup count
Signed-off-by: Rishav Sagar <[email protected]>
- Loading branch information
Rishav Sagar
committed
Sep 25, 2023
1 parent
1dde018
commit 67212b2
Showing
6 changed files
with
142 additions
and
3 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
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
75 changes: 75 additions & 0 deletions
75
server/src/main/java/org/opensearch/index/merge/UnreferencedFileCleanUpStats.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,75 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.index.merge; | ||
|
||
import org.opensearch.core.common.io.stream.StreamInput; | ||
import org.opensearch.core.common.io.stream.StreamOutput; | ||
import org.opensearch.core.common.io.stream.Writeable; | ||
import org.opensearch.core.xcontent.ToXContentFragment; | ||
import org.opensearch.core.xcontent.XContentBuilder; | ||
|
||
import java.io.IOException; | ||
|
||
/** | ||
* Stores stats about unreferenced file cleanup due to segment merge failure. | ||
* | ||
* @opensearch.internal | ||
*/ | ||
public class UnreferencedFileCleanUpStats implements Writeable, ToXContentFragment { | ||
|
||
private long totalUnreferencedFileCleanupCount; | ||
|
||
public UnreferencedFileCleanUpStats() { | ||
|
||
} | ||
|
||
public UnreferencedFileCleanUpStats(StreamInput in) throws IOException { | ||
totalUnreferencedFileCleanupCount = in.readVLong(); | ||
} | ||
|
||
public void add(long totalUnreferencedFileCleanupCount) { | ||
this.totalUnreferencedFileCleanupCount += totalUnreferencedFileCleanupCount; | ||
} | ||
|
||
public long getTotalUnreferencedFileCleanupCount() { | ||
return totalUnreferencedFileCleanupCount; | ||
} | ||
|
||
public void add(UnreferencedFileCleanUpStats cleanUpStats) { | ||
if (cleanUpStats == null) { | ||
return; | ||
} | ||
|
||
this.totalUnreferencedFileCleanupCount += cleanUpStats.totalUnreferencedFileCleanupCount; | ||
} | ||
|
||
@Override | ||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { | ||
builder.startObject(Fields.UNREFERENCED_FILE_CLEANUP); | ||
builder.field(Fields.COUNT, totalUnreferencedFileCleanupCount); | ||
builder.endObject(); | ||
return null; | ||
} | ||
|
||
@Override | ||
public void writeTo(StreamOutput out) throws IOException { | ||
out.writeVLong(totalUnreferencedFileCleanupCount); | ||
} | ||
|
||
/** | ||
* Fields for unreferenced file cleanup statistics | ||
* | ||
* @opensearch.internal | ||
*/ | ||
static final class Fields { | ||
static final String UNREFERENCED_FILE_CLEANUP = "unreferenced_file_cleanup"; | ||
static final String COUNT = "count"; | ||
} | ||
|
||
} |
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