add completed count to thread pools
This commit is contained in:
parent
e1679b89bb
commit
2094207bf1
|
@ -140,18 +140,20 @@ public class ThreadPool extends AbstractComponent {
|
||||||
int active = -1;
|
int active = -1;
|
||||||
long rejected = -1;
|
long rejected = -1;
|
||||||
int largest = -1;
|
int largest = -1;
|
||||||
|
long completed = -1;
|
||||||
if (holder.executor instanceof ThreadPoolExecutor) {
|
if (holder.executor instanceof ThreadPoolExecutor) {
|
||||||
ThreadPoolExecutor threadPoolExecutor = (ThreadPoolExecutor) holder.executor;
|
ThreadPoolExecutor threadPoolExecutor = (ThreadPoolExecutor) holder.executor;
|
||||||
threads = threadPoolExecutor.getPoolSize();
|
threads = threadPoolExecutor.getPoolSize();
|
||||||
queue = threadPoolExecutor.getQueue().size();
|
queue = threadPoolExecutor.getQueue().size();
|
||||||
active = threadPoolExecutor.getActiveCount();
|
active = threadPoolExecutor.getActiveCount();
|
||||||
largest = threadPoolExecutor.getLargestPoolSize();
|
largest = threadPoolExecutor.getLargestPoolSize();
|
||||||
|
completed = threadPoolExecutor.getCompletedTaskCount();
|
||||||
RejectedExecutionHandler rejectedExecutionHandler = threadPoolExecutor.getRejectedExecutionHandler();
|
RejectedExecutionHandler rejectedExecutionHandler = threadPoolExecutor.getRejectedExecutionHandler();
|
||||||
if (rejectedExecutionHandler instanceof XRejectedExecutionHandler) {
|
if (rejectedExecutionHandler instanceof XRejectedExecutionHandler) {
|
||||||
rejected = ((XRejectedExecutionHandler) rejectedExecutionHandler).rejected();
|
rejected = ((XRejectedExecutionHandler) rejectedExecutionHandler).rejected();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stats.add(new ThreadPoolStats.Stats(name, threads, queue, active, rejected, largest));
|
stats.add(new ThreadPoolStats.Stats(name, threads, queue, active, rejected, largest, completed));
|
||||||
}
|
}
|
||||||
return new ThreadPoolStats(stats);
|
return new ThreadPoolStats(stats);
|
||||||
}
|
}
|
||||||
|
@ -481,8 +483,8 @@ public class ThreadPool extends AbstractComponent {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readFrom(StreamInput in) throws IOException {
|
public void readFrom(StreamInput in) throws IOException {
|
||||||
name = in.readUTF();
|
name = in.readString();
|
||||||
type = in.readUTF();
|
type = in.readString();
|
||||||
min = in.readInt();
|
min = in.readInt();
|
||||||
max = in.readInt();
|
max = in.readInt();
|
||||||
if (in.readBoolean()) {
|
if (in.readBoolean()) {
|
||||||
|
@ -495,8 +497,8 @@ public class ThreadPool extends AbstractComponent {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeTo(StreamOutput out) throws IOException {
|
public void writeTo(StreamOutput out) throws IOException {
|
||||||
out.writeUTF(name);
|
out.writeString(name);
|
||||||
out.writeUTF(type);
|
out.writeString(type);
|
||||||
out.writeInt(min);
|
out.writeInt(min);
|
||||||
out.writeInt(max);
|
out.writeInt(max);
|
||||||
if (keepAlive == null) {
|
if (keepAlive == null) {
|
||||||
|
|
|
@ -43,18 +43,20 @@ public class ThreadPoolStats implements Streamable, ToXContent, Iterable<ThreadP
|
||||||
private int active;
|
private int active;
|
||||||
private long rejected;
|
private long rejected;
|
||||||
private int largest;
|
private int largest;
|
||||||
|
private long completed;
|
||||||
|
|
||||||
Stats() {
|
Stats() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Stats(String name, int threads, int queue, int active, long rejected, int largest) {
|
public Stats(String name, int threads, int queue, int active, long rejected, int largest, long completed) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.threads = threads;
|
this.threads = threads;
|
||||||
this.queue = queue;
|
this.queue = queue;
|
||||||
this.active = active;
|
this.active = active;
|
||||||
this.rejected = rejected;
|
this.rejected = rejected;
|
||||||
this.largest = largest;
|
this.largest = largest;
|
||||||
|
this.completed = completed;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String name() {
|
public String name() {
|
||||||
|
@ -105,6 +107,14 @@ public class ThreadPoolStats implements Streamable, ToXContent, Iterable<ThreadP
|
||||||
return largest;
|
return largest;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public long completed() {
|
||||||
|
return this.completed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getCompleted() {
|
||||||
|
return this.completed;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readFrom(StreamInput in) throws IOException {
|
public void readFrom(StreamInput in) throws IOException {
|
||||||
name = in.readString();
|
name = in.readString();
|
||||||
|
@ -113,6 +123,7 @@ public class ThreadPoolStats implements Streamable, ToXContent, Iterable<ThreadP
|
||||||
active = in.readInt();
|
active = in.readInt();
|
||||||
rejected = in.readLong();
|
rejected = in.readLong();
|
||||||
largest = in.readInt();
|
largest = in.readInt();
|
||||||
|
completed = in.readLong();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -123,6 +134,7 @@ public class ThreadPoolStats implements Streamable, ToXContent, Iterable<ThreadP
|
||||||
out.writeInt(active);
|
out.writeInt(active);
|
||||||
out.writeLong(rejected);
|
out.writeLong(rejected);
|
||||||
out.writeInt(largest);
|
out.writeInt(largest);
|
||||||
|
out.writeLong(completed);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -143,6 +155,9 @@ public class ThreadPoolStats implements Streamable, ToXContent, Iterable<ThreadP
|
||||||
if (largest != -1) {
|
if (largest != -1) {
|
||||||
builder.field(Fields.LARGEST, rejected);
|
builder.field(Fields.LARGEST, rejected);
|
||||||
}
|
}
|
||||||
|
if (completed != -1) {
|
||||||
|
builder.field(Fields.COMPLETED, completed);
|
||||||
|
}
|
||||||
builder.endObject();
|
builder.endObject();
|
||||||
return builder;
|
return builder;
|
||||||
}
|
}
|
||||||
|
@ -195,6 +210,7 @@ public class ThreadPoolStats implements Streamable, ToXContent, Iterable<ThreadP
|
||||||
static final XContentBuilderString ACTIVE = new XContentBuilderString("active");
|
static final XContentBuilderString ACTIVE = new XContentBuilderString("active");
|
||||||
static final XContentBuilderString REJECTED = new XContentBuilderString("rejected");
|
static final XContentBuilderString REJECTED = new XContentBuilderString("rejected");
|
||||||
static final XContentBuilderString LARGEST = new XContentBuilderString("largest");
|
static final XContentBuilderString LARGEST = new XContentBuilderString("largest");
|
||||||
|
static final XContentBuilderString COMPLETED = new XContentBuilderString("completed");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue