Java Code Examples for org.jboss.dmr.ModelType#LONG
The following examples show how to use
org.jboss.dmr.ModelType#LONG .
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: OptionAttributeDefinition.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@SuppressWarnings("unchecked") public OptionMap.Builder resolveOption(final ExpressionResolver context, final ModelNode model, OptionMap.Builder builder) throws OperationFailedException { ModelNode value = resolveModelAttribute(context, model); if (value.isDefined()) { if (getType() == ModelType.INT) { builder.set((Option<Integer>) option, value.asInt()); } else if (getType() == ModelType.LONG) { builder.set(option, value.asLong()); } else if (getType() == ModelType.BOOLEAN) { builder.set(option, value.asBoolean()); } else if (optionType.isEnum()) { builder.set(option, option.parseValue(value.asString(), option.getClass().getClassLoader())); }else if (option.getClass().getSimpleName().equals("SequenceOption")) { builder.setSequence(option, value.asString().split("\\s*,\\s*")); } else if (getType() == ModelType.STRING) { builder.set(option, value.asString()); } else { throw new OperationFailedException("Don't know how to handle: " + option + " with value: " + value); } } return builder; }
Example 2
Source File: ModelTypeValidatorUnitTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@Test public void testLong() { ModelTypeValidator testee = new ModelTypeValidator(ModelType.LONG, false, false, false); validateNumbers(testee); invalidateLongRange(testee); testee = new ModelTypeValidator(ModelType.LONG, false, false, true); assertOk(testee, new ModelNode().set(1L)); assertInvalid(testee, new ModelNode().set(1)); }
Example 3
Source File: ManagementModelNode.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
public boolean isNumeric() { ModelType type = getType(); return (type == ModelType.BIG_DECIMAL) || (type == ModelType.BIG_INTEGER) || (type == ModelType.DOUBLE) || (type == ModelType.INT) || (type == ModelType.LONG); }
Example 4
Source File: ModelTestModelDescriptionValidator.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
public String validate(ModelType currentType, ModelNode currentNode, String descriptor) { if (currentNode.hasDefined(descriptor)) { if (currentType != ModelType.BIG_DECIMAL && currentType != ModelType.BIG_INTEGER && currentType != ModelType.DOUBLE && currentType != ModelType.INT && currentType != ModelType.LONG) { return "Unnecessary '" + descriptor + "' for non-numeric type=" + currentType; } if (!descriptor.equals(UNIT)) { try { if (currentType == ModelType.BIG_DECIMAL) { currentNode.get(descriptor).asBigDecimal(); } else if (currentType == ModelType.BIG_INTEGER) { currentNode.get(descriptor).asBigInteger(); } else if (currentType == ModelType.DOUBLE) { currentNode.get(descriptor).asDouble(); } else if (currentType == ModelType.INT) { currentNode.get(descriptor).asInt(); } else if (currentType == ModelType.LONG) { currentNode.get(descriptor).asLong(); } } catch (Exception e) { return "'" + descriptor + "' is not a " + currentType; } } } return null; }
Example 5
Source File: OptionAttributeDefinition.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
private void setType() { try { final Field typeField; if (option.getClass().getSimpleName().equals("SequenceOption")) { typeField = option.getClass().getDeclaredField("elementType"); } else { typeField = option.getClass().getDeclaredField("type"); } typeField.setAccessible(true); optionType = (Class<?>) typeField.get(option); if (optionType.isAssignableFrom(Integer.class)) { type = ModelType.INT; } else if (optionType.isAssignableFrom(Long.class)) { type = ModelType.LONG; } else if (optionType.isAssignableFrom(BigInteger.class)) { type = ModelType.BIG_INTEGER; } else if (optionType.isAssignableFrom(Double.class)) { type = ModelType.DOUBLE; } else if (optionType.isAssignableFrom(BigDecimal.class)) { type = ModelType.BIG_DECIMAL; } else if (optionType.isEnum() || optionType.isAssignableFrom(String.class)) { type = ModelType.STRING; } else if (optionType.isAssignableFrom(Boolean.class)) { type = ModelType.BOOLEAN; } else { type = ModelType.UNDEFINED; } } catch (Exception e) { throw new IllegalArgumentException(e); } }
Example 6
Source File: LongRangeValidator.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
public LongRangeValidator(final long min, final long max, final boolean nullable, final boolean allowExpressions) { super(ModelType.LONG, nullable, allowExpressions, false); this.min = min; this.max = max; }
Example 7
Source File: WorkerAdd.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
@Override @SuppressWarnings("unchecked") protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException { final PathAddress address = PathAddress.pathAddress(operation.get(OP_ADDR)); Resource resource = context.readResourceFromRoot(address.subAddress(0, address.size() - 1)); ModelNode workers = Resource.Tools.readModel(resource).get(IOExtension.WORKER_PATH.getKey()); int allWorkerCount = workers.asList().size(); final String name = context.getCurrentAddressValue(); final XnioWorker.Builder builder = Xnio.getInstance().createWorkerBuilder(); final OptionMap.Builder optionMapBuilder = OptionMap.builder(); for (OptionAttributeDefinition attr : WorkerResourceDefinition.ATTRIBUTES) { Option option = attr.getOption(); ModelNode value = attr.resolveModelAttribute(context, model); if (!value.isDefined()) { continue; } if (attr.getType() == ModelType.INT) { optionMapBuilder.set((Option<Integer>) option, value.asInt()); } else if (attr.getType() == ModelType.LONG) { optionMapBuilder.set(option, value.asLong()); } else if (attr.getType() == ModelType.BOOLEAN) { optionMapBuilder.set(option, value.asBoolean()); } } builder.populateFromOptions(optionMapBuilder.getMap()); builder.setWorkerName(name); ModelNode ioThreadsModel = WORKER_IO_THREADS.resolveModelAttribute(context, model); ModelNode coreTaskThreadsModel = WORKER_TASK_CORE_THREADS.resolveModelAttribute(context, model); ModelNode maxTaskThreadsModel = WORKER_TASK_MAX_THREADS.resolveModelAttribute(context, model); int cpuCount = getCpuCount(); int ioThreadsCalculated = getSuggestedIoThreadCount(); int workerThreads = builder.getMaxWorkerPoolSize(); int coreWorkerThreads = coreTaskThreadsModel.asInt(); if (!ioThreadsModel.isDefined() && !maxTaskThreadsModel.isDefined()) { workerThreads = getWorkerThreads(name, allWorkerCount); builder.setWorkerIoThreads(ioThreadsCalculated); builder.setCoreWorkerPoolSize(coreWorkerThreads); builder.setMaxWorkerPoolSize(workerThreads); IOLogger.ROOT_LOGGER.printDefaults(name, ioThreadsCalculated, workerThreads, cpuCount); } else { if (!ioThreadsModel.isDefined()) { builder.setWorkerIoThreads(ioThreadsCalculated); IOLogger.ROOT_LOGGER.printDefaultsIoThreads(name, ioThreadsCalculated, cpuCount); } if (!maxTaskThreadsModel.isDefined()) { workerThreads = getWorkerThreads(name, allWorkerCount); builder.setCoreWorkerPoolSize(coreWorkerThreads); builder.setMaxWorkerPoolSize(workerThreads); IOLogger.ROOT_LOGGER.printDefaultsWorkerThreads(name, workerThreads, cpuCount); } } registerMax(context, name, workerThreads); final CapabilityServiceBuilder<?> capBuilder = context.getCapabilityServiceTarget().addCapability(IO_WORKER_RUNTIME_CAPABILITY); final Consumer<XnioWorker> workerConsumer = capBuilder.provides(IO_WORKER_RUNTIME_CAPABILITY); final Supplier<ExecutorService> executorSupplier = capBuilder.requiresCapability("org.wildfly.management.executor", ExecutorService.class); capBuilder.setInstance(new WorkerService(workerConsumer, executorSupplier, builder)); capBuilder.setInitialMode(ServiceController.Mode.ON_DEMAND); capBuilder.install(); }