use of com.google.cloud.monitoring.v3.UptimeCheckServiceSettings in project java-monitoring by googleapis.
the class UptimeSample method getUptimeCheckConfig.
// [END monitoring_uptime_check_list_ips]]
// [START monitoring_uptime_check_get]]
private static void getUptimeCheckConfig(String projectId, String checkName) throws IOException {
// Create UptimeCheckServiceSettings instance for add retry mechanism
UptimeCheckServiceSettings.Builder uptimeCheckServiceSettingsBuilder = UptimeCheckServiceSettings.newBuilder();
uptimeCheckServiceSettingsBuilder.getUptimeCheckConfigSettings().setRetrySettings(uptimeCheckServiceSettingsBuilder.getUptimeCheckConfigSettings().getRetrySettings().toBuilder().setInitialRetryDelay(org.threeten.bp.Duration.ofMillis(100L)).setRetryDelayMultiplier(1.3).setMaxRetryDelay(MAX_RECONNECT_BACKOFF_TIME).setInitialRpcTimeout(MAX_RECONNECT_BACKOFF_TIME).setRpcTimeoutMultiplier(1.0).setMaxRpcTimeout(MAX_RECONNECT_BACKOFF_TIME).setTotalTimeout(MAX_RECONNECT_BACKOFF_TIME).setMaxAttempts(6).build());
UptimeCheckServiceSettings uptimeCheckServiceSettings = uptimeCheckServiceSettingsBuilder.build();
// create UptimeCheckServiceClient with retry setting
try (UptimeCheckServiceClient client = UptimeCheckServiceClient.create(uptimeCheckServiceSettings)) {
String fullCheckName = UptimeCheckConfigName.format(projectId, checkName);
UptimeCheckConfig config = client.getUptimeCheckConfig(fullCheckName);
if (config != null) {
System.out.println(config.toString());
} else {
System.out.println("No uptime check config found with name " + checkName + " in project " + projectId);
}
} catch (Exception e) {
usage("Exception getting uptime check: " + e.toString());
throw e;
}
}
Aggregations