Search in sources :

Example 31 with AbstractConfiguration

use of org.apache.commons.configuration.AbstractConfiguration in project zuul by Netflix.

the class IoUringTest method beforeTest.

@Before
public void beforeTest() {
    final AbstractConfiguration config = ConfigurationManager.getConfigInstance();
    config.setProperty("zuul.server.netty.socket.force_io_uring", "true");
    config.setProperty("zuul.server.netty.socket.force_nio", "false");
}
Also used : AbstractConfiguration(org.apache.commons.configuration.AbstractConfiguration) Before(org.junit.Before)

Example 32 with AbstractConfiguration

use of org.apache.commons.configuration.AbstractConfiguration in project zuul by Netflix.

the class ZuulFiltersModuleIntegTest method before.

@BeforeClass
public static void before() {
    AbstractConfiguration configuration = ConfigurationManager.getConfigInstance();
    configuration.setProperty("zuul.filters.locations", "inbound,outbound,endpoint");
    configuration.setProperty("zuul.filters.packages", "com.netflix.zuul.init,com.netflix.zuul.init2");
}
Also used : AbstractConfiguration(org.apache.commons.configuration.AbstractConfiguration) BeforeClass(org.junit.BeforeClass)

Example 33 with AbstractConfiguration

use of org.apache.commons.configuration.AbstractConfiguration in project chassis by Kixeye.

the class WebSocketTransportConfiguration method webSocketServer.

@Bean(initMethod = "start", destroyMethod = "stop")
@Order(0)
public Server webSocketServer(@Value("${websocket.enabled:false}") boolean websocketEnabled, @Value("${websocket.hostname:}") String websocketHostname, @Value("${websocket.port:-1}") int websocketPort, @Value("${secureWebsocket.enabled:false}") boolean secureWebsocketEnabled, @Value("${secureWebsocket.hostname:}") String secureWebsocketHostname, @Value("${secureWebsocket.port:-1}") int secureWebsocketPort, @Value("${secureWebsocket.selfSigned:false}") boolean selfSigned, @Value("${secureWebsocket.mutualSsl:false}") boolean mutualSsl, @Value("${secureWebsocket.keyStorePath:}") String keyStorePath, @Value("${secureWebsocket.keyStoreData:}") String keyStoreData, @Value("${secureWebsocket.keyStorePassword:}") String keyStorePassword, @Value("${secureWebsocket.keyManagerPassword:}") String keyManagerPassword, @Value("${secureWebsocket.trustStorePath:}") String trustStorePath, @Value("${secureWebsocket.trustStoreData:}") String trustStoreData, @Value("${secureWebsocket.trustStorePassword:}") String trustStorePassword, @Value("${securewebsocket.excludedCipherSuites:}") String[] excludedCipherSuites) throws Exception {
    // set up servlets
    ServletContextHandler context = new ServletContextHandler(ServletContextHandler.NO_SESSIONS | ServletContextHandler.NO_SECURITY);
    context.setErrorHandler(null);
    context.setWelcomeFiles(new String[] { "/" });
    for (final MessageSerDe serDe : serDes) {
        // create the websocket creator
        final WebSocketCreator webSocketCreator = new WebSocketCreator() {

            public Object createWebSocket(ServletUpgradeRequest req, ServletUpgradeResponse resp) {
                // this will have spring construct a new one for every session
                ActionInvokingWebSocket webSocket = forwardingWebSocket();
                webSocket.setSerDe(serDe);
                webSocket.setUpgradeRequest(req);
                webSocket.setUpgradeResponse(resp);
                return webSocket;
            }
        };
        // configure the websocket servlet
        ServletHolder webSocketServlet = new ServletHolder(new WebSocketServlet() {

            private static final long serialVersionUID = -3022799271546369505L;

            @Override
            public void configure(WebSocketServletFactory factory) {
                factory.setCreator(webSocketCreator);
            }
        });
        Map<String, String> webSocketProperties = new HashMap<>();
        AbstractConfiguration config = ConfigurationManager.getConfigInstance();
        Iterator<String> webSocketPropertyKeys = config.getKeys("websocket");
        while (webSocketPropertyKeys.hasNext()) {
            String key = webSocketPropertyKeys.next();
            webSocketProperties.put(key.replaceFirst(Pattern.quote("websocket."), ""), config.getString(key));
        }
        webSocketServlet.setInitParameters(webSocketProperties);
        context.addServlet(webSocketServlet, "/" + serDe.getMessageFormatName() + "/*");
    }
    // create the server
    Server server;
    if (metricRegistry == null || !monitorThreadpool) {
        server = new Server();
        server.setHandler(context);
    } else {
        server = new Server(new InstrumentedQueuedThreadPool(metricRegistry));
        InstrumentedHandler instrumented = new InstrumentedHandler(metricRegistry);
        instrumented.setHandler(context);
        server.setHandler(instrumented);
    }
    // set up connectors
    if (websocketEnabled) {
        InetSocketAddress address = StringUtils.isBlank(websocketHostname) ? new InetSocketAddress(websocketPort) : new InetSocketAddress(websocketHostname, websocketPort);
        JettyConnectorRegistry.registerHttpConnector(server, address);
    }
    if (secureWebsocketEnabled) {
        InetSocketAddress address = StringUtils.isBlank(secureWebsocketHostname) ? new InetSocketAddress(secureWebsocketPort) : new InetSocketAddress(secureWebsocketHostname, secureWebsocketPort);
        JettyConnectorRegistry.registerHttpsConnector(server, address, selfSigned, mutualSsl, keyStorePath, keyStoreData, keyStorePassword, keyManagerPassword, trustStorePath, trustStoreData, trustStorePassword, excludedCipherSuites);
    }
    return server;
}
Also used : InstrumentedHandler(com.kixeye.chassis.transport.http.InstrumentedHandler) WebSocketServletFactory(org.eclipse.jetty.websocket.servlet.WebSocketServletFactory) Server(org.eclipse.jetty.server.Server) HashMap(java.util.HashMap) ServletHolder(org.eclipse.jetty.servlet.ServletHolder) InetSocketAddress(java.net.InetSocketAddress) MessageSerDe(com.kixeye.chassis.transport.serde.MessageSerDe) WebSocketServlet(org.eclipse.jetty.websocket.servlet.WebSocketServlet) ServletUpgradeResponse(org.eclipse.jetty.websocket.servlet.ServletUpgradeResponse) AbstractConfiguration(org.apache.commons.configuration.AbstractConfiguration) InstrumentedQueuedThreadPool(com.codahale.metrics.jetty9.InstrumentedQueuedThreadPool) WebSocketCreator(org.eclipse.jetty.websocket.servlet.WebSocketCreator) ServletContextHandler(org.eclipse.jetty.servlet.ServletContextHandler) ServletUpgradeRequest(org.eclipse.jetty.websocket.servlet.ServletUpgradeRequest) Order(org.springframework.core.annotation.Order) Bean(org.springframework.context.annotation.Bean)

