Java 类org.apache.zookeeper.jmx.CommonNames 实例源码

项目:ZooKeeper    文件:HierarchicalQuorumTest.java   
private void verifyElectionTimeTakenJMXAttribute(List<QuorumPeer> peers)
        throws Exception {
    LOG.info("Verify QuorumPeer#electionTimeTaken jmx bean attribute");

    for (int i = 1; i <= peers.size(); i++) {
        QuorumPeer qp = peers.get(i - 1);
        if (qp.getLearnerType() == LearnerType.OBSERVER) {
            continue; // Observer don't have electionTimeTaken attribute.
        }
        Long electionTimeTaken = -1L;
        String bean = "";
        if (qp.getPeerState() == ServerState.FOLLOWING) {
            bean = String.format(
                    "%s:name0=ReplicatedServer_id%d,name1=replica.%d,name2=Follower",
                    CommonNames.DOMAIN, i, i);
        } else if (qp.getPeerState() == ServerState.LEADING) {
            bean = String.format(
                    "%s:name0=ReplicatedServer_id%d,name1=replica.%d,name2=Leader",
                    CommonNames.DOMAIN, i, i);
        }
        electionTimeTaken = (Long) JMXEnv.ensureBeanAttribute(bean,
                "ElectionTimeTaken");
        Assert.assertTrue("Wrong electionTimeTaken value!",
                electionTimeTaken >= 0);
    }
}
项目:bigstreams    文件:JMXEnv.java   
public static void ensureNone(String... expectedNames)
    throws IOException
{
    Set<ObjectName> beans;
    try {
        beans = conn().queryNames(
                new ObjectName(CommonNames.DOMAIN + ":*"), null);
    } catch (MalformedObjectNameException e) {
        throw new RuntimeException(e);
    }

    for (String name : expectedNames) {
        for (ObjectName bean : beans) {
            if (bean.toString().contains(name)) {
                LOG.info("didntexpect:" + name);
                TestCase.fail(name + " " + bean.toString());
            }
        }
    }
}
项目:bigstreams    文件:JMXEnv.java   
public static void ensureNone(String... expectedNames)
    throws IOException
{
    Set<ObjectName> beans;
    try {
        beans = conn().queryNames(
                new ObjectName(CommonNames.DOMAIN + ":*"), null);
    } catch (MalformedObjectNameException e) {
        throw new RuntimeException(e);
    }

    for (String name : expectedNames) {
        for (ObjectName bean : beans) {
            if (bean.toString().contains(name)) {
                System.err.println("didntexpect:" + name);
                TestCase.fail(name + " " + bean.toString());
            }
        }
    }
}
项目:LoadBalanced_zk    文件:JMXEnv.java   
public static void ensureNone(String... expectedNames)
    throws IOException
{
    Set<ObjectName> beans;
    try {
        beans = conn().queryNames(
                new ObjectName(CommonNames.DOMAIN + ":*"), null);
    } catch (MalformedObjectNameException e) {
        throw new RuntimeException(e);
    }

    for (String name : expectedNames) {
        for (ObjectName bean : beans) {
            if (bean.toString().contains(name)) {
                LOG.info("didntexpect:" + name);
                TestCase.fail(name + " " + bean.toString());
            }
        }
    }
}
项目:LoadBalanced_zk    文件:JMXEnv.java   
public static void ensureNone(String... expectedNames)
    throws IOException
{
    Set<ObjectName> beans;
    try {
        beans = conn().queryNames(
                new ObjectName(CommonNames.DOMAIN + ":*"), null);
    } catch (MalformedObjectNameException e) {
        throw new RuntimeException(e);
    }

    for (String name : expectedNames) {
        for (ObjectName bean : beans) {
            if (bean.toString().contains(name)) {
                LOG.info("didntexpect:" + name);
                TestCase.fail(name + " " + bean.toString());
            }
        }
    }
}
项目:zookeeper.dsc    文件:JMXEnv.java   
public static void ensureNone(String... expectedNames)
    throws IOException
{
    Set<ObjectName> beans;
    try {
        beans = conn().queryNames(
                new ObjectName(CommonNames.DOMAIN + ":*"), null);
    } catch (MalformedObjectNameException e) {
        throw new RuntimeException(e);
    }

    for (String name : expectedNames) {
        for (ObjectName bean : beans) {
            if (bean.toString().contains(name)) {
                System.err.println("didntexpect:" + name);
                TestCase.fail(name + " " + bean.toString());
            }
        }
    }
}
项目:zookeeper-pkg    文件:JMXEnv.java   
public static void ensureNone(String... expectedNames)
    throws IOException
{
    Set<ObjectName> beans;
    try {
        beans = conn().queryNames(
                new ObjectName(CommonNames.DOMAIN + ":*"), null);
    } catch (MalformedObjectNameException e) {
        throw new RuntimeException(e);
    }

    for (String name : expectedNames) {
        for (ObjectName bean : beans) {
            if (bean.toString().contains(name)) {
                LOG.info("didntexpect:" + name);
                TestCase.fail(name + " " + bean.toString());
            }
        }
    }
}
项目:fuck_zookeeper    文件:JMXEnv.java   
/**
 * Ensure that all of the specified names are registered.
 * Note that these are components of the name, and in particular
 * order matters - you want the more specific name (leafs) specified
 * before their parent(s) (since names are hierarchical)
 * It waits in a loop up to 60 seconds before failing if there is a
 * mismatch.
 * @param expectedNames
 * @return
 * @throws IOException
 * @throws MalformedObjectNameException
 */
public static Set<ObjectName> ensureAll(String... expectedNames)
    throws IOException, InterruptedException
{
    Set<ObjectName> beans;
    Set<ObjectName> found;
    int nTry = 0;
    do {
        if (nTry++ > 0) {
            Thread.sleep(100);
        }
        try {
            beans = conn().queryNames(
                    new ObjectName(CommonNames.DOMAIN + ":*"), null);
        } catch (MalformedObjectNameException e) {
            throw new RuntimeException(e);
        }

        found = new HashSet<ObjectName>();
        for (String name : expectedNames) {
            LOG.info("expect:" + name);
            for (ObjectName bean : beans) {
                if (bean.toString().contains(name)) {
                    LOG.info("found:" + name + " " + bean);
                    found.add(bean);
                    break;
                }
            }
            beans.removeAll(found);
        }
    } while ((expectedNames.length != found.size()) && (nTry < 600));
    TestCase.assertEquals("expected " + Arrays.toString(expectedNames),
            expectedNames.length, found.size());
    return beans;
}
项目:fuck_zookeeper    文件:JMXEnv.java   
public static void dump() throws IOException {
    LOG.info("JMXEnv.dump() follows");
    Set<ObjectName> beans;
    try {
        beans = conn().queryNames(
                new ObjectName(CommonNames.DOMAIN + ":*"), null);
    } catch (MalformedObjectNameException e) {
        throw new RuntimeException(e);
    }
    for (ObjectName bean : beans) {
        LOG.info("bean:" + bean.toString());
    }
}
项目:fuck_zookeeper    文件:JMXEnv.java   
/**
 * Ensure that the specified parent names are registered. Note that these
 * are components of the name. It waits in a loop up to 60 seconds before
 * failing if there is a mismatch. This will return the beans which are not
 * matched.
 * 
 * {@link https://issues.apache.org/jira/browse/ZOOKEEPER-1858}
 * 
 * @param expectedNames
 *            - expected beans
 * @return the beans which are not matched with the given expected names
 * 
 * @throws IOException
 * @throws InterruptedException
 * 
 */
public static Set<ObjectName> ensureParent(String... expectedNames)
        throws IOException, InterruptedException {
    LOG.info("ensureParent:" + Arrays.toString(expectedNames));

    Set<ObjectName> beans;
    int nTry = 0;
    Set<ObjectName> found = new HashSet<ObjectName>();
    do {
        if (nTry++ > 0) {
            Thread.sleep(500);
        }
        try {
            beans = conn().queryNames(
                    new ObjectName(CommonNames.DOMAIN + ":*"), null);
        } catch (MalformedObjectNameException e) {
            throw new RuntimeException(e);
        }
        found.clear();
        for (String name : expectedNames) {
            LOG.info("expect:" + name);
            for (ObjectName bean : beans) {
                // check the existence of name in bean
                if (compare(bean.toString(), name)) {
                    LOG.info("found:" + name + " " + bean);
                    found.add(bean);
                    break;
                }
            }
            beans.removeAll(found);
        }
    } while (expectedNames.length != found.size() && nTry < 120);
    TestCase.assertEquals("expected " + Arrays.toString(expectedNames),
            expectedNames.length, found.size());
    return beans;
}
项目:https-github.com-apache-zookeeper    文件:JMXEnv.java   
/**
 * Ensure that all of the specified names are registered.
 * Note that these are components of the name, and in particular
 * order matters - you want the more specific name (leafs) specified
 * before their parent(s) (since names are hierarchical)
 * It waits in a loop up to 60 seconds before failing if there is a
 * mismatch.
 * @param expectedNames
 * @return
 * @throws IOException
 * @throws MalformedObjectNameException
 */
public static Set<ObjectName> ensureAll(String... expectedNames)
    throws IOException, InterruptedException
{
    Set<ObjectName> beans;
    Set<ObjectName> found;
    int nTry = 0;
    do {
        if (nTry++ > 0) {
            Thread.sleep(100);
        }
        try {
            beans = conn().queryNames(
                    new ObjectName(CommonNames.DOMAIN + ":*"), null);
        } catch (MalformedObjectNameException e) {
            throw new RuntimeException(e);
        }

        found = new HashSet<ObjectName>();
        for (String name : expectedNames) {
            LOG.info("expect:" + name);
            for (ObjectName bean : beans) {
                if (bean.toString().contains(name)) {
                    LOG.info("found:" + name + " " + bean);
                    found.add(bean);
                    break;
                }
            }
            beans.removeAll(found);
        }
    } while ((expectedNames.length != found.size()) && (nTry < 600));
    Assert.assertEquals("expected " + Arrays.toString(expectedNames),
            expectedNames.length, found.size());
    return beans;
}
项目:https-github.com-apache-zookeeper    文件:JMXEnv.java   
public static void dump() throws IOException {
    LOG.info("JMXEnv.dump() follows");
    Set<ObjectName> beans;
    try {
        beans = conn().queryNames(
                new ObjectName(CommonNames.DOMAIN + ":*"), null);
    } catch (MalformedObjectNameException e) {
        throw new RuntimeException(e);
    }
    for (ObjectName bean : beans) {
        LOG.info("bean:" + bean.toString());
    }
}
项目:https-github.com-apache-zookeeper    文件:JMXEnv.java   
/**
 * Ensure that the specified parent names are registered. Note that these
 * are components of the name. It waits in a loop up to 60 seconds before
 * failing if there is a mismatch. This will return the beans which are not
 * matched.
 * 
 * {@link https://issues.apache.org/jira/browse/ZOOKEEPER-1858}
 * 
 * @param expectedNames
 *            - expected beans
 * @return the beans which are not matched with the given expected names
 * 
 * @throws IOException
 * @throws InterruptedException
 */
public static Set<ObjectName> ensureParent(String... expectedNames)
        throws IOException, InterruptedException {
    LOG.info("ensureParent:" + Arrays.toString(expectedNames));

    Set<ObjectName> beans;
    int nTry = 0;
    Set<ObjectName> found = new HashSet<ObjectName>();
    do {
        if (nTry++ > 0) {
            Thread.sleep(500);
        }
        try {
            beans = conn().queryNames(
                    new ObjectName(CommonNames.DOMAIN + ":*"), null);
        } catch (MalformedObjectNameException e) {
            throw new RuntimeException(e);
        }
        found.clear();
        for (String name : expectedNames) {
            LOG.info("expect:" + name);
            for (ObjectName bean : beans) {
                // check the existence of name in bean
                if (compare(bean.toString(), name)) {
                    LOG.info("found:" + name + " " + bean);
                    found.add(bean);
                    break;
                }
            }
            beans.removeAll(found);
        }
    } while (expectedNames.length != found.size() && nTry < 120);
    Assert.assertEquals("expected " + Arrays.toString(expectedNames),
            expectedNames.length, found.size());
    return beans;
}
项目:https-github.com-apache-zookeeper    文件:JMXEnv.java   
/**
 * Ensure that the specified bean name and its attribute is registered. Note
 * that these are components of the name. It waits in a loop up to 60
 * seconds before failing if there is a mismatch. This will return the beans
 * which are not matched.
 *
 * @param expectedName
 *            - expected bean
 * @param expectedAttribute
 *            - expected attribute
 * @return the value of the attribute
 *
 * @throws Exception
 */
public static Object ensureBeanAttribute(String expectedName,
        String expectedAttribute) throws Exception {
    String value = "";
    LOG.info("ensure bean:{}, attribute:{}", new Object[] { expectedName,
            expectedAttribute });

    Set<ObjectName> beans;
    int nTry = 0;
    do {
        if (nTry++ > 0) {
            Thread.sleep(500);
        }
        try {
            beans = conn().queryNames(
                    new ObjectName(CommonNames.DOMAIN + ":*"), null);
        } catch (MalformedObjectNameException e) {
            throw new RuntimeException(e);
        }
        LOG.info("expect:" + expectedName);
        for (ObjectName bean : beans) {
            // check the existence of name in bean
            if (bean.toString().equals(expectedName)) {
                LOG.info("found:{} {}", new Object[] { expectedName, bean });
                return conn().getAttribute(bean, expectedAttribute);
            }
        }
    } while (nTry < 120);
    Assert.fail("Failed to find bean:" + expectedName + ", attribute:"
            + expectedAttribute);
    return value;
}
项目:ZooKeeper    文件:JMXEnv.java   
/**
 * Ensure that all of the specified names are registered.
 * Note that these are components of the name, and in particular
 * order matters - you want the more specific name (leafs) specified
 * before their parent(s) (since names are hierarchical)
 * It waits in a loop up to 60 seconds before failing if there is a
 * mismatch.
 * @param expectedNames
 * @return
 * @throws IOException
 * @throws MalformedObjectNameException
 */
public static Set<ObjectName> ensureAll(String... expectedNames)
    throws IOException, InterruptedException
{
    Set<ObjectName> beans;
    Set<ObjectName> found;
    int nTry = 0;
    do {
        if (nTry++ > 0) {
            Thread.sleep(100);
        }
        try {
            beans = conn().queryNames(
                    new ObjectName(CommonNames.DOMAIN + ":*"), null);
        } catch (MalformedObjectNameException e) {
            throw new RuntimeException(e);
        }

        found = new HashSet<ObjectName>();
        for (String name : expectedNames) {
            LOG.info("expect:" + name);
            for (ObjectName bean : beans) {
                if (bean.toString().contains(name)) {
                    LOG.info("found:" + name + " " + bean);
                    found.add(bean);
                    break;
                }
            }
            beans.removeAll(found);
        }
    } while ((expectedNames.length != found.size()) && (nTry < 600));
    TestCase.assertEquals("expected " + Arrays.toString(expectedNames),
            expectedNames.length, found.size());
    return beans;
}
项目:ZooKeeper    文件:JMXEnv.java   
public static void dump() throws IOException {
    LOG.info("JMXEnv.dump() follows");
    Set<ObjectName> beans;
    try {
        beans = conn().queryNames(
                new ObjectName(CommonNames.DOMAIN + ":*"), null);
    } catch (MalformedObjectNameException e) {
        throw new RuntimeException(e);
    }
    for (ObjectName bean : beans) {
        LOG.info("bean:" + bean.toString());
    }
}
项目:ZooKeeper    文件:JMXEnv.java   
/**
 * Ensure that the specified parent names are registered. Note that these
 * are components of the name. It waits in a loop up to 60 seconds before
 * failing if there is a mismatch. This will return the beans which are not
 * matched.
 * 
 * {@link https://issues.apache.org/jira/browse/ZOOKEEPER-1858}
 * 
 * @param expectedNames
 *            - expected beans
 * @return the beans which are not matched with the given expected names
 * 
 * @throws IOException
 * @throws InterruptedException
 * 
 */
