Tabnine Logo
SystemInfoUtils
Code IndexAdd Tabnine to your IDE (free)

How to use
SystemInfoUtils
in
org.sonar.process.systeminfo

Best Java code snippets using org.sonar.process.systeminfo.SystemInfoUtils (Showing top 20 results out of 315)

origin: SonarSource/sonarqube

 private static void addAttributeInMb(ProtobufSystemInfo.Section.Builder protobuf, String key, long valueInBytes) {
  if (valueInBytes >= 0L) {
   setAttribute(protobuf, key, valueInBytes / MEGABYTE);
  }
 }
}
origin: SonarSource/sonarqube

@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();
}
origin: SonarSource/sonarqube

protected void writeSections(Collection<ProtobufSystemInfo.Section> sections, JsonWriter json) {
 SystemInfoUtils
  .order(sections, ORDERED_SECTION_NAMES)
  .forEach(section -> writeSection(section, json));
}
origin: SonarSource/sonarqube

@Test
public void node_attributes() {
 ProtobufSystemInfo.Section section = underTest.toProtobuf();
 assertThat(attribute(section, "CPU Usage (%)")).isNotNull();
 assertThat(attribute(section, "Disk Available")).isNotNull();
 assertThat(attribute(section, "Store Size")).isNotNull();
}
origin: SonarSource/sonarqube

public static void assertThatAttributeIs(ProtobufSystemInfo.Section section, String key, String expectedValue) {
 ProtobufSystemInfo.Attribute value = attribute(section, key);
 assertThat(value).as(key).isNotNull();
 assertThat(value.getStringValue()).isEqualTo(expectedValue);
}
origin: SonarSource/sonarqube

 private static void addIfNotEmpty(ProtobufSystemInfo.Section.Builder protobuf, String key, @Nullable List<String> values) {
  if (values != null && !values.isEmpty()) {
   setAttribute(protobuf, key, COMMA_JOINER.join(values));
  }
 }
}
origin: SonarSource/sonarqube

 public static void assertThatAttributeIs(ProtobufSystemInfo.Section section, String key, long expectedValue) {
  ProtobufSystemInfo.Attribute value = attribute(section, key);
  assertThat(value).as(key).isNotNull();
  assertThat(value.getLongValue()).isEqualTo(expectedValue);
 }
}
origin: SonarSource/sonarqube

@Test
public void test_order() {
 Collection<Section> sections = asList(
  newSection("end2"),
  newSection("bar"),
  newSection("end1"),
  newSection("foo"));
 List<String> ordered = SystemInfoUtils.order(sections, "foo", "bar").stream()
  .map(Section::getName)
  .collect(Collectors.toList());
 assertThat(ordered).isEqualTo(asList("foo", "bar", "end1", "end2"));
}
origin: SonarSource/sonarqube

private static void addIfNotEmpty(ProtobufSystemInfo.Section.Builder protobuf, String key, @Nullable List<String> values) {
 if (values != null && !values.isEmpty()) {
  setAttribute(protobuf, key, COMMA_JOINER.join(values));
 }
}
origin: SonarSource/sonarqube

public static void assertThatAttributeIs(ProtobufSystemInfo.Section section, String key, boolean expectedValue) {
 ProtobufSystemInfo.Attribute value = attribute(section, key);
 assertThat(value).as(key).isNotNull();
 assertThat(value.getBooleanValue()).isEqualTo(expectedValue);
}
origin: org.sonarsource.sonarqube/sonar-server

protected void writeSections(Collection<ProtobufSystemInfo.Section> sections, JsonWriter json) {
 SystemInfoUtils
  .order(sections, ORDERED_SECTION_NAMES)
  .forEach(section -> writeSection(section, json));
}
origin: SonarSource/sonarqube

private void completePoolAttributes(Section.Builder protobuf) {
 setAttribute(protobuf, "Pool Active Connections", getPoolActiveConnections());
 setAttribute(protobuf, "Pool Max Connections", getPoolMaxActiveConnections());
 setAttribute(protobuf, "Pool Initial Size", getPoolInitialSize());
 setAttribute(protobuf, "Pool Idle Connections", getPoolIdleConnections());
 setAttribute(protobuf, "Pool Min Idle Connections", getPoolMinIdleConnections());
 setAttribute(protobuf, "Pool Max Idle Connections", getPoolMaxIdleConnections());
 setAttribute(protobuf, "Pool Max Wait (ms)", getPoolMaxWaitMillis());
 setAttribute(protobuf, "Pool Remove Abandoned", getPoolRemoveAbandoned());
 setAttribute(protobuf, "Pool Remove Abandoned Timeout (seconds)", getPoolRemoveAbandonedTimeoutSeconds());
}
origin: SonarSource/sonarqube

