core/metrics-core-service/src/main/java/org/hawkular/metrics/core/util/GCGraceSecondsManager.java
public void maybeUpdateGCGraceSeconds() {
        logger.info("Checking tables in " + keyspace + " to see if gc_grace_seconds needs to be updated");
        Stopwatch stopwatch = Stopwatch.createStarted();
        Map<String, String> replication = session.getCluster().getMetadata().getKeyspace(keyspace).getReplication();
        String replicationFactor = replication.get("replication_factor");
        Completable check;

        if (getClusterSize() == 1 || replicationFactor.equals("1")) {
            check = updateAllGCGraceSeconds(0);
        } else {
            // Need to call Completable.merge in order for subscriptions to happen correctly. See https://goo.gl/l15CRV
            check = Completable.merge(configurationService.load("org.hawkular.metrics", "gcGraceSeconds")
                    .switchIfEmpty(Observable.just(Integer.toString(DEFAULT_GC_GRACE_SECONDS)))
                    .map(property -> {
                        int gcGraceSeconds = Integer.parseInt(property);
                        return updateAllGCGraceSeconds(gcGraceSeconds);
                    }));
        }

        check.subscribe(
                () -> {
                    stopwatch.stop();
                    logger.info("Finished gc_grace_seconds updates in " + stopwatch.elapsed(TimeUnit.MILLISECONDS)
                            + " ms");
                    updatesFinished.ifPresent(subject -> subject.onNext(null));
                },
                t -> {
                    logger.warn("There was an error checking and updating gc_grace_seconds");
                    updatesFinished.ifPresent(subject -> subject.onNext(t));
                }
        );
    }
public void maybeUpdateGCGraceSeconds() {
        logger.info("Checking tables in " + keyspace + " to see if gc_grace_seconds needs to be updated");
        Stopwatch stopwatch = Stopwatch.createStarted();
        Map<String, String> replication = session.getCluster().getMetadata().getKeyspace(keyspace).getReplication();
        String replicationFactor = replication.get("replication_factor");
        Completable check;

        if (getClusterSize() == 1 || replicationFactor.equals("1")) {
            check = updateAllGCGraceSeconds(0);
        } else {
            // Need to call Completable.merge in order for subscriptions to happen correctly. See https://goo.gl/l15CRV
            check = Completable.merge(configurationService.load("org.hawkular.metrics", "gcGraceSeconds")
                    .switchIfEmpty(Observable.just(Integer.toString(DEFAULT_GC_GRACE_SECONDS)))
                    .map(property -> {
                        int gcGraceSeconds = Integer.parseInt(property);
                        return updateAllGCGraceSeconds(gcGraceSeconds);
                    }));
        }

        check.subscribe(
                () -> {
                    stopwatch.stop();
                    logger.info("Finished gc_grace_seconds updates in " + stopwatch.elapsed(TimeUnit.MILLISECONDS)
                            + " ms");
                    updatesFinished.ifPresent(subject -> subject.onNext(null));
                },
                t -> {
                    logger.warn("There was an error checking and updating gc_grace_seconds");
                    updatesFinished.ifPresent(subject -> subject.onNext(t));
                }
        );
    }
public void maybeUpdateGCGraceSeconds ( ) { logger . info ( "Checking tables in " + keyspace + " to see if gc_grace_seconds needs to be updated" ) ; Stopwatch stopwatch = Stopwatch . createStarted ( ) ; Map < String , String > replication = session . getCluster ( ) . getMetadata ( ) . getKeyspace ( keyspace ) . getReplication ( ) ; String replicationFactor = replication . get ( "replication_factor" ) ; Completable check ; if ( getClusterSize ( ) == 1 || replicationFactor . equals ( "1" ) ) { check = updateAllGCGraceSeconds ( 0 ) ; } else { // Need to call Completable.merge in order for subscriptions to happen correctly. See https://goo.gl/l15CRV check = Completable . merge ( configurationService . load ( "org.hawkular.metrics" , "gcGraceSeconds" ) . switchIfEmpty ( Observable . just ( Integer . toString ( DEFAULT_GC_GRACE_SECONDS ) ) ) . map ( property -> { int gcGraceSeconds = Integer . parseInt ( property ) ; return updateAllGCGraceSeconds ( gcGraceSeconds ) ; } ) ) ; } check . subscribe ( ( ) -> { stopwatch . stop ( ) ; logger . info ( "Finished gc_grace_seconds updates in " + stopwatch . elapsed ( TimeUnit . MILLISECONDS ) + " ms" ) ; updatesFinished . ifPresent ( subject -> subject . onNext ( null ) ) ; } , t -> { logger . warn ( "There was an error checking and updating gc_grace_seconds" ) ; updatesFinished . ifPresent ( subject -> subject . onNext ( t ) ) ; } ) ; }
Asynchronously performs gc_grace_seconds updates if necessary. This method should <strong>not</strong> be called
until schema updates have finished.
Asynchronously performs gc_grace_seconds updates if necessary . This method should <strong > not< / strong > be called until schema updates have finished .