public static Set<ObjectName> ensureParent(String... expectedNames)
        throws IOException, InterruptedException {
    LOG.info("ensureParent:" + Arrays.toString(expectedNames));

    Set<ObjectName> beans;
    int nTry = 0;
    Set<ObjectName> found = new HashSet<ObjectName>();
    do {
        if (nTry++ > 0) {
            Thread.sleep(500);
        }
        try {
            beans = conn().queryNames(
                    new ObjectName(CommonNames.DOMAIN + ":*"), null);
        } catch (MalformedObjectNameException e) {
            throw new RuntimeException(e);
        }
        found.clear();
        for (String name : expectedNames) {
            LOG.info("expect:" + name);
            for (ObjectName bean : beans) {
                // check the existence of name in bean
                if (compare(bean.toString(), name)) {
                    LOG.info("found:" + name + " " + bean);
                    found.add(bean);
                    break;
                }
            }
            beans.removeAll(found);
        }
    } while (expectedNames.length != found.size() && nTry < 120);
    TestCase.assertEquals("expected " + Arrays.toString(expectedNames),
            expectedNames.length, found.size());
    return beans;
}
项目:ZooKeeper    文件:JMXEnv.java   
/**
 * Ensure that the specified bean name and its attribute is registered. Note
 * that these are components of the name. It waits in a loop up to 60
 * seconds before failing if there is a mismatch. This will return the beans
 * which are not matched.
 *
 * @param expectedName
 *            - expected bean
 * @param expectedAttribute
 *            - expected attribute
 * @return the value of the attribute
 *
 * @throws Exception
 */
public static Object ensureBeanAttribute(String expectedName,
        String expectedAttribute) throws Exception {
    String value = "";
    LOG.info("ensure bean:{}, attribute:{}", new Object[] { expectedName,
            expectedAttribute });

    Set<ObjectName> beans;
    int nTry = 0;
    do {
        if (nTry++ > 0) {
            Thread.sleep(500);
        }
        try {
            beans = conn().queryNames(
                    new ObjectName(CommonNames.DOMAIN + ":*"), null);
        } catch (MalformedObjectNameException e) {
            throw new RuntimeException(e);
        }
        LOG.info("expect:" + expectedName);
        for (ObjectName bean : beans) {
            // check the existence of name in bean
            if (bean.toString().equals(expectedName)) {
                LOG.info("found:{} {}", new Object[] { expectedName, bean });
                return conn().getAttribute(bean, expectedAttribute);
            }
        }
    } while (nTry < 120);
    Assert.fail("Failed to find bean:" + expectedName + ", attribute:"
            + expectedAttribute);
    return value;
}
项目:StreamProcessingInfrastructure    文件:JMXEnv.java   
/**
 * Ensure that all of the specified names are registered.
 * Note that these are components of the name, and in particular
 * order matters - you want the more specific name (leafs) specified
 * before their parent(s) (since names are hierarchical)
 * It waits in a loop up to 60 seconds before failing if there is a
 * mismatch.
 * @param expectedNames
 * @return
 * @throws IOException
 * @throws MalformedObjectNameException
 */
public static Set<ObjectName> ensureAll(String... expectedNames)
    throws IOException, InterruptedException
{
    Set<ObjectName> beans;
    Set<ObjectName> found;
    int nTry = 0;
    do {
        if (nTry++ > 0) {
            Thread.sleep(100);
        }
        try {
            beans = conn().queryNames(
                    new ObjectName(CommonNames.DOMAIN + ":*"), null);
        } catch (MalformedObjectNameException e) {
            throw new RuntimeException(e);
        }

        found = new HashSet<ObjectName>();
        for (String name : expectedNames) {
            LOG.info("expect:" + name);
            for (ObjectName bean : beans) {
                if (bean.toString().contains(name)) {
                    LOG.info("found:" + name + " " + bean);
                    found.add(bean);
                    break;
                }
            }
            beans.removeAll(found);
        }
    } while ((expectedNames.length != found.size()) && (nTry < 600));
    TestCase.assertEquals("expected " + Arrays.toString(expectedNames),
            expectedNames.length, found.size());
    return beans;
}
项目:StreamProcessingInfrastructure    文件:JMXEnv.java   
public static void dump() throws IOException {
    LOG.info("JMXEnv.dump() follows");
    Set<ObjectName> beans;
    try {
        beans = conn().queryNames(
                new ObjectName(CommonNames.DOMAIN + ":*"), null);
    } catch (MalformedObjectNameException e) {
        throw new RuntimeException(e);
    }
    for (ObjectName bean : beans) {
        LOG.info("bean:" + bean.toString());
    }
}
项目:StreamProcessingInfrastructure    文件:JMXEnv.java   
/**
 * Ensure that the specified parent names are registered. Note that these
 * are components of the name. It waits in a loop up to 60 seconds before
 * failing if there is a mismatch. This will return the beans which are not
 * matched.
 * 
 * {@link https://issues.apache.org/jira/browse/ZOOKEEPER-1858}
 * 
 * @param expectedNames
 *            - expected beans
 * @return the beans which are not matched with the given expected names
 * 
 * @throws IOException
 * @throws InterruptedException
 * 
 */
public static Set<ObjectName> ensureParent(String... expectedNames)
        throws IOException, InterruptedException {
    LOG.info("ensureParent:" + Arrays.toString(expectedNames));

    Set<ObjectName> beans;
    int nTry = 0;
    Set<ObjectName> found = new HashSet<ObjectName>();
    do {
        if (nTry++ > 0) {
            Thread.sleep(500);
        }
        try {
            beans = conn().queryNames(
                    new ObjectName(CommonNames.DOMAIN + ":*"), null);
        } catch (MalformedObjectNameException e) {
            throw new RuntimeException(e);
        }
        found.clear();
        for (String name : expectedNames) {
            LOG.info("expect:" + name);
            for (ObjectName bean : beans) {
                // check the existence of name in bean
                if (compare(bean.toString(), name)) {
                    LOG.info("found:" + name + " " + bean);
                    found.add(bean);
                    break;
                }
            }
            beans.removeAll(found);
        }
    } while (expectedNames.length != found.size() && nTry < 120);
    TestCase.assertEquals("expected " + Arrays.toString(expectedNames),
            expectedNames.length, found.size());
    return beans;
}
项目:bigstreams    文件:JMXEnv.java   
/**
 * Ensure that all of the specified names are registered.
 * Note that these are components of the name, and in particular
 * order matters - you want the more specific name (leafs) specified
 * before their parent(s) (since names are hierarchical)
 * @param expectedNames
 * @return
 * @throws IOException
 * @throws MalformedObjectNameException
 */
