use of org.jgroups.stack.Protocol in project JGroups by belaban.
the class UNICAST_ConnectionTests method setup.
protected void setup(Class<? extends Protocol> unicast_class, Map<String, Object> props) throws Exception {
r1 = new MyReceiver("A");
r2 = new MyReceiver("B");
a = createChannel(unicast_class, "A");
if (props != null) {
Protocol prot = a.getProtocolStack().findProtocol(unicast_class);
for (Map.Entry<String, Object> entry : props.entrySet()) prot.setValue(entry.getKey(), entry.getValue());
}
a.connect(CLUSTER);
a_addr = a.getAddress();
a.setReceiver(r1);
u1 = a.getProtocolStack().findProtocol(unicast_class);
b = createChannel(unicast_class, "B");
if (props != null) {
Protocol prot = b.getProtocolStack().findProtocol(unicast_class);
for (Map.Entry<String, Object> entry : props.entrySet()) prot.setValue(entry.getKey(), entry.getValue());
}
b.connect(CLUSTER);
b_addr = b.getAddress();
b.setReceiver(r2);
u2 = b.getProtocolStack().findProtocol(unicast_class);
}
use of org.jgroups.stack.Protocol in project JGroups by belaban.
the class UNICAST_DropFirstAndLastTest method testFirstMessageDropped.
/**
* A sends unicast message 1 to B, but we drop message 1. The code in
* https://issues.jboss.org/browse/JGRP-1563 now needs to make sure message 1 is retransmitted to B
* within a short time period, and we don't have to rely on the stable task to kick in.
*/
@Test(dataProvider = "configProvider")
public void testFirstMessageDropped(Class<? extends Protocol> unicast_class) throws Exception {
setup(unicast_class);
System.out.println("**** closing all connections ****");
// close all connections, so we can start from scratch and send message A1 to B
for (JChannel ch : Arrays.asList(a, b)) {
Protocol unicast = ch.getProtocolStack().findProtocol(Util.getUnicastProtocols());
removeAllConnections(unicast);
}
setLevel("trace", a, b);
System.out.println("--> A sending first message to B (dropped before it reaches B)");
// drops the next unicast
discard.setDropDownUnicasts(1);
a.send(new Message(b.getAddress(), 1));
List<Integer> msgs = rb.list();
try {
Util.waitUntilListHasSize(msgs, 1, 500000, 500);
} catch (AssertionError err) {
printConnectionTables(a, b);
throw err;
}
System.out.println("list=" + msgs);
printConnectionTables(a, b);
// assert ((UNICAST2)a.getProtocolStack().findProtocol(UNICAST2.class)).connectionEstablished(b.getAddress());
}
use of org.jgroups.stack.Protocol in project JGroups by belaban.
the class ViewHandlerTest method configureGMS.
protected static void configureGMS(GMS gms) {
Address local_addr = Util.createRandomAddress("A");
ThreadFactory fac = new DefaultThreadFactory("test", true);
set(gms, "local_addr", local_addr);
set(gms, "timer", new TimeScheduler3(fac, 1, 3, 5000, 100, "run"));
gms.setDownProtocol(new Protocol() {
public ThreadFactory getThreadFactory() {
return fac;
}
});
}
use of org.jgroups.stack.Protocol in project JGroups by belaban.
the class ProgrammaticApiTest method testChannelCreation.
public void testChannelCreation() throws Exception {
ch = new JChannel(new SHARED_LOOPBACK(), new MockProtocol1(), new MockProtocol2()).name("A");
MyReceiver receiver = new MyReceiver();
ch.setReceiver(receiver);
ch.connect("demo");
Protocol transport = ch.getProtocolStack().getTransport();
transport.up((Message) new BytesMessage(null, "hello world").setSrc(Util.createRandomAddress()));
assert receiver.num_msgs_received == 1;
}
use of org.jgroups.stack.Protocol in project JGroups by belaban.
the class ProtocolConfigurationTest method testConfigurableObject.
/*
* Checks InetAddress and IpAddress processing
*/
public void testConfigurableObject() throws Exception {
List<ProtocolConfiguration> protocol_configs = new ArrayList<>();
List<Protocol> protocols = new ArrayList<>();
// create the layer described by INETADDRESSES
protocol = Configurator.createProtocol(configurableObjectsProps, stack);
ProtocolConfiguration cfg = new ProtocolConfiguration(configurableObjectsProps);
ProtocolStack.initComponents(protocol, cfg);
// process the defaults (want this eventually)
protocol_configs.add(new ProtocolConfiguration(configurableObjectsProps));
protocols.add(protocol);
// get the value which should have been assigned a default
List<Object> configObjs = protocol.getComponents();
assert configObjs.size() == 1;
Object configObj = configObjs.get(0);
assert configObj instanceof ConfigurableObject;
assert ((ConfigurableObject) configObj).getStringProp().equals("test");
}
Aggregations