Search in sources :

Example 1 with UptimeCheckServiceSettings

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;
    }
}
Also used : UptimeCheckServiceSettings(com.google.cloud.monitoring.v3.UptimeCheckServiceSettings) UptimeCheckConfig(com.google.monitoring.v3.UptimeCheckConfig) UptimeCheckServiceClient(com.google.cloud.monitoring.v3.UptimeCheckServiceClient) IOException(java.io.IOException) ParseException(org.apache.commons.cli.ParseException)

Aggregations

UptimeCheckServiceClient (com.google.cloud.monitoring.v3.UptimeCheckServiceClient)1 UptimeCheckServiceSettings (com.google.cloud.monitoring.v3.UptimeCheckServiceSettings)1 UptimeCheckConfig (com.google.monitoring.v3.UptimeCheckConfig)1 IOException (java.io.IOException)1 ParseException (org.apache.commons.cli.ParseException)1