public static Set<ObjectName> ensureAll(String... expectedNames)
    throws IOException
{
    Set<ObjectName> beans;
    try {
        beans = conn().queryNames(
                new ObjectName(CommonNames.DOMAIN + ":*"), null);
    } catch (MalformedObjectNameException e) {
        throw new RuntimeException(e);
    }

    Set<ObjectName> found = new HashSet<ObjectName>();
    for (String name : expectedNames) {
        LOG.info("expect:" + name);
        for (ObjectName bean : beans) {
            if (bean.toString().contains(name)) {
                LOG.info("found:" + name + " " + bean);
                found.add(bean);
                break;
            }
        }
        beans.removeAll(found);
    }
    TestCase.assertEquals("expected " + Arrays.toString(expectedNames),
            expectedNames.length, found.size());
    return beans;
}
项目:bigstreams    文件:JMXEnv.java   
public static void dump() throws IOException {
    LOG.info("JMXEnv.dump() follows");
    Set<ObjectName> beans;
    try {
        beans = conn().queryNames(
                new ObjectName(CommonNames.DOMAIN + ":*"), null);
    } catch (MalformedObjectNameException e) {
        throw new RuntimeException(e);
    }
    for (ObjectName bean : beans) {
        LOG.info("bean:" + bean.toString());
    }
}
项目:bigstreams    文件:JMXEnv.java   
/**
 * Ensure that all of the specified names are registered.
 * Note that these are components of the name, and in particular
 * order matters - you want the more specific name (leafs) specified
 * before their parent(s) (since names are hierarchical)
 * @param expectedNames
 * @return
 * @throws IOException
 * @throws MalformedObjectNameException
 */
public static Set<ObjectName> ensureAll(String... expectedNames)
    throws IOException
{
    Set<ObjectName> beans;
    try {
        beans = conn().queryNames(
                new ObjectName(CommonNames.DOMAIN + ":*"), null);
    } catch (MalformedObjectNameException e) {
        throw new RuntimeException(e);
    }

    Set<ObjectName> found = new HashSet<ObjectName>();
    for (String name : expectedNames) {
        System.err.println("expect:" + name);
        for (ObjectName bean : beans) {
            if (bean.toString().contains(name)) {
                System.err.println("found:" + name + " " + bean);
                found.add(bean);
                break;
            }
        }
        beans.removeAll(found);
    }
    TestCase.assertEquals("expected " + Arrays.toString(expectedNames),
            expectedNames.length, found.size());
    return beans;
}
项目:bigstreams    文件:JMXEnv.java   
public static void dump() throws IOException {
    System.err.println("JMXEnv.dump() follows");
    Set<ObjectName> beans;
    try {
        beans = conn().queryNames(
                new ObjectName(CommonNames.DOMAIN + ":*"), null);
    } catch (MalformedObjectNameException e) {
        throw new RuntimeException(e);
    }
    for (ObjectName bean : beans) {
        System.err.println("bean:" + bean.toString());
    }
}
项目:zookeeper    文件:JMXEnv.java   
/**
 * Ensure that all of the specified names are registered.
 * Note that these are components of the name, and in particular
 * order matters - you want the more specific name (leafs) specified
 * before their parent(s) (since names are hierarchical)
 * It waits in a loop up to 60 seconds before failing if there is a
 * mismatch.
 * @param expectedNames
 * @return
 * @throws IOException
 * @throws MalformedObjectNameException
 */
public static Set<ObjectName> ensureAll(String... expectedNames)
    throws IOException, InterruptedException
{
    Set<ObjectName> beans;
    Set<ObjectName> found;
    int nTry = 0;
    do {
        if (nTry++ > 0) {
            Thread.sleep(100);
        }
        try {
            beans = conn().queryNames(
                    new ObjectName(CommonNames.DOMAIN + ":*"), null);
        } catch (MalformedObjectNameException e) {
            throw new RuntimeException(e);
        }

        found = new HashSet<ObjectName>();
        for (String name : expectedNames) {
            LOG.info("expect:" + name);
            for (ObjectName bean : beans) {
                if (bean.toString().contains(name)) {
                    LOG.info("found:" + name + " " + bean);
                    found.add(bean);
                    break;
                }
            }
            beans.removeAll(found);
        }
    } while ((expectedNames.length != found.size()) && (nTry < 600));
    TestCase.assertEquals("expected " + Arrays.toString(expectedNames),
            expectedNames.length, found.size());
    return beans;
}
项目:zookeeper    文件:JMXEnv.java   
public static void dump() throws IOException {
    LOG.info("JMXEnv.dump() follows");
    Set<ObjectName> beans;
    try {
        beans = conn().queryNames(
                new ObjectName(CommonNames.DOMAIN + ":*"), null);
    } catch (MalformedObjectNameException e) {
        throw new RuntimeException(e);
    }
    for (ObjectName bean : beans) {
        LOG.info("bean:" + bean.toString());
    }
}
项目:zookeeper    文件:JMXEnv.java   
/**
 * Ensure that the specified parent names are registered. Note that these
 * are components of the name. It waits in a loop up to 60 seconds before
 * failing if there is a mismatch. This will return the beans which are not
 * matched.
 * 
 * {@link https://issues.apache.org/jira/browse/ZOOKEEPER-1858}
 * 
 * @param expectedNames
 *            - expected beans
 * @return the beans which are not matched with the given expected names
 * 
 * @throws IOException
 * @throws InterruptedException
 * 
 */
