use of io.questdb.cutlass.http.HttpChunkedResponseSocket in project questdb by bluestreak01.
the class PrometheusMetricsProcessor method onRequestComplete.
@Override
public void onRequestComplete(HttpConnectionContext context) throws PeerDisconnectedException, PeerIsSlowToReadException {
HttpChunkedResponseSocket r = context.getChunkedResponseSocket();
r.status(200, CONTENT_TYPE_TEXT);
r.sendHeader();
metrics.scrapeIntoPrometheus(r);
r.done();
}
use of io.questdb.cutlass.http.HttpChunkedResponseSocket in project questdb by bluestreak01.
the class TableStatusCheckProcessor method onRequestComplete.
@Override
public void onRequestComplete(HttpConnectionContext context) throws PeerDisconnectedException, PeerIsSlowToReadException {
CharSequence tableName = context.getRequestHeader().getUrlParam("j");
if (tableName == null) {
context.simpleResponse().sendStatus(200, "table name missing");
} else {
int check = cairoEngine.getStatus(context.getCairoSecurityContext(), path, tableName);
if (Chars.equalsNc("json", context.getRequestHeader().getUrlParam("f"))) {
HttpChunkedResponseSocket r = context.getChunkedResponseSocket();
r.status(200, "application/json");
r.headers().put(keepAliveHeader);
r.sendHeader();
r.put('{').putQuoted("status").put(':').putQuoted(toResponse(check)).put('}');
r.sendChunk(true);
} else {
context.simpleResponse().sendStatus(200, toResponse(check));
}
}
}
use of io.questdb.cutlass.http.HttpChunkedResponseSocket in project questdb by bluestreak01.
the class JsonQueryProcessorState method of.
boolean of(RecordCursorFactory factory, SqlExecutionContextImpl sqlExecutionContext) throws PeerDisconnectedException, PeerIsSlowToReadException, SqlException {
this.recordCursorFactory = factory;
queryCacheable = true;
this.cursor = factory.getCursor(sqlExecutionContext);
final RecordMetadata metadata = factory.getMetadata();
HttpRequestHeader header = httpConnectionContext.getRequestHeader();
DirectByteCharSequence columnNames = header.getUrlParam("cols");
int columnCount;
columnSkewList.clear();
if (columnNames != null) {
columnsQueryParameter.clear();
try {
TextUtil.utf8Decode(columnNames.getLo(), columnNames.getHi(), columnsQueryParameter);
} catch (Utf8Exception e) {
info().$("utf8 error when decoding column list '").$(columnNames).$('\'').$();
HttpChunkedResponseSocket socket = getHttpConnectionContext().getChunkedResponseSocket();
JsonQueryProcessor.header(socket, "");
socket.put('{').putQuoted("error").put(':').putQuoted("utf8 error in column list");
socket.put('}');
socket.sendChunk(true);
return false;
}
columnCount = 1;
int start = 0;
int comma = 0;
while (comma > -1) {
comma = Chars.indexOf(columnsQueryParameter, start, ',');
if (comma > -1) {
if (addColumnToOutput(metadata, columnsQueryParameter, start, comma)) {
return false;
}
start = comma + 1;
columnCount++;
} else {
int hi = columnsQueryParameter.length();
if (addColumnToOutput(metadata, columnsQueryParameter, start, hi)) {
return false;
}
}
}
} else {
columnCount = metadata.getColumnCount();
for (int i = 0; i < columnCount; i++) {
addColumnTypeAndName(metadata, i);
}
}
this.columnCount = columnCount;
return true;
}
use of io.questdb.cutlass.http.HttpChunkedResponseSocket in project questdb by bluestreak01.
the class HealthCheckProcessor method onRequestComplete.
@Override
public void onRequestComplete(HttpConnectionContext context) throws PeerDisconnectedException, PeerIsSlowToReadException {
HttpChunkedResponseSocket r = context.getChunkedResponseSocket();
r.status(200, "text/plain");
r.sendHeader();
r.done();
}
use of io.questdb.cutlass.http.HttpChunkedResponseSocket in project questdb by bluestreak01.
the class JsonQueryProcessorState method addColumnToOutput.
private boolean addColumnToOutput(RecordMetadata metadata, CharSequence columnNames, int start, int hi) throws PeerDisconnectedException, PeerIsSlowToReadException {
if (start == hi) {
info().$("empty column in list '").$(columnNames).$('\'').$();
HttpChunkedResponseSocket socket = getHttpConnectionContext().getChunkedResponseSocket();
JsonQueryProcessor.header(socket, "");
socket.put('{').putQuoted("query").put(':').encodeUtf8AndQuote(query).put(',').putQuoted("error").put(':').putQuoted("empty column in list");
socket.put('}');
socket.sendChunk(true);
return true;
}
int columnIndex = metadata.getColumnIndexQuiet(columnNames, start, hi);
if (columnIndex == RecordMetadata.COLUMN_NOT_FOUND) {
info().$("invalid column in list: '").$(columnNames, start, hi).$('\'').$();
HttpChunkedResponseSocket socket = getHttpConnectionContext().getChunkedResponseSocket();
JsonQueryProcessor.header(socket, "");
socket.put('{').putQuoted("query").put(':').encodeUtf8AndQuote(query).put(',').putQuoted("error").put(':').put('\'').put("invalid column in list: ").put(columnNames, start, hi).put('\'');
socket.put('}');
socket.sendChunk(true);
return true;
}
addColumnTypeAndName(metadata, columnIndex);
this.columnSkewList.add(columnIndex);
return false;
}
Aggregations