private void setAttributes() throws IOException { InputStream is = getClass().getResourceAsStream(PROPERTIES_FILE); if (is != null) { Properties properties = new Properties(); properties.load(is); //for (Object propertyNameObj : properties.keySet()) { Iterator it = properties.keySet().iterator(); while (it.hasNext()) { String propertyName = (String) it.next(); String propertyValue = properties.getProperty(propertyName); setAttribute(propertyName, propertyValue); } } }
private void setAttributes(String propertiesFile) throws IOException { InputStream is = getClass().getResourceAsStream(propertiesFile); if (is != null) { Properties properties = new Properties(); properties.load(is); //for (Object propertyNameObj : properties.keySet()) { Iterator it = properties.keySet().iterator(); while (it.hasNext()) { String propertyName = (String) it.next(); String propertyValue = properties.getProperty(propertyName); setAttribute(propertyName, propertyValue); } } }
private void setAttributes() throws IOException { InputStream is = getClass().getResourceAsStream(PROPERTIES_FILE); if (is != null) { try { Properties properties = new Properties(); properties.load(is); //for (Object propertyNameObj : properties.keySet()) { Iterator it = properties.keySet().iterator(); while (it.hasNext()) { String propertyName = (String) it.next(); String propertyValue = properties.getProperty(propertyName); setAttribute(propertyName, propertyValue); } } finally { is.close(); } } }
private void setAttributes() throws IOException { InputStream is = getClass().getResourceAsStream(PROPERTIES_FILE); if (is != null) { try { Properties properties = new Properties(); properties.load(is); //for (Object propertyNameObj : properties.keySet()) { Iterator it = properties.keySet().iterator(); while (it.hasNext()) { String propertyName = (String) it.next(); String propertyValue = properties.getProperty(propertyName); setAttribute(propertyName, propertyValue); } } finally { is.close(); } } }
private void setAttributes() throws IOException { InputStream is = getClass().getResourceAsStream(PROPERTIES_FILE); if (is != null) { try { Properties properties = new Properties(); properties.load(is); //for (Object propertyNameObj : properties.keySet()) { Iterator it = properties.keySet().iterator(); while (it.hasNext()) { String propertyName = (String) it.next(); String propertyValue = properties.getProperty(propertyName); setAttribute(propertyName, propertyValue); } } finally { is.close(); } } }
private void setAttributes() throws IOException { InputStream is = getClass().getResourceAsStream(PROPERTIES_FILE); if (is != null) { try { Properties properties = new Properties(); properties.load(is); //for (Object propertyNameObj : properties.keySet()) { Iterator it = properties.keySet().iterator(); while (it.hasNext()) { String propertyName = (String) it.next(); String propertyValue = properties.getProperty(propertyName); setAttribute(propertyName, propertyValue); } } finally { is.close(); } } }
@Test public void testShouldSetMulticastSocketTtl() throws Exception { GangliaContext context = new GangliaContext(); ContextFactory factory = ContextFactory.getFactory(); factory.setAttribute("gangliaContext.multicast", "true"); factory.setAttribute("gangliaContext.multicast.ttl", "10"); context.init("gangliaContext", factory); MulticastSocket multicastSocket = (MulticastSocket) context.datagramSocket; assertEquals("Did not set TTL", multicastSocket.getTimeToLive(), 10); }
@Test public void testShouldSetMulticastSocketTtl() throws Exception { GangliaContext context = new GangliaContext(); ContextFactory factory = ContextFactory.getFactory(); factory.setAttribute("gangliaContext.multicast", "true"); factory.setAttribute("gangliaContext.multicast.ttl", "10"); context.init("gangliaContext", factory); MulticastSocket multicastSocket = (MulticastSocket) context.datagramSocket; assertEquals("Did not set TTL", multicastSocket.getTimeToLive(), 10); }
public Metrics(Conf conf) throws IOException { ContextFactory contextFactory = ContextFactory.getFactory(); for (Conf attr : conf.getChild("hadoopMetricsAttributes").getChildren("attribute")) { contextFactory.setAttribute(attr.getAttribute("name"), attr.getAttribute(("value"))); } boolean enableJvmMetrics = conf.getChild("enableJvmMetrics").getValueAsBoolean(); if (enableJvmMetrics) { JvmMetrics.init("lily", "aLilySession"); } } }
@Test public void testShouldCreateDatagramSocketIfMulticastIsDisabled() throws Exception { GangliaContext context = new GangliaContext(); ContextFactory factory = ContextFactory.getFactory(); factory.setAttribute("gangliaContext.multicast", "false"); context.init("gangliaContext", factory); assertFalse("Created MulticastSocket", context.datagramSocket instanceof MulticastSocket); }
@Test public void testShouldCreateDatagramSocketIfMulticastIsDisabled() throws Exception { GangliaContext context = new GangliaContext(); ContextFactory factory = ContextFactory.getFactory(); factory.setAttribute("gangliaContext.multicast", "false"); context.init("gangliaContext", factory); assertFalse("Created MulticastSocket", context.datagramSocket instanceof MulticastSocket); }
@Test public void testShouldCreateMulticastSocket() throws Exception { GangliaContext context = new GangliaContext(); ContextFactory factory = ContextFactory.getFactory(); factory.setAttribute("gangliaContext.multicast", "true"); context.init("gangliaContext", factory); assertTrue("Did not create MulticastSocket", context.datagramSocket instanceof MulticastSocket); MulticastSocket multicastSocket = (MulticastSocket) context.datagramSocket; assertEquals("Did not set default TTL", multicastSocket.getTimeToLive(), 1); }
@Test public void testShouldCreateMulticastSocket() throws Exception { GangliaContext context = new GangliaContext(); ContextFactory factory = ContextFactory.getFactory(); factory.setAttribute("gangliaContext.multicast", "true"); context.init("gangliaContext", factory); assertTrue("Did not create MulticastSocket", context.datagramSocket instanceof MulticastSocket); MulticastSocket multicastSocket = (MulticastSocket) context.datagramSocket; assertEquals("Did not set default TTL", multicastSocket.getTimeToLive(), 1); }