Search in sources :

Example 1 with XmlConfigurationLoader

use of org.mobicents.tools.configuration.XmlConfigurationLoader in project load-balancer by RestComm.

the class SipBalancerShutdownHook method start.

/**
 * @param configurationFileLocation
 */
public void start(final String configurationFileLocation) {
    File file = new File(configurationFileLocation);
    lastupdate = file.lastModified();
    final XmlConfigurationLoader configLoader = new XmlConfigurationLoader();
    LoadBalancerConfiguration lbConfig = configLoader.load(file);
    timer = new Timer();
    timer.scheduleAtFixedRate(new TimerTask() {

        public void run() {
            File conf = new File(configurationFileLocation);
            if (lastupdate < conf.lastModified()) {
                lastupdate = conf.lastModified();
                logger.info("Configuration file changed, applying changes.");
                try {
                    for (InvocationContext ctx : contexts.values()) {
                        balancerContext.lbConfig = configLoader.load(conf);
                        ctx.balancerAlgorithm.configurationChanged();
                        if (ctx.smppToNodeBalancerAlgorithm != null)
                            ctx.smppToNodeBalancerAlgorithm.configurationChanged();
                        ctx.smppToProviderBalancerAlgorithm.configurationChanged();
                        smppBalancerRunner.remoteServersUpdated();
                    }
                } catch (Exception e) {
                    logger.warn("Problem reloading configuration " + e);
                }
            }
        }
    }, 3000, 2000);
    start(lbConfig);
}
Also used : XmlConfigurationLoader(org.mobicents.tools.configuration.XmlConfigurationLoader) Timer(java.util.Timer) TimerTask(java.util.TimerTask) LoadBalancerConfiguration(org.mobicents.tools.configuration.LoadBalancerConfiguration) File(java.io.File) UnknownHostException(java.net.UnknownHostException)

Aggregations

File (java.io.File)1 UnknownHostException (java.net.UnknownHostException)1 Timer (java.util.Timer)1 TimerTask (java.util.TimerTask)1 LoadBalancerConfiguration (org.mobicents.tools.configuration.LoadBalancerConfiguration)1 XmlConfigurationLoader (org.mobicents.tools.configuration.XmlConfigurationLoader)1