本文整理汇总了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);
}
}
示例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());
}
}
}
}
示例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());
}
}
}
}
示例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;
}
示例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());
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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());
}
}