@Test
public void pool_info() {
 ProtobufSystemInfo.Section section = underTest.toProtobuf();
 assertThat(attribute(section, "Pool Max Connections").getLongValue()).isGreaterThan(0L);
 assertThat(attribute(section, "Pool Idle Connections").getLongValue()).isGreaterThanOrEqualTo(0L);
 assertThat(attribute(section, "Pool Min Idle Connections").getLongValue()).isGreaterThanOrEqualTo(0L);
 assertThat(attribute(section, "Pool Max Idle Connections").getLongValue()).isGreaterThanOrEqualTo(0L);
 assertThat(attribute(section, "Pool Max Wait (ms)")).isNotNull();
 assertThat(attribute(section, "Pool Remove Abandoned")).isNotNull();
 assertThat(attribute(section, "Pool Remove Abandoned Timeout (seconds)").getLongValue()).isGreaterThanOrEqualTo(0L);
}
origin: SonarSource/sonarqube

 @Override
 public Section toProtobuf() {
  Section.Builder protobuf = Section.newBuilder();
  protobuf.setName("Database");
  try (DbSession dbSession = dbClient.openSession(false)) {
   DatabaseMetaData metadata = dbSession.getConnection().getMetaData();
   setAttribute(protobuf, "Database", metadata.getDatabaseProductName());
   setAttribute(protobuf, "Database Version", metadata.getDatabaseProductVersion());
   setAttribute(protobuf, "Username", metadata.getUserName());
   setAttribute(protobuf, "URL", metadata.getURL());
   setAttribute(protobuf, "Driver", metadata.getDriverName());
   setAttribute(protobuf, "Driver Version", metadata.getDriverVersion());
  } catch (SQLException e) {
   throw new IllegalStateException("Fail to get DB metadata", e);
  }
  return protobuf.build();
 }
}
origin: SonarSource/sonarqube

@Test
public void index_attributes() {
 ProtobufSystemInfo.Section section = underTest.toProtobuf();
 // one index "issues"
 assertThat(attribute(section, "Index issues - Docs").getLongValue()).isEqualTo(0L);
 assertThat(attribute(section, "Index issues - Shards").getLongValue()).isGreaterThan(0);
 assertThat(attribute(section, "Index issues - Store Size").getStringValue()).isNotNull();
}
origin: SonarSource/sonarqube

 @Override
 public ProtobufSystemInfo.Section toProtobuf() {
  ProtobufSystemInfo.Section.Builder protobuf = ProtobufSystemInfo.Section.newBuilder();
  protobuf.setName(name);

  Map<Object, Object> sortedProperties = new TreeMap<>(System.getProperties());
  for (Map.Entry<Object, Object> systemProp : sortedProperties.entrySet()) {
   if (systemProp.getValue() != null) {
    setAttribute(protobuf, Objects.toString(systemProp.getKey()), Objects.toString(systemProp.getValue()));
   }
  }
  return protobuf.build();
 }
}
origin: SonarSource/sonarqube

@Test
public void no_realm() {
 when(securityRealmFactory.getRealm()).thenReturn(null);
 ProtobufSystemInfo.Section protobuf = underTest.toProtobuf();
 assertThat(attribute(protobuf, "External User Authentication")).isNull();
}
origin: SonarSource/sonarqube

@Override
public ProtobufSystemInfo.Section toProtobuf() {
 ProtobufSystemInfo.Section.Builder protobuf = ProtobufSystemInfo.Section.newBuilder();
 protobuf.setName("System");
 setAttribute(protobuf, "Version", server.getVersion());
 setAttribute(protobuf, "Official Distribution", officialDistribution.check());
 setAttribute(protobuf, "Home Dir", config.get(PATH_HOME.getKey()).orElse(null));
 setAttribute(protobuf, "Data Dir", config.get(PATH_DATA.getKey()).orElse(null));
 setAttribute(protobuf, "Temp Dir", config.get(PATH_TEMP.getKey()).orElse(null));
 setAttribute(protobuf, "Processors", Runtime.getRuntime().availableProcessors());
 return protobuf.build();
}
origin: SonarSource/sonarqube

@Test
public void no_realm() {
 when(securityRealmFactory.getRealm()).thenReturn(null);
 ProtobufSystemInfo.Section protobuf = underTest.toProtobuf();
 assertThat(attribute(protobuf, "External User Authentication")).isNull();
}
origin: SonarSource/sonarqube

@Override
public ProtobufSystemInfo.Section toProtobuf() {
 ProtobufSystemInfo.Section.Builder protobuf = ProtobufSystemInfo.Section.newBuilder();
 protobuf.setName("System");
 setAttribute(protobuf, "Server ID", server.getId());
 setAttribute(protobuf, "Version", getVersion());
 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, "High Availability", false);
 setAttribute(protobuf, "Official Distribution", officialDistribution.check());
 setAttribute(protobuf, "Force authentication", getForceAuthentication());
 setAttribute(protobuf, "Home Dir", config.get(PATH_HOME.getKey()).orElse(null));
 setAttribute(protobuf, "Data Dir", config.get(PATH_DATA.getKey()).orElse(null));
 setAttribute(protobuf, "Temp Dir", config.get(PATH_TEMP.getKey()).orElse(null));
 setAttribute(protobuf, "Processors", Runtime.getRuntime().availableProcessors());
 return protobuf.build();
}
org.sonar.process.systeminfoSystemInfoUtils

Most used methods

  • setAttribute
  • attribute
  • order

Popular in Java

  • Making http post requests using okhttp
  • getSharedPreferences (Context)
  • startActivity (Activity)
  • runOnUiThread (Activity)
  • Menu (java.awt)
  • SocketException (java.net)
    This SocketException may be thrown during socket creation or setting options, and is the superclass
  • Format (java.text)
    The base class for all formats. This is an abstract base class which specifies the protocol for clas
  • Collection (java.util)
    Collection is the root of the collection hierarchy. It defines operations on data collections and t
  • HttpServlet (javax.servlet.http)
    Provides an abstract class to be subclassed to create an HTTP servlet suitable for a Web site. A sub
  • LogFactory (org.apache.commons.logging)
    Factory for creating Log instances, with discovery and configuration features similar to that employ
  • From CI to AI: The AI layer in your organization
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now