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

Include size of snapshot in snapshot metadata #29602

Merged
merged 25 commits into from
May 25, 2018
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
6bcfcb8
Include size of snapshot in snapshot metadata
vladimirdolzhenko Apr 18, 2018
a08c807
Include size of snapshot in snapshot metadata - changes on Yannick's PR
vladimirdolzhenko Apr 19, 2018
50d7c78
Include size of snapshot in snapshot metadata - changes on 2nd Yannic…
vladimirdolzhenko Apr 20, 2018
6ea7e01
Include size of snapshot in snapshot metadata - changes on 3nd Yannic…
vladimirdolzhenko Apr 20, 2018
4ca0ba9
Include size of snapshot in snapshot metadata #29602
May 11, 2018
7ab7262
Include size of snapshot in snapshot metadata #29602
May 11, 2018
9a839f3
Revert "Include size of snapshot in snapshot metadata #29602"
May 11, 2018
4a0bbc7
Include size of snapshot in snapshot metadata #29602
May 11, 2018
3ebc769
#29602 added snapshot stats section to docs
May 14, 2018
828bb12
#18543 use "file_count" to eliminate "incremental", "processed" and "…
May 15, 2018
5582562
origin/master merged
May 17, 2018
f3c2306
fix doc generation
May 22, 2018
39e0190
adjusted docs, some comments
May 22, 2018
34243af
added section for 7.0 migration
May 23, 2018
816c7d9
Merge remote-tracking branch 'remotes/origin/master' into fix/18543
May 23, 2018
d13d991
Merge remote-tracking branch 'remotes/origin/master' into fix/18543
May 23, 2018
76fe2ac
typos fixed
May 23, 2018
c86c6e5
Merge remote-tracking branch 'remotes/origin/master' into fix/18543
May 23, 2018
4176564
Merge remote-tracking branch 'remotes/origin/master' into fix/18543
May 24, 2018
c05b191
added REST API test for snapshot/status (suspended before backporting…
May 25, 2018
563bea7
Merge remote-tracking branch 'remotes/origin/master' into fix/18543
May 25, 2018
e1400a8
added REST API test for snapshot/status with BWC fields
May 25, 2018
ccf7b22
fixed matching of time_in_millis/start_time_in_millis
May 25, 2018
f2a33d6
fix snapshot name for bwc test
May 25, 2018
7df83ef
fix snapshot name for bwc test
May 25, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ private SnapshotIndexShardStatus() {
throw new IllegalArgumentException("Unknown stage type " + indexShardStatus.getStage());
}
this.stats = new SnapshotStats(indexShardStatus.getStartTime(), indexShardStatus.getTotalTime(),
indexShardStatus.getNumberOfFiles(), indexShardStatus.getProcessedFiles(),
indexShardStatus.getTotalSize(), indexShardStatus.getProcessedSize());
indexShardStatus.getIncrementalFileCount(), indexShardStatus.getTotalFileCount(), indexShardStatus.getProcessedFileCount(),
indexShardStatus.getIncrementalSize(), indexShardStatus.getTotalSize(), indexShardStatus.getProcessedSize());
this.failure = indexShardStatus.getFailure();
this.nodeId = nodeId;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}
Expand All @@ -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;
}

