@Test public void testReusingOldInstance() throws InstanceAlreadyExistsException, ConflictingVersionException, ValidationException { ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction(); createInstance(transaction, instanceName); transaction.commit(); transaction = configRegistryClient.createTransaction(); assertBeanCount(1, factory.getImplementationName()); CommitStatus status = transaction.commit(); assertBeanCount(1, factory.getImplementationName()); assertStatus(status, 0, 0, 1); }
public static void registerMBean(final String mBeanObjectName,final Object mBean) { try { final ObjectName name = new ObjectName(mBeanObjectName); mbs.registerMBean(mBean, name); } catch (MalformedObjectNameException badObjectName) { logger.error(badObjectName.getMessage()); } catch (InstanceAlreadyExistsException duplicateMBeanInstance) { logger.error(duplicateMBeanInstance.getMessage()); } catch (MBeanRegistrationException mbeanRegistrationProblem) { logger.error(mbeanRegistrationProblem.getMessage()); } catch (NotCompliantMBeanException badMBean) { logger.error(badMBean.getMessage()); } }
public boolean init() throws MalformedObjectNameException, InstanceAlreadyExistsException, MBeanRegistrationException, NotCompliantMBeanException, FileNotFoundException, NoSuchElementException, IOException { //Initialize SPARQL 1.1 processing service properties endpointProperties = new SPARQL11Properties("endpoint.jpar"); //Initialize SPARQL 1.1 SE processing service properties engineProperties = new EngineProperties("engine.jpar"); //SPARQL 1.1 SE request processor processor = new Processor(endpointProperties); //SPARQL 1.1 SE request scheduler scheduler = new Scheduler(engineProperties,processor); //SPARQL 1.1 Protocol handlers httpGate = new HTTPGate(engineProperties,scheduler); httpsGate = new HTTPSGate(engineProperties,scheduler,am); //SPARQL 1.1 SE Protocol handler for WebSocket based subscriptions websocketApp = new WSGate(engineProperties,scheduler); secureWebsocketApp = new WSSGate(engineProperties,scheduler,am); return true; }
public synchronized void registerAll() throws InstanceNotFoundException, InstanceAlreadyExistsException, MBeanRegistrationException, NotCompliantMBeanException { Iterator<RegisteredMBean> iter1 = unregisteredMBeans.iterator(); while (iter1.hasNext()) { RegisteredMBean mBean = iter1.next(); mBean.register(); iter1.remove(); mBeans.add(mBean); } Iterator<RegisteredListener> iter2 = unregisteredListeners.iterator(); while (iter2.hasNext()) { RegisteredListener listener = iter2.next(); listener.register(); iter2.remove(); if (listener instanceof Listener1) { listeners1.add((Listener1) listener); } else { listeners2.add((Listener2) listener); } } }
@Override public HierarchicalRuntimeBeanRegistrationImpl register(final String key, final String value, final RuntimeBean mxBean) { Map<String, String> currentProperties = new HashMap<>(properties); currentProperties.put(key, value); ObjectName on = ObjectNameUtil.createRuntimeBeanName( moduleIdentifier.getFactoryName(), moduleIdentifier.getInstanceName(), currentProperties); InternalJMXRegistrator child = internalJMXRegistrator.createChild(); try { child.registerMBean(mxBean, on); } catch (final InstanceAlreadyExistsException e) { throw RootRuntimeBeanRegistratorImpl.sanitize(e, moduleIdentifier, on); } return new HierarchicalRuntimeBeanRegistrationImpl(moduleIdentifier, child, currentProperties); }
/** * Register the MBean using our standard MBeanName format * "hadoop:service=<serviceName>,name=<nameName>" * Where the <serviceName> and <nameName> are the supplied parameters * * @param serviceName * @param nameName * @param theMbean - the MBean to register * @return the named used to register the MBean */ static public ObjectName registerMBean(final String serviceName, final String nameName, final Object theMbean) { final MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); ObjectName name = getMBeanName(serviceName, nameName); try { mbs.registerMBean(theMbean, name); return name; } catch (InstanceAlreadyExistsException ie) { // Ignore if instance already exists } catch (Exception e) { e.printStackTrace(); } return null; }
public ObjectInstance createMBean(String className, ObjectName name, Object[] params, String[] signature) throws ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException, NotCompliantMBeanException { try { return createMBean(className, name, null, true, params, signature); } catch (InstanceNotFoundException e) { /* Can only happen if loaderName doesn't exist, but we just passed null, so we shouldn't get this exception. */ throw EnvHelp.initCause( new IllegalArgumentException("Unexpected exception: " + e), e); } }
private static ObjectName preRegister( DynamicMBean mbean, MBeanServer mbs, ObjectName name) throws InstanceAlreadyExistsException, MBeanRegistrationException { ObjectName newName = null; try { if (mbean instanceof MBeanRegistration) newName = ((MBeanRegistration) mbean).preRegister(mbs, name); } catch (Throwable t) { throwMBeanRegistrationException(t, "in preRegister method"); } if (newName != null) return newName; else return name; }
/** * Call <code>checkCreate(className)</code>, then forward this method to the * wrapped object. */ public ObjectInstance createMBean(String className, ObjectName name) throws ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException, NotCompliantMBeanException { checkCreate(className); SecurityManager sm = System.getSecurityManager(); if (sm == null) { Object object = getMBeanServer().instantiate(className); checkClassLoader(object); return getMBeanServer().registerMBean(object, name); } else { return getMBeanServer().createMBean(className, name); } }
private void doTest(JMXConnector connector) throws IOException, MalformedObjectNameException, ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException, NotCompliantMBeanException, InstanceNotFoundException, AttributeNotFoundException, InvalidAttributeValueException { MBeanServerConnection mbsc = connector.getMBeanServerConnection(); ObjectName objName = new ObjectName("com.redhat.test.jmx:type=NameMBean"); System.out.println("DEBUG: Calling createMBean"); mbsc.createMBean(Name.class.getName(), objName); System.out.println("DEBUG: Calling setAttributes"); AttributeList attList = new AttributeList(); attList.add(new Attribute("FirstName", ANY_NAME)); attList.add(new Attribute("LastName", ANY_NAME)); mbsc.setAttributes(objName, attList); }
/** * Call <code>checkCreate(className)</code>, then forward this method to the * wrapped object. */ public ObjectInstance createMBean(String className, ObjectName name, Object params[], String signature[]) throws ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException, NotCompliantMBeanException { checkCreate(className); SecurityManager sm = System.getSecurityManager(); if (sm == null) { Object object = getMBeanServer().instantiate(className, params, signature); checkClassLoader(object); return getMBeanServer().registerMBean(object, name); } else { return getMBeanServer().createMBean(className, name, params, signature); } }
/** * Registers a DynamicMBean. */ private static void addDynamicMBean(final MBeanServer mbs, final DynamicMBean dmbean, final ObjectName on) { try { AccessController.doPrivileged(new PrivilegedExceptionAction<Void>() { @Override public Void run() throws InstanceAlreadyExistsException, MBeanRegistrationException, NotCompliantMBeanException { mbs.registerMBean(dmbean, on); return null; } }); } catch (PrivilegedActionException e) { throw new RuntimeException(e.getException()); } }
@Test public void testReconfigure() throws InstanceAlreadyExistsException, ConflictingVersionException, ValidationException, InstanceNotFoundException { ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction(); createInstance(transaction, instanceName, null); transaction.commit(); transaction = configRegistryClient.createTransaction(); assertBeanCount(1, factory.getImplementationName()); NettyThreadgroupModuleMXBean mxBean = transaction.newMBeanProxy( transaction.lookupConfigBean(AbstractNettyThreadgroupModuleFactory.NAME, instanceName), NettyThreadgroupModuleMXBean.class); mxBean.setThreadCount(1); CommitStatus status = transaction.commit(); assertBeanCount(1, factory.getImplementationName()); assertStatus(status, 0, 1, 0); }
public ObjectInstance registerMBean(Object object, ObjectName name) throws InstanceAlreadyExistsException, MBeanRegistrationException, NotCompliantMBeanException { // ------------------------------ // ------------------------------ Class<?> theClass = object.getClass(); Introspector.checkCompliance(theClass); final String infoClassName = getNewMBeanClassName(object); checkMBeanPermission(infoClassName, null, name, "registerMBean"); checkMBeanTrustPermission(theClass); return registerObject(infoClassName, object, name); }
/** * Call <code>checkCreate(className)</code>, then forward this method to the * wrapped object. */ public ObjectInstance createMBean(String className, ObjectName name, ObjectName loaderName) throws ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException, NotCompliantMBeanException, InstanceNotFoundException { checkCreate(className); SecurityManager sm = System.getSecurityManager(); if (sm == null) { Object object = getMBeanServer().instantiate(className, loaderName); checkClassLoader(object); return getMBeanServer().registerMBean(object, name); } else { return getMBeanServer().createMBean(className, name, loaderName); } }
@Override public synchronized ObjectName createModule(final String factoryName, final String instanceName) throws InstanceAlreadyExistsException { transactionStatus.checkNotCommitStarted(); transactionStatus.checkNotAborted(); ModuleIdentifier moduleIdentifier = new ModuleIdentifier(factoryName, instanceName); dependencyResolverManager.assertNotExists(moduleIdentifier); // find factory ModuleFactory moduleFactory = factoriesHolder.findByModuleName(factoryName); DependencyResolver dependencyResolver = dependencyResolverManager.getOrCreate(moduleIdentifier); BundleContext bundleContext = getModuleFactoryBundleContext(moduleFactory.getImplementationName()); Module module = moduleFactory.createModule(instanceName, dependencyResolver, bundleContext); boolean defaultBean = false; return putConfigBeanToJMXAndInternalMaps(moduleIdentifier, module, moduleFactory, null, dependencyResolver, defaultBean, bundleContext); }
protected ObjectName createParallelAPSP( final ConfigTransactionJMXClient transaction, final ObjectName threadPoolON) throws InstanceAlreadyExistsException { ObjectName apspName = transaction.createModule( TestingParallelAPSPModuleFactory.NAME, apsp1); TestingParallelAPSPConfigMXBean parallelAPSPConfigProxy = transaction .newMXBeanProxy(apspName, TestingParallelAPSPConfigMXBean.class); parallelAPSPConfigProxy.setSomeParam("ahoj"); parallelAPSPConfigProxy.setThreadPool(threadPoolON); return apspName; }
public Scheduler(EngineProperties properties,Processor processor) throws MalformedObjectNameException, InstanceAlreadyExistsException, MBeanRegistrationException, NotCompliantMBeanException { requestHandler = new RequestResponseHandler(properties); tokenHandler = new TokenHandler(properties); if (processor == null) logger.error("Processor is null"); else { this.processor = processor; this.processor.addObserver(this); } }
public static void main(String[] args) throws Exception { boolean expectException = (System.getProperty("jmx.mxbean.multiname") == null); try { ObjectName objectName1 = new ObjectName("test:index=1"); ObjectName objectName2 = new ObjectName("test:index=2"); MBeanServer mbs = MBeanServerFactory.createMBeanServer(); MXBC_SimpleClass01 mxBeanObject = new MXBC_SimpleClass01(); mbs.registerMBean(mxBeanObject, objectName1); mbs.registerMBean(mxBeanObject, objectName2); if (expectException) { throw new Exception("TEST FAILED: " + "InstanceAlreadyExistsException was not thrown"); } else System.out.println("Correctly got no exception with compat property"); } catch (InstanceAlreadyExistsException e) { if (expectException) { System.out.println("Got expected InstanceAlreadyExistsException:"); e.printStackTrace(System.out); } else { throw new Exception( "TEST FAILED: Got exception even though compat property set", e); } } System.out.println("TEST PASSED"); }
public ObjectInstance createMBean( String className, ObjectName name, ObjectName loaderName, Object[] params, String[] signature) throws ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException, NotCompliantMBeanException, InstanceNotFoundException { Object mbean = instantiate(className, loaderName, params, signature); return registerMBean(mbean, name); }
/** * * @param flag Flag to be exposed through JMX. * @param source MBean or ObjectName of the object where the flag resides. * @param nbs NotificationBroadcasterSupport through which the events will be send. */ public JMXFlagDecorator(Flag<T> flag, ObjectName source, MBeanServer mbs, String flagName) throws MalformedObjectNameException, InstanceAlreadyExistsException, MBeanRegistrationException, NotCompliantMBeanException { this.flag = flag; this.source = source; this.flagName = flagName; ObjectName name = PogamutJMX.getObjectName(source, flagName, PogamutJMX.FLAGS_SUBTYPE); mbs.registerMBean(this, name); flag.addListener(listener); }
@Test public void createPositiveTest() throws InstanceAlreadyExistsException { final User user = prepareUser(); user.removeCart(); when(userService.find(anyString())).thenReturn(user); when(userService.update(anyObject())).thenReturn(user); cartService.create(random(40)); verify(userService).find(anyString()); verify(userService).update(anyObject()); }
@Override public synchronized ObjectInstance createMBean(String className, ObjectName name) throws ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException, NotCompliantMBeanException { throw new UnsupportedOperationException("Not supported by PogamutMBeanServer yet..."); }
@Override public synchronized ObjectInstance createMBean(String className, ObjectName name, Object[] params, String[] signature) throws ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException, NotCompliantMBeanException { throw new UnsupportedOperationException("Not supported by PogamutMBeanServer yet..."); }
@Override public synchronized ObjectInstance createMBean(String className, ObjectName name, ObjectName loaderName, Object[] params, String[] signature) throws ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException, NotCompliantMBeanException, InstanceNotFoundException { throw new UnsupportedOperationException("Not supported by PogamutMBeanServer yet..."); }
@Override public synchronized ObjectInstance registerMBean(Object object, ObjectName name) throws InstanceAlreadyExistsException, MBeanRegistrationException, NotCompliantMBeanException { ObjectInstance obj = mbs.registerMBean(object, name); mBeans.add(new MBean1(name, object)); unregisteredMBeans.remove(new MBean1(name, object)); return obj; }
public TransactionModuleJMXRegistration registerMBean(final Object object, final ObjectName on) throws InstanceAlreadyExistsException { if (!transactionName.equals(ObjectNameUtil.getTransactionName(on))) { throw new IllegalArgumentException("Transaction name mismatch between expected " + transactionName + " " + "and " + on); } ObjectNameUtil.checkTypeOneOf(on, ObjectNameUtil.TYPE_MODULE); return new TransactionModuleJMXRegistration( currentJMXRegistrator.registerMBean(object, on)); }
@Override protected AgentJMXComponents createAgentJMX() { return new AgentJMXComponents<IAgent3D>(this) { @Override protected AgentMBeanAdapter createAgentMBean(ObjectName objectName, MBeanServer mbs) throws MalformedObjectNameException, InstanceAlreadyExistsException, InstanceAlreadyExistsException, MBeanRegistrationException, NotCompliantMBeanException { return new Agent3DMBeanAdapter(AbstractAgent3D.this, objectName, mbs); } }; }
@Override void handleMissingInstance(Map<String, AttributeConfigElement> configuration, ConfigTransactionClient ta, String module, String instance, ServiceRegistryWrapper services) throws ConfigHandlingException { try { ObjectName on = ta.createModule(module, instance); LOG.trace("New instance for {} {} created under name {}", module, instance, on); } catch (InstanceAlreadyExistsException e1) { throw new ConfigHandlingException(String.format("Unable to create instance for %s : %s.", module, instance), DocumentedException.ErrorType.APPLICATION, DocumentedException.ErrorTag.OPERATION_FAILED, DocumentedException.ErrorSeverity.ERROR); } }
@Override protected AgentJMXComponents createAgentJMX() { return new AgentJMXComponents<IUT2004Bot>(this) { @Override protected AgentMBeanAdapter createAgentMBean(ObjectName objectName, MBeanServer mbs) throws MalformedObjectNameException, InstanceAlreadyExistsException, InstanceAlreadyExistsException, MBeanRegistrationException, NotCompliantMBeanException { return new BotJMXMBeanAdapter(UT2004Bot.this, objectName, mbs); } }; }
public ObjectInstance createMBean( String className, ObjectName name, Object[] params, String[] signature) throws ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException, NotCompliantMBeanException { try { return createMBean(className, name, clrName, params, signature); } catch (InstanceNotFoundException ex) { throw new RuntimeException(ex); // can't happen } }
@Override public void copyExistingModulesAndProcessFactoryDiff(final Collection<ModuleInternalInfo> existingModules, final List<ModuleFactory> lastListOfFactories) { // copy old configuration to this server for (ModuleInternalInfo oldConfigInfo : existingModules) { try { copyExistingModule(oldConfigInfo); } catch (final InstanceAlreadyExistsException e) { throw new IllegalStateException("Error while copying " + oldConfigInfo, e); } } processDefaultBeans(lastListOfFactories); }