Package org.lilyproject.runtime.conf

Examples of org.lilyproject.runtime.conf.Conf


    public VersionManager(LilyRuntime runtime) {
        this.runtime = runtime;
    }

    public String getPreferredVersion(String groupId, String artifactId) {
        Conf versionsConf = runtime.getConfManager().getRuntimeConfRegistry().getConfiguration("versions", false, true);
        String preferred = null;

        if (versionsConf != null) {
            for (Conf conf: versionsConf.getChildren("version")) {
                String vGroupId = conf.getAttribute("groupId", null);
                String vArtifactId = conf.getAttribute("artifactId", null);

                if ((vGroupId == null || vGroupId.equals(groupId)) &&
                        (vArtifactId == null || vArtifactId.equals(artifactId))) {
View Full Code Here


                    + getClass().getName() + " instance concurrently or sequentially without proper shutdown?");
        }

        executor = Executors.newScheduledThreadPool(1);

        Conf conf = getConfRegistry(RUNTIME_CONF_NAME).getConfiguration("configuration", true);
        Conf reloadingConf = conf.getChild("reloading");
        boolean reloadingEnabled = reloadingConf.getAttributeAsBoolean("enabled", true);
        int delay = reloadingConf.getAttributeAsInteger("delay", 5000);

        if (reloadingEnabled) {
            executor.scheduleWithFixedDelay(new Runnable() {
                public void run() {
                    refresh(true);
View Full Code Here

        long runDelay = 1000 * blobManagerConf.getChild("blobIncubatorMonitor").getAttributeAsLong("runDelay");
        blobIncubatorMonitor = new BlobIncubatorMonitor(zookeeper, hbaseTableFactory, tableManager,
                                        blobManager, typeManager, minimalAge, monitorDelay, runDelay);

        List<String> blobIncubatorNodes = Collections.EMPTY_LIST;
        Conf nodesConf = blobManagerConf.getChild("blobIncubatorMonitor").getChild("nodes");
        if (nodesConf != null) {
            String nodes = nodesConf.getValue("");
            if (!nodes.isEmpty()) {
                blobIncubatorNodes = Arrays.asList(nodes.split(","));
            }
        }
        if (blobIncubatorNodes.isEmpty() || blobIncubatorNodes.contains(hostName)) {
View Full Code Here

public class ConfModelTest extends TestCase {
    public void testConfig1() throws Exception {
        String configPath = "config1.xml";
        InputStream configStream = getClass().getResourceAsStream(configPath);

        Conf config = XmlConfBuilder.build(configStream, configPath);
        assertEquals("value1", config.getAttribute("att1"));
        assertEquals("value2", config.getAttribute("att2"));

        assertEquals(3, config.getChildren().size());
        assertEquals(2, config.getChildren("element").size());

        for (Conf childConf : config.getChildren("element")) {
            assertEquals("element", childConf.getName());
            assertEquals("abc", childConf.getValue());
        }

        assertEquals(2, config.getChild("parent").getChildren("child").size());

        for (Conf childConf : config.getChild("parent").getChildren("child")) {
            assertEquals("def", childConf.getValue());
        }

        assertEquals(0, config.getChild("parent").getChild("child").getChildren().size());

        assertNotNull(config.getChild("nonexistingchild"));
        assertNull(config.getChild("nonexistingchild", false));

        // Getting the value of a node without a value should throw an error
        try {
            config.getChild("nonexistingchild").getValue();
            fail("expected exception");
        } catch (ConfException e) { /* ignore */ }

        assertEquals("zit", config.getChild("nonexistingchild").getValue("zit"));
    }
View Full Code Here

     */
    public void testConfig5() throws Exception {
        String configPath = "config5.xml";
        InputStream configStream = getClass().getResourceAsStream(configPath);

        Conf config = XmlConfBuilder.build(configStream, configPath);

        assertTrue(config.getChild("boolean").getValueAsBoolean());
        assertEquals(5, config.getChild("int").getValueAsInteger());
        assertEquals(6l, config.getChild("long").getValueAsLong());
        assertEquals(3.3f, config.getChild("float").getValueAsFloat(), 0.0001f);
        assertEquals(5.5d, config.getChild("double").getValueAsDouble(), 0.0001d);

        // Test fallback to default
        assertTrue(config.getChild("boolean2").getValueAsBoolean(true));
        assertEquals(new Integer(5), config.getChild("int2").getValueAsInteger(5));
        assertEquals(new Long(6l), config.getChild("long2").getValueAsLong(6l));
        assertEquals(3.3f, config.getChild("float2").getValueAsFloat(3.3f), 0.0001f);
        assertEquals(5.5d, config.getChild("double2").getValueAsDouble(5.5d), 0.0001d);

        // Test attributes
        assertTrue(config.getAttributeAsBoolean("boolean"));
        assertEquals(5, config.getAttributeAsInteger("int"));
        assertEquals(6l, config.getAttributeAsLong("long"));
        assertEquals(3.3f, config.getAttributeAsFloat("float"), 0.0001f);
        assertEquals(5.5d, config.getAttributeAsDouble("double"), 0.0001d);

        // Test attribute fallback to default
        assertTrue(config.getAttributeAsBoolean("boolean2", true));
        assertEquals(new Integer(5), config.getAttributeAsInteger("int2", 5));
        assertEquals(new Long(6l), config.getAttributeAsLong("long2", 6l));
        assertEquals(3.3f, config.getAttributeAsFloat("float2", 3.3f), 0.0001f);
        assertEquals(5.5d, config.getAttributeAsDouble("double2", 5.5d), 0.0001d);
    }
View Full Code Here

import org.lilyproject.runtime.conf.XmlConfBuilder;

public class JXPathTest extends TestCase {
    public void testIt() throws Exception {
        String path = "jxpathconf.xml";
        Conf conf = XmlConfBuilder.build(getClass().getResourceAsStream(path), path);

        JXPathContext context = JXPathContext.newContext(conf);

        assertEquals("Venus", context.getValue("planet"));
        assertEquals("Mars", context.getValue("@planet"));
View Full Code Here

        ApplicationContext appContext = runtime.getModuleById("confmod").getApplicationContext();

        Map beans = appContext.getBeansOfType(ConfRegistry.class);
        ConfRegistry confRegistry = (ConfRegistry)beans.get("conf");

        Conf conf = confRegistry.getConfiguration("test1");
        Assert.assertEquals("Jef", conf.getChild("name").getValue());

        conf = confRegistry.getConfiguration("test2");
        Assert.assertEquals("foobar@hotmail.com", conf.getChild("email").getValue());
        Assert.assertEquals("smtp.google.com", conf.getChild("smtp").getValue());

        conf = confRegistry.getConfiguration("test3");
        Assert.assertEquals(599, conf.getChild("delay").getValueAsInteger());

        String confTestBean1 = (String)appContext.getBean("confTestBean1");
        Assert.assertEquals("foobar@hotmail.com", confTestBean1);

        ConfDependentBean confTestBean2 = (ConfDependentBean)appContext.getBean("confTestBean2");
View Full Code Here

TOP

Related Classes of org.lilyproject.runtime.conf.Conf

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.