public static Set<ObjectName> ensureParent(String... expectedNames)
        throws IOException, InterruptedException {
    LOG.info("ensureParent:" + Arrays.toString(expectedNames));

    Set<ObjectName> beans;
    int nTry = 0;
    Set<ObjectName> found = new HashSet<ObjectName>();
    do {
        if (nTry++ > 0) {
            Thread.sleep(500);
        }
        try {
            beans = conn().queryNames(
                    new ObjectName(CommonNames.DOMAIN + ":*"), null);
        } catch (MalformedObjectNameException e) {
            throw new RuntimeException(e);
        }
        found.clear();
        for (String name : expectedNames) {
            LOG.info("expect:" + name);
            for (ObjectName bean : beans) {
                // check the existence of name in bean
                if (compare(bean.toString(), name)) {
                    LOG.info("found:" + name + " " + bean);
                    found.add(bean);
                    break;
                }
            }
            beans.removeAll(found);
        }
    } while (expectedNames.length != found.size() && nTry < 120);
    TestCase.assertEquals("expected " + Arrays.toString(expectedNames),
            expectedNames.length, found.size());
    return beans;
}
项目:SecureKeeper    文件:JMXEnv.java   
/**
 * Ensure that all of the specified names are registered.
 * Note that these are components of the name, and in particular
 * order matters - you want the more specific name (leafs) specified
 * before their parent(s) (since names are hierarchical)
 * It waits in a loop up to 60 seconds before failing if there is a
 * mismatch.
 * @param expectedNames
 * @return
 * @throws IOException
 * @throws MalformedObjectNameException
 */
public static Set<ObjectName> ensureAll(String... expectedNames)
    throws IOException, InterruptedException
{
    Set<ObjectName> beans;
    Set<ObjectName> found;
    int nTry = 0;
    do {
        if (nTry++ > 0) {
            Thread.sleep(100);
        }
        try {
            beans = conn().queryNames(
                    new ObjectName(CommonNames.DOMAIN + ":*"), null);
        } catch (MalformedObjectNameException e) {
            throw new RuntimeException(e);
        }

        found = new HashSet<ObjectName>();
        for (String name : expectedNames) {
            LOG.info("expect:" + name);
            for (ObjectName bean : beans) {
                if (bean.toString().contains(name)) {
                    LOG.info("found:" + name + " " + bean);
                    found.add(bean);
                    break;
                }
            }
            beans.removeAll(found);
        }
    } while ((expectedNames.length != found.size()) && (nTry < 600));
    Assert.assertEquals("expected " + Arrays.toString(expectedNames),
            expectedNames.length, found.size());
    return beans;
}
项目:SecureKeeper    文件:JMXEnv.java   
public static void dump() throws IOException {
    LOG.info("JMXEnv.dump() follows");
    Set<ObjectName> beans;
    try {
        beans = conn().queryNames(
                new ObjectName(CommonNames.DOMAIN + ":*"), null);
    } catch (MalformedObjectNameException e) {
        throw new RuntimeException(e);
    }
    for (ObjectName bean : beans) {
        LOG.info("bean:" + bean.toString());
    }
}
项目:SecureKeeper    文件:JMXEnv.java   
/**
 * Ensure that the specified parent names are registered. Note that these
 * are components of the name. It waits in a loop up to 60 seconds before
 * failing if there is a mismatch. This will return the beans which are not
 * matched.
 * 
 * {@link https://issues.apache.org/jira/browse/ZOOKEEPER-1858}
 * 
 * @param expectedNames
 *            - expected beans
 * @return the beans which are not matched with the given expected names
 * 
 * @throws IOException
 * @throws InterruptedException
 */
public static Set<ObjectName> ensureParent(String... expectedNames)
        throws IOException, InterruptedException {
    LOG.info("ensureParent:" + Arrays.toString(expectedNames));

    Set<ObjectName> beans;
    int nTry = 0;
    Set<ObjectName> found = new HashSet<ObjectName>();
    do {
        if (nTry++ > 0) {
            Thread.sleep(500);
        }
        try {
            beans = conn().queryNames(
                    new ObjectName(CommonNames.DOMAIN + ":*"), null);
        } catch (MalformedObjectNameException e) {
            throw new RuntimeException(e);
        }
        found.clear();
        for (String name : expectedNames) {
            LOG.info("expect:" + name);
            for (ObjectName bean : beans) {
                // check the existence of name in bean
                if (compare(bean.toString(), name)) {
                    LOG.info("found:" + name + " " + bean);
                    found.add(bean);
                    break;
                }
            }
            beans.removeAll(found);
        }
    } while (expectedNames.length != found.size() && nTry < 120);
    Assert.assertEquals("expected " + Arrays.toString(expectedNames),
            expectedNames.length, found.size());
    return beans;
}
项目:SecureKeeper    文件:JMXEnv.java   
/**
 * Ensure that the specified bean name and its attribute is registered. Note
 * that these are components of the name. It waits in a loop up to 60
 * seconds before failing if there is a mismatch. This will return the beans
 * which are not matched.
 *
 * @param expectedName
 *            - expected bean
 * @param expectedAttribute
 *            - expected attribute
 * @return the value of the attribute
 *
 * @throws Exception
 */
