Example usage for org.apache.cassandra.utils ResourceWatcher watch

List of usage examples for org.apache.cassandra.utils ResourceWatcher watch

Introduction

In this page you can find the example usage for org.apache.cassandra.utils ResourceWatcher watch.

Prototype

public static void watch(String resource, Runnable callback, int period) 

Source Link

Usage

From source file:brooklyn.entity.nosql.cassandra.customsnitch.MultiCloudSnitch.java

License:Apache License

public MultiCloudSnitch() throws ConfigurationException {
    reloadConfiguration();//from w  w w  .  ja va2s.com
    logger.info("CustomSnitch using datacenter: " + datacenter + ", rack: " + rack + ", publicip: " + public_ip
            + ", privateip: " + private_ip);

    try {
        FBUtilities.resourceToFile(SNITCH_PROPERTIES_FILENAME);
        Runnable runnable = new WrappedRunnable() {
            protected void runMayThrow() throws ConfigurationException {
                reloadConfiguration();
            }
        };
        ResourceWatcher.watch(SNITCH_PROPERTIES_FILENAME, runnable, 60 * 1000);
    } catch (ConfigurationException ex) {
        logger.debug(SNITCH_PROPERTIES_FILENAME
                + " found, but does not look like a plain file. Will not watch it for changes");
    }
}