private ModelNode addAttributeDescription(final ResourceDescriptionResolver resolver, final Locale locale, final ResourceBundle bundle, final ModelNode node, final ModelType type, final boolean nillable, final MeasurementUnit measurementUnit, final String... suffixes) { final ModelNode valNode = node.get(suffixes[suffixes.length -1]); valNode.get(DESCRIPTION).set(resolver.getResourceAttributeValueTypeDescription(getName(), locale, bundle, suffixes)); valNode.get(TYPE).set(type); valNode.get(NILLABLE).set(nillable); if (measurementUnit != null) { valNode.get(UNIT).set(measurementUnit.getName()); } return valNode; }
public static Double calculateOffset(MeasurementUnit first, MeasurementUnit second) throws MeasurementConversionException { if (first.isComparableTo(second) == false) { throw new MeasurementConversionException(MESSAGES.cannotConvert(first.name(), second.name())); } return Scale.calculateOffset(first.scale, second.scale); }
/** * A Java bean style getter to allow us to access the enum name from JSPs (e.g. ${measureUnits.name}). * * @return the enum name */ public String getName() { return name(); }
if (unitModelNode.isDefined()) { try { sizeUnit = MeasurementUnit.valueOf(unitModelNode.asString()); } catch (IllegalArgumentException ex) { replyParameterName, model); Double offset = MeasurementUnit.calculateOffset(MeasurementUnit.BYTES, sizeUnit); try { Path folder = new File(result).toPath();
private static MeasurementUnit getMeasurementUnit(ModelNode metricValueNode, OperationContext context, SimpleAttributeDefinition metricUnits) throws OperationFailedException { String metricUnitsStr = getString(metricValueNode, context, metricUnits); if (metricUnitsStr == null) { return MeasurementUnit.NONE; } else { return MeasurementUnit.valueOf(metricUnitsStr.toUpperCase(Locale.ENGLISH)); } }
public static Double calculateOffset(MeasurementUnit first, MeasurementUnit second) throws MeasurementConversionException { if (first.isComparableTo(second) == false) { throw new MeasurementConversionException(ControllerClientLogger.ROOT_LOGGER.cannotConvert(first.name(), second.name())); } return Scale.calculateOffset(first.scale, second.scale); }
/** * A Java bean style getter to allow us to access the enum name from JSPs (e.g. ${measureUnits.name}). * * @return the enum name */ public String getName() { return name(); }
if (unitModelNode.isDefined()) { try { sizeUnit = MeasurementUnit.valueOf(unitModelNode.asString()); } catch (IllegalArgumentException ex) { replyParameterName, model); Double offset = MeasurementUnit.calculateOffset(MeasurementUnit.BYTES, sizeUnit); try { Path folder = new File(result).toPath();
@Override public void validateParameter(String parameterName, ModelNode value) throws OperationFailedException { super.validateParameter(parameterName, value); if (value.isDefined()) { String muString = value.asString(); MeasurementUnit mu = MeasurementUnit.valueOf(muString.toUpperCase(Locale.ENGLISH)); if (mu == null || !allowedValues.contains(mu)) { throw new OperationFailedException("Bad value [" + muString + "] for param [" + parameterName + "]"); } } }
.setAutoEnableContexts(AUTO_ENABLE_CONTEXTS.resolveModelAttribute(context, model).asBoolean()) .setStopContextTimeout(STOP_CONTEXT_TIMEOUT.resolveModelAttribute(context, model).asInt()) .setStopContextTimeoutUnit(TimeUnit.valueOf(STOP_CONTEXT_TIMEOUT.getDefinition().getMeasurementUnit().getName())) .setSocketTimeout(SOCKET_TIMEOUT.resolveModelAttribute(context, model).asInt() * 1000) .setSessionDrainingStrategy(Enum.valueOf(SessionDrainingStrategyEnum.class, SESSION_DRAINING_STRATEGY.resolveModelAttribute(context, model).asString()))
@Override public List<ModelNode> getAllowedValues() { List<ModelNode> result = new ArrayList<ModelNode>(); for (MeasurementUnit mu : allowedValues) { result.add(new ModelNode().set(mu.name())); } return result; } }
private static ModelNode populateAttribute(final ModelNode attributes, final String name, final ModelType type, final boolean required, MeasurementUnit measurementUnit) { final ModelNode attr = attributes.get(name); attr.get(TYPE).set(type); attr.get(NILLABLE).set(!required); if (measurementUnit != null) { attr.get(UNIT).set(measurementUnit.getName()); } return attr; }
private static void populateMemoryUsage(final ModelNode toPopulate, ResourceBundle bundle) { toPopulate.get(INIT, DESCRIPTION).set(bundle.getString("memory.usage.init")); toPopulate.get(INIT, TYPE).set(ModelType.LONG); toPopulate.get(INIT, NILLABLE).set(true); toPopulate.get(INIT, UNIT).set(MeasurementUnit.BYTES.getName()); toPopulate.get(USED, DESCRIPTION).set(bundle.getString("memory.usage.used")); toPopulate.get(USED, TYPE).set(ModelType.LONG); toPopulate.get(USED, NILLABLE).set(true); toPopulate.get(USED, UNIT).set(MeasurementUnit.BYTES.getName()); toPopulate.get(COMMITTED, DESCRIPTION).set(bundle.getString("memory.usage.committed")); toPopulate.get(COMMITTED, TYPE).set(ModelType.LONG); toPopulate.get(COMMITTED, NILLABLE).set(true); toPopulate.get(COMMITTED, UNIT).set(MeasurementUnit.BYTES.getName()); toPopulate.get(MAX, DESCRIPTION).set(bundle.getString("memory.usage.max")); toPopulate.get(MAX, TYPE).set(ModelType.LONG); toPopulate.get(MAX, NILLABLE).set(true); toPopulate.get(MAX, UNIT).set(MeasurementUnit.BYTES.getName()); }
private ModelNode addAttributeDescription(final ResourceDescriptionResolver resolver, final Locale locale, final ResourceBundle bundle, final ModelNode node, final ModelType type, final boolean nillable, final MeasurementUnit measurementUnit, final String... suffixes) { final ModelNode valNode = node.get(suffixes[suffixes.length -1]); valNode.get(DESCRIPTION).set(resolver.getResourceAttributeValueTypeDescription(getName(), locale, bundle, suffixes)); valNode.get(TYPE).set(type); valNode.get(NILLABLE).set(nillable); if (measurementUnit != null) { valNode.get(UNIT).set(measurementUnit.getName()); } return valNode; }
toPopulate.get(BLOCKED_TIME, TYPE).set(ModelType.LONG); toPopulate.get(BLOCKED_TIME, NILLABLE).set(false); toPopulate.get(BLOCKED_TIME, UNIT).set(MeasurementUnit.MILLISECONDS.getName()); toPopulate.get(BLOCKED_COUNT, DESCRIPTION).set(bundle.getString("threading.thread-info.blocked-count")); toPopulate.get(BLOCKED_COUNT, TYPE).set(ModelType.LONG); toPopulate.get(WAITED_TIME, TYPE).set(ModelType.LONG); toPopulate.get(WAITED_TIME, NILLABLE).set(false); toPopulate.get(WAITED_TIME, UNIT).set(MeasurementUnit.MILLISECONDS.getName()); toPopulate.get(WAITED_COUNT, DESCRIPTION).set(bundle.getString("threading.thread-info.waited-count")); toPopulate.get(WAITED_COUNT, TYPE).set(ModelType.STRING);
result.get(ModelDescriptionConstants.UNIT).set(measurementUnit.getName());
result.get(ModelDescriptionConstants.UNIT).set(measurementUnit.getName());
result.get(ModelDescriptionConstants.UNIT).set(measurementUnit.getName());