-
Notifications
You must be signed in to change notification settings - Fork 24.8k
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
Include size of snapshot in snapshot metadata #29602
Changes from 14 commits
6bcfcb8
a08c807
50d7c78
6ea7e01
4ca0ba9
7ab7262
9a839f3
4a0bbc7
3ebc769
828bb12
5582562
f3c2306
39e0190
34243af
816c7d9
d13d991
76fe2ac
c86c6e5
4176564
c05b191
563bea7
e1400a8
ccf7b22
f2a33d6
7df83ef
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
[[breaking_70_snapshotstats_changes]] | ||
=== Snapshot stats changes | ||
|
||
Snapshot stats details are provided in a new structured way: | ||
|
||
* `total` section for all the files that are referenced by the snapshot | ||
* `incremental` section for those files that actually needed to be copied over as part of the incremental snapshotting. | ||
* In case of a snapshot that's still in progress, there's also a`processed` section for files that are in the process of being copied. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. space between |
||
|
||
==== Deprecated `number_of_files`, `processed_files`, `total_size_in_bytes` and `processed_size_in_bytes` snapshot stats properties have been removed | ||
|
||
* Properties `number_of_files` and `total_size_in_bytes` are removed and should be replaced by values of nested object `total`. | ||
* Properties `processed_files` and `processed_size_in_bytes` are removed and should be replaced by values of nested object `processed`. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ | |
|
||
package org.elasticsearch.action.admin.cluster.snapshots.status; | ||
|
||
import org.elasticsearch.Version; | ||
import org.elasticsearch.common.io.stream.StreamInput; | ||
import org.elasticsearch.common.io.stream.StreamOutput; | ||
import org.elasticsearch.common.io.stream.Streamable; | ||
|
@@ -34,19 +35,25 @@ public class SnapshotStats implements Streamable, ToXContentFragment { | |
|
||
private long startTime; | ||
private long time; | ||
private int numberOfFiles; | ||
private int processedFiles; | ||
private int incrementalFileCount; | ||
private int totalFileCount; | ||
private int processedFileCount; | ||
private long incrementalSize; | ||
private long totalSize; | ||
private long processedSize; | ||
|
||
SnapshotStats() { | ||
} | ||
|
||
SnapshotStats(long startTime, long time, int numberOfFiles, int processedFiles, long totalSize, long processedSize) { | ||
SnapshotStats(long startTime, long time, | ||
int incrementalFileCount, int totalFileCount, int processedFileCount, | ||
long incrementalSize, long totalSize, long processedSize) { | ||
this.startTime = startTime; | ||
this.time = time; | ||
this.numberOfFiles = numberOfFiles; | ||
this.processedFiles = processedFiles; | ||
this.incrementalFileCount = incrementalFileCount; | ||
this.totalFileCount = totalFileCount; | ||
this.processedFileCount = processedFileCount; | ||
this.incrementalSize = incrementalSize; | ||
this.totalSize = totalSize; | ||
this.processedSize = processedSize; | ||
} | ||
|
@@ -66,17 +73,31 @@ public long getTime() { | |
} | ||
|
||
/** | ||
* Returns number of files in the snapshot | ||
* Returns incremental file count of the snapshot | ||
*/ | ||
public int getNumberOfFiles() { | ||
return numberOfFiles; | ||
public int getIncrementalFileCount() { | ||
return incrementalFileCount; | ||
} | ||
|
||
/** | ||
* Returns total number of files in the snapshot | ||
*/ | ||
public int getTotalFileCount() { | ||
return totalFileCount; | ||
} | ||
|
||
/** | ||
* Returns number of files in the snapshot that were processed so far | ||
*/ | ||
public int getProcessedFiles() { | ||
return processedFiles; | ||
public int getProcessedFileCount() { | ||
return processedFileCount; | ||
} | ||
|
||
/** | ||
* Return incremental files size of the snapshot | ||
*/ | ||
public long getIncrementalSize() { | ||
return incrementalSize; | ||
} | ||
|
||
/** | ||
|
@@ -105,59 +126,109 @@ public void writeTo(StreamOutput out) throws IOException { | |
out.writeVLong(startTime); | ||
out.writeVLong(time); | ||
|
||
out.writeVInt(numberOfFiles); | ||
out.writeVInt(processedFiles); | ||
out.writeVInt(incrementalFileCount); | ||
out.writeVInt(processedFileCount); | ||
|
||
out.writeVLong(totalSize); | ||
out.writeVLong(incrementalSize); | ||
out.writeVLong(processedSize); | ||
|
||
if (out.getVersion().onOrAfter(Version.V_7_0_0_alpha1)) { | ||
out.writeVInt(totalFileCount); | ||
out.writeVLong(totalSize); | ||
} | ||
} | ||
|
||
@Override | ||
public void readFrom(StreamInput in) throws IOException { | ||
startTime = in.readVLong(); | ||
time = in.readVLong(); | ||
|
||
numberOfFiles = in.readVInt(); | ||
processedFiles = in.readVInt(); | ||
incrementalFileCount = in.readVInt(); | ||
processedFileCount = in.readVInt(); | ||
|
||
totalSize = in.readVLong(); | ||
incrementalSize = in.readVLong(); | ||
processedSize = in.readVLong(); | ||
|
||
if (in.getVersion().onOrAfter(Version.V_7_0_0_alpha1)) { | ||
totalFileCount = in.readVInt(); | ||
totalSize = in.readVLong(); | ||
} else { | ||
totalFileCount = incrementalFileCount; | ||
totalSize = incrementalSize; | ||
} | ||
} | ||
|
||
static final class Fields { | ||
static final String STATS = "stats"; | ||
|
||
static final String INCREMENTAL = "incremental"; | ||
static final String PROCESSED = "processed"; | ||
static final String TOTAL = "total"; | ||
|
||
static final String FILE_COUNT = "file_count"; | ||
static final String SIZE = "size"; | ||
static final String SIZE_IN_BYTES = "size_in_bytes"; | ||
|
||
static final String START_TIME_IN_MILLIS = "start_time_in_millis"; | ||
static final String TIME_IN_MILLIS = "time_in_millis"; | ||
static final String TIME = "time"; | ||
|
||
// BWC | ||
static final String NUMBER_OF_FILES = "number_of_files"; | ||
static final String PROCESSED_FILES = "processed_files"; | ||
static final String TOTAL_SIZE_IN_BYTES = "total_size_in_bytes"; | ||
static final String TOTAL_SIZE = "total_size"; | ||
static final String TOTAL_SIZE_IN_BYTES = "total_size_in_bytes"; | ||
static final String PROCESSED_SIZE_IN_BYTES = "processed_size_in_bytes"; | ||
static final String PROCESSED_SIZE = "processed_size"; | ||
static final String START_TIME_IN_MILLIS = "start_time_in_millis"; | ||
static final String TIME_IN_MILLIS = "time_in_millis"; | ||
static final String TIME = "time"; | ||
|
||
} | ||
|
||
@Override | ||
public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws IOException { | ||
builder.startObject(Fields.STATS); | ||
builder.field(Fields.NUMBER_OF_FILES, getNumberOfFiles()); | ||
builder.field(Fields.PROCESSED_FILES, getProcessedFiles()); | ||
builder.humanReadableField(Fields.TOTAL_SIZE_IN_BYTES, Fields.TOTAL_SIZE, new ByteSizeValue(getTotalSize())); | ||
builder.humanReadableField(Fields.PROCESSED_SIZE_IN_BYTES, Fields.PROCESSED_SIZE, new ByteSizeValue(getProcessedSize())); | ||
builder.field(Fields.START_TIME_IN_MILLIS, getStartTime()); | ||
builder.humanReadableField(Fields.TIME_IN_MILLIS, Fields.TIME, new TimeValue(getTime())); | ||
builder.endObject(); | ||
return builder; | ||
builder.startObject(Fields.STATS) | ||
// incremental starts | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you mean "stats", not "starts"? Idem for the other comments in this method There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nope, i meant "starts" as "begins" There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. right, ok |
||
.startObject(Fields.INCREMENTAL) | ||
.field(Fields.FILE_COUNT, getIncrementalFileCount()) | ||
.humanReadableField(Fields.SIZE_IN_BYTES, Fields.SIZE, new ByteSizeValue(getIncrementalSize())) | ||
// incremental ends | ||
.endObject(); | ||
|
||
if (getProcessedFileCount() != getIncrementalFileCount()) { | ||
// processed starts | ||
builder.startObject(Fields.PROCESSED) | ||
.field(Fields.FILE_COUNT, getProcessedFileCount()) | ||
.humanReadableField(Fields.SIZE_IN_BYTES, Fields.SIZE, new ByteSizeValue(getProcessedSize())) | ||
// processed ends | ||
.endObject(); | ||
} | ||
// total starts | ||
builder.startObject(Fields.TOTAL) | ||
.field(Fields.FILE_COUNT, getTotalFileCount()) | ||
.humanReadableField(Fields.SIZE_IN_BYTES, Fields.SIZE, new ByteSizeValue(getTotalSize())) | ||
// total ends | ||
.endObject(); | ||
// timings stats | ||
builder.field(Fields.START_TIME_IN_MILLIS, getStartTime()) | ||
.humanReadableField(Fields.TIME_IN_MILLIS, Fields.TIME, new TimeValue(getTime())); | ||
|
||
// BWC part | ||
return builder.field(Fields.NUMBER_OF_FILES, getIncrementalFileCount()) | ||
.field(Fields.PROCESSED_FILES, getProcessedFileCount()) | ||
.humanReadableField(Fields.TOTAL_SIZE_IN_BYTES, Fields.TOTAL_SIZE, new ByteSizeValue(getIncrementalSize())) | ||
.humanReadableField(Fields.PROCESSED_SIZE_IN_BYTES, Fields.PROCESSED_SIZE, new ByteSizeValue(getProcessedSize())) | ||
// BWC part ends | ||
.endObject(); | ||
} | ||
|
||
void add(SnapshotStats stats) { | ||
numberOfFiles += stats.numberOfFiles; | ||
processedFiles += stats.processedFiles; | ||
incrementalFileCount += stats.incrementalFileCount; | ||
totalFileCount += stats.totalFileCount; | ||
processedFileCount += stats.processedFileCount; | ||
|
||
incrementalSize += stats.incrementalSize; | ||
totalSize += stats.totalSize; | ||
processedSize += stats.processedSize; | ||
|
||
|
||
if (startTime == 0) { | ||
// First time here | ||
startTime = stats.startTime; | ||
|
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.
dot at the end of sentence