/**
Expand Down Expand Up @@ -105,29 +126,45 @@ public void writeTo(StreamOutput out) throws IOException {
out.writeVLong(startTime);
out.writeVLong(time);

out.writeVInt(numberOfFiles);
out.writeVInt(processedFiles);
out.writeVInt(totalFileCount);
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn't this be the incrementalFileCount?

out.writeVInt(processedFileCount);

out.writeVLong(totalSize);
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this be incrementalSize now?

out.writeVLong(processedSize);

if (out.getVersion().onOrAfter(Version.V_7_0_0_alpha1)) {
out.writeVInt(incrementalFileCount);
out.writeVLong(incrementalSize);
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this be totalFileCount and totalSize here? (That's the new stats that we've added)

}
}

@Override
public void readFrom(StreamInput in) throws IOException {
startTime = in.readVLong();
time = in.readVLong();

numberOfFiles = in.readVInt();
processedFiles = in.readVInt();
totalFileCount = in.readVInt();
processedFileCount = in.readVInt();

totalSize = in.readVLong();
processedSize = in.readVLong();

if (in.getVersion().onOrAfter(Version.V_7_0_0_alpha1)) {
incrementalFileCount = in.readVInt();
incrementalSize = in.readVLong();
} else {
incrementalFileCount = totalFileCount;
incrementalSize = totalSize;
Copy link
Contributor

Choose a reason for hiding this comment

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

same comments here as above.

}
}

static final class Fields {
static final String STATS = "stats";
static final String NUMBER_OF_FILES = "number_of_files";
static final String PROCESSED_FILES = "processed_files";
static final String INCREMENTAL_FILE_COUNT = "incremental_file_count";
static final String TOTAL_FILE_COUNT = "total_file_count";
static final String PROCESSED_FILE_COUNT = "processed_file_count";
static final String INCREMENTAL_SIZE_IN_BYTES = "incremental_size_in_bytes";
static final String INCREMENTAL_SIZE = "incremental_size";
static final String TOTAL_SIZE_IN_BYTES = "total_size_in_bytes";
static final String TOTAL_SIZE = "total_size";
static final String PROCESSED_SIZE_IN_BYTES = "processed_size_in_bytes";
Expand All @@ -140,8 +177,10 @@ static final class Fields {
@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.field(Fields.INCREMENTAL_FILE_COUNT, getIncrementalFileCount());
builder.field(Fields.TOTAL_FILE_COUNT, getTotalFileCount());
builder.field(Fields.PROCESSED_FILE_COUNT, getProcessedFileCount());
builder.humanReadableField(Fields.INCREMENTAL_SIZE_IN_BYTES, Fields.INCREMENTAL_SIZE, new ByteSizeValue(getIncrementalSize()));
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());
Expand All @@ -151,13 +190,14 @@ public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params par
}

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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,31 +60,39 @@ public enum Stage {
private final AtomicReference<Stage> stage;
private long startTime;
private long totalTime;
private int numberOfFiles;
private int processedFiles;
private int incrementalFileCount;
private int totalFileCount;
private int processedFileCount;
private long totalSize;
private long incrementalSize;
private long processedSize;
private long indexVersion;
private String failure;

private IndexShardSnapshotStatus(final Stage stage, final long startTime, final long totalTime,
final int numberOfFiles, final int processedFiles, final long totalSize, final long processedSize,
final int incrementalFileCount, final int totalFileCount, final int processedFileCount,
final long incrementalSize, final long totalSize, final long processedSize,
final long indexVersion, final String failure) {
this.stage = new AtomicReference<>(Objects.requireNonNull(stage));
this.startTime = startTime;
this.totalTime = totalTime;
this.numberOfFiles = numberOfFiles;
this.processedFiles = processedFiles;
this.incrementalFileCount = incrementalFileCount;
this.totalFileCount = totalFileCount;
this.processedFileCount = processedFileCount;
this.totalSize = totalSize;
this.processedSize = processedSize;
this.incrementalSize = incrementalSize;
this.indexVersion = indexVersion;
this.failure = failure;
}

public synchronized Copy moveToStarted(final long startTime, final int numberOfFiles, final long totalSize) {
public synchronized Copy moveToStarted(final long startTime, final int incrementalFileCount, final int totalFileCount,
final long incrementalSize, final long totalSize) {
if (stage.compareAndSet(Stage.INIT, Stage.STARTED)) {
this.startTime = startTime;
this.numberOfFiles = numberOfFiles;
this.incrementalFileCount = incrementalFileCount;
this.totalFileCount = totalFileCount;
this.incrementalSize = incrementalSize;
this.totalSize = totalSize;
} else {
throw new IllegalStateException("Unable to move the shard snapshot status to [STARTED]: " +
Expand Down Expand Up @@ -135,7 +143,7 @@ public boolean isAborted() {
* Increments number of processed files
*/
public synchronized void addProcessedFile(long size) {
processedFiles++;
processedFileCount++;
processedSize += size;
}

