javax.management.relation.RoleList Java Examples
The following examples show how to use
javax.management.relation.RoleList.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RelationServiceExample.java From cacheonix-core with GNU Lesser General Public License v2.1 | 6 votes |
private void testAllAccessQueries(String relationId) { Logger logger = getLogger(); // retrieve all roles try { Object[] params = {relationId}; String[] signature = {"java.lang.String"}; RoleResult roleResult = (RoleResult)(m_server.invoke(m_relationObjectName, "getAllRoles", params, signature)); RoleList roleList = roleResult.getRoles(); for (Iterator i = roleList.iterator(); i.hasNext();) { Role currentRole = (Role)i.next(); System.out.println(">>>> role name: " + currentRole.getRoleName()); System.out.println(">>>> role values: " + currentRole.getRoleValue().toString()); } System.out.println("No unresolved Roles roleUnresolved size: " + roleResult.getRolesUnresolved().size()); } catch (Exception ex) { logger.error("Exception printing the results from relationId: " + relationId); System.out.println("Printing the Exception message to validate exception: " + ex.getMessage()); } }
Example #2
Source File: CellValidatorTest.java From deep-spark with Apache License 2.0 | 5 votes |
public void testObjectToKind() { assertEquals(Kind.objectToKind(null), Kind.NOT_A_COLLECTION); /* let's try with some set implementation */ assertEquals(Kind.objectToKind(new HashSet()), Kind.SET); assertEquals(Kind.objectToKind(new CopyOnWriteArraySet()), Kind.SET); assertEquals(Kind.objectToKind(new ConcurrentSkipListSet()), Kind.SET); assertEquals(Kind.objectToKind(new LinkedHashSet()), Kind.SET); assertEquals(Kind.objectToKind(new TreeSet()), Kind.SET); /* let's try with some list implementation */ assertEquals(Kind.objectToKind(new ArrayList()), Kind.LIST); assertEquals(Kind.objectToKind(new CopyOnWriteArrayList<>()), Kind.LIST); assertEquals(Kind.objectToKind(new LinkedList<>()), Kind.LIST); assertEquals(Kind.objectToKind(new RoleList()), Kind.LIST); assertEquals(Kind.objectToKind(new RoleUnresolvedList()), Kind.LIST); assertEquals(Kind.objectToKind(new Stack()), Kind.LIST); assertEquals(Kind.objectToKind(new Vector<>()), Kind.LIST); /* let's try with some map implementation */ assertEquals(Kind.objectToKind(new HashMap()), Kind.MAP); assertEquals(Kind.objectToKind(new ConcurrentHashMap<>()), Kind.MAP); assertEquals(Kind.objectToKind(new ConcurrentSkipListMap<>()), Kind.MAP); assertEquals(Kind.objectToKind(new Hashtable<>()), Kind.MAP); assertEquals(Kind.objectToKind(new IdentityHashMap<>()), Kind.MAP); assertEquals(Kind.objectToKind(new LinkedHashMap<>()), Kind.MAP); assertEquals(Kind.objectToKind(new PrinterStateReasons()), Kind.MAP); assertEquals(Kind.objectToKind(new Properties()), Kind.MAP); assertEquals(Kind.objectToKind(new TreeMap<>()), Kind.MAP); assertEquals(Kind.objectToKind(new WeakHashMap<>()), Kind.MAP); }
Example #3
Source File: RelationServiceExample.java From cacheonix-core with GNU Lesser General Public License v2.1 | 5 votes |
private void createLibraryRelation(String personalLibraryId, String libraryTypeName, RoleList libraryList) { Logger logger = getLogger(); try { Object[] params = {personalLibraryId, libraryTypeName, libraryList}; String[] signature = {"java.lang.String", "java.lang.String", "javax.management.relation.RoleList"}; m_server.invoke(m_relationObjectName, "createRelation", params, signature); } catch (Exception ex) { logger.error("Exception creating Library Relation: " + ex.getMessage()); ex.printStackTrace(); } }
Example #4
Source File: RelationNotificationSeqNoTest.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { MBeanServer mbs = MBeanServerFactory.newMBeanServer(); ObjectName relSvcName = new ObjectName("a:type=relationService"); RelationServiceMBean relSvc = JMX.newMBeanProxy(mbs, relSvcName, RelationServiceMBean.class); mbs.createMBean("javax.management.relation.RelationService", relSvcName, new Object[] {Boolean.TRUE}, new String[] {"boolean"}); final BlockingQueue<Notification> q = new ArrayBlockingQueue<Notification>(100); NotificationListener qListener = new NotificationListener() { public void handleNotification(Notification notification, Object handback) { q.add(notification); } }; mbs.addNotificationListener(relSvcName, qListener, null, null); RoleInfo leftInfo = new RoleInfo("left", "javax.management.timer.TimerMBean"); RoleInfo rightInfo = new RoleInfo("right", "javax.management.timer.Timer"); relSvc.createRelationType("typeName", new RoleInfo[] {leftInfo, rightInfo}); ObjectName timer1 = new ObjectName("a:type=timer,number=1"); ObjectName timer2 = new ObjectName("a:type=timer,number=2"); mbs.createMBean("javax.management.timer.Timer", timer1); mbs.createMBean("javax.management.timer.Timer", timer2); Role leftRole = new Role("left", Arrays.asList(new ObjectName[] {timer1})); Role rightRole = new Role("right", Arrays.asList(new ObjectName[] {timer2})); RoleList roles = new RoleList(Arrays.asList(new Role[] {leftRole, rightRole})); final int NREPEAT = 10; for (int i = 0; i < NREPEAT; i++) { relSvc.createRelation("relationName", "typeName", roles); relSvc.removeRelation("relationName"); } Notification firstNotif = q.remove(); long seqNo = firstNotif.getSequenceNumber(); for (int i = 0; i < NREPEAT * 2 - 1; i++) { Notification n = q.remove(); long nSeqNo = n.getSequenceNumber(); if (nSeqNo != seqNo + 1) { throw new Exception( "TEST FAILED: expected seqNo " + (seqNo + 1) + "; got " + nSeqNo); } seqNo++; } System.out.println("TEST PASSED: got " + (NREPEAT * 2) + " notifications " + "with contiguous sequence numbers"); }
Example #5
Source File: RelationNotificationSeqNoTest.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { MBeanServer mbs = MBeanServerFactory.newMBeanServer(); ObjectName relSvcName = new ObjectName("a:type=relationService"); RelationServiceMBean relSvc = JMX.newMBeanProxy(mbs, relSvcName, RelationServiceMBean.class); mbs.createMBean("javax.management.relation.RelationService", relSvcName, new Object[] {Boolean.TRUE}, new String[] {"boolean"}); final BlockingQueue<Notification> q = new ArrayBlockingQueue<Notification>(100); NotificationListener qListener = new NotificationListener() { public void handleNotification(Notification notification, Object handback) { q.add(notification); } }; mbs.addNotificationListener(relSvcName, qListener, null, null); RoleInfo leftInfo = new RoleInfo("left", "javax.management.timer.TimerMBean"); RoleInfo rightInfo = new RoleInfo("right", "javax.management.timer.Timer"); relSvc.createRelationType("typeName", new RoleInfo[] {leftInfo, rightInfo}); ObjectName timer1 = new ObjectName("a:type=timer,number=1"); ObjectName timer2 = new ObjectName("a:type=timer,number=2"); mbs.createMBean("javax.management.timer.Timer", timer1); mbs.createMBean("javax.management.timer.Timer", timer2); Role leftRole = new Role("left", Arrays.asList(new ObjectName[] {timer1})); Role rightRole = new Role("right", Arrays.asList(new ObjectName[] {timer2})); RoleList roles = new RoleList(Arrays.asList(new Role[] {leftRole, rightRole})); final int NREPEAT = 10; for (int i = 0; i < NREPEAT; i++) { relSvc.createRelation("relationName", "typeName", roles); relSvc.removeRelation("relationName"); } Notification firstNotif = q.remove(); long seqNo = firstNotif.getSequenceNumber(); for (int i = 0; i < NREPEAT * 2 - 1; i++) { Notification n = q.remove(); long nSeqNo = n.getSequenceNumber(); if (nSeqNo != seqNo + 1) { throw new Exception( "TEST FAILED: expected seqNo " + (seqNo + 1) + "; got " + nSeqNo); } seqNo++; } System.out.println("TEST PASSED: got " + (NREPEAT * 2) + " notifications " + "with contiguous sequence numbers"); }
Example #6
Source File: RelationNotificationSeqNoTest.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { MBeanServer mbs = MBeanServerFactory.newMBeanServer(); ObjectName relSvcName = new ObjectName("a:type=relationService"); RelationServiceMBean relSvc = JMX.newMBeanProxy(mbs, relSvcName, RelationServiceMBean.class); mbs.createMBean("javax.management.relation.RelationService", relSvcName, new Object[] {Boolean.TRUE}, new String[] {"boolean"}); final BlockingQueue<Notification> q = new ArrayBlockingQueue<Notification>(100); NotificationListener qListener = new NotificationListener() { public void handleNotification(Notification notification, Object handback) { q.add(notification); } }; mbs.addNotificationListener(relSvcName, qListener, null, null); RoleInfo leftInfo = new RoleInfo("left", "javax.management.timer.TimerMBean"); RoleInfo rightInfo = new RoleInfo("right", "javax.management.timer.Timer"); relSvc.createRelationType("typeName", new RoleInfo[] {leftInfo, rightInfo}); ObjectName timer1 = new ObjectName("a:type=timer,number=1"); ObjectName timer2 = new ObjectName("a:type=timer,number=2"); mbs.createMBean("javax.management.timer.Timer", timer1); mbs.createMBean("javax.management.timer.Timer", timer2); Role leftRole = new Role("left", Arrays.asList(new ObjectName[] {timer1})); Role rightRole = new Role("right", Arrays.asList(new ObjectName[] {timer2})); RoleList roles = new RoleList(Arrays.asList(new Role[] {leftRole, rightRole})); final int NREPEAT = 10; for (int i = 0; i < NREPEAT; i++) { relSvc.createRelation("relationName", "typeName", roles); relSvc.removeRelation("relationName"); } Notification firstNotif = q.remove(); long seqNo = firstNotif.getSequenceNumber(); for (int i = 0; i < NREPEAT * 2 - 1; i++) { Notification n = q.remove(); long nSeqNo = n.getSequenceNumber(); if (nSeqNo != seqNo + 1) { throw new Exception( "TEST FAILED: expected seqNo " + (seqNo + 1) + "; got " + nSeqNo); } seqNo++; } System.out.println("TEST PASSED: got " + (NREPEAT * 2) + " notifications " + "with contiguous sequence numbers"); }
Example #7
Source File: RoleListRandomGenerator.java From openpojo with Apache License 2.0 | 4 votes |
public Collection doGenerate(Class<?> type) { Helper.assertIsAssignableTo(type, getTypes()); return CollectionHelper.buildCollections(new RoleList(), SomeRole.class); }
Example #8
Source File: SimpleRelationTestSupport.java From cacheonix-core with GNU Lesser General Public License v2.1 | 4 votes |
public SimpleRelationTestSupport(String relationId, ObjectName relationServiceName, String relationTypeName, RoleList roleList) throws InvalidRoleValueException, IllegalArgumentException { super(relationId, relationServiceName, relationTypeName, roleList); }
Example #9
Source File: RelationNotificationSeqNoTest.java From jdk8u_jdk with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { MBeanServer mbs = MBeanServerFactory.newMBeanServer(); ObjectName relSvcName = new ObjectName("a:type=relationService"); RelationServiceMBean relSvc = JMX.newMBeanProxy(mbs, relSvcName, RelationServiceMBean.class); mbs.createMBean("javax.management.relation.RelationService", relSvcName, new Object[] {Boolean.TRUE}, new String[] {"boolean"}); final BlockingQueue<Notification> q = new ArrayBlockingQueue<Notification>(100); NotificationListener qListener = new NotificationListener() { public void handleNotification(Notification notification, Object handback) { q.add(notification); } }; mbs.addNotificationListener(relSvcName, qListener, null, null); RoleInfo leftInfo = new RoleInfo("left", "javax.management.timer.TimerMBean"); RoleInfo rightInfo = new RoleInfo("right", "javax.management.timer.Timer"); relSvc.createRelationType("typeName", new RoleInfo[] {leftInfo, rightInfo}); ObjectName timer1 = new ObjectName("a:type=timer,number=1"); ObjectName timer2 = new ObjectName("a:type=timer,number=2"); mbs.createMBean("javax.management.timer.Timer", timer1); mbs.createMBean("javax.management.timer.Timer", timer2); Role leftRole = new Role("left", Arrays.asList(new ObjectName[] {timer1})); Role rightRole = new Role("right", Arrays.asList(new ObjectName[] {timer2})); RoleList roles = new RoleList(Arrays.asList(new Role[] {leftRole, rightRole})); final int NREPEAT = 10; for (int i = 0; i < NREPEAT; i++) { relSvc.createRelation("relationName", "typeName", roles); relSvc.removeRelation("relationName"); } Notification firstNotif = q.remove(); long seqNo = firstNotif.getSequenceNumber(); for (int i = 0; i < NREPEAT * 2 - 1; i++) { Notification n = q.remove(); long nSeqNo = n.getSequenceNumber(); if (nSeqNo != seqNo + 1) { throw new Exception( "TEST FAILED: expected seqNo " + (seqNo + 1) + "; got " + nSeqNo); } seqNo++; } System.out.println("TEST PASSED: got " + (NREPEAT * 2) + " notifications " + "with contiguous sequence numbers"); }
Example #10
Source File: RelationNotificationSeqNoTest.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { MBeanServer mbs = MBeanServerFactory.newMBeanServer(); ObjectName relSvcName = new ObjectName("a:type=relationService"); RelationServiceMBean relSvc = JMX.newMBeanProxy(mbs, relSvcName, RelationServiceMBean.class); mbs.createMBean("javax.management.relation.RelationService", relSvcName, new Object[] {Boolean.TRUE}, new String[] {"boolean"}); final BlockingQueue<Notification> q = new ArrayBlockingQueue<Notification>(100); NotificationListener qListener = new NotificationListener() { public void handleNotification(Notification notification, Object handback) { q.add(notification); } }; mbs.addNotificationListener(relSvcName, qListener, null, null); RoleInfo leftInfo = new RoleInfo("left", "javax.management.timer.TimerMBean"); RoleInfo rightInfo = new RoleInfo("right", "javax.management.timer.Timer"); relSvc.createRelationType("typeName", new RoleInfo[] {leftInfo, rightInfo}); ObjectName timer1 = new ObjectName("a:type=timer,number=1"); ObjectName timer2 = new ObjectName("a:type=timer,number=2"); mbs.createMBean("javax.management.timer.Timer", timer1); mbs.createMBean("javax.management.timer.Timer", timer2); Role leftRole = new Role("left", Arrays.asList(new ObjectName[] {timer1})); Role rightRole = new Role("right", Arrays.asList(new ObjectName[] {timer2})); RoleList roles = new RoleList(Arrays.asList(new Role[] {leftRole, rightRole})); final int NREPEAT = 10; for (int i = 0; i < NREPEAT; i++) { relSvc.createRelation("relationName", "typeName", roles); relSvc.removeRelation("relationName"); } Notification firstNotif = q.remove(); long seqNo = firstNotif.getSequenceNumber(); for (int i = 0; i < NREPEAT * 2 - 1; i++) { Notification n = q.remove(); long nSeqNo = n.getSequenceNumber(); if (nSeqNo != seqNo + 1) { throw new Exception( "TEST FAILED: expected seqNo " + (seqNo + 1) + "; got " + nSeqNo); } seqNo++; } System.out.println("TEST PASSED: got " + (NREPEAT * 2) + " notifications " + "with contiguous sequence numbers"); }
Example #11
Source File: RelationNotificationSeqNoTest.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { MBeanServer mbs = MBeanServerFactory.newMBeanServer(); ObjectName relSvcName = new ObjectName("a:type=relationService"); RelationServiceMBean relSvc = JMX.newMBeanProxy(mbs, relSvcName, RelationServiceMBean.class); mbs.createMBean("javax.management.relation.RelationService", relSvcName, new Object[] {Boolean.TRUE}, new String[] {"boolean"}); final BlockingQueue<Notification> q = new ArrayBlockingQueue<Notification>(100); NotificationListener qListener = new NotificationListener() { public void handleNotification(Notification notification, Object handback) { q.add(notification); } }; mbs.addNotificationListener(relSvcName, qListener, null, null); RoleInfo leftInfo = new RoleInfo("left", "javax.management.timer.TimerMBean"); RoleInfo rightInfo = new RoleInfo("right", "javax.management.timer.Timer"); relSvc.createRelationType("typeName", new RoleInfo[] {leftInfo, rightInfo}); ObjectName timer1 = new ObjectName("a:type=timer,number=1"); ObjectName timer2 = new ObjectName("a:type=timer,number=2"); mbs.createMBean("javax.management.timer.Timer", timer1); mbs.createMBean("javax.management.timer.Timer", timer2); Role leftRole = new Role("left", Arrays.asList(new ObjectName[] {timer1})); Role rightRole = new Role("right", Arrays.asList(new ObjectName[] {timer2})); RoleList roles = new RoleList(Arrays.asList(new Role[] {leftRole, rightRole})); final int NREPEAT = 10; for (int i = 0; i < NREPEAT; i++) { relSvc.createRelation("relationName", "typeName", roles); relSvc.removeRelation("relationName"); } Notification firstNotif = q.remove(); long seqNo = firstNotif.getSequenceNumber(); for (int i = 0; i < NREPEAT * 2 - 1; i++) { Notification n = q.remove(); long nSeqNo = n.getSequenceNumber(); if (nSeqNo != seqNo + 1) { throw new Exception( "TEST FAILED: expected seqNo " + (seqNo + 1) + "; got " + nSeqNo); } seqNo++; } System.out.println("TEST PASSED: got " + (NREPEAT * 2) + " notifications " + "with contiguous sequence numbers"); }
Example #12
Source File: RelationNotificationSeqNoTest.java From hottub with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { MBeanServer mbs = MBeanServerFactory.newMBeanServer(); ObjectName relSvcName = new ObjectName("a:type=relationService"); RelationServiceMBean relSvc = JMX.newMBeanProxy(mbs, relSvcName, RelationServiceMBean.class); mbs.createMBean("javax.management.relation.RelationService", relSvcName, new Object[] {Boolean.TRUE}, new String[] {"boolean"}); final BlockingQueue<Notification> q = new ArrayBlockingQueue<Notification>(100); NotificationListener qListener = new NotificationListener() { public void handleNotification(Notification notification, Object handback) { q.add(notification); } }; mbs.addNotificationListener(relSvcName, qListener, null, null); RoleInfo leftInfo = new RoleInfo("left", "javax.management.timer.TimerMBean"); RoleInfo rightInfo = new RoleInfo("right", "javax.management.timer.Timer"); relSvc.createRelationType("typeName", new RoleInfo[] {leftInfo, rightInfo}); ObjectName timer1 = new ObjectName("a:type=timer,number=1"); ObjectName timer2 = new ObjectName("a:type=timer,number=2"); mbs.createMBean("javax.management.timer.Timer", timer1); mbs.createMBean("javax.management.timer.Timer", timer2); Role leftRole = new Role("left", Arrays.asList(new ObjectName[] {timer1})); Role rightRole = new Role("right", Arrays.asList(new ObjectName[] {timer2})); RoleList roles = new RoleList(Arrays.asList(new Role[] {leftRole, rightRole})); final int NREPEAT = 10; for (int i = 0; i < NREPEAT; i++) { relSvc.createRelation("relationName", "typeName", roles); relSvc.removeRelation("relationName"); } Notification firstNotif = q.remove(); long seqNo = firstNotif.getSequenceNumber(); for (int i = 0; i < NREPEAT * 2 - 1; i++) { Notification n = q.remove(); long nSeqNo = n.getSequenceNumber(); if (nSeqNo != seqNo + 1) { throw new Exception( "TEST FAILED: expected seqNo " + (seqNo + 1) + "; got " + nSeqNo); } seqNo++; } System.out.println("TEST PASSED: got " + (NREPEAT * 2) + " notifications " + "with contiguous sequence numbers"); }
Example #13
Source File: RelationNotificationSeqNoTest.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { MBeanServer mbs = MBeanServerFactory.newMBeanServer(); ObjectName relSvcName = new ObjectName("a:type=relationService"); RelationServiceMBean relSvc = JMX.newMBeanProxy(mbs, relSvcName, RelationServiceMBean.class); mbs.createMBean("javax.management.relation.RelationService", relSvcName, new Object[] {Boolean.TRUE}, new String[] {"boolean"}); final BlockingQueue<Notification> q = new ArrayBlockingQueue<Notification>(100); NotificationListener qListener = new NotificationListener() { public void handleNotification(Notification notification, Object handback) { q.add(notification); } }; mbs.addNotificationListener(relSvcName, qListener, null, null); RoleInfo leftInfo = new RoleInfo("left", "javax.management.timer.TimerMBean"); RoleInfo rightInfo = new RoleInfo("right", "javax.management.timer.Timer"); relSvc.createRelationType("typeName", new RoleInfo[] {leftInfo, rightInfo}); ObjectName timer1 = new ObjectName("a:type=timer,number=1"); ObjectName timer2 = new ObjectName("a:type=timer,number=2"); mbs.createMBean("javax.management.timer.Timer", timer1); mbs.createMBean("javax.management.timer.Timer", timer2); Role leftRole = new Role("left", Arrays.asList(new ObjectName[] {timer1})); Role rightRole = new Role("right", Arrays.asList(new ObjectName[] {timer2})); RoleList roles = new RoleList(Arrays.asList(new Role[] {leftRole, rightRole})); final int NREPEAT = 10; for (int i = 0; i < NREPEAT; i++) { relSvc.createRelation("relationName", "typeName", roles); relSvc.removeRelation("relationName"); } Notification firstNotif = q.remove(); long seqNo = firstNotif.getSequenceNumber(); for (int i = 0; i < NREPEAT * 2 - 1; i++) { Notification n = q.remove(); long nSeqNo = n.getSequenceNumber(); if (nSeqNo != seqNo + 1) { throw new Exception( "TEST FAILED: expected seqNo " + (seqNo + 1) + "; got " + nSeqNo); } seqNo++; } System.out.println("TEST PASSED: got " + (NREPEAT * 2) + " notifications " + "with contiguous sequence numbers"); }
Example #14
Source File: RelationNotificationSeqNoTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { MBeanServer mbs = MBeanServerFactory.newMBeanServer(); ObjectName relSvcName = new ObjectName("a:type=relationService"); RelationServiceMBean relSvc = JMX.newMBeanProxy(mbs, relSvcName, RelationServiceMBean.class); mbs.createMBean("javax.management.relation.RelationService", relSvcName, new Object[] {Boolean.TRUE}, new String[] {"boolean"}); final BlockingQueue<Notification> q = new ArrayBlockingQueue<Notification>(100); NotificationListener qListener = new NotificationListener() { public void handleNotification(Notification notification, Object handback) { q.add(notification); } }; mbs.addNotificationListener(relSvcName, qListener, null, null); RoleInfo leftInfo = new RoleInfo("left", "javax.management.timer.TimerMBean"); RoleInfo rightInfo = new RoleInfo("right", "javax.management.timer.Timer"); relSvc.createRelationType("typeName", new RoleInfo[] {leftInfo, rightInfo}); ObjectName timer1 = new ObjectName("a:type=timer,number=1"); ObjectName timer2 = new ObjectName("a:type=timer,number=2"); mbs.createMBean("javax.management.timer.Timer", timer1); mbs.createMBean("javax.management.timer.Timer", timer2); Role leftRole = new Role("left", Arrays.asList(new ObjectName[] {timer1})); Role rightRole = new Role("right", Arrays.asList(new ObjectName[] {timer2})); RoleList roles = new RoleList(Arrays.asList(new Role[] {leftRole, rightRole})); final int NREPEAT = 10; for (int i = 0; i < NREPEAT; i++) { relSvc.createRelation("relationName", "typeName", roles); relSvc.removeRelation("relationName"); } Notification firstNotif = q.remove(); long seqNo = firstNotif.getSequenceNumber(); for (int i = 0; i < NREPEAT * 2 - 1; i++) { Notification n = q.remove(); long nSeqNo = n.getSequenceNumber(); if (nSeqNo != seqNo + 1) { throw new Exception( "TEST FAILED: expected seqNo " + (seqNo + 1) + "; got " + nSeqNo); } seqNo++; } System.out.println("TEST PASSED: got " + (NREPEAT * 2) + " notifications " + "with contiguous sequence numbers"); }
Example #15
Source File: RelationNotificationSeqNoTest.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { MBeanServer mbs = MBeanServerFactory.newMBeanServer(); ObjectName relSvcName = new ObjectName("a:type=relationService"); RelationServiceMBean relSvc = JMX.newMBeanProxy(mbs, relSvcName, RelationServiceMBean.class); mbs.createMBean("javax.management.relation.RelationService", relSvcName, new Object[] {Boolean.TRUE}, new String[] {"boolean"}); final BlockingQueue<Notification> q = new ArrayBlockingQueue<Notification>(100); NotificationListener qListener = new NotificationListener() { public void handleNotification(Notification notification, Object handback) { q.add(notification); } }; mbs.addNotificationListener(relSvcName, qListener, null, null); RoleInfo leftInfo = new RoleInfo("left", "javax.management.timer.TimerMBean"); RoleInfo rightInfo = new RoleInfo("right", "javax.management.timer.Timer"); relSvc.createRelationType("typeName", new RoleInfo[] {leftInfo, rightInfo}); ObjectName timer1 = new ObjectName("a:type=timer,number=1"); ObjectName timer2 = new ObjectName("a:type=timer,number=2"); mbs.createMBean("javax.management.timer.Timer", timer1); mbs.createMBean("javax.management.timer.Timer", timer2); Role leftRole = new Role("left", Arrays.asList(new ObjectName[] {timer1})); Role rightRole = new Role("right", Arrays.asList(new ObjectName[] {timer2})); RoleList roles = new RoleList(Arrays.asList(new Role[] {leftRole, rightRole})); final int NREPEAT = 10; for (int i = 0; i < NREPEAT; i++) { relSvc.createRelation("relationName", "typeName", roles); relSvc.removeRelation("relationName"); } Notification firstNotif = q.remove(); long seqNo = firstNotif.getSequenceNumber(); for (int i = 0; i < NREPEAT * 2 - 1; i++) { Notification n = q.remove(); long nSeqNo = n.getSequenceNumber(); if (nSeqNo != seqNo + 1) { throw new Exception( "TEST FAILED: expected seqNo " + (seqNo + 1) + "; got " + nSeqNo); } seqNo++; } System.out.println("TEST PASSED: got " + (NREPEAT * 2) + " notifications " + "with contiguous sequence numbers"); }
Example #16
Source File: RelationNotificationSeqNoTest.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { MBeanServer mbs = MBeanServerFactory.newMBeanServer(); ObjectName relSvcName = new ObjectName("a:type=relationService"); RelationServiceMBean relSvc = JMX.newMBeanProxy(mbs, relSvcName, RelationServiceMBean.class); mbs.createMBean("javax.management.relation.RelationService", relSvcName, new Object[] {Boolean.TRUE}, new String[] {"boolean"}); final BlockingQueue<Notification> q = new ArrayBlockingQueue<Notification>(100); NotificationListener qListener = new NotificationListener() { public void handleNotification(Notification notification, Object handback) { q.add(notification); } }; mbs.addNotificationListener(relSvcName, qListener, null, null); RoleInfo leftInfo = new RoleInfo("left", "javax.management.timer.TimerMBean"); RoleInfo rightInfo = new RoleInfo("right", "javax.management.timer.Timer"); relSvc.createRelationType("typeName", new RoleInfo[] {leftInfo, rightInfo}); ObjectName timer1 = new ObjectName("a:type=timer,number=1"); ObjectName timer2 = new ObjectName("a:type=timer,number=2"); mbs.createMBean("javax.management.timer.Timer", timer1); mbs.createMBean("javax.management.timer.Timer", timer2); Role leftRole = new Role("left", Arrays.asList(new ObjectName[] {timer1})); Role rightRole = new Role("right", Arrays.asList(new ObjectName[] {timer2})); RoleList roles = new RoleList(Arrays.asList(new Role[] {leftRole, rightRole})); final int NREPEAT = 10; for (int i = 0; i < NREPEAT; i++) { relSvc.createRelation("relationName", "typeName", roles); relSvc.removeRelation("relationName"); } Notification firstNotif = q.remove(); long seqNo = firstNotif.getSequenceNumber(); for (int i = 0; i < NREPEAT * 2 - 1; i++) { Notification n = q.remove(); long nSeqNo = n.getSequenceNumber(); if (nSeqNo != seqNo + 1) { throw new Exception( "TEST FAILED: expected seqNo " + (seqNo + 1) + "; got " + nSeqNo); } seqNo++; } System.out.println("TEST PASSED: got " + (NREPEAT * 2) + " notifications " + "with contiguous sequence numbers"); }
Example #17
Source File: RelationNotificationSeqNoTest.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { MBeanServer mbs = MBeanServerFactory.newMBeanServer(); ObjectName relSvcName = new ObjectName("a:type=relationService"); RelationServiceMBean relSvc = JMX.newMBeanProxy(mbs, relSvcName, RelationServiceMBean.class); mbs.createMBean("javax.management.relation.RelationService", relSvcName, new Object[] {Boolean.TRUE}, new String[] {"boolean"}); final BlockingQueue<Notification> q = new ArrayBlockingQueue<Notification>(100); NotificationListener qListener = new NotificationListener() { public void handleNotification(Notification notification, Object handback) { q.add(notification); } }; mbs.addNotificationListener(relSvcName, qListener, null, null); RoleInfo leftInfo = new RoleInfo("left", "javax.management.timer.TimerMBean"); RoleInfo rightInfo = new RoleInfo("right", "javax.management.timer.Timer"); relSvc.createRelationType("typeName", new RoleInfo[] {leftInfo, rightInfo}); ObjectName timer1 = new ObjectName("a:type=timer,number=1"); ObjectName timer2 = new ObjectName("a:type=timer,number=2"); mbs.createMBean("javax.management.timer.Timer", timer1); mbs.createMBean("javax.management.timer.Timer", timer2); Role leftRole = new Role("left", Arrays.asList(new ObjectName[] {timer1})); Role rightRole = new Role("right", Arrays.asList(new ObjectName[] {timer2})); RoleList roles = new RoleList(Arrays.asList(new Role[] {leftRole, rightRole})); final int NREPEAT = 10; for (int i = 0; i < NREPEAT; i++) { relSvc.createRelation("relationName", "typeName", roles); relSvc.removeRelation("relationName"); } Notification firstNotif = q.remove(); long seqNo = firstNotif.getSequenceNumber(); for (int i = 0; i < NREPEAT * 2 - 1; i++) { Notification n = q.remove(); long nSeqNo = n.getSequenceNumber(); if (nSeqNo != seqNo + 1) { throw new Exception( "TEST FAILED: expected seqNo " + (seqNo + 1) + "; got " + nSeqNo); } seqNo++; } System.out.println("TEST PASSED: got " + (NREPEAT * 2) + " notifications " + "with contiguous sequence numbers"); }
Example #18
Source File: RelationNotificationSeqNoTest.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { MBeanServer mbs = MBeanServerFactory.newMBeanServer(); ObjectName relSvcName = new ObjectName("a:type=relationService"); RelationServiceMBean relSvc = JMX.newMBeanProxy(mbs, relSvcName, RelationServiceMBean.class); mbs.createMBean("javax.management.relation.RelationService", relSvcName, new Object[] {Boolean.TRUE}, new String[] {"boolean"}); final BlockingQueue<Notification> q = new ArrayBlockingQueue<Notification>(100); NotificationListener qListener = new NotificationListener() { public void handleNotification(Notification notification, Object handback) { q.add(notification); } }; mbs.addNotificationListener(relSvcName, qListener, null, null); RoleInfo leftInfo = new RoleInfo("left", "javax.management.timer.TimerMBean"); RoleInfo rightInfo = new RoleInfo("right", "javax.management.timer.Timer"); relSvc.createRelationType("typeName", new RoleInfo[] {leftInfo, rightInfo}); ObjectName timer1 = new ObjectName("a:type=timer,number=1"); ObjectName timer2 = new ObjectName("a:type=timer,number=2"); mbs.createMBean("javax.management.timer.Timer", timer1); mbs.createMBean("javax.management.timer.Timer", timer2); Role leftRole = new Role("left", Arrays.asList(new ObjectName[] {timer1})); Role rightRole = new Role("right", Arrays.asList(new ObjectName[] {timer2})); RoleList roles = new RoleList(Arrays.asList(new Role[] {leftRole, rightRole})); final int NREPEAT = 10; for (int i = 0; i < NREPEAT; i++) { relSvc.createRelation("relationName", "typeName", roles); relSvc.removeRelation("relationName"); } Notification firstNotif = q.remove(); long seqNo = firstNotif.getSequenceNumber(); for (int i = 0; i < NREPEAT * 2 - 1; i++) { Notification n = q.remove(); long nSeqNo = n.getSequenceNumber(); if (nSeqNo != seqNo + 1) { throw new Exception( "TEST FAILED: expected seqNo " + (seqNo + 1) + "; got " + nSeqNo); } seqNo++; } System.out.println("TEST PASSED: got " + (NREPEAT * 2) + " notifications " + "with contiguous sequence numbers"); }