Example 34 with AbstractConfiguration

use of org.apache.commons.configuration.AbstractConfiguration in project chassis by Kixeye.

the class BootstrapConfiguration method applicationConfiguration.

@Bean
@SuppressWarnings("resource")
public AbstractConfiguration applicationConfiguration() throws ClassNotFoundException {
    AppMetadata appMetadata = appMetadata();
    ServerInstanceContext serverInstanceContext = serverInstanceContext();
    if (appEnvironment == null && serverInstanceContext != null) {
        appEnvironment = serverInstanceContext.getEnvironment();
    }
    ConfigurationBuilder configurationBuilder = new ConfigurationBuilder(appMetadata.getName(), appEnvironment, addSystemConfigs, reflections());
    configurationBuilder.withConfigurationProvider(configurationProvider());
    configurationBuilder.withServerInstanceContext(serverInstanceContext());
    configurationBuilder.withApplicationProperties(appMetadata.getPropertiesResourceLocation());
    configurationBuilder.withScanModuleConfigurations(scanModuleConfigurations);
    configurationBuilder.withAppVersion(appMetadata.getDeclaringClass().getPackage().getImplementationVersion());
    AbstractConfiguration configuration = configurationBuilder.build();
    if (serverInstanceContext != null) {
        serverInstanceContext.setAppName(appMetadata.getName());
        serverInstanceContext.setVersion(configuration.getString(BootstrapConfigKeys.APP_VERSION_KEY.getPropertyName()));
    }
    return configuration;
}
Also used : AbstractConfiguration(org.apache.commons.configuration.AbstractConfiguration) ConfigurationBuilder(com.kixeye.chassis.bootstrap.configuration.ConfigurationBuilder) ServerInstanceContext(com.kixeye.chassis.bootstrap.aws.ServerInstanceContext) Bean(org.springframework.context.annotation.Bean)

Example 35 with AbstractConfiguration

use of org.apache.commons.configuration.AbstractConfiguration in project chassis by Kixeye.

the class LoggingConfiguration method initialize.