public static Object ensureBeanAttribute(String expectedName,
        String expectedAttribute) throws Exception {
    String value = "";
    LOG.info("ensure bean:{}, attribute:{}", new Object[] { expectedName,
            expectedAttribute });

    Set<ObjectName> beans;
    int nTry = 0;
    do {
        if (nTry++ > 0) {
            Thread.sleep(500);
        }
        try {
            beans = conn().queryNames(
                    new ObjectName(CommonNames.DOMAIN + ":*"), null);
        } catch (MalformedObjectNameException e) {
            throw new RuntimeException(e);
        }
        LOG.info("expect:" + expectedName);
        for (ObjectName bean : beans) {
            // check the existence of name in bean
            if (bean.toString().equals(expectedName)) {
                LOG.info("found:{} {}", new Object[] { expectedName, bean });
                return conn().getAttribute(bean, expectedAttribute);
            }
        }
    } while (nTry < 120);
    Assert.fail("Failed to find bean:" + expectedName + ", attribute:"
            + expectedAttribute);
    return value;
}
项目:SecureKeeper    文件:JMXEnv.java   
/**
 * Ensure that all of the specified names are registered.
 * Note that these are components of the name, and in particular
 * order matters - you want the more specific name (leafs) specified
 * before their parent(s) (since names are hierarchical)
 * It waits in a loop up to 60 seconds before failing if there is a
 * mismatch.
 * @param expectedNames
 * @return
 * @throws IOException
 * @throws MalformedObjectNameException
 */
public static Set<ObjectName> ensureAll(String... expectedNames)
    throws IOException, InterruptedException
{
    Set<ObjectName> beans;
    Set<ObjectName> found;
    int nTry = 0;
    do {
        if (nTry++ > 0) {
            Thread.sleep(100);
        }
        try {
            beans = conn().queryNames(
                    new ObjectName(CommonNames.DOMAIN + ":*"), null);
        } catch (MalformedObjectNameException e) {
            throw new RuntimeException(e);
        }

        found = new HashSet<ObjectName>();
        for (String name : expectedNames) {
            LOG.info("expect:" + name);
            for (ObjectName bean : beans) {
                if (bean.toString().contains(name)) {
                    LOG.info("found:" + name + " " + bean);
                    found.add(bean);
                    break;
                }
            }
            beans.removeAll(found);
        }
    } while ((expectedNames.length != found.size()) && (nTry < 600));
    Assert.assertEquals("expected " + Arrays.toString(expectedNames),
            expectedNames.length, found.size());
    return beans;
}
项目:SecureKeeper    文件:JMXEnv.java   
public static void dump() throws IOException {
    LOG.info("JMXEnv.dump() follows");
    Set<ObjectName> beans;
    try {
        beans = conn().queryNames(
                new ObjectName(CommonNames.DOMAIN + ":*"), null);
    } catch (MalformedObjectNameException e) {
        throw new RuntimeException(e);
    }
    for (ObjectName bean : beans) {
        LOG.info("bean:" + bean.toString());
    }
}
项目:SecureKeeper    文件:JMXEnv.java   
/**
 * Ensure that the specified parent names are registered. Note that these
 * are components of the name. It waits in a loop up to 60 seconds before
 * failing if there is a mismatch. This will return the beans which are not
 * matched.
 * 
 * {@link https://issues.apache.org/jira/browse/ZOOKEEPER-1858}
 * 
 * @param expectedNames
 *            - expected beans
 * @return the beans which are not matched with the given expected names
 * 
 * @throws IOException
 * @throws InterruptedException
 */
public static Set<ObjectName> ensureParent(String... expectedNames)
        throws IOException, InterruptedException {
    LOG.info("ensureParent:" + Arrays.toString(expectedNames));

    Set<ObjectName> beans;
    int nTry = 0;
    Set<ObjectName> found = new HashSet<ObjectName>();
    do {
        if (nTry++ > 0) {
            Thread.sleep(500);
        }
        try {
            beans = conn().queryNames(
                    new ObjectName(CommonNames.DOMAIN + ":*"), null);
        } catch (MalformedObjectNameException e) {
            throw new RuntimeException(e);
        }
        found.clear();
        for (String name : expectedNames) {
            LOG.info("expect:" + name);
            for (ObjectName bean : beans) {
                // check the existence of name in bean
                if (compare(bean.toString(), name)) {
                    LOG.info("found:" + name + " " + bean);
                    found.add(bean);
                    break;
                }
            }
            beans.removeAll(found);
        }
    } while (expectedNames.length != found.size() && nTry < 120);
    Assert.assertEquals("expected " + Arrays.toString(expectedNames),
            expectedNames.length, found.size());
    return beans;
}
项目:SecureKeeper    文件:JMXEnv.java   
/**
 * Ensure that the specified bean name and its attribute is registered. Note
 * that these are components of the name. It waits in a loop up to 60
 * seconds before failing if there is a mismatch. This will return the beans
 * which are not matched.
 *
 * @param expectedName
 *            - expected bean
 * @param expectedAttribute
 *            - expected attribute
 * @return the value of the attribute
 *
 * @throws Exception
 */
