// Set-up the first ServerNode.
kernel1 = new Kernel("test.kernel1", "test");
kernel1.boot();
node1Name = new ObjectName("geronimo.test:role=node1");
GBeanMBean node1GB = new GBeanMBean(NodeImpl.GBEAN_INFO);
node1GB.setAttribute("NodeInfo", primaryNode);
repNode1Name = new ObjectName("geronimo.test:role=replication");
GBeanMBean repNode1GB = new GBeanMBean(ReplicationMemberImpl.GBEAN_INFO);
repNode1GB.setReferencePatterns("Node",
Collections.singleton(node1Name));
repNode1GB.setAttribute("Name", "Replication");
repNode1GB.setAttribute("TargetNodes", new NodeInfo[] {secondaryNode});
loadAndStart(kernel1, repNode1Name, repNode1GB);
loadAndStart(kernel1, node1Name, node1GB);
repNode1 = (ReplicationMember) repNode1GB.getTarget();
// Set-up the second ServerNode.
kernel2 = new Kernel("test.kernel2", "test");
kernel2.boot();
node2Name = new ObjectName("geronimo.test:role=node2");
GBeanMBean node2GB = new GBeanMBean(NodeImpl.GBEAN_INFO);
node2GB.setAttribute("NodeInfo", secondaryNode);
repNode2Name = new ObjectName("geronimo.test:role=replication");
GBeanMBean repNode2GB = new GBeanMBean(ReplicationMemberImpl.GBEAN_INFO);
repNode2GB.setReferencePatterns("Node",
Collections.singleton(node2Name));
repNode2GB.setAttribute("Name", "Replication");
repNode2GB.setAttribute("TargetNodes", new NodeInfo[] {primaryNode});
loadAndStart(kernel2, repNode2Name, repNode2GB);
loadAndStart(kernel2, node2Name, node2GB);
repNode2 = (ReplicationMember) repNode2GB.getTarget();
Node node = (Node) node2GB.getTarget();
// The second ServerNode joins the first one.
node.join(primaryNode);