Package org.apache.ace.agent

Examples of org.apache.ace.agent.ConfigurationHandler


        System.setProperty(systemKey1, "value1");
        System.setProperty(systemKey2, "value2");

        resetConfigurationHandler();

        ConfigurationHandler configurationHandler = m_agentContextImpl.getHandler(ConfigurationHandler.class);

        assertEquals(configurationHandler.get(systemKey1, "default1"), "value1");
        assertEquals(configurationHandler.get(systemKey2, "default2"), "value2");

        // System props should *not* be persisted, they are not in our control...

        System.clearProperty(systemKey1);
        System.clearProperty(systemKey2);

        resetConfigurationHandler();

        configurationHandler = m_agentContextImpl.getHandler(ConfigurationHandler.class);

        assertEquals(configurationHandler.get(systemKey1, "qux"), "qux");
        assertEquals(configurationHandler.get(systemKey2, "quu"), "quu");

        // System props should not override the configured values...

        System.setProperty(systemKey1, "value1");
        System.setProperty(systemKey2, "value2");

        configureAgent(configurationHandler, systemKey1, "newvalue1", systemKey2, "newvalue2");

        resetConfigurationHandler();

        configurationHandler = m_agentContextImpl.getHandler(ConfigurationHandler.class);

        assertEquals(configurationHandler.get(systemKey1, "qux"), "newvalue1");
        assertEquals(configurationHandler.get(systemKey2, "quu"), "newvalue2");

        // System props should not override if explicitly configured values are present...

        System.setProperty(systemKey1, "valueX");
        System.setProperty(systemKey2, "valueY");

        resetConfigurationHandler();

        configurationHandler = m_agentContextImpl.getHandler(ConfigurationHandler.class);

        assertEquals(configurationHandler.get(systemKey1, "qqq"), "newvalue1");
        assertEquals(configurationHandler.get(systemKey2, "qqq"), "newvalue2");
    }
View Full Code Here


    private void resetConfigurationHandler() throws Exception {
        resetConfigurationHandler(new ConfigurationHandlerImpl(m_context));
    }

    private void resetConfigurationHandler(ConfigurationHandler configurationHandler) throws Exception {
        ConfigurationHandler oldConfigurationHandler = m_agentContextImpl.getHandler(ConfigurationHandler.class);
        if (oldConfigurationHandler instanceof ComponentBase) {
            ((ComponentBase) oldConfigurationHandler).stop();
        }

        m_agentContextImpl.setHandler(ConfigurationHandler.class, configurationHandler);
View Full Code Here

    protected void onInit() throws Exception {
        getEventsHandler().addListener(this);

        // The controller is started *after* all other components, causing it to miss the initial configuration-update
        // event, hence we need to get the configuration ourselves for the first time...
        ConfigurationHandler config = getConfigurationHandler();
        m_updateStreaming.set(config.getBoolean(CONFIG_CONTROLLER_STREAMING, m_updateStreaming.get()));
        m_fixPackage.set(config.getBoolean(CONFIG_CONTROLLER_FIXPACKAGES, m_fixPackage.get()));
        m_interval.set(config.getLong(CONFIG_CONTROLLER_SYNCINTERVAL, m_interval.get()));
        m_syncDelay.set(config.getLong(CONFIG_CONTROLLER_SYNCDELAY, m_syncDelay.get()));
        m_maxRetries.set(config.getLong(CONFIG_CONTROLLER_RETRIES, m_maxRetries.get()));

        logDebug("Config initialized: update: %s, fixPkg: %s, syncDelay: %d, syncInterval: %d, maxRetries: %d", m_updateStreaming.get(), m_fixPackage.get(), m_syncDelay.get(), m_interval.get(), m_maxRetries.get());
    }
View Full Code Here

        expect(identificationHandler.getAgentId()).andReturn(identification).anyTimes();

        DiscoveryHandler discoveryHandler = addTestMock(DiscoveryHandler.class);
        expect(discoveryHandler.getServerUrl()).andReturn(serverURL).anyTimes();

        ConfigurationHandler configurationHandler = addTestMock(ConfigurationHandler.class);
        expect(configurationHandler.get(notNull(String.class), anyObject(String.class))).andReturn(null).anyTimes();

        DeploymentAdmin deploymentAdmin = addTestMock(DeploymentAdmin.class);
        expect(deploymentAdmin.listDeploymentPackages()).andReturn(
            new DeploymentPackage[] { deploymentPackage2, deploymentPackage1 }).anyTimes();
        expect(deploymentAdmin.installDeploymentPackage(notNull(InputStream.class)
View Full Code Here

    public void testGetSizeEstimateForDeploymentPackage() throws Exception {
        AgentControl control = getService(AgentControl.class);

        Map<String, String> props = createAgentConfiguration(false /* useStreaming */, 1000 /* secs */);

        ConfigurationHandler configurationHandler = control.getConfigurationHandler();
        configurationHandler.putAll(props);

        // Allow configuration to propagate...
        Thread.sleep(100L);

        synchronized (m_servlet) {
View Full Code Here

    private void setupAgentForNonStreamingDeployment() throws Exception {
        AgentControl control = getService(AgentControl.class);

        Map<String, String> props = createAgentConfiguration(false /* useStreaming */, 1 /* sec */);

        ConfigurationHandler configurationHandler = control.getConfigurationHandler();
        configurationHandler.putAll(props);

        synchronized (m_servlet) {
            m_servlet.reset();
        }

View Full Code Here

    private void setupAgentForStreamingDeployment() throws Exception {
        AgentControl control = getService(AgentControl.class);

        Map<String, String> props = createAgentConfiguration(true /* useStreaming */, 1 /* sec */);

        ConfigurationHandler configurationHandler = control.getConfigurationHandler();
        configurationHandler.putAll(props);

        waitForInstalledVersion(Version.emptyVersion);
    }
View Full Code Here

TOP

Related Classes of org.apache.ace.agent.ConfigurationHandler

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.