This closes #25 CLI and Divert changes

This commit is contained in:
Clebert Suconic 2015-06-11 21:38:04 -04:00
commit d3a960b28d
4 changed files with 45 additions and 1 deletions

View File

@ -37,6 +37,7 @@ import io.airlift.airline.Arguments;
import io.airlift.airline.Command;
import io.airlift.airline.Option;
import org.apache.activemq.artemis.core.asyncio.impl.AsynchronousFileImpl;
import org.apache.activemq.artemis.core.server.cluster.impl.MessageLoadBalancingType;
import static java.nio.file.attribute.PosixFilePermission.GROUP_EXECUTE;
import static java.nio.file.attribute.PosixFilePermission.GROUP_READ;
@ -106,6 +107,9 @@ public class Create extends InputAbstract
@Option(name = "--max-hops", description = "Number of hops on the cluster configuration")
int maxHops = 0;
@Option(name = "--message-load-balancing", description = "What kind of message load balancing to use for clustered configurations. Can be ON_DEMAND, STRICT, or OFF. (Default: ON_DEMAND)")
String messageLoadBalancing = MessageLoadBalancingType.ON_DEMAND.toString();
@Option(name = "--replicated", description = "Enable broker replication")
boolean replicated = false;
@ -176,6 +180,16 @@ public class Create extends InputAbstract
this.portOffset = portOffset;
}
public String getMessageLoadBalancing()
{
return messageLoadBalancing;
}
public void setMessageLoadBalancing(String messageLoadBalancing)
{
this.messageLoadBalancing = messageLoadBalancing;
}
public String getJavaOptions()
{
return javaOptions;
@ -471,6 +485,11 @@ public class Create extends InputAbstract
filters.put("${http.port}", String.valueOf(HTTP_PORT + portOffset));
filters.put("${data.dir}", data);
filters.put("${max-hops}", String.valueOf(maxHops));
// validate message-load-balancing
Enum.valueOf(MessageLoadBalancingType.class, messageLoadBalancing);
filters.put("${message-load-balancing}", messageLoadBalancing);
filters.put("${user}", getUser());
filters.put("${password}", getPassword());
filters.put("${role}", getRole());

View File

@ -20,6 +20,7 @@
<cluster-connection name="my-cluster">
<address>jms</address>
<connector-ref>artemis</connector-ref>
<message-load-balancing>${message-load-balancing}</message-load-balancing>
<max-hops>${max-hops}</max-hops>
<discovery-group-ref discovery-group-name="dg-group1"/>
</cluster-connection>

View File

@ -92,7 +92,14 @@ public class DivertConfiguration implements Serializable
*/
public DivertConfiguration setRoutingName(final String routingName)
{
this.routingName = routingName;
if (routingName == null)
{
this.routingName = UUIDGenerator.getInstance().generateStringUUID();
}
else
{
this.routingName = routingName;
}
return this;
}

View File

@ -657,6 +657,23 @@ public class ActiveMQServerControlTest extends ManagementTestBase
}
@Test
public void testNullRouteNameOnDivert() throws Exception
{
String address = RandomUtil.randomString();
String name = RandomUtil.randomString();
String forwardingAddress = RandomUtil.randomString();
ActiveMQServerControl serverControl = createManagementControl();
checkNoResource(ObjectNameBuilder.DEFAULT.getDivertObjectName(name));
assertEquals(0, serverControl.getDivertNames().length);
serverControl.createDivert(name.toString(), null, address, forwardingAddress, true, null, null);
checkResource(ObjectNameBuilder.DEFAULT.getDivertObjectName(name));
}
@Test
public void testCreateAndDestroyDivert() throws Exception
{