use of org.jgroups.stack.Protocol in project JGroups by belaban.
the class FlowControlUnitTest method replaceMFC.
protected static void replaceMFC(int max_queue_size, JChannel... channels) throws Exception {
for (JChannel ch : channels) {
ProtocolStack stack = ch.getProtocolStack();
MFC_NB mfc_nb = new MFC_NB().setMaxCredits(MAX_CREDITS).setMinThreshold(0.2);
mfc_nb.setMaxQueueSize(max_queue_size);
mfc_nb.frag_size = 1500;
mfc_nb.init();
stack.replaceProtocol(stack.findProtocol(MFC.class), mfc_nb);
View view = ch.getView();
// needs to setup received and sent hashmaps
mfc_nb.handleViewChange(view.getMembers());
for (Protocol p = mfc_nb; p != null; p = p.getDownProtocol()) p.setAddress(ch.getAddress());
mfc_nb.start();
}
}
use of org.jgroups.stack.Protocol in project JGroups by belaban.
the class NAKACK2_RetransmissionTest method setup.
@BeforeMethod
protected void setup() throws Exception {
receiver = new MockProtocol();
nak = new NAKACK2().useMcastXmit(false);
transport = new MockTransport();
ProtocolStack stack = new ProtocolStack();
stack.addProtocols(transport, nak, receiver);
stack.init();
nak.down(new Event(Event.BECOME_SERVER));
for (Protocol p = nak; p != null; p = p.getDownProtocol()) p.setAddress(A);
Digest digest = new Digest(view.getMembersRaw(), new long[] { 0, 0, 0, 0 });
nak.down(new Event(Event.SET_DIGEST, digest));
}
use of org.jgroups.stack.Protocol in project JGroups by belaban.
the class RpcDispatcherTest method setProps.
protected static void setProps(JChannel... channels) {
for (JChannel ch : channels) {
Protocol prot = ch.getProtocolStack().findProtocol(FRAG2.class);
if (prot != null) {
((FRAG2) prot).setFragSize(12000);
}
prot = ch.getProtocolStack().findProtocol(FRAG.class);
if (prot != null) {
((FRAG) prot).setFragSize(12000);
}
prot = ch.getProtocolStack().getTransport();
if (prot != null)
((TP) prot).getBundler().setMaxSize(14000);
}
}
use of org.jgroups.stack.Protocol in project JGroups by belaban.
the class JmxConfigurator method unregisterChannel.
public static void unregisterChannel(JChannel c, MBeanServer server, ObjectName prefix, String clusterName) throws Exception {
if (clusterName != null)
clusterName = ObjectName.quote(clusterName);
ProtocolStack stack = c.getProtocolStack();
List<Protocol> protocols = stack.getProtocols();
for (Protocol p : protocols) {
if (p.getClass().isAnnotationPresent(MBean.class)) {
try {
String obj_name = getProtocolRegistrationName(clusterName, prefix, p);
unregister(p, server, obj_name);
} catch (MBeanRegistrationException e) {
log.warn("MBean unregistration failed: " + e.getCause());
}
}
}
unregister(c, server, getChannelRegistrationName(prefix, clusterName));
}
use of org.jgroups.stack.Protocol in project JGroups by belaban.
the class JmxConfigurator method registerChannel.
/**
* Registers an already created channel with the given MBeanServer. Wraps instance of JChannel
* with DynamicMBean and delegates all calls to the actual JChannel wrapped.<br/>
* Optionally, this method will also wrap each protocol in the given channel with DynamicMBean
* and register it as well.
* @param channel The channel
* @param server The MBeanServer
* @param domain Has to be a JMX ObjectName of the domain, e.g. DefaultDomain:name=JGroups
* @param register_protocols Whether or not to register the protocols, too
*/
public static void registerChannel(JChannel channel, MBeanServer server, String domain, String cluster_name, boolean register_protocols) throws Exception {
if (channel == null)
throw new NullPointerException("channel cannot be null");
if (cluster_name == null)
cluster_name = channel.getClusterName();
if (cluster_name == null)
cluster_name = "null";
cluster_name = ObjectName.quote(cluster_name);
if (register_protocols) {
ProtocolStack stack = channel.getProtocolStack();
List<Protocol> protocols = stack.getProtocols();
for (Protocol p : protocols) {
if (p.getClass().isAnnotationPresent(MBean.class)) {
String jmx_name = getProtocolRegistrationName(cluster_name, domain, p);
register(p, server, jmx_name);
}
}
}
register(channel, server, getChannelRegistrationName(domain, cluster_name));
}
Aggregations