Skip to content

Commit

Permalink
Revert JGroups stack:add() signature back to original 1.1 api version.
Browse files Browse the repository at this point in the history
  • Loading branch information
rachmatowicz authored and bstansberry committed Jan 31, 2013
1 parent 7c1da20 commit 0567585
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
package org.jboss.as.clustering.jgroups.subsystem;

import org.jboss.as.controller.AttributeDefinition;
import org.jboss.as.controller.ObjectListAttributeDefinition;
import org.jboss.as.controller.ObjectTypeAttributeDefinition;
import org.jboss.as.controller.OperationDefinition;
import org.jboss.as.controller.OperationStepHandler;
Expand Down Expand Up @@ -78,6 +79,10 @@ public class ProtocolResource extends SimpleResourceDefinition {
setSuffix("protocol").
build();

static final ObjectListAttributeDefinition PROTOCOLS = ObjectListAttributeDefinition.
Builder.of(ModelKeys.PROTOCOLS, PROTOCOL).
setAllowNull(true).
build();

// operations
static final OperationDefinition PROTOCOL_ADD = new SimpleOperationDefinitionBuilder(ModelKeys.ADD_PROTOCOL, JGroupsExtension.getResourceDescriptionResolver("stack"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@

import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OPERATION_NAME;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.PRODUCT_NAME;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.TYPE;

import java.lang.reflect.Field;
import java.security.AccessController;
Expand All @@ -39,6 +37,7 @@
import java.util.concurrent.ExecutorService;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ThreadFactory;

import javax.management.MBeanServer;

import org.jboss.as.clustering.jgroups.ChannelFactory;
Expand Down Expand Up @@ -115,8 +114,13 @@ protected void populateModel(final OperationContext context, final ModelNode ope
for (int i = protocols.size()-1; i >= 0; i--) {
ModelNode protocol = protocols.get(i);
// create an ADD operation to add the protocol=* child
ModelNode addProtocol = Util.createOperation(ModelKeys.ADD_PROTOCOL,PathAddress.pathAddress(operation.get(OP_ADDR)));
addProtocol.get(TYPE).set(protocol);
ModelNode addProtocol = protocol.clone();
addProtocol.get(OPERATION_NAME).set(ModelKeys.ADD_PROTOCOL);
// add-protocol is a stack operation
ModelNode protocolAddress = operation.get(OP_ADDR).clone();
protocolAddress.protect();
addProtocol.get(OP_ADDR).set(protocolAddress);

// execute the operation using the transport handler
context.addStep(addProtocol, ProtocolResource.PROTOCOL_ADD_HANDLER, OperationContext.Stage.IMMEDIATE);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@

package org.jboss.as.clustering.jgroups.subsystem;

import org.jboss.as.controller.ObjectListAttributeDefinition;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.ADD;

import org.jboss.as.controller.OperationDefinition;
import org.jboss.as.controller.OperationStepHandler;
import org.jboss.as.controller.PathElement;
Expand Down Expand Up @@ -51,6 +52,12 @@ public class StackResource extends SimpleResourceDefinition {

// attributes
// operations
private static final OperationDefinition PROTOCOL_STACK_ADD = new SimpleOperationDefinitionBuilder(ADD, JGroupsExtension.getResourceDescriptionResolver(ModelKeys.STACK))
.addParameter(TransportResource.TRANSPORT)
.addParameter(ProtocolResource.PROTOCOLS)
.setAttributeResolver(JGroupsExtension.getResourceDescriptionResolver("stack.add"))
.build();

static final OperationDefinition EXPORT_NATIVE_CONFIGURATION = new SimpleOperationDefinitionBuilder(ModelKeys.EXPORT_NATIVE_CONFIGURATION, JGroupsExtension.getResourceDescriptionResolver("stack"))
.setReplyType(ModelType.STRING)
.build();
Expand All @@ -59,14 +66,17 @@ public class StackResource extends SimpleResourceDefinition {
public StackResource(boolean runtimeRegistration) {
super(STACK_PATH,
JGroupsExtension.getResourceDescriptionResolver(ModelKeys.STACK),
ProtocolStackAdd.INSTANCE,
// register below with custom signature
null,
ProtocolStackRemove.INSTANCE);
this.runtimeRegistration = runtimeRegistration;
}

@Override
public void registerOperations(ManagementResourceRegistration resourceRegistration) {
super.registerOperations(resourceRegistration);
// override to set up TRANSPORT and PROTOCOLS parameters
resourceRegistration.registerOperationHandler(PROTOCOL_STACK_ADD, ProtocolStackAdd.INSTANCE);
// register protocol add and remove
resourceRegistration.registerOperationHandler(ProtocolResource.PROTOCOL_ADD, ProtocolResource.PROTOCOL_ADD_HANDLER);
resourceRegistration.registerOperationHandler(ProtocolResource.PROTOCOL_REMOVE, ProtocolResource.PROTOCOL_REMOVE_HANDLER);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public class TransportResource extends SimpleResourceDefinition {
Builder.of(ModelKeys.TRANSPORT, TRANSPORT_ATTRIBUTES).
setAllowNull(true).
setSuffix(null).
setSuffix("transport").
//setSuffix("transport").
build();

// operations
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ jgroups.stack.add.transport.site=The site (i.e. data centre) identifier for this
jgroups.stack.add.transport.rack=The rack (i.e. server rack) identifier for this node. Used by Infinispan topology-aware consistent hash.
jgroups.stack.add.transport.machine=The machine (i.e. host) identifier for this node. Used by Infinispan topology-aware consistent hash.
jgroups.stack.add.transport.property=A JGroups transport property.
jgroups.stack.add.protocol.type=The implementation class for a protocol, which determines protocol functionality.
jgroups.stack.add.protocol.socket-binding=The socket binding specification for this protocol layer, used to specify IP interfaces and ports for communication.
jgroups.stack.add.protocol.properties=Optional LIST parameter specifying the protocol list for the stack.
jgroups.stack.add.protocol.property=A JGroups protocol property.
jgroups.stack.add.protocols.protocol.type=The implementation class for a protocol, which determines protocol functionality.
jgroups.stack.add.protocols.protocol.socket-binding=The socket binding specification for this protocol layer, used to specify IP interfaces and ports for communication.
jgroups.stack.add.protocols.protocol.properties=Optional LIST parameter specifying the protocol list for the stack.
jgroups.stack.add.protocols.protocol.property=A JGroups protocol property.
jgroups.stack.add.protocols=Optional LIST parameter specifying the protocol list for the stack.
jgroups.stack.remove=Remove a protocol stack from the jgroups subsystem.
jgroups.stack.add-protocol=Add the configuration of a protocol within a protocol stack.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,10 @@
import org.jboss.as.controller.PathAddress;
import org.jboss.as.controller.PathElement;
import org.jboss.as.controller.RunningMode;
import org.jboss.as.controller.descriptions.ModelDescriptionConstants;
import org.jboss.as.controller.operations.common.Util;
import org.jboss.as.model.test.ModelTestUtils;
import org.jboss.as.subsystem.test.AbstractSubsystemBaseTest;
import org.jboss.as.subsystem.test.AdditionalInitialization;
import org.jboss.as.subsystem.test.KernelServices;
import org.jboss.as.subsystem.test.ModelDescriptionValidator;
import org.jboss.dmr.ModelNode;
import org.junit.Test;

Expand Down Expand Up @@ -127,20 +124,17 @@ public void testLegacyOperations() throws Exception {
transport.get("socket-binding").set("jgroups-udp");

ModelNode protocols = new ModelNode();
protocols.add("PING");
protocols.add("MERGE3");
protocols.add("FD_SOCK");
protocols.add("FD");
protocols.add("VERIFY_SUSPECT");
protocols.add("BARRIER");
protocols.add("pbcast.NAKACK2");
protocols.add("UNICAST2");
protocols.add("pbcast.STABLE");
protocols.add("pbcast.GMS");
protocols.add("UFC");
protocols.add("MFC");
protocols.add("FRAG2");
protocols.add("RSVP");
String[] protocolList = {"PING", "MERGE3", "FD_SOCK", "FD", "VERIFY_SUSPECT", "BARRIER", "pbcast.NAKACK2", "UNICAST2",
"pbcast.STABLE", "pbcast.GMS", "UFC", "MFC", "FRAG2", "RSVP"} ;

for (int i = 0; i < protocolList.length; i++) {
ModelNode protocol = new ModelNode();
protocol.get(ModelKeys.TYPE).set(protocolList[i]) ;
protocol.get("socket-binding").set("jgroups-udp");
System.out.println("adding protovcol = " + protocol.toString());
protocols.add(protocol);
}

op.get("transport").set(transport);
op.get("protocols").set(protocols);
ops.add(op);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,8 @@
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.VALUE;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.WRITE_ATTRIBUTE_OPERATION;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.StringWriter;
import java.net.URISyntaxException;
import java.net.URL;

import org.jboss.as.clustering.jgroups.JGroupsMessages;
import org.jboss.as.controller.PathAddress;
import org.jboss.as.controller.PathElement;
import org.jboss.as.subsystem.test.AbstractSubsystemTest;
Expand Down Expand Up @@ -110,17 +103,22 @@ protected static ModelNode getProtocolStackAddOperation(String stackName) {
}

protected static ModelNode getProtocolStackAddOperationWithParameters(String stackName) {
ModelNode addOp = getProtocolStackAddOperation(stackName);
// add optional TRANSPORT attribute
ModelNode transport = addOp.get(ModelKeys.TRANSPORT);
transport.get(ModelKeys.TYPE).set("UDP");

// add optional PROTOCOLS attribute
ModelNode protocolsList = addOp.get(ModelKeys.PROTOCOLS);
protocolsList.add("MPING");
protocolsList.add("pbcast.FLUSH");
return addOp ;
}
ModelNode addOp = getProtocolStackAddOperation(stackName);
// add optional TRANSPORT attribute
ModelNode transport = addOp.get(ModelKeys.TRANSPORT);
transport.get(ModelKeys.TYPE).set("UDP");

// add optional PROTOCOLS attribute
ModelNode protocolsList = new ModelNode();
ModelNode mping = new ModelNode() ;
mping.get(ModelKeys.TYPE).set("MPING");
protocolsList.add(mping);
ModelNode flush = new ModelNode() ;
flush.get(ModelKeys.TYPE).set("pbcast.FLUSH");
protocolsList.add(flush);
addOp.get(ModelKeys.PROTOCOLS).set(protocolsList);
return addOp ;
}

protected static ModelNode getProtocolStackRemoveOperation(String stackName) {
// create the address of the cache
Expand Down

0 comments on commit 0567585

Please sign in to comment.