Expand All @@ -146,25 +154,30 @@ public synchronized void addProcessedFile(long size) {
* @return a {@link IndexShardSnapshotStatus.Copy}
*/
public synchronized IndexShardSnapshotStatus.Copy asCopy() {
return new IndexShardSnapshotStatus.Copy(stage.get(), startTime, totalTime, numberOfFiles, processedFiles, totalSize, processedSize,
indexVersion, failure);
return new IndexShardSnapshotStatus.Copy(stage.get(), startTime, totalTime,
incrementalFileCount, totalFileCount, processedFileCount,
incrementalSize, totalSize, processedSize,
indexVersion, failure);
}

public static IndexShardSnapshotStatus newInitializing() {
return new IndexShardSnapshotStatus(Stage.INIT, 0L, 0L, 0, 0, 0, 0, 0, null);
return new IndexShardSnapshotStatus(Stage.INIT, 0L, 0L, 0, 0, 0, 0, 0, 0, 0, null);
}

public static IndexShardSnapshotStatus newFailed(final String failure) {
assert failure != null : "expecting non null failure for a failed IndexShardSnapshotStatus";
if (failure == null) {
throw new IllegalArgumentException("A failure description is required for a failed IndexShardSnapshotStatus");
}
return new IndexShardSnapshotStatus(Stage.FAILURE, 0L, 0L, 0, 0, 0, 0, 0, failure);
return new IndexShardSnapshotStatus(Stage.FAILURE, 0L, 0L, 0, 0, 0, 0, 0, 0, 0, failure);
}

public static IndexShardSnapshotStatus newDone(final long startTime, final long totalTime, final int files, final long size) {
public static IndexShardSnapshotStatus newDone(final long startTime, final long totalTime,
final int incrementalFileCount, final int fileCount,
final long incrementalSize, final long size) {
// The snapshot is done which means the number of processed files is the same as total
return new IndexShardSnapshotStatus(Stage.DONE, startTime, totalTime, files, files, size, size, 0, null);
return new IndexShardSnapshotStatus(Stage.DONE, startTime, totalTime, incrementalFileCount, fileCount, incrementalFileCount,
incrementalSize, size, incrementalSize, 0, null);
}

/**
Expand All @@ -175,23 +188,28 @@ public static class Copy {
private final Stage stage;
private final long startTime;
private final long totalTime;
private final int numberOfFiles;
private final int processedFiles;
private final int incrementalFileCount;
private final int totalFileCount;
private final int processedFileCount;
private final long totalSize;
private final long processedSize;
private final long incrementalSize;
private final long indexVersion;
private final String failure;

public Copy(final Stage stage, final long startTime, final long totalTime,
final int numberOfFiles, final int processedFiles, final long totalSize, final long processedSize,
final int incrementalFileCount, final int totalFileCount, final int processedFileCount,
final long incrementalSize, final long totalSize, final long processedSize,
final long indexVersion, final String failure) {
this.stage = stage;
this.startTime = startTime;
this.totalTime = totalTime;
this.numberOfFiles = numberOfFiles;
this.processedFiles = processedFiles;
this.incrementalFileCount = incrementalFileCount;
this.totalFileCount = totalFileCount;
this.processedFileCount = processedFileCount;
this.totalSize = totalSize;
this.processedSize = processedSize;
this.incrementalSize = incrementalSize;
this.indexVersion = indexVersion;
this.failure = failure;
}
Expand All @@ -208,12 +226,20 @@ public long getTotalTime() {
return totalTime;
}

public int getNumberOfFiles() {
return numberOfFiles;
public int getIncrementalFileCount() {
return incrementalFileCount;
}

public int getProcessedFiles() {
return processedFiles;
public int getTotalFileCount() {
return totalFileCount;
}

public int getProcessedFileCount() {
return processedFileCount;
}

public long getIncrementalSize() {
return incrementalSize;
}

public long getTotalSize() {
Expand All @@ -238,8 +264,10 @@ public String toString() {
"stage=" + stage +
", startTime=" + startTime +
", totalTime=" + totalTime +
", numberOfFiles=" + numberOfFiles +
", processedFiles=" + processedFiles +
", incrementalFileCount=" + incrementalFileCount +
", totalFileCount=" + totalFileCount +
", processedFileCount=" + processedFileCount +
", incrementalSize=" + incrementalSize +
", totalSize=" + totalSize +
", processedSize=" + processedSize +
", indexVersion=" + indexVersion +
Expand Down
Loading