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