@PostConstruct
public void initialize() {
    AbstractConfiguration config = ConfigurationManager.getConfigInstance();
    if (config.containsKey(LOGBACK_CONFIG_NAME)) {
        System.out.println("Loading logging config.");
        reloadLogging(config.getString(LOGBACK_CONFIG_NAME));
    }
    config.addConfigurationListener(new ConfigurationListener() {

        @Override
        public synchronized void configurationChanged(ConfigurationEvent event) {
            if ((event.getType() == AbstractConfiguration.EVENT_ADD_PROPERTY || event.getType() == AbstractConfiguration.EVENT_SET_PROPERTY) && StringUtils.equalsIgnoreCase(LOGBACK_CONFIG_NAME, event.getPropertyName()) && event.getPropertyValue() != null && !event.isBeforeUpdate()) {
                System.out.println("Reloading logging config.");
                reloadLogging((String) event.getPropertyValue());
            }
        }
    });
    ConfigurationListener flumeConfigListener = new ConfigurationListener() {

        private FlumeLoggerLoader loggerLoader = null;

        public synchronized void configurationChanged(ConfigurationEvent event) {
            if (!(event.getType() == AbstractConfiguration.EVENT_SET_PROPERTY || event.getType() == AbstractConfiguration.EVENT_ADD_PROPERTY || event.getType() == AbstractConfiguration.EVENT_CLEAR_PROPERTY)) {
                return;
            }
            if (FlumeLoggerLoader.FLUME_LOGGER_ENABLED_PROPERTY.equals(event.getPropertyName())) {
                if ("true".equals(event.getPropertyValue())) {
                    if (loggerLoader == null) {
                        // construct the bean
                        loggerLoader = (FlumeLoggerLoader) applicationContext.getBean(FlumeLoggerLoader.PROTOTYPE_BEAN_NAME, "chassis");
                    }
                // else we already have one so we're cool
                } else {
                    if (loggerLoader != null) {
                        // delete the bean
                        ConfigurableBeanFactory beanFactory = (ConfigurableBeanFactory) applicationContext.getParentBeanFactory();
                        beanFactory.destroyBean(FlumeLoggerLoader.PROTOTYPE_BEAN_NAME, loggerLoader);
                        loggerLoader = null;
                    }
                // else we don't have any so we're cool
                }
            } else if (FlumeLoggerLoader.RELOAD_PROPERTIES.contains(event.getPropertyValue())) {
                // only reload if we're already running - otherwise ignore
                if (loggerLoader != null) {
                    // delete the bean
                    ConfigurableBeanFactory beanFactory = (ConfigurableBeanFactory) applicationContext.getParentBeanFactory();
                    beanFactory.destroyBean(FlumeLoggerLoader.PROTOTYPE_BEAN_NAME, loggerLoader);
                    loggerLoader = null;
                    // construct the bean
                    loggerLoader = (FlumeLoggerLoader) applicationContext.getBean(FlumeLoggerLoader.PROTOTYPE_BEAN_NAME, "chassis");
                }
            // else we don't have any so we're cool
            }
        }
    };
    config.addConfigurationListener(flumeConfigListener);
    flumeConfigListener.configurationChanged(new ConfigurationEvent(this, AbstractConfiguration.EVENT_SET_PROPERTY, FlumeLoggerLoader.FLUME_LOGGER_ENABLED_PROPERTY, config.getProperty(FlumeLoggerLoader.FLUME_LOGGER_ENABLED_PROPERTY), false));
}
Also used : AbstractConfiguration(org.apache.commons.configuration.AbstractConfiguration) ConfigurationListener(org.apache.commons.configuration.event.ConfigurationListener) ConfigurationEvent(org.apache.commons.configuration.event.ConfigurationEvent) ConfigurableBeanFactory(org.springframework.beans.factory.config.ConfigurableBeanFactory) PostConstruct(javax.annotation.PostConstruct)

Aggregations

AbstractConfiguration (org.apache.commons.configuration.AbstractConfiguration)80 Test (org.junit.Test)29 ConcurrentCompositeConfiguration (com.netflix.config.ConcurrentCompositeConfiguration)18 BeforeClass (org.junit.BeforeClass)10 Configuration (org.apache.commons.configuration.Configuration)9 URI (java.net.URI)6 BaseConfiguration (org.apache.commons.configuration.BaseConfiguration)6 HttpRequest (com.netflix.client.http.HttpRequest)5 ArrayList (java.util.ArrayList)5 DynamicConfiguration (com.netflix.config.DynamicConfiguration)4 EnvironmentConfiguration (org.apache.commons.configuration.EnvironmentConfiguration)4 SystemConfiguration (org.apache.commons.configuration.SystemConfiguration)4 HttpResponse (com.netflix.client.http.HttpResponse)3 ConcurrentMapConfiguration (com.netflix.config.ConcurrentMapConfiguration)3 ExpandedConfigurationListenerAdapter (com.netflix.config.ExpandedConfigurationListenerAdapter)3 LinkedHashMap (java.util.LinkedHashMap)3 Properties (java.util.Properties)3 AggregatedConfiguration (com.netflix.config.AggregatedConfiguration)2 ConfigurationManager (com.netflix.config.ConfigurationManager)2 DynamicURLConfiguration (com.netflix.config.DynamicURLConfiguration)2