use of org.elasticsearch.common.unit.SizeValue in project elasticsearch by elastic.
the class FixedExecutorBuilder method build.
@Override
ThreadPool.ExecutorHolder build(final FixedExecutorSettings settings, final ThreadContext threadContext) {
int size = settings.size;
int queueSize = settings.queueSize;
final ThreadFactory threadFactory = EsExecutors.daemonThreadFactory(EsExecutors.threadName(settings.nodeName, name()));
final ExecutorService executor = EsExecutors.newFixed(name(), size, queueSize, threadFactory, threadContext);
final ThreadPool.Info info = new ThreadPool.Info(name(), ThreadPool.ThreadPoolType.FIXED, size, size, null, queueSize < 0 ? null : new SizeValue(queueSize));
return new ThreadPool.ExecutorHolder(executor, info);
}
use of org.elasticsearch.common.unit.SizeValue in project elasticsearch by elastic.
the class RestTable method renderValue.
private static String renderValue(RestRequest request, Object value) {
if (value == null) {
return null;
}
if (value instanceof ByteSizeValue) {
ByteSizeValue v = (ByteSizeValue) value;
String resolution = request.param("bytes");
if ("b".equals(resolution)) {
return Long.toString(v.getBytes());
} else if ("k".equals(resolution) || "kb".equals(resolution)) {
return Long.toString(v.getKb());
} else if ("m".equals(resolution) || "mb".equals(resolution)) {
return Long.toString(v.getMb());
} else if ("g".equals(resolution) || "gb".equals(resolution)) {
return Long.toString(v.getGb());
} else if ("t".equals(resolution) || "tb".equals(resolution)) {
return Long.toString(v.getTb());
} else if ("p".equals(resolution) || "pb".equals(resolution)) {
return Long.toString(v.getPb());
} else {
return v.toString();
}
}
if (value instanceof SizeValue) {
SizeValue v = (SizeValue) value;
String resolution = request.param("size");
if ("".equals(resolution)) {
return Long.toString(v.singles());
} else if ("k".equals(resolution)) {
return Long.toString(v.kilo());
} else if ("m".equals(resolution)) {
return Long.toString(v.mega());
} else if ("g".equals(resolution)) {
return Long.toString(v.giga());
} else if ("t".equals(resolution)) {
return Long.toString(v.tera());
} else if ("p".equals(resolution)) {
return Long.toString(v.peta());
} else {
return v.toString();
}
}
if (value instanceof TimeValue) {
TimeValue v = (TimeValue) value;
String resolution = request.param("time");
if ("nanos".equals(resolution)) {
return Long.toString(v.nanos());
} else if ("micros".equals(resolution)) {
return Long.toString(v.micros());
} else if ("ms".equals(resolution)) {
return Long.toString(v.millis());
} else if ("s".equals(resolution)) {
return Long.toString(v.seconds());
} else if ("m".equals(resolution)) {
return Long.toString(v.minutes());
} else if ("h".equals(resolution)) {
return Long.toString(v.hours());
} else if ("d".equals(resolution)) {
return Long.toString(v.days());
} else {
return v.toString();
}
}
// Add additional built in data points we can render based on request parameters?
return value.toString();
}
use of org.elasticsearch.common.unit.SizeValue in project elasticsearch-skywalker by jprante.
the class RestConsistencyCheckAction method handleRequest.
@Override
public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) throws Exception {
ConsistencyCheckRequest r = new ConsistencyCheckRequest();
client.admin().cluster().execute(ConsistencyCheckAction.INSTANCE, r, new RestResponseListener<ConsistencyCheckResponse>(channel) {
@Override
public RestResponse buildResponse(ConsistencyCheckResponse response) throws Exception {
XContentBuilder builder = XContentFactory.jsonBuilder();
builder.startObject();
builder.field("ok", true);
builder.startObject("state");
response.getState().toXContent(builder, ToXContent.EMPTY_PARAMS);
builder.startArray("files");
for (File file : response.getFiles()) {
Instant instant = new Instant(file.lastModified());
builder.startObject().field("path", file.getAbsolutePath()).field("lastmodified", instant.toDateTime().toString()).field("size", new SizeValue(file.length(), SizeUnit.SINGLE).toString()).field("totalspace", new SizeValue(file.getTotalSpace(), SizeUnit.SINGLE).toString()).field("usablespace", new SizeValue(file.getUsableSpace(), SizeUnit.SINGLE).toString()).field("freespace", new SizeValue(file.getFreeSpace(), SizeUnit.SINGLE).toString()).endObject();
}
builder.endArray();
builder.endObject();
return new BytesRestResponse(OK, builder);
}
});
}
use of org.elasticsearch.common.unit.SizeValue in project crate by crate.
the class FixedExecutorBuilder method build.
@Override
ThreadPool.ExecutorHolder build(final FixedExecutorSettings settings) {
int size = settings.size;
int queueSize = settings.queueSize;
final ThreadFactory threadFactory = EsExecutors.daemonThreadFactory(EsExecutors.threadName(settings.nodeName, name()));
final ExecutorService executor = EsExecutors.newFixed(settings.nodeName + "/" + name(), size, queueSize, threadFactory);
final ThreadPool.Info info = new ThreadPool.Info(name(), ThreadPool.ThreadPoolType.FIXED, size, size, null, queueSize < 0 ? null : new SizeValue(queueSize));
return new ThreadPool.ExecutorHolder(executor, info);
}
Aggregations