@Override protected void executeReadAttribute(OperationContext context, ModelNode operation) throws OperationFailedException { final String memPoolName = PathAddress.pathAddress(operation.require(ModelDescriptionConstants.OP_ADDR)).getLastElement().getValue(); final String name = operation.require(ModelDescriptionConstants.NAME).asString(); try { if ((PlatformMBeanUtil.JVM_MAJOR_VERSION > 6 && PlatformMBeanConstants.OBJECT_NAME.equals(name)) || PlatformMBeanConstants.MEMORY_POOL_READ_ATTRIBUTES.contains(name) || PlatformMBeanConstants.MEMORY_POOL_READ_WRITE_ATTRIBUTES.contains(name) || PlatformMBeanConstants.MEMORY_POOL_METRICS.contains(name)) { MemoryPoolMXBean memoryPoolMXBean = getMemoryPoolMXBean(memPoolName); storeResult(name, context.getResult(), memoryPoolMXBean, memPoolName); } else { // Shouldn't happen; the global handler should reject throw unknownAttribute(operation); } } catch (UnsupportedOperationException e) { throw new OperationFailedException(new ModelNode().set(e.toString())); } }
MemoryPoolMXBean memoryPoolMXBean = MemoryPoolMXBeanAttributeHandler.getMemoryPoolMXBean(memPoolName); final ModelNode store = result.get(attribute); try { MemoryPoolMXBeanAttributeHandler.storeResult(attribute, store, memoryPoolMXBean, memPoolName); } catch (UnsupportedOperationException ignored) { final ModelNode store = result.get(attribute); try { MemoryPoolMXBeanAttributeHandler.storeResult(attribute, store, memoryPoolMXBean, memPoolName); } catch (UnsupportedOperationException ignored) { final ModelNode store = result.get(attribute); try { MemoryPoolMXBeanAttributeHandler.storeResult(attribute, store, memoryPoolMXBean, memPoolName); } catch (UnsupportedOperationException ignored) { MemoryPoolMXBeanAttributeHandler.storeResult(PlatformMBeanConstants.OBJECT_NAME, store, memoryPoolMXBean, memPoolName);
@Override protected void executeWriteAttribute(OperationContext context, ModelNode operation) throws OperationFailedException { final String memPoolName = PathAddress.pathAddress(operation.require(ModelDescriptionConstants.OP_ADDR)).getLastElement().getValue(); MemoryPoolMXBean memoryPoolMXBean = getMemoryPoolMXBean(memPoolName); final String name = operation.require(ModelDescriptionConstants.NAME).asString(); try { if (PlatformMBeanConstants.USAGE_THRESHOLD.equals(name)) { usageValidator.validate(operation); memoryPoolMXBean.setUsageThreshold(operation.require(ModelDescriptionConstants.VALUE).asLong()); } else if (PlatformMBeanConstants.COLLECTION_USAGE_THRESHOLD.equals(name)) { usageValidator.validate(operation); memoryPoolMXBean.setCollectionUsageThreshold(operation.require(ModelDescriptionConstants.VALUE).asLong()); } else if (PlatformMBeanConstants.MEMORY_POOL_READ_WRITE_ATTRIBUTES.contains(name)) { // Bug throw PlatformMBeanMessages.MESSAGES.badWriteAttributeImpl3(name); } else { // Shouldn't happen; the global handler should reject throw unknownAttribute(operation); } } catch (SecurityException e) { throw new OperationFailedException(new ModelNode().set(e.toString())); } catch (UnsupportedOperationException e) { throw new OperationFailedException(new ModelNode().set(e.toString())); } }
memPool.registerOperationHandler(ReadResourceHandler.DEFINITION, MemoryPoolMXBeanReadResourceHandler.INSTANCE); memPool.registerOperationHandler(RESET_PEAK_USAGE, MemoryPoolMXBeanResetPeakUsageHandler.INSTANCE, MemoryPoolMXBeanResetPeakUsageHandler.INSTANCE, RUNTIME_ONLY_FLAG); MemoryPoolMXBeanAttributeHandler.INSTANCE.register(memPool);
@Override protected void executeWriteAttribute(OperationContext context, ModelNode operation) throws OperationFailedException { final String memPoolName = PathAddress.pathAddress(operation.require(ModelDescriptionConstants.OP_ADDR)).getLastElement().getValue(); MemoryPoolMXBean memoryPoolMXBean = getMemoryPoolMXBean(memPoolName); final String name = operation.require(ModelDescriptionConstants.NAME).asString(); try { if (PlatformMBeanConstants.USAGE_THRESHOLD.equals(name)) { context.getServiceRegistry(true); //to trigger auth usageValidator.validate(operation); memoryPoolMXBean.setUsageThreshold(operation.require(ModelDescriptionConstants.VALUE).asLong()); } else if (PlatformMBeanConstants.COLLECTION_USAGE_THRESHOLD.equals(name)) { context.getServiceRegistry(true); //to trigger auth usageValidator.validate(operation); memoryPoolMXBean.setCollectionUsageThreshold(operation.require(ModelDescriptionConstants.VALUE).asLong()); } else if (MemoryPoolResourceDefinition.MEMORY_POOL_READ_WRITE_ATTRIBUTES.contains(name)) { // Bug throw PlatformMBeanLogger.ROOT_LOGGER.badWriteAttributeImpl(name); } else { // Shouldn't happen; the global handler should reject throw unknownAttribute(operation); } } catch (SecurityException e) { throw new OperationFailedException(e.toString()); } catch (UnsupportedOperationException e) { throw new OperationFailedException(e.toString()); } }
MemoryPoolMXBean memoryPoolMXBean = MemoryPoolMXBeanAttributeHandler.getMemoryPoolMXBean(memPoolName); final ModelNode store = result.get(attribute); try { MemoryPoolMXBeanAttributeHandler.storeResult(attribute, store, memoryPoolMXBean, memPoolName); } catch (UnsupportedOperationException ignored) { final ModelNode store = result.get(attribute); try { MemoryPoolMXBeanAttributeHandler.storeResult(attribute, store, memoryPoolMXBean, memPoolName); } catch (UnsupportedOperationException ignored) { final ModelNode store = result.get(attribute); try { MemoryPoolMXBeanAttributeHandler.storeResult(attribute, store, memoryPoolMXBean, memPoolName); } catch (UnsupportedOperationException ignored) { MemoryPoolMXBeanAttributeHandler.storeResult(PlatformMBeanConstants.OBJECT_NAME.getName(), store, memoryPoolMXBean, memPoolName);
@Override protected void executeReadAttribute(OperationContext context, ModelNode operation) throws OperationFailedException { final String memPoolName = PathAddress.pathAddress(operation.require(ModelDescriptionConstants.OP_ADDR)).getLastElement().getValue(); final String name = operation.require(ModelDescriptionConstants.NAME).asString(); try { if ((PlatformMBeanConstants.OBJECT_NAME.getName().equals(name)) || MemoryPoolResourceDefinition.MEMORY_POOL_READ_ATTRIBUTES.contains(name) || MemoryPoolResourceDefinition.MEMORY_POOL_READ_WRITE_ATTRIBUTES.contains(name) || MemoryPoolResourceDefinition.MEMORY_POOL_METRICS.contains(name)) { MemoryPoolMXBean memoryPoolMXBean = getMemoryPoolMXBean(memPoolName); storeResult(name, context.getResult(), memoryPoolMXBean, memPoolName); } else { // Shouldn't happen; the global handler should reject throw unknownAttribute(operation); } } catch (UnsupportedOperationException e) { throw new OperationFailedException(e.toString()); } }
@Override protected void executeWriteAttribute(OperationContext context, ModelNode operation) throws OperationFailedException { final String memPoolName = PathAddress.pathAddress(operation.require(ModelDescriptionConstants.OP_ADDR)).getLastElement().getValue(); MemoryPoolMXBean memoryPoolMXBean = getMemoryPoolMXBean(memPoolName); final String name = operation.require(ModelDescriptionConstants.NAME).asString(); try { if (PlatformMBeanConstants.USAGE_THRESHOLD.equals(name)) { context.getServiceRegistry(true); //to trigger auth usageValidator.validate(operation); memoryPoolMXBean.setUsageThreshold(operation.require(ModelDescriptionConstants.VALUE).asLong()); } else if (PlatformMBeanConstants.COLLECTION_USAGE_THRESHOLD.equals(name)) { context.getServiceRegistry(true); //to trigger auth usageValidator.validate(operation); memoryPoolMXBean.setCollectionUsageThreshold(operation.require(ModelDescriptionConstants.VALUE).asLong()); } else if (MemoryPoolResourceDefinition.MEMORY_POOL_READ_WRITE_ATTRIBUTES.contains(name)) { // Bug throw PlatformMBeanLogger.ROOT_LOGGER.badWriteAttributeImpl(name); } else { // Shouldn't happen; the global handler should reject throw unknownAttribute(operation); } } catch (SecurityException e) { throw new OperationFailedException(e.toString()); } catch (UnsupportedOperationException e) { throw new OperationFailedException(e.toString()); } }
MemoryPoolMXBean memoryPoolMXBean = MemoryPoolMXBeanAttributeHandler.getMemoryPoolMXBean(memPoolName); final ModelNode store = result.get(attribute); try { MemoryPoolMXBeanAttributeHandler.storeResult(attribute, store, memoryPoolMXBean, memPoolName); } catch (UnsupportedOperationException ignored) { final ModelNode store = result.get(attribute); try { MemoryPoolMXBeanAttributeHandler.storeResult(attribute, store, memoryPoolMXBean, memPoolName); } catch (UnsupportedOperationException ignored) { final ModelNode store = result.get(attribute); try { MemoryPoolMXBeanAttributeHandler.storeResult(attribute, store, memoryPoolMXBean, memPoolName); } catch (UnsupportedOperationException ignored) { MemoryPoolMXBeanAttributeHandler.storeResult(PlatformMBeanConstants.OBJECT_NAME.getName(), store, memoryPoolMXBean, memPoolName);
@Override protected void executeReadAttribute(OperationContext context, ModelNode operation) throws OperationFailedException { final String memPoolName = PathAddress.pathAddress(operation.require(ModelDescriptionConstants.OP_ADDR)).getLastElement().getValue(); final String name = operation.require(ModelDescriptionConstants.NAME).asString(); try { if ((PlatformMBeanConstants.OBJECT_NAME.getName().equals(name)) || MemoryPoolResourceDefinition.MEMORY_POOL_READ_ATTRIBUTES.contains(name) || MemoryPoolResourceDefinition.MEMORY_POOL_READ_WRITE_ATTRIBUTES.contains(name) || MemoryPoolResourceDefinition.MEMORY_POOL_METRICS.contains(name)) { MemoryPoolMXBean memoryPoolMXBean = getMemoryPoolMXBean(memPoolName); storeResult(name, context.getResult(), memoryPoolMXBean, memPoolName); } else { // Shouldn't happen; the global handler should reject throw unknownAttribute(operation); } } catch (UnsupportedOperationException e) { throw new OperationFailedException(e.toString()); } }