public static void setAttribute(Section.Builder section, String key, long value) { section.addAttributesBuilder() .setKey(key) .setLongValue(value) .build(); }
public static void setAttribute(Section.Builder section, String key, @Nullable Boolean value) { if (value != null) { section.addAttributesBuilder() .setKey(key) .setBooleanValue(value) .build(); } }
public static void setAttribute(Section.Builder section, String key, @Nullable String value) { if (value != null) { section.addAttributesBuilder() .setKey(key) .setStringValue(value) .build(); } }
@Override public Section toProtobuf() { Section.Builder protobuf = Section.newBuilder(); String side = runtime.getSonarQubeSide() == SonarQubeSide.COMPUTE_ENGINE ? "Compute Engine" : "Web"; protobuf.setName(side + " Database Connection"); completePoolAttributes(protobuf); return protobuf.build(); }
@Override public ProtobufSystemInfo.Section toProtobuf() { ProtobufSystemInfo.Section.Builder builder = ProtobufSystemInfo.Section.newBuilder(); builder.setName("Compute Engine Database Connection"); builder.addAttributesBuilder().setKey("Pool Initial Size").setLongValue(getPoolInitialSize()).build(); builder.addAttributesBuilder().setKey("Pool Active Connections").setLongValue(getPoolActiveConnections()).build(); builder.addAttributesBuilder().setKey("Pool Idle Connections").setLongValue(getPoolIdleConnections()).build(); builder.addAttributesBuilder().setKey("Pool Max Active Connections").setLongValue(getPoolMaxActiveConnections()).build(); builder.addAttributesBuilder().setKey("Pool Max Idle Connections").setLongValue(getPoolMaxIdleConnections()).build(); builder.addAttributesBuilder().setKey("Pool Min Idle Connections").setLongValue(getPoolMinIdleConnections()).build(); builder.addAttributesBuilder().setKey("Pool Max Wait (ms)").setLongValue(getPoolMaxWaitMillis()).build(); builder.addAttributesBuilder().setKey("Pool Remove Abandoned").setBooleanValue(getPoolRemoveAbandoned()).build(); builder.addAttributesBuilder().setKey("Pool Remove Abandoned Timeout (sec)").setLongValue(getPoolRemoveAbandonedTimeoutSeconds()).build(); return builder.build(); } }
private static Section createSection(String name) { return Section.newBuilder() .addAttributes(Attribute.newBuilder().setKey("name").setStringValue(name).build()) .build(); } }
@Test public void test_setAttribute_with_boolean_parameter() { Section.Builder builder = Section.newBuilder(); SystemInfoUtils.setAttribute(builder, "isNull", (Boolean)null); SystemInfoUtils.setAttribute(builder, "isTrue", true); SystemInfoUtils.setAttribute(builder, "isFalse", false); Section section = builder.build(); assertThat(SystemInfoUtils.attribute(section, "isNull")).isNull(); assertThat(SystemInfoUtils.attribute(section, "isTrue").getBooleanValue()).isTrue(); assertThat(SystemInfoUtils.attribute(section, "isFalse").getBooleanValue()).isFalse(); }
@Override public ProtobufSystemInfo.Section toProtobuf() { return ProtobufSystemInfo.Section.newBuilder().build(); } }
@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); } }
public static ProtobufSystemInfo.SystemInfo provide() { ProtobufSystemInfo.SystemInfo.Builder protobuf = ProtobufSystemInfo.SystemInfo.newBuilder(); if (instance != null) { instance.sections.forEach(section -> protobuf.addSections(section.toProtobuf())); } return protobuf.build(); } }
public static void setAttribute(Section.Builder section, String key, @Nullable Collection<String> values) { if (values != null) { section.addAttributesBuilder() .setKey(key) .addAllStringValues(values) .build(); } }
@CheckForNull public static ProtobufSystemInfo.Attribute attribute(Section section, String key) { for (ProtobufSystemInfo.Attribute attribute : section.getAttributesList()) { if (attribute.getKey().equals(key)) { return attribute; } } return null; }
private static Section newSection(String name) { return Section.newBuilder().setName(name).build(); } }
@Override public ProtobufSystemInfo.Section toProtobuf() { ProtobufSystemInfo.Section.Builder builder = ProtobufSystemInfo.Section.newBuilder(); builder.setName("Compute Engine Tasks"); builder.addAttributesBuilder().setKey("Pending").setLongValue(getPendingCount()).build(); builder.addAttributesBuilder().setKey("In Progress").setLongValue(getInProgressCount()).build(); builder.addAttributesBuilder().setKey("Processed With Error").setLongValue(getErrorCount()).build(); builder.addAttributesBuilder().setKey("Processed With Success").setLongValue(getSuccessCount()).build(); builder.addAttributesBuilder().setKey("Processing Time (ms)").setLongValue(getProcessingTime()).build(); builder.addAttributesBuilder().setKey("Worker Count").setLongValue(getWorkerCount()).build(); builder.addAttributesBuilder().setKey("Max Worker Count").setLongValue(getWorkerMaxCount()).build(); builder.addAttributesBuilder().setKey("Workers Paused").setBooleanValue(queueStatus.areWorkersPaused()).build(); return builder.build(); } }
@Override public ProtobufSystemInfo.Section toProtobuf() { return ProtobufSystemInfo.Section.newBuilder().setName(name).build(); } }
@Override public ProtobufSystemInfo.Section toProtobuf() { return ProtobufSystemInfo.Section.newBuilder().setName(name).build(); } }
@Override public ProtobufSystemInfo.Section toProtobuf() { ProtobufSystemInfo.Section.Builder protobuf = ProtobufSystemInfo.Section.newBuilder(); protobuf.setName("Settings"); PropertyDefinitions definitions = settings.getDefinitions(); TreeMap<String, String> orderedProps = new TreeMap<>(settings.getProperties()); for (Map.Entry<String, String> prop : orderedProps.entrySet()) { String key = prop.getKey(); String value = obfuscateValue(definitions, key, prop.getValue()); setAttribute(protobuf, key, value); } return protobuf.build(); }
@Override public ProtobufSystemInfo.Section toProtobuf() { ProtobufSystemInfo.Section.Builder protobuf = ProtobufSystemInfo.Section.newBuilder(); if (runtime.getSonarQubeSide() == SonarQubeSide.COMPUTE_ENGINE) { protobuf.setName("Compute Engine Logging"); } else { protobuf.setName("Web Logging"); } SystemInfoUtils.setAttribute(protobuf, "Logs Level", logging.getRootLoggerLevel().name()); SystemInfoUtils.setAttribute(protobuf, "Logs Dir", logging.getLogsDir().getAbsolutePath()); return protobuf.build(); } }
private static NodeInfo toNodeInfo(NodeStats stat) { String nodeName = stat.getNode().getName(); NodeInfo info = new NodeInfo(nodeName); info.setHost(stat.getHostname()); ProtobufSystemInfo.Section.Builder section = ProtobufSystemInfo.Section.newBuilder(); section.setName("Search State"); EsStateSection.toProtobuf(stat, section); info.addSection(section.build()); return info; }
@Override public ProtobufSystemInfo.Section toProtobuf() { ProtobufSystemInfo.Section.Builder protobuf = ProtobufSystemInfo.Section.newBuilder(); protobuf.setName("System"); setAttribute(protobuf, "Server ID", server.getId()); setAttribute(protobuf, "High Availability", true); setAttribute(protobuf, "External User Authentication", getExternalUserAuthentication()); addIfNotEmpty(protobuf, "Accepted external identity providers", getEnabledIdentityProviders()); addIfNotEmpty(protobuf, "External identity providers whose users are allowed to sign themselves up", getAllowsToSignUpEnabledIdentityProviders()); setAttribute(protobuf, "Force authentication", getForceAuthentication()); return protobuf.build(); }