Package com.netflix.exhibitor.core.config

Examples of com.netflix.exhibitor.core.config.PropertyBasedInstanceConfig


        Properties          properties = new Properties();
        properties.putAll(DefaultProperties.get(backupProvider));   // put in standard defaults first

        addInitialConfigFile(commandLine, properties);

        return new PropertyBasedInstanceConfig(properties, new Properties()).getProperties();
    }
View Full Code Here


            finally
            {
                Closeables.closeQuietly(in);
            }
        }
        PropertyBasedInstanceConfig config = new PropertyBasedInstanceConfig(properties, defaultProperties);
        return new LoadedInstanceConfig(config, propertiesFile.lastModified());
    }
View Full Code Here

    @Override
    public LoadedInstanceConfig storeConfig(ConfigCollection config, long compareVersion) throws Exception
    {
        File                            propertiesFile = new File(directory, FILE_NAME);
        PropertyBasedInstanceConfig     propertyBasedInstanceConfig = new PropertyBasedInstanceConfig(config);

        long                            lastModified = 0;
        OutputStream                    out = new BufferedOutputStream(new FileOutputStream(propertiesFile));
        try
        {
            propertyBasedInstanceConfig.getProperties().store(out, "Auto-generated by Exhibitor");
            lastModified = propertiesFile.lastModified();
        }
        finally
        {
            Closeables.closeQuietly(out);
View Full Code Here

                }
            );

            Properties              properties = new Properties();
            properties.setProperty(PropertyBasedInstanceConfig.toName(StringConfigs.ZOO_CFG_EXTRA, PropertyBasedInstanceConfig.ROOT_PROPERTY_PREFIX), "1,2,3");
            LoadedInstanceConfig    loaded1 = config1.storeConfig(new PropertyBasedInstanceConfig(properties, new Properties()), -1);

            Assert.assertTrue(timing.acquireSemaphore(cacheUpdate2));
            timing.sleepABit();

            LoadedInstanceConfig    loaded2 = config2.loadConfig();
            Assert.assertEquals("1,2,3", loaded2.getConfig().getRootConfig().getString(StringConfigs.ZOO_CFG_EXTRA));

            properties.setProperty(PropertyBasedInstanceConfig.toName(StringConfigs.ZOO_CFG_EXTRA, PropertyBasedInstanceConfig.ROOT_PROPERTY_PREFIX), "4,5,6");
            config2.storeConfig(new PropertyBasedInstanceConfig(properties, new Properties()), loaded2.getVersion());

            Assert.assertNull(config1.storeConfig(new PropertyBasedInstanceConfig(properties, new Properties()), loaded1.getVersion()));

            LoadedInstanceConfig    newLoaded1 = config1.loadConfig();
            Assert.assertNotEquals(loaded1.getVersion(), newLoaded1.getVersion());
        }
        finally
View Full Code Here

            config.loadConfig();    // make sure there's no exception

            Properties      properties = new Properties();
            properties.setProperty(PropertyBasedInstanceConfig.toName(StringConfigs.ZOO_CFG_EXTRA, PropertyBasedInstanceConfig.ROOT_PROPERTY_PREFIX), "1,2,3");
            config.storeConfig(new PropertyBasedInstanceConfig(properties, new Properties()), 0);

            timing.sleepABit();

            LoadedInstanceConfig instanceConfig = config.loadConfig();
            Assert.assertEquals("1,2,3", instanceConfig.getConfig().getRootConfig().getString(StringConfigs.ZOO_CFG_EXTRA));
View Full Code Here

            finally
            {
                Closeables.closeQuietly(raf);
            }
        }
        PropertyBasedInstanceConfig config = new PropertyBasedInstanceConfig(properties, defaults);
        return new LoadedInstanceConfig(config, propertiesFile.lastModified());
    }
View Full Code Here

        if ( propertiesFile.lastModified() != compareVersion )
        {
            return null;
        }

        PropertyBasedInstanceConfig     propertyBasedInstanceConfig = new PropertyBasedInstanceConfig(config);

        long                lastModified = 0;
        FileOutputStream    fileStream = new FileOutputStream(propertiesFile);
        OutputStream        out = new BufferedOutputStream(fileStream);
        try
        {
            FileLock lock = fileStream.getChannel().lock();
            try
            {
                propertyBasedInstanceConfig.getProperties().store(out, "Auto-generated by Exhibitor");
                lastModified = propertiesFile.lastModified();
            }
            finally
            {
                lock.release();
View Full Code Here

        if ( childData != null )
        {
            version = childData.getStat().getVersion();
            properties.load(new ByteArrayInputStream(childData.getData()));
        }
        PropertyBasedInstanceConfig config = new PropertyBasedInstanceConfig(properties, defaults);
        return new LoadedInstanceConfig(config, version);
    }
View Full Code Here

    }

    @Override
    public LoadedInstanceConfig storeConfig(ConfigCollection config, long compareVersion) throws Exception
    {
        PropertyBasedInstanceConfig     propertyBasedInstanceConfig = new PropertyBasedInstanceConfig(config);
        ByteArrayOutputStream           out = new ByteArrayOutputStream();
        propertyBasedInstanceConfig.getProperties().store(out, "Auto-generated by Exhibitor " + hostname);

        byte[]          bytes = out.toByteArray();
        int             newVersion;
        try
        {
View Full Code Here

        else
        {
            lastModified = new Date(0L);
        }

        PropertyBasedInstanceConfig config = new PropertyBasedInstanceConfig(properties, defaults);
        return new LoadedInstanceConfig(config, lastModified.getTime());
    }
View Full Code Here

TOP

Related Classes of com.netflix.exhibitor.core.config.PropertyBasedInstanceConfig

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.