• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java CommonNames类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.zookeeper.jmx.CommonNames的典型用法代码示例。如果您正苦于以下问题:Java CommonNames类的具体用法?Java CommonNames怎么用?Java CommonNames使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



CommonNames类属于org.apache.zookeeper.jmx包,在下文中一共展示了CommonNames类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: verifyElectionTimeTakenJMXAttribute

import org.apache.zookeeper.jmx.CommonNames; //导入依赖的package包/类
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);
    }
}
 
开发者ID:l294265421,项目名称:ZooKeeper,代码行数:27,代码来源:HierarchicalQuorumTest.java


示例2: ensureNone

import org.apache.zookeeper.jmx.CommonNames; //导入依赖的package包/类
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());
            }
        }
    }
}
 
开发者ID:gerritjvv,项目名称:bigstreams,代码行数:21,代码来源:JMXEnv.java


示例3: ensureNone

import org.apache.zookeeper.jmx.CommonNames; //导入依赖的package包/类
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());
            }
        }
    }
}
 
开发者ID:gerritjvv,项目名称:bigstreams,代码行数:21,代码来源:JMXEnv.java


示例4: ensureAll

import org.apache.zookeeper.jmx.CommonNames; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:47,代码来源:JMXEnv.java


示例5: dump

import org.apache.zookeeper.jmx.CommonNames; //导入依赖的package包/类
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());
    }
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:14,代码来源:JMXEnv.java


示例6: ensureParent

import org.apache.zookeeper.jmx.CommonNames; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:52,代码来源:JMXEnv.java


示例7: ensureAll

import org.apache.zookeeper.jmx.CommonNames; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:47,代码来源:JMXEnv.java


示例8: ensureParent

import org.apache.zookeeper.jmx.CommonNames; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:51,代码来源:JMXEnv.java


示例9: ensureBeanAttribute

import org.apache.zookeeper.jmx.CommonNames; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:46,代码来源:JMXEnv.java


示例10: ensureAll

import org.apache.zookeeper.jmx.CommonNames; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:gerritjvv,项目名称:bigstreams,代码行数:38,代码来源:JMXEnv.java


示例11: ensureAll

import org.apache.zookeeper.jmx.CommonNames; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:gerritjvv,项目名称:bigstreams,代码行数:38,代码来源:JMXEnv.java


示例12: dump

import org.apache.zookeeper.jmx.CommonNames; //导入依赖的package包/类
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());
    }
}
 
开发者ID:gerritjvv,项目名称:bigstreams,代码行数:14,代码来源:JMXEnv.java



注:本文中的org.apache.zookeeper.jmx.CommonNames类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ClipboardHolder类代码示例发布时间:2022-05-22
下一篇:
Java CalendarProvider类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap