Package com.netflix.config

Examples of com.netflix.config.DynamicStringProperty


public class ValidationTest {
   
    @Test
    public void testValidation() {
        DynamicStringProperty prop = new DynamicStringProperty("abc", "default") {
            public void validate(String newValue) {
                throw new ValidationException("failed");
            }
        };
        try {
            ConfigurationManager.getConfigInstance().setProperty("abc", "new");
            fail("ValidationException expected");
        } catch (ValidationException e) {
            assertNotNull(e);
        }
        assertEquals("default", prop.get());
        assertNull(ConfigurationManager.getConfigInstance().getProperty("abc"));
       
        try {
            ConfigurationManager.getConfigInstance().addProperty("abc", "new");
            fail("ValidationException expected");
        } catch (ValidationException e) {
            assertNotNull(e);
        }
        assertEquals("default", prop.get());
        assertNull(ConfigurationManager.getConfigInstance().getProperty("abc"));
    }
View Full Code Here


        0, 10, false);
    DynamicConfiguration configuration = new DynamicConfiguration(source,
        scheduler);
    DynamicPropertyFactory.initWithConfigurationSource(configuration);

    DynamicStringProperty defaultProp = DynamicPropertyFactory.getInstance().getStringProperty(
        "this.prop.does.not.exist.use.default", "default");
    assertEquals("default", defaultProp.get());
   
    DynamicStringProperty prop1 = DynamicPropertyFactory.getInstance().getStringProperty(
        "prop1", "default");
    assertEquals("value1", prop1.get());

  }
View Full Code Here

      BlobStoreConfigurationSource source = new BlobStoreConfigurationSource(ctx);
      FixedDelayPollingScheduler scheduler = new FixedDelayPollingScheduler(0, 1000, false);
      DynamicConfiguration dynamicConfig = new DynamicConfiguration(source, scheduler);
      ConfigurationManager.loadPropertiesFromConfiguration(dynamicConfig);

      DynamicStringProperty test1 = DynamicPropertyFactory.getInstance().getStringProperty("test1", "");
      DynamicStringProperty test2 = DynamicPropertyFactory.getInstance().getStringProperty("test2", "");
      DynamicStringProperty test3 = DynamicPropertyFactory.getInstance().getStringProperty("test3", "");

      assertEquals("val1", test1.get());
      assertEquals("val2", test2.get());
      assertEquals("val3", test3.get());

      update();
      Thread.sleep(1250);

      assertEquals("vala", test1.get());
      assertEquals("valb", test2.get());
      assertEquals("valc", test3.get());
   }
View Full Code Here

        props.setProperty("log4j.appender.stdout.layout", "com.netflix.logging.log4jAdapter.NFPatternLayout");
        props.setProperty("log4j.appender.stdout.layout.ConversionPattern", "%d %-5p %C:%L [%t] [%M] %m%n");
        props.setProperty("log4j.logger.asyncAppenders", "DEBUG,stdout");
        LoggingConfiguration.getInstance().configure(props);
*/
        DynamicStringProperty virtualizationType = DynamicPropertyFactory.getInstance().getStringProperty("com.dowdandassociates.gentoo.bootstrap.Image.virtualizationType", "paravirtual");

        LoggingConfiguration.getInstance().configure();

        try
        {
//            Injector injector = Guice.createInjector(new Amd64MinimalBootstrapModule());
       
//            Injector injector = LifecycleInjector.builder().withBootstrapModule(new GentooBootstrapModule()).createInjector();

            Injector injector;
            if ("hvm".equals(virtualizationType.get()))
            {
                injector = LifecycleInjector.builder().withBootstrapModule(new HvmBootstrapModule()).createInjector();
            }
            else
            {
View Full Code Here

        if (stack != null && !stack.trim().isEmpty() && RibbonConfig.isAutodetectingBackendVips()) {
            RibbonConfig.setupDefaultRibbonConfig();
            ZuulApplicationInfo.setApplicationName(RibbonConfig.getApplicationName());
        } else {
            DynamicStringProperty DEFAULT_CLIENT = DynamicPropertyFactory.getInstance().getStringProperty(ZUUL_NIWS_DEFAULTCLIENT, null);
            if (DEFAULT_CLIENT.get() != null) {
                ZuulApplicationInfo.setApplicationName(DEFAULT_CLIENT.get());
            } else {
                ZuulApplicationInfo.setApplicationName(stack);
            }
        }
        String clientPropertyList = DynamicPropertyFactory.getInstance().getStringProperty(ZUUL_NIWS_CLIENTLIST, "").get();
View Full Code Here

        if (null == regionName) {
            regionName = "global";
        } else {
            regionName = regionName.trim().toLowerCase();
        }
        DynamicStringProperty appWhiteListProp =
                configInstance.getStringProperty(namespace + "remoteRegion." + regionName + ".appWhiteList", null);
        if (null == appWhiteListProp || null == appWhiteListProp.get()) {
            return null;
        } else {
            String appWhiteListStr = appWhiteListProp.get();
            String[] whitelistEntries = appWhiteListStr.split(",");
            return new HashSet<String>(Arrays.asList(whitelistEntries));
        }
    }
View Full Code Here

    }   
  }

  @Override
  public String getString(String key, String defaultValue) {
    final DynamicStringProperty property = DynamicPropertyFactory
        .getInstance().getStringProperty(key, defaultValue);
    return property.get();
  }
View Full Code Here

            log.error("Exception while refreshing the Server list", t);
        }
    }

    private DynamicStringProperty getHostsFastProperty(String zone) {
        DynamicStringProperty hostsInZone = hostsByZoneFPMap.get(zone);
        if (hostsInZone != null) return hostsInZone;

        hostsInZone = DynamicPropertyFactory.getInstance().getStringProperty(getAppName() + "." + zone + ".EVCacheClientPool.hosts", "");
        hostsInZone.addCallback(this);
        hostsByZoneFPMap.put(zone, hostsInZone);
        return hostsInZone;
    }
View Full Code Here

        /* Iterate all the discovered instances to find usable ones */
        while (zoneListTokenizer.hasMoreTokens()) {
            final String zone = zoneListTokenizer.nextToken();

            final DynamicStringProperty hostsInZoneFP = getHostsFastProperty(zone);
            final StringTokenizer hostListTokenizer = new StringTokenizer(hostsInZoneFP.get(), ",");

            while (hostListTokenizer.hasMoreTokens()) {
                final String token = hostListTokenizer.nextToken();
                final String memcachedHost;
                final String memcachedPort;
View Full Code Here

        this.jsonMapper  = jsonMapper;
    }

    @PostConstruct
    public void init() {
        DynamicStringProperty sinkDescription = new DynamicStringProperty(SINK_PROPERTY, initialSink) {
            @Override
            protected void propertyChanged() {
                buildSink(get(), false);
            }
        };

        buildSink(sinkDescription.get(), true);
    }
View Full Code Here

TOP

Related Classes of com.netflix.config.DynamicStringProperty

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.