public static Object ensureBeanAttribute(String expectedName,
        String expectedAttribute) throws Exception {
    String value = "";
    LOG.info("ensure bean:{}, attribute:{}", new Object[] { expectedName,
            expectedAttribute });

    Set<ObjectName> beans;
    int nTry = 0;
    do {
        if (nTry++ > 0) {
            Thread.sleep(500);
        }
        try {
            beans = conn().queryNames(
                    new ObjectName(CommonNames.DOMAIN + ":*"), null);
        } catch (MalformedObjectNameException e) {
            throw new RuntimeException(e);
        }
        LOG.info("expect:" + expectedName);
        for (ObjectName bean : beans) {
            // check the existence of name in bean
            if (bean.toString().equals(expectedName)) {
                LOG.info("found:{} {}", new Object[] { expectedName, bean });
                return conn().getAttribute(bean, expectedAttribute);
            }
        }
    } while (nTry < 120);
    Assert.fail("Failed to find bean:" + expectedName + ", attribute:"
            + expectedAttribute);
    return value;
}
项目:StreamBench    文件:JMXEnv.java   
/**
 * Ensure that all of the specified names are registered.
 * Note that these are components of the name, and in particular
 * order matters - you want the more specific name (leafs) specified
 * before their parent(s) (since names are hierarchical)
 * It waits in a loop up to 60 seconds before failing if there is a
 * mismatch.
 * @param expectedNames
 * @return
 * @throws IOException
 * @throws MalformedObjectNameException
 */
public static Set<ObjectName> ensureAll(String... expectedNames)
    throws IOException, InterruptedException
{
    Set<ObjectName> beans;
    Set<ObjectName> found;
    int nTry = 0;
    do {
        if (nTry++ > 0) {
            Thread.sleep(100);
        }
        try {
            beans = conn().queryNames(
                    new ObjectName(CommonNames.DOMAIN + ":*"), null);
        } catch (MalformedObjectNameException e) {
            throw new RuntimeException(e);
        }

        found = new HashSet<ObjectName>();
        for (String name : expectedNames) {
            LOG.info("expect:" + name);
            for (ObjectName bean : beans) {
                if (bean.toString().contains(name)) {
                    LOG.info("found:" + name + " " + bean);
                    found.add(bean);
                    break;
                }
            }
            beans.removeAll(found);
        }
    } while ((expectedNames.length != found.size()) && (nTry < 600));
    TestCase.assertEquals("expected " + Arrays.toString(expectedNames),
            expectedNames.length, found.size());
    return beans;
}
项目:StreamBench    文件:JMXEnv.java   
public static void dump() throws IOException {
    LOG.info("JMXEnv.dump() follows");
    Set<ObjectName> beans;
    try {
        beans = conn().queryNames(
                new ObjectName(CommonNames.DOMAIN + ":*"), null);
    } catch (MalformedObjectNameException e) {
        throw new RuntimeException(e);
    }
    for (ObjectName bean : beans) {
        LOG.info("bean:" + bean.toString());
    }
}
项目:StreamBench    文件:JMXEnv.java   
/**
 * Ensure that the specified parent names are registered. Note that these
 * are components of the name. It waits in a loop up to 60 seconds before
 * failing if there is a mismatch. This will return the beans which are not
 * matched.
 * 
 * {@link https://issues.apache.org/jira/browse/ZOOKEEPER-1858}
 * 
 * @param expectedNames
 *            - expected beans
 * @return the beans which are not matched with the given expected names
 * 
 * @throws IOException
 * @throws InterruptedException
 * 
 */
public static Set<ObjectName> ensureParent(String... expectedNames)
        throws IOException, InterruptedException {
    LOG.info("ensureParent:" + Arrays.toString(expectedNames));

    Set<ObjectName> beans;
    int nTry = 0;
    Set<ObjectName> found = new HashSet<ObjectName>();
    do {
        if (nTry++ > 0) {
            Thread.sleep(500);
        }
        try {
            beans = conn().queryNames(
                    new ObjectName(CommonNames.DOMAIN + ":*"), null);
        } catch (MalformedObjectNameException e) {
            throw new RuntimeException(e);
        }
        found.clear();
        for (String name : expectedNames) {
            LOG.info("expect:" + name);
            for (ObjectName bean : beans) {
                // check the existence of name in bean
                if (compare(bean.toString(), name)) {
                    LOG.info("found:" + name + " " + bean);
                    found.add(bean);
                    break;
                }
            }
            beans.removeAll(found);
        }
    } while (expectedNames.length != found.size() && nTry < 120);
    TestCase.assertEquals("expected " + Arrays.toString(expectedNames),
            expectedNames.length, found.size());
    return beans;
}
项目:LoadBalanced_zk    文件:JMXEnv.java   
/**
 * Ensure that all of the specified names are registered.
 * Note that these are components of the name, and in particular
 * order matters - you want the more specific name (leafs) specified
 * before their parent(s) (since names are hierarchical)
 * @param expectedNames
 * @return
 * @throws IOException
 * @throws MalformedObjectNameException
 */
public static Set<ObjectName> ensureAll(String... expectedNames)
    throws IOException
{
    Set<ObjectName> beans;
    try {
        beans = conn().queryNames(
                new ObjectName(CommonNames.DOMAIN + ":*"), null);
    } catch (MalformedObjectNameException e) {
        throw new RuntimeException(e);
    }

    Set<ObjectName> found = new HashSet<ObjectName>();
    for (String name : expectedNames) {
        LOG.info("expect:" + name);
        for (ObjectName bean : beans) {
            if (bean.toString().contains(name)) {
                LOG.info("found:" + name + " " + bean);
                found.add(bean);
                break;
            }
        }
        beans.removeAll(found);
    }
    TestCase.assertEquals("expected " + Arrays.toString(expectedNames),
            expectedNames.length, found.size());
    return beans;
}