Search in sources :

Example 1 with SystemInfoSection

use of org.sonar.process.systeminfo.SystemInfoSection in project sonarqube by SonarSource.

the class SystemInfoHttpAction method serve.

@Override
public NanoHTTPD.Response serve(NanoHTTPD.IHTTPSession session) {
    if (session.getMethod() != NanoHTTPD.Method.GET) {
        return newFixedLengthResponse(METHOD_NOT_ALLOWED, MIME_PLAINTEXT, null);
    }
    ProtobufSystemInfo.SystemInfo.Builder infoBuilder = ProtobufSystemInfo.SystemInfo.newBuilder();
    for (SystemInfoSection sectionProvider : sectionProviders) {
        ProtobufSystemInfo.Section section = sectionProvider.toProtobuf();
        infoBuilder.addSections(section);
    }
    byte[] bytes = infoBuilder.build().toByteArray();
    return newFixedLengthResponse(OK, PROTOBUF_MIME_TYPE, new ByteArrayInputStream(bytes), bytes.length);
}
Also used : ProtobufSystemInfo(org.sonar.process.systeminfo.protobuf.ProtobufSystemInfo) ProtobufSystemInfo(org.sonar.process.systeminfo.protobuf.ProtobufSystemInfo) ByteArrayInputStream(java.io.ByteArrayInputStream) SystemInfoSection(org.sonar.process.systeminfo.SystemInfoSection)

Aggregations

ByteArrayInputStream (java.io.ByteArrayInputStream)1 SystemInfoSection (org.sonar.process.systeminfo.SystemInfoSection)1 ProtobufSystemInfo (org.sonar.process.systeminfo.protobuf.ProtobufSystemInfo)1