Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
This artifact provides a single jar that contains all classes required to use remote Jakarta Enterprise Beans and Jakarta Messaging, including
all dependencies. It is intended for use by those not using maven, maven users should just import the Jakarta Enterprise Beans and
Jakarta Messaging BOM's instead (shaded JAR's cause lots of problems with maven, as it is very easy to inadvertently end up
with different versions on classes on the class path).
{@link #start()}: subclasses must call super.start() after they initialize themselves
* (e.g., created their sockets).
*
{@link #stop()}: subclasses must call super.stop() after they deinitialized themselves
*
{@link #destroy()}
*
* The create() or start() method has to create a local address.
* The {@link #receive(Address, byte[], int, int)} method must
* be called by subclasses when a unicast or multicast message has been received.
* @author Bela Ban
*/
@MBean(description="Transport protocol")
public abstract class TP extends Protocol implements DiagnosticsHandler.ProbeHandler {
public static final byte LIST=1; // we have a list of messages rather than a single message when set
public static final byte MULTICAST=2; // message is a multicast (versus a unicast) message when set
public static final int MSG_OVERHEAD=Global.SHORT_SIZE*2 + Global.BYTE_SIZE; // version + flags
protected static final long MIN_WAIT_BETWEEN_DISCOVERIES=TimeUnit.NANOSECONDS.convert(10, TimeUnit.SECONDS); // ns
/* ------------------------------------------ JMX and Properties ------------------------------------------ */
@LocalAddress
@Property(name="bind_addr",
description="The bind address which should be used by this transport. The following special values " +
"are also recognized: GLOBAL, SITE_LOCAL, LINK_LOCAL, NON_LOOPBACK, match-interface, match-host, match-address",
defaultValueIPv4=Global.NON_LOOPBACK_ADDRESS, defaultValueIPv6=Global.NON_LOOPBACK_ADDRESS,
systemProperty={Global.BIND_ADDR},writable=false)
protected InetAddress bind_addr;
@Property(description="Use \"external_addr\" if you have hosts on different networks, behind " +
"firewalls. On each firewall, set up a port forwarding rule (sometimes called \"virtual server\") to " +
"the local IP (e.g. 192.168.1.100) of the host then on each host, set \"external_addr\" TCP transport " +
"parameter to the external (public IP) address of the firewall.",
systemProperty=Global.EXTERNAL_ADDR,writable=false)
protected InetAddress external_addr;
@Property(description="Used to map the internal port (bind_port) to an external port. Only used if > 0",
systemProperty=Global.EXTERNAL_PORT,writable=false)
protected int external_port;
@ManagedAttribute(description="tracing is enabled or disabled for the given log",writable=true)
protected boolean is_trace=log.isTraceEnabled();
@Property(description="If true, the transport should use all available interfaces to receive multicast messages")
protected boolean receive_on_all_interfaces;
/**
* List of interfaces to receive multicasts on. The multicast receive socket will listen
* on all of these interfaces. This is a comma-separated list of IP addresses or interface names. E.g.
* "192.168.5.1,eth1,127.0.0.1". Duplicates are discarded; we only bind to
* an interface once. If this property is set, it overrides receive_on_all_interfaces.
*/
@Property(converter=PropertyConverters.NetworkInterfaceList.class,
description="Comma delimited list of interfaces (IP addresses or interface names) to receive multicasts on")
protected List receive_interfaces;
@Property(description="Max number of elements in the logical address cache before eviction starts")
protected int logical_addr_cache_max_size=2000;
@Property(description="Time (in ms) after which entries in the logical address cache marked as removable " +
"can be removed. 0 never removes any entries (not recommended)",type=AttributeType.TIME)
protected long logical_addr_cache_expiration=360000;
@Property(description="Interval (in ms) at which the reaper task scans logical_addr_cache and removes entries " +
"marked as removable. 0 disables reaping.",type=AttributeType.TIME)
protected long logical_addr_cache_reaper_interval=60000;
/** The port to which the transport binds. 0 means to bind to any (ephemeral) port. See also {@link #port_range} */
@Property(description="The port to which the transport binds. Default of 0 binds to any (ephemeral) port." +
" See also port_range",systemProperty={Global.BIND_PORT},writable=false)
protected int bind_port;
@Property(description="The range of valid ports: [bind_port .. bind_port+port_range ]. " +
"0 only binds to bind_port and fails if taken")
protected int port_range=10; // 27-6-2003 bgooren, Only try one port by default
@Property(description="Whether or not to make a copy of a message before looping it back up. Don't use this; might " +
"get removed without warning")
protected boolean loopback_copy;
@Property(description="Loop back the message on a separate thread or use the current thread. Don't use this; " +
"might get removed without warning")
protected boolean loopback_separate_thread=true;
@Property(description="The fully qualified name of a class implementing MessageProcessingPolicy")
protected String message_processing_policy;
@Property(description="The fully qualified name of a class implementing LocalTransport")
protected String local_transport_class;
@Property(description="If true, create virtual threads, otherwise create native threads")
protected boolean use_virtual_threads;
@Property(description="Thread naming pattern for threads in this channel. Valid values are \"pcl\": " +
"\"p\": includes the thread name, e.g. \"Incoming thread-1\", \"UDP ucast receiver\", " +
"\"c\": includes the cluster name, e.g. \"MyCluster\", " +
"\"l\": includes the local address of the current member, e.g. \"192.168.5.1:5678\"")
protected String thread_naming_pattern="cl";
@Property(description="Interval (in ms) at which the time service updates its timestamp. 0 disables the time service",
type=AttributeType.TIME)
protected long time_service_interval=500;
/** Whether warnings about messages from different groups are logged - private flag, not for common use */
@Property(description="whether or not warnings about messages from different groups are logged")
protected boolean log_discard_msgs=true;
@Property(description="whether or not warnings about messages from members with a different version are discarded")
protected boolean log_discard_msgs_version=true;
@Property(description="Timeout (in ms) to determine how long to wait until a request to fetch the physical address " +
"for a given logical address will be sent again. Subsequent requests for the same physical address will therefore " +
"be spaced at least who_has_cache_timeout ms apart",type=AttributeType.TIME)
protected long who_has_cache_timeout=2000;
@Property(description="Time during which identical warnings about messages from a member with a different version " +
"will be suppressed. 0 disables this (every warning will be logged). Setting the log level to ERROR also " +
"disables this.",type=AttributeType.TIME)
protected long suppress_time_different_version_warnings=60000;
@Property(description="Time during which identical warnings about messages from a member from a different cluster " +
"will be suppressed. 0 disables this (every warning will be logged). Setting the log level to ERROR also " +
"disables this.",type=AttributeType.TIME)
protected long suppress_time_different_cluster_warnings=60000;
@Property(description="The fully qualified name of a MessageFactory implementation",exposeAsManagedAttribute=false)
protected String msg_factory_class;
protected MessageFactory msg_factory=new DefaultMessageFactory();
@Property(description="The type of bundler used (\"ring-buffer\", \"transfer-queue\" (default), \"sender-sends\" or " +
"\"no-bundler\") or the fully qualified classname of a Bundler implementation")
protected String bundler_type="transfer-queue";
@ManagedAttribute(description="Fully qualified classname of bundler")
public String getBundlerClass() {
return bundler != null? bundler.getClass().getName() : "null";
}
public MessageFactory getMessageFactory() {return msg_factory;}
public T setMessageFactory(MessageFactory m) {msg_factory=m; return (T)this;}
public InetAddress getBindAddr() {return bind_addr;}
public T setBindAddr(InetAddress b) {this.bind_addr=b; return (T)this;}
public InetAddress getExternalAddr() {return external_addr;}
public T setExternalAddr(InetAddress e) {this.external_addr=e; return (T)this;}
public int getExternalPort() {return external_port;}
public T setExternalPort(int e) {this.external_port=e; return (T)this;}
public boolean isTrace() {return is_trace;}
public T isTrace(boolean i) {this.is_trace=i; return (T)this;}
public boolean receiveOnAllInterfaces() {return receive_on_all_interfaces;}
public T receiveOnAllInterfaces(boolean r) {this.receive_on_all_interfaces=r; return (T)this;}
public int getLogicalAddrCacheMaxSize() {return logical_addr_cache_max_size;}
public T setLogicalAddrCacheMaxSize(int l) {this.logical_addr_cache_max_size=l; return (T)this;}
public long getLogicalAddrCacheExpiration() {return logical_addr_cache_expiration;}
public T setLogicalAddrCacheExpiration(long l) {this.logical_addr_cache_expiration=l; return (T)this;}
public long getLogicalAddrCacheReaperInterval() {return logical_addr_cache_reaper_interval;}
public T setLogicalAddrCacheReaperInterval(long l) {this.logical_addr_cache_reaper_interval=l; return (T)this;}
public boolean loopbackCopy() {return loopback_copy;}
public T loopbackCopy(boolean l) {this.loopback_copy=l; return (T)this;}
public boolean loopbackSeparateThread() {return loopback_separate_thread;}
public T loopbackSeparateThread(boolean l) {this.loopback_separate_thread=l; return (T)this;}
public boolean useVirtualThreads() {return use_virtual_threads;}
public T useVirtualThreads(boolean b) {use_virtual_threads=b; return (T)this;}
public long getTimeServiceInterval() {return time_service_interval;}
public T setTimeServiceInterval(long t) {this.time_service_interval=t; return (T)this;}
public boolean logDiscardMsgs() {return log_discard_msgs;}
public T logDiscardMsgs(boolean l) {this.log_discard_msgs=l; return (T)this;}
public boolean logDiscardMsgsVersion() {return log_discard_msgs_version;}
public T logDiscardMsgsVersion(boolean l) {this.log_discard_msgs_version=l; return (T)this;}
public long getWhoHasCacheTimeout() {return who_has_cache_timeout;}
public T setWhoHasCacheTimeout(long w) {this.who_has_cache_timeout=w; return (T)this;}
public long getSuppressTimeDifferentVersionWarnings() {return suppress_time_different_version_warnings;}
public T setSuppressTimeDifferentVersionWarnings(long s) {this.suppress_time_different_version_warnings=s; return (T)this;}
public long getSuppressTimeDifferentClusterWarnings() {return suppress_time_different_cluster_warnings;}
public T setSuppressTimeDifferentClusterWarnings(long s) {this.suppress_time_different_cluster_warnings=s; return (T)this;}
public String getMsgFactoryClass() {return msg_factory_class;}
public T setMsgFactoryClass(String m) {this.msg_factory_class=m; return (T)this;}
public String getBundlerType() {return bundler_type;}
public T setBundlerType(String b) {this.bundler_type=b; return (T)this;}
@ManagedAttribute
public String getMessageFactoryClass() {
return msg_factory != null? msg_factory.getClass().getName() : "n/a";
}
@ManagedAttribute(description="Is the logical_addr_cache reaper task running")
public boolean isLogicalAddressCacheReaperRunning() {
return logical_addr_cache_reaper != null && !logical_addr_cache_reaper.isDone();
}
@Property(name="level", description="Sets the level")
public T setLevel(String level) {
T retval=super.setLevel(level);
is_trace=log.isTraceEnabled();
return retval;
}
@ManagedOperation(description="Changes the message processing policy. The fully qualified name of a class " +
"implementing MessageProcessingPolicy needs to be given")
public void setMessageProcessingPolicy(String policy) {
if(policy == null)
return;
if(policy.startsWith("submit"))
msg_processing_policy=new SubmitToThreadPool();
else if(policy.startsWith("max"))
msg_processing_policy=new MaxOneThreadPerSender();
else if(policy.startsWith("direct"))
msg_processing_policy=new PassRegularMessagesUpDirectly();
else if(policy.startsWith("unbatch"))
msg_processing_policy=new UnbatchOOBBatches();
try {
if(msg_processing_policy == null) {
Class clazz=(Class)Util.loadClass(policy, getClass());
msg_processing_policy=clazz.getDeclaredConstructor().newInstance();
message_processing_policy=policy;
}
msg_processing_policy.init(this);
}
catch(Exception e) {
log.error("failed setting message_processing_policy", e);
}
}
public MessageProcessingPolicy getMessageProcessingPolicy() {return msg_processing_policy;}
/* --------------------------------------------- JMX ---------------------------------------------- */
@Component(name="msg_stats")
protected final MsgStats msg_stats=new MsgStats().enable(stats);
/** The name of the group to which this member is connected. With a shared transport, the channel name is
* in TP.ProtocolAdapter (cluster_name), and this field is not used */
@ManagedAttribute(description="Channel (cluster) name")
protected AsciiString cluster_name;
@ManagedAttribute(description="If enabled, the timer will run non-blocking tasks on its own (runner) thread, and " +
"not submit them to the thread pool. Otherwise, all tasks are submitted to the thread pool. This attribute is " +
"experimental and may be removed without notice.")
protected boolean timer_handle_non_blocking_tasks=true;
@ManagedAttribute(description="Class of the timer implementation")
public String getTimerClass() {
return timer != null? timer.getClass().getSimpleName() : "null";
}
@ManagedAttribute(description="Name of the cluster to which this transport is connected")
public String getClusterName() {
return cluster_name != null? cluster_name.toString() : null;
}
public AsciiString getClusterNameAscii() {return cluster_name;}
@ManagedAttribute(description="Number of messages from members in a different cluster",type=SCALAR)
public int getDifferentClusterMessages() {
return suppress_log_different_cluster != null? suppress_log_different_cluster.getCache().size() : 0;
}
@ManagedAttribute(description="Number of messages from members with a different JGroups version",type=SCALAR)
public int getDifferentVersionMessages() {
return suppress_log_different_version != null? suppress_log_different_version.getCache().size() : 0;
}
@ManagedOperation(description="Clears the cache for messages from different clusters")
public T clearDifferentClusterCache() {
if(suppress_log_different_cluster != null)
suppress_log_different_cluster.getCache().clear();
return (T)this;
}
@ManagedOperation(description="Clears the cache for messages from members with different versions")
public T clearDifferentVersionCache() {
if(suppress_log_different_version != null)
suppress_log_different_version.getCache().clear();
return (T)this;
}
@ManagedAttribute(description="Type of logger used")
public static String loggerType() {return LogFactory.loggerType();}
/* --------------------------------------------- Fields ------------------------------------------------------ */
@ManagedOperation(description="If enabled, the timer will run non-blocking tasks on its own (runner) thread, and " +
"not submit them to the thread pool. Otherwise, all tasks are submitted to the thread pool. This attribute is " +
"experimental and may be removed without notice.")
public T enableBlockingTimerTasks(boolean flag) {
if(flag != this.timer_handle_non_blocking_tasks) {
this.timer_handle_non_blocking_tasks=flag;
timer.setNonBlockingTaskHandling(flag);
}
return (T)this;
}
/** The address (host and port) of this member */
protected PhysicalAddress local_physical_addr;
protected volatile View view;
/** The members of this group (updated when a member joins or leaves). With a shared transport,
* members contains _all_ members from all channels sitting on the shared transport */
protected final Set members=new CopyOnWriteArraySet<>();
//https://issues.redhat.com/browse/JGRP-849
protected final ReentrantLock connectLock = new ReentrantLock();
// ================================== Thread pool ======================
/** The thread pool which handles unmarshalling, version checks and dispatching of messages */
@Component(name="thread_pool")
protected ThreadPool thread_pool=new ThreadPool().log(this.log);
@Component(name="async_executor")
protected AsyncExecutor