/** * Creates a composite operation using the specified operation steps. * @param operations steps * @return a composite operation */ public static ModelNode createCompositeOperation(ModelNode... operations) { return createCompositeOperation(Arrays.asList(operations)); }
@Override public ModelNode transformOperation(ModelNode operation) { PathAddress address = Operations.getPathAddress(operation); return Operations.createCompositeOperation(operation, Operations.createUndefineAttributeOperation(cacheAddress(address), CacheResourceDefinition.DeprecatedAttribute.BATCHING)); } };
@Override public ModelNode transformOperation(ModelNode operation) { PathAddress address = Operations.getPathAddress(operation); return Operations.createCompositeOperation(Operations.createReadAttributeOperation(cacheAddress(address), CacheResourceDefinition.DeprecatedAttribute.BATCHING), operation); } };
@Override public ModelNode transformOperation(ModelNode operation) { PathAddress address = Operations.getPathAddress(operation); return Operations.createCompositeOperation(operation, Operations.createUndefineAttributeOperation(cacheAddress(address), CacheResourceDefinition.DeprecatedAttribute.BATCHING)); } };
@Override public ModelNode transformOperation(ModelNode operation) { if (operation.hasDefined(PROPERTIES)) { final ModelNode addOperation = operation.clone(); List<Property> properties = addOperation.remove(PROPERTIES).asPropertyList(); List<ModelNode> operations = new ArrayList<>(properties.size() + 1); operations.add(addOperation); PathAddress address = this.addressResolver.apply(addOperation); for (final Property property : properties) { String key = property.getName(); ModelNode value = property.getValue(); ModelNode propertyAddOperation = Util.createAddOperation(address.append(PathElement.pathElement(PROPERTY, key))); propertyAddOperation.get(VALUE).set(value); operations.add(propertyAddOperation); } return Operations.createCompositeOperation(operations); } return operation; } }
@Override public ModelNode transformOperation(ModelNode operation) { ModelNode mode = Operations.getAttributeValue(operation); boolean batching = (mode.isDefined() && (mode.getType() == ModelType.STRING)) ? (TransactionMode.valueOf(mode.asString()) == TransactionMode.BATCH) : false; if (batching) { mode.set(TransactionMode.NONE.name()); } PathAddress address = Operations.getPathAddress(operation); return Operations.createCompositeOperation(operation, Operations.createWriteAttributeOperation(cacheAddress(address), CacheResourceDefinition.DeprecatedAttribute.BATCHING, new ModelNode(batching))); } };
@Override public ModelNode transformOperation(ModelNode operation) { if (operation.hasDefined(Attribute.MODE.getName())) { ModelNode mode = operation.get(Attribute.MODE.getName()); if ((mode.getType() == ModelType.STRING) && (TransactionMode.valueOf(mode.asString()) == TransactionMode.BATCH)) { mode.set(TransactionMode.NONE.name()); PathAddress address = Operations.getPathAddress(operation); return Operations.createCompositeOperation(operation, Operations.createWriteAttributeOperation(cacheAddress(address), CacheResourceDefinition.DeprecatedAttribute.BATCHING, new ModelNode(true))); } } return operation; } };
steps.add(operation); steps.addAll(postSteps); operation = Operations.createCompositeOperation(steps);
@Test public void testProtocolStackRemoveRemoveSequence() throws Exception { KernelServices services = buildKernelServices(); ModelNode operation = Operations.createCompositeOperation(addStackOp, addTransportOp, addProtocolOp); // add a protocol stack ModelNode result = services.executeOperation(operation); Assert.assertEquals(SUCCESS, result.get(OUTCOME).asString()); // remove the protocol stack result = services.executeOperation(removeStackOp); Assert.assertEquals(SUCCESS, result.get(OUTCOME).asString()); // remove the protocol stack again result = services.executeOperation(removeStackOp); Assert.assertEquals(FAILED, result.get(OUTCOME).asString()); }
protected static ModelNode getProtocolAddOperationWithProperties(String stackName, String type) { ModelNode[] operations = new ModelNode[] { getProtocolAddOperation(stackName, type), getProtocolPropertyAddOperation(stackName, type, "A", "a"), getProtocolPropertyAddOperation(stackName, type, "B", "b"), }; return Operations.createCompositeOperation(operations); }
protected static ModelNode getTransportAddOperationWithProperties(String stackName, String type) { ModelNode[] operations = new ModelNode[] { getTransportAddOperation(stackName, type), getProtocolPropertyAddOperation(stackName, type, "A", "a"), getProtocolPropertyAddOperation(stackName, type, "B", "b"), }; return Operations.createCompositeOperation(operations); }
@Test public void testProtocolStackAddRemoveAddSequence() throws Exception { KernelServices services = buildKernelServices(); ModelNode operation = Operations.createCompositeOperation(addStackOp, addTransportOp, addProtocolOp); // add a protocol stack, its transport and a protocol as a batch ModelNode result = services.executeOperation(operation); Assert.assertEquals(SUCCESS, result.get(OUTCOME).asString()); // remove the stack result = services.executeOperation(removeStackOp); Assert.assertEquals(SUCCESS, result.get(OUTCOME).asString()); // add the same stack result = services.executeOperation(operation); Assert.assertEquals(SUCCESS, result.get(OUTCOME).asString()); }
return new TransformedOperation(Operations.createCompositeOperation(operations), OperationResultTransformer.ORIGINAL_RESULT);
protected static ModelNode getProtocolStackAddOperationWithParameters(String stackName) { ModelNode[] operations = new ModelNode[] { getProtocolStackAddOperation(stackName), getTransportAddOperation(stackName, "UDP"), getProtocolAddOperation(stackName, "PING"), getProtocolAddOperation(stackName, "pbcast.FLUSH"), }; return Operations.createCompositeOperation(operations); }
/** * Creates a composite operation using the specified operation steps. * @param operations steps * @return a composite operation */ public static ModelNode createCompositeOperation(ModelNode... operations) { return createCompositeOperation(Arrays.asList(operations)); }
@Override public ModelNode transformOperation(ModelNode operation) { PathAddress address = Operations.getPathAddress(operation); return Operations.createCompositeOperation(operation, Operations.createUndefineAttributeOperation(cacheAddress(address), CacheResourceDefinition.DeprecatedAttribute.BATCHING)); } };
@Override public ModelNode transformOperation(ModelNode operation) { PathAddress address = Operations.getPathAddress(operation); return Operations.createCompositeOperation(Operations.createReadAttributeOperation(cacheAddress(address), CacheResourceDefinition.DeprecatedAttribute.BATCHING), operation); } };
@Override public ModelNode transformOperation(ModelNode operation) { PathAddress address = Operations.getPathAddress(operation); return Operations.createCompositeOperation(operation, Operations.createUndefineAttributeOperation(cacheAddress(address), CacheResourceDefinition.DeprecatedAttribute.BATCHING)); } };
@Override public ModelNode transformOperation(ModelNode operation) { ModelNode mode = Operations.getAttributeValue(operation); boolean batching = (mode.isDefined() && (mode.getType() == ModelType.STRING)) ? (TransactionMode.valueOf(mode.asString()) == TransactionMode.BATCH) : false; if (batching) { mode.set(TransactionMode.NONE.name()); } PathAddress address = Operations.getPathAddress(operation); return Operations.createCompositeOperation(operation, Operations.createWriteAttributeOperation(cacheAddress(address), CacheResourceDefinition.DeprecatedAttribute.BATCHING, new ModelNode(batching))); } };
@Override public ModelNode transformOperation(ModelNode operation) { if (operation.hasDefined(Attribute.MODE.getName())) { ModelNode mode = operation.get(Attribute.MODE.getName()); if ((mode.getType() == ModelType.STRING) && (TransactionMode.valueOf(mode.asString()) == TransactionMode.BATCH)) { mode.set(TransactionMode.NONE.name()); PathAddress address = Operations.getPathAddress(operation); return Operations.createCompositeOperation(operation, Operations.createWriteAttributeOperation(cacheAddress(address), CacheResourceDefinition.DeprecatedAttribute.BATCHING, new ModelNode(true))); } } return operation; } };