-
Notifications
You must be signed in to change notification settings - Fork 25k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Bulk stats track the bulk sizes per shard and the time spent on t…
- Loading branch information
Showing
26 changed files
with
512 additions
and
8 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
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
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
32 changes: 32 additions & 0 deletions
32
server/src/main/java/org/elasticsearch/index/bulk/stats/BulkOperationListener.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,32 @@ | ||
/* | ||
* Licensed to Elasticsearch under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package org.elasticsearch.index.bulk.stats; | ||
|
||
/** | ||
* An bulk operation listener for bulk events. | ||
*/ | ||
public interface BulkOperationListener { | ||
/** | ||
* Called after the bulk operation occurred. | ||
*/ | ||
default void afterBulk(long bulkShardSizeInBytes, long tookInNanos) { | ||
} | ||
} | ||
|
106 changes: 106 additions & 0 deletions
106
server/src/main/java/org/elasticsearch/index/bulk/stats/BulkStats.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,106 @@ | ||
/* | ||
* Licensed to Elasticsearch under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package org.elasticsearch.index.bulk.stats; | ||
|
||
import org.elasticsearch.common.io.stream.StreamInput; | ||
import org.elasticsearch.common.io.stream.StreamOutput; | ||
import org.elasticsearch.common.io.stream.Writeable; | ||
import org.elasticsearch.common.unit.TimeValue; | ||
import org.elasticsearch.common.xcontent.ToXContent; | ||
import org.elasticsearch.common.xcontent.ToXContentFragment; | ||
import org.elasticsearch.common.xcontent.XContentBuilder; | ||
|
||
import java.io.IOException; | ||
|
||
public class BulkStats implements Writeable, ToXContentFragment { | ||
|
||
private long total = 0; | ||
private long totalTimeInMillis = 0; | ||
private long totalSizeInBytes = 0; | ||
|
||
public BulkStats() { | ||
|
||
} | ||
|
||
public BulkStats(StreamInput in) throws IOException { | ||
total = in.readVLong(); | ||
totalTimeInMillis = in.readVLong(); | ||
totalSizeInBytes = in.readVLong(); | ||
} | ||
|
||
public BulkStats(long total, long totalTimeInMillis, long totalSizeInBytes) { | ||
this.total = total; | ||
this.totalTimeInMillis = totalTimeInMillis; | ||
this.totalSizeInBytes = totalSizeInBytes; | ||
} | ||
|
||
public void add(BulkStats bulkStats) { | ||
addTotals(bulkStats); | ||
} | ||
|
||
public void addTotals(BulkStats bulkStats) { | ||
if (bulkStats == null) { | ||
return; | ||
} | ||
this.total += bulkStats.total; | ||
this.totalTimeInMillis += bulkStats.totalTimeInMillis; | ||
this.totalSizeInBytes += bulkStats.totalSizeInBytes; | ||
} | ||
|
||
public long getTotalSizeInBytes() { | ||
return totalSizeInBytes; | ||
} | ||
|
||
public long getTotal() { | ||
return total; | ||
} | ||
|
||
public TimeValue getTotalTime() { | ||
return new TimeValue(totalTimeInMillis); | ||
} | ||
|
||
public long getTotalTimeInMillis() { | ||
return totalTimeInMillis; | ||
} | ||
|
||
@Override public void writeTo(StreamOutput out) throws IOException { | ||
out.writeVLong(total); | ||
out.writeVLong(totalTimeInMillis); | ||
out.writeVLong(totalSizeInBytes); | ||
} | ||
|
||
@Override public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws IOException { | ||
builder.startObject(Fields.BULK); | ||
builder.field(Fields.TOTAL, total); | ||
builder.humanReadableField(Fields.TOTAL_TIME_IN_MILLIS, Fields.TOTAL_TIME, getTotalTime()); | ||
builder.field(Fields.TOTAL_SIZE_IN_BYTES, totalSizeInBytes); | ||
builder.endObject(); | ||
return builder; | ||
} | ||
|
||
static final class Fields { | ||
static final String BULK = "bulk"; | ||
static final String TOTAL = "total"; | ||
static final String TOTAL_TIME = "total_time"; | ||
static final String TOTAL_TIME_IN_MILLIS = "total_time_in_millis"; | ||
static final String TOTAL_SIZE_IN_BYTES = "total_size_in_bytes"; | ||
} | ||
} | ||
|
Oops, something went wrong.