@Override public String validate(String setting, String value, ClusterState clusterState) { // TODO: the type equality validation can be removed after #3760/#6732 are addressed Matcher matcher = Pattern.compile("threadpool\\.(.*)\\.type").matcher(setting); if (!matcher.matches()) { return null; } else { String threadPool = matcher.group(1); ThreadPool.ThreadPoolType defaultThreadPoolType = ThreadPool.THREAD_POOL_TYPES.get(threadPool); ThreadPool.ThreadPoolType threadPoolType; try { threadPoolType = ThreadPool.ThreadPoolType.fromType(value); } catch (IllegalArgumentException e) { return e.getMessage(); } if (defaultThreadPoolType.equals(threadPoolType)) { return null; } else { return String.format( Locale.ROOT, "thread pool type for [%s] can only be updated to [%s] but was [%s]", threadPool, defaultThreadPoolType.getType(), threadPoolType.getType() ); } } } }
String type = settings.get("type", previousInfo != null ? previousInfo.getThreadPoolType().getType() : defaultSettings.get("type")); ThreadPoolType threadPoolType = ThreadPoolType.fromType(type); ThreadFactory threadFactory = EsExecutors.daemonThreadFactory(this.settings, name); if (ThreadPoolType.DIRECT == threadPoolType) {
table.addCell(poolInfo == null ? null : poolInfo.getThreadPoolType().getType()); table.addCell(poolStats == null ? null : poolStats.getActive()); table.addCell(poolStats == null ? null : poolStats.getThreads());
table.addCell(poolInfo == null ? null : poolInfo.getThreadPoolType().getType()); table.addCell(poolStats == null ? null : poolStats.getActive()); table.addCell(poolStats == null ? null : poolStats.getThreads());
table.addCell(poolInfo == null ? null : poolInfo.getThreadPoolType().getType()); table.addCell(poolStats == null ? null : poolStats.getActive()); table.addCell(poolStats == null ? null : poolStats.getThreads());
table.addCell(poolInfo == null ? null : poolInfo.getThreadPoolType().getType()); table.addCell(poolStats == null ? null : poolStats.getActive()); table.addCell(poolStats == null ? null : poolStats.getThreads());
if (!executors.get(Names.GENERIC).info.getThreadPoolType().equals(ThreadPoolType.CACHED)) { throw new IllegalArgumentException("generic thread pool must be of type cached");
@Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(name, XContentBuilder.FieldCaseConversion.NONE); builder.field(Fields.TYPE, type.getType()); if (min != -1) { builder.field(Fields.MIN, min); } if (max != -1) { builder.field(Fields.MAX, max); } if (keepAlive != null) { builder.field(Fields.KEEP_ALIVE, keepAlive.toString()); } if (queueSize == null) { builder.field(Fields.QUEUE_SIZE, -1); } else { builder.field(Fields.QUEUE_SIZE, queueSize.singles()); } builder.endObject(); return builder; }
@Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(name); builder.field(Fields.TYPE, type.getType()); if (min != -1) { builder.field(Fields.MIN, min); } if (max != -1) { builder.field(Fields.MAX, max); } if (keepAlive != null) { builder.field(Fields.KEEP_ALIVE, keepAlive.toString()); } if (queueSize == null) { builder.field(Fields.QUEUE_SIZE, -1); } else { builder.field(Fields.QUEUE_SIZE, queueSize.singles()); } builder.endObject(); return builder; }
@Override public void writeTo(StreamOutput out) throws IOException { out.writeString(name); out.writeString(type.getType()); out.writeInt(min); out.writeInt(max); if (keepAlive == null) { out.writeBoolean(false); } else { out.writeBoolean(true); keepAlive.writeTo(out); } if (queueSize == null) { out.writeBoolean(false); } else { out.writeBoolean(true); queueSize.writeTo(out); } out.writeBoolean(false); // here to conform with removed waitTime out.writeBoolean(false); // here to conform with removed rejected setting out.writeBoolean(false); // here to conform with queue type }
@Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(name); builder.field(Fields.TYPE, type.getType()); if (min != -1) { builder.field(Fields.MIN, min); } if (max != -1) { builder.field(Fields.MAX, max); } if (keepAlive != null) { builder.field(Fields.KEEP_ALIVE, keepAlive.toString()); } if (queueSize == null) { builder.field(Fields.QUEUE_SIZE, -1); } else { builder.field(Fields.QUEUE_SIZE, queueSize.singles()); } builder.endObject(); return builder; }
@Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(name); builder.field(Fields.TYPE, type.getType()); if (min != -1) { builder.field(Fields.MIN, min); } if (max != -1) { builder.field(Fields.MAX, max); } if (keepAlive != null) { builder.field(Fields.KEEP_ALIVE, keepAlive.toString()); } if (queueSize == null) { builder.field(Fields.QUEUE_SIZE, -1); } else { builder.field(Fields.QUEUE_SIZE, queueSize.singles()); } builder.endObject(); return builder; }
@Override public void readFrom(StreamInput in) throws IOException { name = in.readString(); type = ThreadPoolType.fromType(in.readString()); min = in.readInt(); max = in.readInt(); if (in.readBoolean()) { keepAlive = TimeValue.readTimeValue(in); } if (in.readBoolean()) { queueSize = SizeValue.readSizeValue(in); } in.readBoolean(); // here to conform with removed waitTime in.readBoolean(); // here to conform with removed rejected setting in.readBoolean(); // here to conform with queue type }
@Override public void writeTo(StreamOutput out) throws IOException { out.writeString(name); if (type == ThreadPoolType.FIXED_AUTO_QUEUE_SIZE && out.getVersion().before(Version.V_6_0_0_alpha1)) { // 5.x doesn't know about the "fixed_auto_queue_size" thread pool type, just write fixed. out.writeString(ThreadPoolType.FIXED.getType()); } else { out.writeString(type.getType()); } out.writeInt(min); out.writeInt(max); out.writeOptionalTimeValue(keepAlive); out.writeOptionalWriteable(queueSize); }
@Override public void writeTo(StreamOutput out) throws IOException { out.writeString(name); if (type == ThreadPoolType.FIXED_AUTO_QUEUE_SIZE && out.getVersion().before(Version.V_6_0_0_alpha1)) { // 5.x doesn't know about the "fixed_auto_queue_size" thread pool type, just write fixed. out.writeString(ThreadPoolType.FIXED.getType()); } else { out.writeString(type.getType()); } out.writeInt(min); out.writeInt(max); out.writeOptionalTimeValue(keepAlive); out.writeOptionalWriteable(queueSize); }
private void validate(Map<String, Settings> groupSettings) { for (String key : groupSettings.keySet()) { if (!THREAD_POOL_TYPES.containsKey(key)) { continue; } String type = groupSettings.get(key).get("type"); ThreadPoolType correctThreadPoolType = THREAD_POOL_TYPES.get(key); // TODO: the type equality check can be removed after #3760/#6732 are addressed if (type != null && !correctThreadPoolType.getType().equals(type)) { throw new IllegalArgumentException("setting " + THREADPOOL_GROUP + key + ".type to " + type + " is not permitted; must be " + correctThreadPoolType.getType()); } } }
public ExecutorSettingsBuilder(String name) { settings.put("name", name); settings.put("type", THREAD_POOL_TYPES.get(name).getType()); }
@Override public void writeTo(StreamOutput out) throws IOException { out.writeString(name); out.writeString(type.getType()); out.writeInt(min); out.writeInt(max); out.writeOptionalWriteable(keepAlive); out.writeOptionalWriteable(queueSize); }
public Info(StreamInput in) throws IOException { name = in.readString(); type = ThreadPoolType.fromType(in.readString()); min = in.readInt(); max = in.readInt(); keepAlive = in.readOptionalTimeValue(); queueSize = in.readOptionalWriteable(SizeValue::new); }
public Info(StreamInput in) throws IOException { name = in.readString(); type = ThreadPoolType.fromType(in.readString()); min = in.readInt(); max = in.readInt(); keepAlive = in.readOptionalTimeValue(); queueSize = in.readOptionalWriteable(SizeValue::new); }