Node Stats: Add largest thread pool count per thread pool stats
closes #2382
This commit is contained in:
parent
af1e8c0eb1
commit
33900476f4
|
@ -139,17 +139,19 @@ public class ThreadPool extends AbstractComponent {
|
|||
int queue = -1;
|
||||
int active = -1;
|
||||
long rejected = -1;
|
||||
int largest = -1;
|
||||
if (holder.executor instanceof ThreadPoolExecutor) {
|
||||
ThreadPoolExecutor threadPoolExecutor = (ThreadPoolExecutor) holder.executor;
|
||||
threads = threadPoolExecutor.getPoolSize();
|
||||
queue = threadPoolExecutor.getQueue().size();
|
||||
active = threadPoolExecutor.getActiveCount();
|
||||
largest = threadPoolExecutor.getLargestPoolSize();
|
||||
RejectedExecutionHandler rejectedExecutionHandler = threadPoolExecutor.getRejectedExecutionHandler();
|
||||
if (rejectedExecutionHandler instanceof XRejectedExecutionHandler) {
|
||||
rejected = ((XRejectedExecutionHandler) rejectedExecutionHandler).rejected();
|
||||
}
|
||||
}
|
||||
stats.add(new ThreadPoolStats.Stats(name, threads, queue, active, rejected));
|
||||
stats.add(new ThreadPoolStats.Stats(name, threads, queue, active, rejected, largest));
|
||||
}
|
||||
return new ThreadPoolStats(stats);
|
||||
}
|
||||
|
|
|
@ -42,17 +42,19 @@ public class ThreadPoolStats implements Streamable, ToXContent, Iterable<ThreadP
|
|||
private int queue;
|
||||
private int active;
|
||||
private long rejected;
|
||||
private int largest;
|
||||
|
||||
Stats() {
|
||||
|
||||
}
|
||||
|
||||
public Stats(String name, int threads, int queue, int active, long rejected) {
|
||||
public Stats(String name, int threads, int queue, int active, long rejected, int largest) {
|
||||
this.name = name;
|
||||
this.threads = threads;
|
||||
this.queue = queue;
|
||||
this.active = active;
|
||||
this.rejected = rejected;
|
||||
this.largest = largest;
|
||||
}
|
||||
|
||||
public String name() {
|
||||
|
@ -95,22 +97,32 @@ public class ThreadPoolStats implements Streamable, ToXContent, Iterable<ThreadP
|
|||
return rejected;
|
||||
}
|
||||
|
||||
public int largest() {
|
||||
return largest;
|
||||
}
|
||||
|
||||
public int getLargest() {
|
||||
return largest;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFrom(StreamInput in) throws IOException {
|
||||
name = in.readUTF();
|
||||
name = in.readString();
|
||||
threads = in.readInt();
|
||||
queue = in.readInt();
|
||||
active = in.readInt();
|
||||
rejected = in.readLong();
|
||||
largest = in.readInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
out.writeUTF(name);
|
||||
out.writeString(name);
|
||||
out.writeInt(threads);
|
||||
out.writeInt(queue);
|
||||
out.writeInt(active);
|
||||
out.writeLong(rejected);
|
||||
out.writeInt(largest);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -128,6 +140,9 @@ public class ThreadPoolStats implements Streamable, ToXContent, Iterable<ThreadP
|
|||
if (rejected != -1) {
|
||||
builder.field(Fields.REJECTED, rejected);
|
||||
}
|
||||
if (largest != -1) {
|
||||
builder.field(Fields.LARGEST, rejected);
|
||||
}
|
||||
builder.endObject();
|
||||
return builder;
|
||||
}
|
||||
|
@ -179,6 +194,7 @@ public class ThreadPoolStats implements Streamable, ToXContent, Iterable<ThreadP
|
|||
static final XContentBuilderString QUEUE = new XContentBuilderString("queue");
|
||||
static final XContentBuilderString ACTIVE = new XContentBuilderString("active");
|
||||
static final XContentBuilderString REJECTED = new XContentBuilderString("rejected");
|
||||
static final XContentBuilderString LARGEST = new XContentBuilderString("largest");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue