Codota Logo
SystemInfoUtils.setAttribute
Code IndexAdd Codota to your IDE (free)

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

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

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
ArrayList a =
  • Codota Iconnew ArrayList<String>()
  • Codota Iconnew ArrayList()
  • Codota Iconnew ArrayList<Object>()
  • Smart code suggestions by Codota
}
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

 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

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

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

 @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

 @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

@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

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

 @Override
 public ProtobufSystemInfo.Section toProtobuf() {
  ProtobufSystemInfo.Section.Builder protobuf = ProtobufSystemInfo.Section.newBuilder();
  protobuf.setName("Compute Engine Tasks");
  try (DbSession dbSession = dbClient.openSession(false)) {
   setAttribute(protobuf, "Total Pending", dbClient.ceQueueDao().countByStatus(dbSession, CeQueueDto.Status.PENDING));
   setAttribute(protobuf, "Total In Progress", dbClient.ceQueueDao().countByStatus(dbSession, CeQueueDto.Status.IN_PROGRESS));
   setAttribute(protobuf, "Max Workers per Node", workerCountProvider == null ? DEFAULT_NB_OF_WORKERS : workerCountProvider.get());
   setAttribute(protobuf, "Workers Paused", "true".equals(dbClient.internalPropertiesDao().selectByKey(dbSession, InternalProperties.COMPUTE_ENGINE_PAUSE).orElse(null)));
  }
  return protobuf.build();
 }
}
origin: SonarSource/sonarqube

@Override
public ProtobufSystemInfo.Section toProtobuf() {
 ProtobufSystemInfo.Section.Builder protobuf = ProtobufSystemInfo.Section.newBuilder();
 protobuf.setName("Search State");
 try {
  setAttribute(protobuf, "State", getStateAsEnum().name());
  completeNodeAttributes(protobuf);
 } catch (Exception es) {
  Loggers.get(EsStateSection.class).warn("Failed to retrieve ES attributes. There will be only a single \"state\" attribute.", es);
  setAttribute(protobuf, "State", es.getCause() instanceof ElasticsearchException ? es.getCause().getMessage() : es.getMessage());
 }
 return protobuf.build();
}
origin: SonarSource/sonarqube

@Override
public ProtobufSystemInfo.Section toProtobuf() {
 ProtobufSystemInfo.Section.Builder protobuf = ProtobufSystemInfo.Section.newBuilder();
 protobuf.setName("Search Indexes");
 try {
  completeIndexAttributes(protobuf);
 } catch (Exception es) {
  Loggers.get(EsIndexesSection.class).warn("Failed to retrieve ES attributes. There will be only a single \"Error\" attribute.", es);
  setAttribute(protobuf, "Error", es.getCause() instanceof ElasticsearchException ? es.getCause().getMessage() : es.getMessage());
 }
 return protobuf.build();
}
origin: SonarSource/sonarqube

 private void completeIndexAttributes(ProtobufSystemInfo.Section.Builder protobuf) {
  IndicesStatsResponse indicesStats = esClient.prepareStats().all().get();
  for (Map.Entry<String, IndexStats> indexStats : indicesStats.getIndices().entrySet()) {
   String prefix = "Index " + indexStats.getKey() + " - ";
   setAttribute(protobuf, prefix + "Docs", indexStats.getValue().getPrimaries().getDocs().getCount());
   setAttribute(protobuf, prefix + "Shards", indexStats.getValue().getShards().length);
   setAttribute(protobuf, prefix + "Store Size", byteCountToDisplaySize(indexStats.getValue().getPrimaries().getStore().getSizeInBytes()));
  }
 }
}
origin: SonarSource/sonarqube

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

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

@Override
public ProtobufSystemInfo.Section toProtobuf() {
 ProtobufSystemInfo.Section.Builder protobuf = ProtobufSystemInfo.Section.newBuilder();
 protobuf.setName("Search State");
 ClusterStatsResponse stats = esClient.prepareClusterStats().get();
 setAttribute(protobuf, "State", stats.getStatus().name());
 setAttribute(protobuf, "Nodes", stats.getNodesStats().getCounts().getTotal());
 return protobuf.build();
}
origin: SonarSource/sonarqube

public static void toProtobuf(NodeStats stats, ProtobufSystemInfo.Section.Builder protobuf) {
 setAttribute(protobuf, "CPU Usage (%)", stats.getProcess().getCpu().getPercent());
 setAttribute(protobuf, "Disk Available", byteCountToDisplaySize(stats.getFs().getTotal().getAvailable().getBytes()));
 setAttribute(protobuf, "Store Size", byteCountToDisplaySize(stats.getIndices().getStore().getSizeInBytes()));
 setAttribute(protobuf, "Open File Descriptors", stats.getProcess().getOpenFileDescriptors());
 setAttribute(protobuf, "Max File Descriptors", stats.getProcess().getMaxFileDescriptors());
 setAttribute(protobuf, "Spinning", stats.getFs().getTotal().getSpins());
 setAttribute(protobuf, "JVM Heap Usage", formatPercent(stats.getJvm().getMem().getHeapUsedPercent()));
 setAttribute(protobuf, "JVM Heap Used", byteCountToDisplaySize(stats.getJvm().getMem().getHeapUsed().getBytes()));
 setAttribute(protobuf, "JVM Heap Max", byteCountToDisplaySize(stats.getJvm().getMem().getHeapMax().getBytes()));
 setAttribute(protobuf, "JVM Non Heap Used", byteCountToDisplaySize(stats.getJvm().getMem().getNonHeapUsed().getBytes()));
 setAttribute(protobuf, "JVM Threads", stats.getJvm().getThreads().getCount());
 setAttribute(protobuf, "Field Data Memory", byteCountToDisplaySize(stats.getIndices().getFieldData().getMemorySizeInBytes()));
 setAttribute(protobuf, "Field Data Circuit Breaker Limit", byteCountToDisplaySize(stats.getBreaker().getStats(CircuitBreaker.FIELDDATA).getLimit()));
 setAttribute(protobuf, "Field Data Circuit Breaker Estimation", byteCountToDisplaySize(stats.getBreaker().getStats(CircuitBreaker.FIELDDATA).getEstimated()));
 setAttribute(protobuf, "Request Circuit Breaker Limit", byteCountToDisplaySize(stats.getBreaker().getStats(CircuitBreaker.REQUEST).getLimit()));
 setAttribute(protobuf, "Request Circuit Breaker Estimation", byteCountToDisplaySize(stats.getBreaker().getStats(CircuitBreaker.REQUEST).getEstimated()));
 setAttribute(protobuf, "Query Cache Memory", byteCountToDisplaySize(stats.getIndices().getQueryCache().getMemorySizeInBytes()));
 setAttribute(protobuf, "Request Cache Memory", byteCountToDisplaySize(stats.getIndices().getRequestCache().getMemorySizeInBytes()));
}
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

@Test
public void write_json() {
 logInAsSystemAdministrator();
 ProtobufSystemInfo.Section.Builder attributes1 = ProtobufSystemInfo.Section.newBuilder()
  .setName("Section One");
 setAttribute(attributes1, "foo", "bar");
 when(section1.toProtobuf()).thenReturn(attributes1.build());
 ProtobufSystemInfo.Section.Builder attributes2 = ProtobufSystemInfo.Section.newBuilder()
  .setName("Section Two");
 setAttribute(attributes2, "one", 1);
 setAttribute(attributes2, "two", 2);
 when(section2.toProtobuf()).thenReturn(attributes2.build());
 when(ceHttpClient.retrieveSystemInfo()).thenReturn(Optional.empty());
 StringWriter writer = new StringWriter();
 JsonWriter jsonWriter = JsonWriter.of(writer);
 jsonWriter.beginObject();
 underTest.write(jsonWriter);
 jsonWriter.endObject();
 // response does not contain empty "Section Three"
 assertThat(writer.toString()).isEqualTo("{\"Health\":\"GREEN\",\"Health Causes\":[],\"Section One\":{\"foo\":\"bar\"},\"Section Two\":{\"one\":1,\"two\":2}," +
  "\"Statistics\":{\"id\":\"\",\"version\":\"\",\"database\":{\"name\":\"\",\"version\":\"\"},\"plugins\":[],\"userCount\":0,\"projectCount\":0,\"usingBranches\":false," +
  "\"ncloc\":0,\"projectCountByLanguage\":[],\"nclocByLanguage\":[]}}");
}
origin: SonarSource/sonarqube

 @Override
 public ProtobufSystemInfo.Section toProtobuf() {
  ProtobufSystemInfo.Section.Builder protobuf = ProtobufSystemInfo.Section.newBuilder();
  protobuf.setName("Plugins");
  for (PluginInfo plugin : repository.getPluginInfos()) {
   String label = "[" + plugin.getName() + "]";
   Version version = plugin.getVersion();
   if (version != null) {
    label = version.getName() + " " + label;
   }
   setAttribute(protobuf, plugin.getKey(), label);
  }
  return protobuf.build();
 }
}
org.sonar.process.systeminfoSystemInfoUtilssetAttribute

Popular methods of SystemInfoUtils

  • attribute
  • order

Popular in Java

  • Creating JSON documents from java classes using gson
  • addToBackStack (FragmentTransaction)
  • getResourceAsStream (ClassLoader)
    Returns a stream for the resource with the specified name. See #getResource(String) for a descriptio
  • getSystemService (Context)
  • Date (java.sql)
    A class which can consume and produce dates in SQL Date format. Dates are represented in SQL as yyyy
  • BitSet (java.util)
    This class implements a vector of bits that grows as needed. Each component of the bit set has a boo
  • Comparator (java.util)
    A Comparator is used to compare two objects to determine their ordering with respect to each other.
  • UUID (java.util)
    UUID is an immutable representation of a 128-bit universally unique identifier (UUID). There are mul
  • DateTimeFormat (org.joda.time.format)
    Factory that creates instances of DateTimeFormatter from patterns and styles. Datetime formatting i
  • SAXParseException (org.xml.sax)
    Encapsulate an XML parse error or warning.This exception may include information for locating the er
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now