├── .github ├── dependabot.yml └── workflows │ └── ci.yml ├── .gitignore ├── Dockerfile ├── Jenkinsfile ├── LICENSE ├── README.adoc ├── bin ├── bm-uperf.sh ├── bm.sh ├── bundler-stress_test.sh ├── chat.sh ├── codenames.sh ├── compile.sh ├── context-switches.sh ├── count-tests.sh ├── draw ├── draw.bat ├── dump_jdbc.sh ├── echo.sh ├── gaps.sh ├── gen-keys.sh ├── gen-profiling.sh ├── gen.sh ├── generate-certificate-chain.sh ├── gossiprouter.sh ├── jg ├── jgroups-asprof.sh ├── jgroups-perf.sh ├── jgroups.bat ├── jgroups.sh ├── jt ├── mperf.sh ├── probe.bat ├── probe.sh ├── profile.sh ├── release-perform.sh ├── release-prepare.sh └── uperf.sh ├── build.properties.template ├── build.properties.template.ipv6 ├── build.xml ├── conf ├── JGROUPS_VERSION.properties ├── asym-encrypt.xml ├── asym-ssl.xml ├── auth_X509.xml ├── auth_fixedlist.xml ├── auth_krb5.xml ├── auth_regex.xml ├── comment-test.xml ├── echo.yaml ├── encrypt.xml ├── fast.xml ├── fork-stacks.xml ├── fork-stacks.xsd ├── fork.xml ├── jdbc-hsql.xml ├── jdbc-mysql.xml ├── jdbc-pg.xml ├── jg-magic-map.xml ├── jg-messages.properties ├── jg-messages_de.properties ├── jg-protocol-ids.xml ├── jgrp.yaml ├── kerberos │ ├── kerbtest.ldif │ ├── krb5.conf │ └── login.conf ├── keystore.jks ├── log4j2.xml ├── reflection.json ├── relay.xsd ├── relay │ ├── bridge-net1-hf.xml │ ├── bridge-net1-net2.xml │ ├── bridge-net2-net3.xml │ ├── hf.xml │ ├── net1.xml │ ├── net2.xml │ └── net3.xml ├── relay1.xml ├── relay2.xml ├── rogue.jks ├── scripts │ ├── ASYM_ENCRYPT_BlockTest │ │ └── testASYM_ENCRYPT_NotBlockingJoin.btm │ ├── BecomeServerTest │ │ └── testSendingOfMsgsOnUnconnectedChannel.btm │ ├── MessageBeforeConnectedTest │ │ └── testSendingOfMsgsOnUnconnectedChannel.btm │ ├── ProtPerf │ │ └── prot-perf.btm │ ├── RingBufferSeqnoTest │ │ ├── testRemoveAndConcurrentAdd.btm │ │ └── testRemoveAndConcurrentAdd2.btm │ ├── RttTest │ │ └── rtt.btm │ ├── SequencerFailoverTest │ │ └── testResendingVersusNewMessages.btm │ ├── ServerTest │ │ └── testConcurrentConnect.btm │ ├── bundler.btm │ ├── profile.btm │ └── profiled-methods.txt ├── sequencer.xml ├── settings.xml ├── sos.cfg ├── sym-encrypt.xml ├── tcp-low-latency.xml ├── tcp-new.xml ├── tcp-nio-new.xml ├── tcp-nio.xml ├── tcp.xml ├── tunnel.xml ├── udp-new.xml └── udp.xml ├── doc ├── README ├── design │ ├── ABP.txt │ ├── ASYM_ENCRYPT.txt │ ├── AUTH.md │ ├── AddressTranslation.txt │ ├── Bundling.txt │ ├── CENTRAL_LOCK2.txt │ ├── CLOUD_TCP.txt │ ├── CloudBasedDiscovery.txt │ ├── ConcurrentConnectionEstablishment.txt │ ├── ConcurrentStack.txt │ ├── CounterService.txt │ ├── DataCenterReplication.fig │ ├── DataCenterReplication.png │ ├── DataCenterReplication.txt │ ├── FD_SOCK2.txt │ ├── FILE_PING.txt │ ├── FORK.txt │ ├── FixedBuffer.txt │ ├── FlowControl.txt │ ├── GossipRouterChanges-1.8.txt │ ├── JDBC_PING.txt │ ├── JoinAndStateTransfer.txt │ ├── LargeClusters.txt │ ├── LargeMessages.txt │ ├── LatencyVersusThroughput.txt │ ├── LogicalAddresses.txt │ ├── MERGE.new.txt │ ├── MERGE4.txt │ ├── MERGE_View_Separation.txt │ ├── MaliciousAttacks.txt │ ├── MarshalingFormat.txt │ ├── NAKACK.txt │ ├── NAKACK2_NoRetransmission.txt │ ├── NAKACK4.txt │ ├── NIO2.txt │ ├── NullDestAddresses.txt │ ├── NullingSrcAddresses.txt │ ├── PartialStateTransfer.txt │ ├── PortingToGraalVM.txt │ ├── ProbabilisticBroadcast.txt │ ├── RACKSPACE_PING.txt │ ├── RELAY.png │ ├── RELAY2.txt │ ├── Reincarnation.txt │ ├── ReliableViewInstallation.txt │ ├── ReplCache.txt │ ├── RingBufferSeqnoOld.txt │ ├── SEQUENCER.txt │ ├── STABLE.txt │ ├── StreamingStateTransfer.txt │ ├── TCPConnectionMap.txt │ ├── TestNG.txt │ ├── TransportNextGen │ ├── UNICAST.txt │ ├── UNICAST2.txt │ ├── UNICAST3-SYNC.txt │ ├── UNICAST3.txt │ ├── UNIFORM.txt │ ├── VERIFY_SUSPECT2.txt │ ├── ViewHandling.txt │ ├── varia1.txt │ └── varia2.txt ├── history.txt ├── manual │ ├── advanced.adoc │ ├── api.adoc │ ├── blocks.adoc │ ├── images │ │ ├── Architecture.fig │ │ ├── Architecture.png │ │ ├── ChannelStates.fig │ │ ├── ChannelStates.png │ │ ├── DrawScreenshot.png │ │ ├── ForkArchitecture.fig │ │ ├── ForkArchitecture.png │ │ ├── Message.fig │ │ ├── Message.png │ │ ├── RELAY.fig │ │ ├── RELAY.png │ │ ├── StompArchitecture.fig │ │ ├── StompArchitecture.png │ │ ├── StompProtocol.fig │ │ ├── StompProtocol.png │ │ ├── TransportDetails.fig │ │ ├── TransportDetails.png │ │ ├── Tunneling.fig │ │ ├── Tunneling.png │ │ ├── icons │ │ │ ├── README │ │ │ ├── callouts │ │ │ │ ├── 1.png │ │ │ │ ├── 10.png │ │ │ │ ├── 11.png │ │ │ │ ├── 12.png │ │ │ │ ├── 13.png │ │ │ │ ├── 14.png │ │ │ │ ├── 15.png │ │ │ │ ├── 2.png │ │ │ │ ├── 3.png │ │ │ │ ├── 4.png │ │ │ │ ├── 5.png │ │ │ │ ├── 6.png │ │ │ │ ├── 7.png │ │ │ │ ├── 8.png │ │ │ │ └── 9.png │ │ │ ├── caution.png │ │ │ ├── example.png │ │ │ ├── home.png │ │ │ ├── important.png │ │ │ ├── next.png │ │ │ ├── note.png │ │ │ ├── prev.png │ │ │ ├── tip.png │ │ │ ├── up.png │ │ │ └── warning.png │ │ ├── network.png │ │ └── wireshark.png │ ├── installation-template.adoc │ ├── manual.adoc │ ├── overview.adoc │ └── protocols-template.adoc ├── stylesheets │ ├── asciidoctor.css │ ├── colony.css │ ├── github.css │ └── golo.css ├── todo.lst └── tutorial │ ├── code │ └── SimpleChat.java │ ├── images │ └── DrawScreenshot.png │ ├── installation.adoc │ ├── sampleapp.adoc │ └── tutorial.adoc ├── ivy.xml ├── ivysettings.xml ├── pom.xml ├── project.properties ├── src └── org │ └── jgroups │ ├── Address.java │ ├── BaseMessage.java │ ├── BatchMessage.java │ ├── BytesMessage.java │ ├── ChannelListener.java │ ├── CompositeMessage.java │ ├── Constructable.java │ ├── EmptyMessage.java │ ├── Event.java │ ├── FragmentedMessage.java │ ├── Global.java │ ├── Header.java │ ├── JChannel.java │ ├── JChannelProbeHandler.java │ ├── Lifecycle.java │ ├── LongMessage.java │ ├── Membership.java │ ├── MergeView.java │ ├── Message.java │ ├── MessageFactory.java │ ├── NioMessage.java │ ├── NullAddress.java │ ├── ObjectMessage.java │ ├── PhysicalAddress.java │ ├── Receiver.java │ ├── StateTransferException.java │ ├── SuspectedException.java │ ├── UnreachableException.java │ ├── UpHandler.java │ ├── Version.java │ ├── View.java │ ├── ViewId.java │ ├── annotations │ ├── Component.java │ ├── Experimental.java │ ├── GuardedBy.java │ ├── Immutable.java │ ├── LocalAddress.java │ ├── MBean.java │ ├── ManagedAttribute.java │ ├── ManagedOperation.java │ ├── Property.java │ ├── RecommendedForUpgrade.java │ ├── Unsupported.java │ ├── XmlAttribute.java │ ├── XmlElement.java │ └── XmlInclude.java │ ├── auth │ ├── AuthToken.java │ ├── FixedMembershipToken.java │ ├── Krb5Token.java │ ├── Krb5TokenUtils.java │ ├── RegexMembership.java │ └── X509Token.java │ ├── blocks │ ├── Cache.java │ ├── GridFile.java │ ├── GridFilesystem.java │ ├── GridInputStream.java │ ├── GridOutputStream.java │ ├── GroupRequest.java │ ├── MessageDispatcher.java │ ├── MethodCall.java │ ├── MethodInvoker.java │ ├── MethodLookup.java │ ├── ReplCache.java │ ├── ReplicatedHashMap.java │ ├── ReplicatedMap.java │ ├── ReplicatedTree.java │ ├── Request.java │ ├── RequestCorrelator.java │ ├── RequestHandler.java │ ├── RequestOptions.java │ ├── Response.java │ ├── ResponseMode.java │ ├── RpcDispatcher.java │ ├── RspFilter.java │ ├── UnicastRequest.java │ ├── atomic │ │ ├── AsyncCounter.java │ │ ├── BaseCounter.java │ │ ├── Counter.java │ │ ├── CounterFunction.java │ │ ├── CounterService.java │ │ ├── CounterView.java │ │ └── SyncCounter.java │ ├── cs │ │ ├── BaseServer.java │ │ ├── Client.java │ │ ├── Connection.java │ │ ├── ConnectionListener.java │ │ ├── NioBaseServer.java │ │ ├── NioClient.java │ │ ├── NioConnection.java │ │ ├── NioServer.java │ │ ├── Receiver.java │ │ ├── ReceiverAdapter.java │ │ ├── TcpBaseServer.java │ │ ├── TcpClient.java │ │ ├── TcpConnection.java │ │ ├── TcpConnectionNonBlocking.java │ │ └── TcpServer.java │ └── package.html │ ├── client │ └── StompConnection.java │ ├── conf │ ├── AttributeType.java │ ├── ClassConfigurator.java │ ├── ConfiguratorFactory.java │ ├── PropertyConverter.java │ ├── PropertyConverters.java │ ├── PropertyHelper.java │ ├── ProtocolConfiguration.java │ ├── ProtocolStackConfigurator.java │ ├── XmlConfigurator.java │ ├── XmlNode.java │ └── package.html │ ├── demos │ ├── Chat.java │ ├── CounterServiceDemo.java │ ├── Draw.java │ ├── DrawCommand.java │ ├── EchoServer.java │ ├── JmxDemo.java │ ├── KeyStoreGenerator.java │ ├── ProgrammaticChat.java │ ├── PubClient.java │ ├── PubServer.java │ ├── RelayDemo.java │ ├── RelayDemoRpc.java │ ├── ReplCacheDemo.java │ ├── ReplicatedHashMapDemo.java │ ├── StompChat.java │ ├── StompDraw.java │ ├── Topology.java │ ├── TotalOrder.java │ └── package.html │ ├── fork │ ├── ForkChannel.java │ ├── ForkConfig.java │ ├── ForkProtocol.java │ ├── ForkProtocolStack.java │ └── UnknownForkHandler.java │ ├── jmx │ ├── JmxConfigurator.java │ ├── ReflectUtils.java │ └── ResourceDMBean.java │ ├── logging │ ├── CustomLogFactory.java │ ├── JDKLogImpl.java │ ├── Log.java │ ├── Log4J2LogImpl.java │ ├── LogFactory.java │ └── Slf4jLogImpl.java │ ├── nio │ ├── Buffers.java │ └── MockSocketChannel.java │ ├── overview.html │ ├── package.html │ ├── protocols │ ├── ASYM_ENCRYPT.java │ ├── ASYNC.java │ ├── AUTH.java │ ├── AlternatingBundler.java │ ├── AuthHeader.java │ ├── BARRIER.java │ ├── BATCH.java │ ├── BATCH2.java │ ├── BPING.java │ ├── BaseBundler.java │ ├── BasicTCP.java │ ├── BatchBundler.java │ ├── Bundler.java │ ├── CLEAR_FLAGS.java │ ├── COMPRESS.java │ ├── COUNTER.java │ ├── CertficateCNMatcher.java │ ├── DAISYCHAIN.java │ ├── DELAY.java │ ├── DETECT_LOOPBACKS.java │ ├── DH_KEY_EXCHANGE.java │ ├── DISCARD.java │ ├── DISCARD_PAYLOAD.java │ ├── DROP.java │ ├── DUPL.java │ ├── Discovery.java │ ├── EXAMPLE.java │ ├── Encrypt.java │ ├── EncryptHeader.java │ ├── FD_ALL.java │ ├── FD_ALL2.java │ ├── FD_ALL3.java │ ├── FD_HOST.java │ ├── FD_SOCK.java │ ├── FD_SOCK2.java │ ├── FILE_PING.java │ ├── FORK.java │ ├── FRAG.java │ ├── FRAG2.java │ ├── FRAG3.java │ ├── FRAG4.java │ ├── FailureDetection.java │ ├── FcHeader.java │ ├── FlowControl.java │ ├── Frag3Header.java │ ├── FragHeader.java │ ├── Fragmentation.java │ ├── HDRS.java │ ├── INJECT_VIEW.java │ ├── JDBC_PING.java │ ├── JDBC_PING2.java │ ├── KeyExchange.java │ ├── LOCAL_PING.java │ ├── LocalTransport.java │ ├── MAKE_BATCH.java │ ├── MERGE3.java │ ├── MFC.java │ ├── MFC_NB.java │ ├── MPING.java │ ├── MsgStats.java │ ├── NAKACK3.java │ ├── NAKACK4.java │ ├── NON_BLOCKING_SENDS.java │ ├── NakAckHeader.java │ ├── NoBundler.java │ ├── PDC.java │ ├── PERF.java │ ├── PING.java │ ├── PerDestinationBundler.java │ ├── PerfHeader.java │ ├── PingData.java │ ├── PingHeader.java │ ├── ProtPerfHeader.java │ ├── RACKSPACE_PING.java │ ├── RATE.java │ ├── RATE_LIMITER.java │ ├── RATE_LIMITER2.java │ ├── RED.java │ ├── REVERSE.java │ ├── REVERSE2.java │ ├── RSVP.java │ ├── RTTHeader.java │ ├── ReliableMulticast.java │ ├── ReliableUnicast.java │ ├── RemoveQueueBundler.java │ ├── RingBufferBundler.java │ ├── RingBufferBundlerLockless.java │ ├── RingBufferBundlerLockless2.java │ ├── SEQUENCER.java │ ├── SEQUENCER2.java │ ├── SERIALIZE.java │ ├── SHARED_LOOPBACK.java │ ├── SHARED_LOOPBACK_PING.java │ ├── SHUFFLE.java │ ├── SIZE.java │ ├── SNIFF.java │ ├── SOS.java │ ├── SSL_KEY_EXCHANGE.java │ ├── STATS.java │ ├── STOMP.java │ ├── SWIFT_PING.java │ ├── SYM_ENCRYPT.java │ ├── SenderSendsBundler.java │ ├── SimpleTCP.java │ ├── TCP.java │ ├── TCPGOSSIP.java │ ├── TCPPING.java │ ├── TCP_NIO2.java │ ├── THREAD_COUNT.java │ ├── TIME.java │ ├── TP.java │ ├── TRACE.java │ ├── TUNNEL.java │ ├── TpHeader.java │ ├── TransferQueueBundler.java │ ├── UDP.java │ ├── UFC.java │ ├── UFC_NB.java │ ├── UNBATCH.java │ ├── UNICAST3.java │ ├── UNICAST4.java │ ├── UnicastHeader.java │ ├── UnicastHeader3.java │ ├── VERIFY_SUSPECT.java │ ├── VERIFY_SUSPECT2.java │ ├── dns │ │ ├── AddressedDNSResolver.java │ │ ├── DNSResolver.java │ │ ├── DNS_PING.java │ │ └── DefaultDNSResolver.java │ ├── package.html │ ├── pbcast │ │ ├── ClientGmsImpl.java │ │ ├── CoordGmsImpl.java │ │ ├── DeltaView.java │ │ ├── GMS.java │ │ ├── GmsImpl.java │ │ ├── JoinRsp.java │ │ ├── Leaver.java │ │ ├── MergeData.java │ │ ├── Merger.java │ │ ├── NAKACK2.java │ │ ├── NakAckHeader2.java │ │ ├── ParticipantGmsImpl.java │ │ ├── STABLE.java │ │ ├── STATE.java │ │ ├── STATE_SOCK.java │ │ ├── STATE_TRANSFER.java │ │ ├── ServerGmsImpl.java │ │ ├── StreamingStateTransfer.java │ │ └── ViewHandler.java │ └── relay │ │ ├── Bridge.java │ │ ├── DefaultRouteStatusListener.java │ │ ├── ForwardingRoute.java │ │ ├── RELAY.java │ │ ├── RELAY2.java │ │ ├── RELAY3.java │ │ ├── RandomSiteMasterPicker.java │ │ ├── RelayHeader.java │ │ ├── Relayer.java │ │ ├── Relayer2.java │ │ ├── Relayer3.java │ │ ├── Route.java │ │ ├── RouteStatusListener.java │ │ ├── SiteAddress.java │ │ ├── SiteMaster.java │ │ ├── SiteMasterPicker.java │ │ ├── SiteStatus.java │ │ ├── SiteUUID.java │ │ ├── StickySiteMasterPicker.java │ │ ├── Topology.java │ │ └── config │ │ └── RelayConfig.java │ ├── stack │ ├── AddressGenerator.java │ ├── Configurator.java │ ├── DiagnosticsHandler.java │ ├── GossipData.java │ ├── GossipRouter.java │ ├── GossipType.java │ ├── IpAddress.java │ ├── LargestWinningPolicy.java │ ├── MembershipChangePolicy.java │ ├── MessageProcessingPolicy.java │ ├── NonReflectiveProbeHandler.java │ ├── Policy.java │ ├── Protocol.java │ ├── ProtocolHook.java │ ├── ProtocolStack.java │ ├── RouterStub.java │ ├── RouterStubManager.java │ ├── StateTransferInfo.java │ └── package.html │ └── util │ ├── AckCollector.java │ ├── AckTable.java │ ├── AgeOutCache.java │ ├── ArrayIterator.java │ ├── AsciiString.java │ ├── AsyncExecutor.java │ ├── Average.java │ ├── AverageMinMax.java │ ├── Base64.java │ ├── BaseDataOutputStream.java │ ├── Bits.java │ ├── BlockingInputStream.java │ ├── BoundedHashMap.java │ ├── BoundedList.java │ ├── Buffer.java │ ├── ByteArray.java │ ├── ByteArrayDataInputStream.java │ ├── ByteArrayDataOutputStream.java │ ├── ByteBufferInputStream.java │ ├── ByteBufferOutputStream.java │ ├── CompareMetrics.java │ ├── CompletableFutures.java │ ├── ConcurrentLinkedBlockingQueue.java │ ├── ConcurrentLinkedBlockingQueue2.java │ ├── CondVar.java │ ├── Credit.java │ ├── CreditMap.java │ ├── CustomRejectionPolicy.java │ ├── DefaultSocketFactory.java │ ├── DefaultThreadFactory.java │ ├── Delayer.java │ ├── Digest.java │ ├── DirectExecutor.java │ ├── DynamicBuffer.java │ ├── ExpiryCache.java │ ├── ExtendedUUID.java │ ├── FastArray.java │ ├── FileWatcher.java │ ├── FixedBuffer.java │ ├── FixedSizeBitSet.java │ ├── FlagsUUID.java │ ├── GenerateGettersAndSetters.java │ ├── GenerateProfilingScript.java │ ├── GetNetworkInterfaces.java │ ├── Headers.java │ ├── InputStreamAdapter.java │ ├── IntHashMap.java │ ├── LazyRemovalCache.java │ ├── LazyRemovalList.java │ ├── LazyThreadFactory.java │ ├── LongSizeStreamable.java │ ├── LongTuple.java │ ├── MaxOneThreadPerSender.java │ ├── MergeId.java │ ├── MessageBatch.java │ ├── MessageCache.java │ ├── Metrics.java │ ├── MockTransport.java │ ├── MutableDigest.java │ ├── MyReceiver.java │ ├── NameCache.java │ ├── NoProgressException.java │ ├── NonBlockingCredit.java │ ├── NonBlockingCreditMap.java │ ├── ObjectInputStreamWithClassloader.java │ ├── ObjectWrapperPrimitive.java │ ├── ObjectWrapperSerializable.java │ ├── OneTimeAddressGenerator.java │ ├── OutputStreamAdapter.java │ ├── Owner.java │ ├── PaddedAtomicBoolean.java │ ├── PaddedAtomicInteger.java │ ├── PaddedAtomicLong.java │ ├── PartialOutputStream.java │ ├── PassRegularMessagesUpDirectly.java │ ├── ProcessingQueue.java │ ├── Profiler.java │ ├── ProfilingHelper.java │ ├── ProgressCheckRejectionPolicy.java │ ├── Promise.java │ ├── PropertiesToAsciidoc.java │ ├── RTT.java │ ├── Range.java │ ├── Ref.java │ ├── ReloadingX509KeyManager.java │ ├── ReloadingX509TrustManager.java │ ├── RequestTable.java │ ├── ResourceManager.java │ ├── ResponseCollector.java │ ├── ResponseCollectorTask.java │ ├── Responses.java │ ├── RingBuffer.java │ ├── RingBufferSeqnoLockless.java │ ├── RingBufferSeqnoOld.java │ ├── RpcStats.java │ ├── Rsp.java │ ├── RspList.java │ ├── Runner.java │ ├── SecurityActions.java │ ├── SeqnoList.java │ ├── ShutdownRejectedExecutionHandler.java │ ├── SizeBoundedQueue.java │ ├── SizeStreamable.java │ ├── SocketFactory.java │ ├── SslContextFactory.java │ ├── StackType.java │ ├── StateTransferResult.java │ ├── Streamable.java │ ├── SubmitToThreadPool.java │ ├── SuppressCache.java │ ├── SuppressLog.java │ ├── TLS.java │ ├── TLSClientAuth.java │ ├── Table.java │ ├── Tests.java │ ├── ThreadCreator.java │ ├── ThreadFactory.java │ ├── ThreadPool.java │ ├── TimeScheduler.java │ ├── TimeScheduler3.java │ ├── TimeService.java │ ├── Triple.java │ ├── Tuple.java │ ├── UUID.java │ ├── UnbatchOOBBatches.java │ ├── Util.java │ ├── WriteVersionTo.java │ ├── XMLSchemaGenerator.java │ └── package.html └── tests ├── byteman └── org │ └── jgroups │ └── tests │ ├── byteman │ ├── ASYM_ENCRYPT_BlockTest.java │ ├── BecomeServerTest.java │ ├── MessageBeforeConnectedTest.java │ ├── RingBufferSeqnoTest.java │ ├── SequencerFailoverTest.java │ └── ServerTest.java │ └── helpers │ ├── BecomeServerTestHelper.java │ ├── MessageBeforeConnectedTestHelper.java │ ├── RttTestHelper.java │ ├── SendUnicast.java │ ├── SequencerFailoverTestHelper.java │ └── ServerTestHelper.java ├── junit-functional └── org │ └── jgroups │ ├── blocks │ ├── CacheTest.java │ ├── CounterTest.java │ ├── GroupRequestTest.java │ ├── RpcDispatcherTest.java │ └── UnicastRequestTest.java │ ├── protocols │ ├── ASYM_ENCRYPT_LeaveTest.java │ ├── ASYM_ENCRYPT_LeaveTestCbc.java │ ├── ASYM_ENCRYPT_LeaveTestKeyExchange.java │ ├── ASYM_ENCRYPT_LeaveTestKeyExchangeCbc.java │ ├── ASYM_ENCRYPT_Test.java │ ├── ASYM_ENCRYPT_TestCbc.java │ ├── ASYM_ENCRYPT_TestKeyExchange.java │ ├── ASYM_ENCRYPT_TestKeyExchangeCbc.java │ ├── AUTHTest.java │ ├── COMPRESS_Test.java │ ├── ENCRYPTKeystoreTest.java │ ├── ENCRYPTKeystoreTestCbc.java │ ├── EncryptTest.java │ ├── FD_SOCK2_Test.java │ ├── FILE_PING_Test.java │ ├── FlowControlUnitTest.java │ ├── GMS_MergeTest.java │ ├── INJECT_VIEWTest.java │ ├── MFC_Test.java │ ├── NAKACK_Delivery_Test.java │ ├── NAKACK_RetransmissionTest.java │ ├── NAKACK_RetransmitTest.java │ ├── NAKACK_SET_DIGEST_Test.java │ ├── NAKACK_StressTest.java │ ├── RATE_LIMITER_Test.java │ ├── RED_Test.java │ ├── STABLE_Test.java │ ├── SYM_ENCRYPT_Test.java │ ├── SYM_ENCRYPT_TestCbc.java │ ├── TCPPING_Test.java │ ├── TLSTest.java │ ├── UFC_Test.java │ ├── UNBATCH_Test.java │ ├── UNICAST_ConnectionTests.java │ ├── UNICAST_ContentionTest.java │ ├── UNICAST_DropFirstAndLastTest.java │ ├── UNICAST_DroppedAckTest.java │ ├── UNICAST_MessagesToSelfTest.java │ ├── UNICAST_OOB_Test.java │ ├── UNICAST_RetransmitTest.java │ ├── UNICAST_Test.java │ ├── VERIFY_SUSPECT_Test.java │ └── dns │ │ ├── AddressedDNSResolverTest.java │ │ ├── DNSDiscoveryTester.java │ │ ├── DNS_PINGTest.java │ │ ├── MockDNSResolverBuilder.java │ │ └── MockDirContext.java │ ├── tests │ ├── AckCollectorTest.java │ ├── AckTableTest.java │ ├── AgeOutCacheTest.java │ ├── AsciiStringTest.java │ ├── AverageTest.java │ ├── BARRIERTest.java │ ├── BaseLeaveTest.java │ ├── BatchMessageTest.java │ ├── BitmapTest.java │ ├── BitsTest.java │ ├── BlockingInputStreamTest.java │ ├── BoundedListTest.java │ ├── BufferTest.java │ ├── BuffersTest.java │ ├── BundlerTest.java │ ├── ByteArrayDataInputOutputStreamTest.java │ ├── ByteArrayTest.java │ ├── ByteBufferOutputStreamTest.java │ ├── ClassConfiguratorTest.java │ ├── CompositeMessageTest.java │ ├── CondVarTest.java │ ├── ConfigTest.java │ ├── ConfiguratorTest.java │ ├── ConnectStressTest.java │ ├── CreditMapTest.java │ ├── CreditTest.java │ ├── CustomProtocolTest.java │ ├── DelayerTest.java │ ├── DeltaViewTest.java │ ├── DigestTest.java │ ├── DiscoveryTest.java │ ├── DrainTest.java │ ├── DynamicDiscardTest.java │ ├── ExpiryCacheTest.java │ ├── ExtendedUUIDTest.java │ ├── FCTest.java │ ├── FalseSuspicionTest.java │ ├── FastArrayTest.java │ ├── FixedSizeBitSetTest.java │ ├── ForkChannelTest.java │ ├── FragTest.java │ ├── FragmentedMessageTest.java │ ├── FrozenCoordinatorTest.java │ ├── HeadersResizeTest.java │ ├── HeadersTest.java │ ├── InetAddressChecksTest.java │ ├── IntHashMapTest.java │ ├── InterruptTest.java │ ├── IpAddressTest.java │ ├── JDBC_PING2_Test.java │ ├── JmxTest.java │ ├── LargeMergeTest.java │ ├── LazyThreadFactoryTest.java │ ├── LeaveTest.java │ ├── LongMessageTest.java │ ├── MembershipTest.java │ ├── MergeTest2.java │ ├── MergeTest3.java │ ├── MergeTest4.java │ ├── MergeTest5.java │ ├── MergeTest6.java │ ├── MergerTest.java │ ├── MessageBatchDrainTest.java │ ├── MessageBatchDrainTest2.java │ ├── MessageBatchTest.java │ ├── MessageCacheTest.java │ ├── MessageDispatcherRSVPTest.java │ ├── MessageFactoryTest.java │ ├── MessageSizeTest.java │ ├── MessageTest.java │ ├── MessageTestBase.java │ ├── MethodCallTest.java │ ├── MsgStatsTest.java │ ├── NakackTest.java │ ├── NakackUnitTest.java │ ├── NioMessageTest.java │ ├── NioServerTest.java │ ├── NioServerTest2.java │ ├── NonBlockingCreditMapTest.java │ ├── NonBlockingCreditTest.java │ ├── ObjectMessageTest.java │ ├── ObjectWrapperTest.java │ ├── OrderingTest.java │ ├── OwnerTest.java │ ├── PartialOutputStreamTest.java │ ├── PolymorphismTest.java │ ├── ProgrammaticApiTest.java │ ├── PromiseTest.java │ ├── PropertyConvertersTest.java │ ├── ProtocolConfigurationTest.java │ ├── RSVPTest.java │ ├── ReceiverAdapterTest.java │ ├── ReentrantLockTest.java │ ├── RelayRpcDispatcherTest.java │ ├── RelayTest.java │ ├── RelayTestAsym.java │ ├── RelayTests.java │ ├── ReliableMulticastBlockTest.java │ ├── ReliableUnicastBlockTest.java │ ├── ReliableUnicastTest.java │ ├── RequestTableTest.java │ ├── ResponseCollectorTaskTest.java │ ├── ResponseCollectorTest.java │ ├── ResponsesTest.java │ ├── RingBufferSeqnoOldTest.java │ ├── RingBufferTest.java │ ├── RingBundlerTest.java │ ├── RingBundlerTestLockless.java │ ├── RingBundlerTestLockless2.java │ ├── RouterStubTest.java │ ├── RpcDispatcherAsyncInvocationTest.java │ ├── RspListTest.java │ ├── RunnerTest.java │ ├── SeqnoListTest.java │ ├── ServerTests.java │ ├── ServerUnitTest.java │ ├── SetPropertyTest.java │ ├── SiteStatusTest.java │ ├── SiteUUIDTest.java │ ├── SizeBoundedQueueTest.java │ ├── SizeTest.java │ ├── StreamableTest.java │ ├── SuppressCacheTest.java │ ├── TableTest.java │ ├── TcpServerTest.java │ ├── ThreadPoolIncreaseTest.java │ ├── TimeSchedulerTest.java │ ├── TimeServiceTest.java │ ├── TupleTest.java │ ├── UnicastUnitTest.java │ ├── UtilTest.java │ ├── VersionTest.java │ ├── ViewHandlerTest.java │ ├── ViewIdTest.java │ ├── ViewTest.java │ └── XmlParseTest.java │ └── util │ ├── LazyRemovalCacheTest.java │ └── LazyRemovalListTest.java ├── junit └── org │ └── jgroups │ ├── blocks │ ├── RpcDispatcherAnycastMultipleCallsTest.java │ ├── RpcDispatcherAnycastServerObject.java │ ├── RpcDispatcherAnycastTest.java │ ├── RpcDispatcherExceptionTest.java │ ├── RpcDispatcherInterruptTest.java │ ├── RpcDispatcherSerializationTest.java │ ├── RpcDispatcherUnicastMethodExceptionTest.java │ └── RpcDispatcherUnitTest.java │ ├── protocols │ └── FORK_UnitTest.java │ └── tests │ ├── ChannelTest.java │ ├── ChannelTestBase.java │ ├── CloseTest.java │ ├── ConcurrentCloseTest.java │ ├── ConcurrentStartupTest.java │ ├── ConnectTest.java │ ├── Deadlock2Test.java │ ├── DiscardTest.java │ ├── DiscoveryTest2.java │ ├── DuplicateTest.java │ ├── FifoOrderTest.java │ ├── GossipRouterTest.java │ ├── JoinTest.java │ ├── LargeStateTransferTest.java │ ├── LastMessageDroppedTest.java │ ├── LoopbackTest.java │ ├── MergeTest.java │ ├── MessageBundlingTest.java │ ├── MessageDispatcherUnitTest.java │ ├── NAKACK_Test.java │ ├── OOBTest.java │ ├── OverlappingMergeTest.java │ ├── OverlappingUnicastMergeTest.java │ ├── RejectionPoliciesTest.java │ ├── ReplicatedHashMapTest.java │ ├── SequencerMergeTest.java │ ├── SequencerOrderTest.java │ ├── StateTransferTest.java │ ├── StateTransferTest2.java │ ├── TCPGOSSIP_Test.java │ ├── TUNNELDeadLockTest.java │ ├── TUNNEL_Test.java │ ├── ThreadFactoryTest.java │ ├── TransportThreadPoolTest.java │ └── UUIDCacheClearTest.java ├── other └── org │ └── jgroups │ └── tests │ ├── BufferSizeTest.java │ ├── CheckGaps.java │ ├── CheckMonotonicallyIncreasingNumbers.java │ ├── FlowControlTest.java │ ├── GridFilesystemTest.java │ ├── HexToBinary.java │ ├── InfinispanStackMerge3Test.java │ ├── LargeState.java │ ├── MakeUnique.java │ ├── McastDiscovery.java │ ├── McastReceiverTest.java │ ├── McastSenderTest.java │ ├── MessageDispatcherSpeedTest.java │ ├── MessageSendTest.java │ ├── ModClusterAdvertizeListener.java │ ├── MulticastTest.java │ ├── MulticastTest2.java │ ├── NioClientTest.java │ ├── NioServerPerfTest.java │ ├── ParseMessages.java │ ├── ParseMessagesFields.java │ ├── ParsePacketDissections.java │ ├── PingPong.java │ ├── PingPongDatagram.java │ ├── PinnedVThreads.java │ ├── Probe.java │ ├── RoundTrip.java │ ├── RoundTripRpc.java │ ├── RouterStubGet.java │ ├── RpcDispatcherBlocking.java │ ├── RpcDispatcherSpeedTest.java │ ├── ShmTest.java │ ├── UnicastTest.java │ ├── UnicastTestRpc.java │ ├── UnicastTestTcp.java │ ├── UnicastTestTcpRpc.java │ ├── UnicastTestTcpSlow.java │ ├── mcast.java │ └── rt │ ├── RtReceiver.java │ ├── RtTransport.java │ └── transports │ ├── JGroupsTransport.java │ ├── NioTransport.java │ ├── ServerTransport.java │ ├── TcpTransport.java │ └── UdpTransport.java ├── perf └── org │ └── jgroups │ └── tests │ └── perf │ ├── JPerf.java │ ├── MPerf.java │ ├── MPerfRpc.java │ ├── PerfUtil.java │ ├── UPerf.java │ └── UdpPerf.java ├── stress └── org │ └── jgroups │ └── tests │ ├── BundlerStressTest.java │ ├── RemoteGetStressTest.java │ ├── RingBufferLocklessStressTest.java │ ├── RingBufferStressTest.java │ ├── TableStressTest.java │ └── TimeSchedulerStressTest.java └── util └── org └── jgroups └── util ├── BundlerHelper.java ├── CountTests.java ├── DumpData.java ├── JUnitXMLReporter.java └── ProtPerfHelper.java /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: maven 4 | directory: "/" 5 | schedule: 6 | interval: daily 7 | open-pull-requests-limit: 10 8 | - package-ecosystem: github-actions 9 | directory: "/" 10 | schedule: 11 | interval: daily 12 | open-pull-requests-limit: 10 13 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | on: 3 | push: 4 | branches: 5 | - '*' 6 | pull_request: 7 | branches: 8 | - '*' 9 | permissions: 10 | contents: read 11 | jobs: 12 | ci: 13 | runs-on: ${{ matrix.os }} 14 | strategy: 15 | matrix: 16 | os: [ ubuntu-latest, windows-latest, macos-latest ] 17 | # Keep this list as: all supported LTS JDKs, the latest GA JDK, and the latest EA JDK (optional). 18 | java: [ 11, 17, 21, 23 ] 19 | steps: 20 | - name: Checkout 21 | uses: actions/checkout@v4 22 | - name: Set up JDK ${{ matrix.java }} 23 | uses: actions/setup-java@v4 24 | with: 25 | distribution: temurin 26 | java-version: ${{ matrix.java }} 27 | - name: Cache local Maven repository 28 | uses: actions/cache@v4 29 | with: 30 | path: ~/.m2/repository 31 | key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} 32 | restore-keys: | 33 | ${{ runner.os }}-maven- 34 | - name: Build with Maven 35 | # In order to support Windows PowerShell, a space between --define property=true is required. 36 | run: mvn --batch-mode --no-transfer-progress verify --define skipTests=true 37 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | *.iws 3 | *.ipr 4 | *.iml 5 | .project 6 | .classpath 7 | .factorypath 8 | .settings/ 9 | .idea/ 10 | .vscode/ 11 | .DS_Store 12 | classes/ 13 | build.properties 14 | dist/ 15 | atlassian* 16 | keystore/* 17 | tmp/ 18 | bla*.java 19 | doc/manual/*.css 20 | doc/manual/build/* 21 | doc/manual/*.tmp 22 | doc/tutorial/build/* 23 | doc/tutorial/*.css 24 | conf/MANIFEST.MF 25 | target/ 26 | lib/ 27 | hs_err_pid*.log 28 | .ant-targets-build.xml 29 | *.pem 30 | release.properties 31 | doc/manual/*generated*.adoc 32 | -------------------------------------------------------------------------------- /Jenkinsfile: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env groovy 2 | 3 | pipeline { 4 | agent any 5 | stages { 6 | stage('SCM Checkout') { 7 | steps { 8 | checkout scm 9 | } 10 | } 11 | 12 | stage('Build') { 13 | steps { 14 | script { 15 | def mvnHome = tool 'Maven' 16 | sh "${mvnHome}/bin/mvn clean install" 17 | } 18 | } 19 | } 20 | 21 | 22 | stage('Deploy SNAPSHOT') { 23 | when { 24 | branch 'master' 25 | } 26 | steps { 27 | configFileProvider([configFile(fileId: 'maven-settings-with-deploy-snapshot', variable: 'MAVEN_SETTINGS')]) { 28 | script { 29 | def mvnHome = tool 'Maven' 30 | sh "${mvnHome}/bin/mvn deploy -s $MAVEN_SETTINGS -DskipTests" 31 | } 32 | } 33 | } 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /bin/bm-uperf.sh: -------------------------------------------------------------------------------- 1 | ## Uses byteman to measure RTT times for UPerf 2 | 3 | #!/bin/bash 4 | 5 | bm.sh conf/scripts/RttTest/rtt.btm org.jgroups.tests.perf.UPerf $* -------------------------------------------------------------------------------- /bin/bm.sh: -------------------------------------------------------------------------------- 1 | ## Uses byteman plus script to run a program 2 | 3 | #!/bin/bash 4 | 5 | if [ $# -lt 2 ]; 6 | then echo "bm.sh byteman-script classname "; 7 | exit 1 8 | fi 9 | 10 | SCRIPT=$1 11 | PGM=$2 12 | 13 | 14 | if [ ! -f $SCRIPT ]; then 15 | echo "** Script $SCRIPT not found **" 16 | exit 1 17 | fi 18 | 19 | SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) 20 | LIB=`dirname $SCRIPT_DIR`/lib 21 | BM_OPTS="-Dorg.jboss.byteman.compile.to.bytecode=true" 22 | 23 | shift 24 | shift 25 | 26 | 27 | jgroups.sh -javaagent:$LIB/byteman.jar=script:$SCRIPT $BM_OPTS $PGM $* 28 | -------------------------------------------------------------------------------- /bin/bundler-stress_test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ## Rund BundlerStressTest, writes results to $OUTPUT (removes it first, when started) 4 | 5 | ## The bundler to be tested 6 | BUNDLERS="no-bundler transfer-queue per-destination" 7 | OUTPUT="bst.txt" 8 | THREADS="1 8 100" 9 | PROPS="$HOME/tcp.xml" 10 | PGM=BundlerStressTest 11 | 12 | rm -f $OUTPUT 13 | for i in $BUNDLERS; 14 | do for j in $THREADS; 15 | do jt $PGM -props $PROPS -bundler $i -num_sender_threads $j -interactive false -time 60 -warmup 60 >> $OUTPUT; 16 | done; 17 | done; 18 | 19 | -------------------------------------------------------------------------------- /bin/chat.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | `dirname $0`/jgroups.sh org.jgroups.demos.Chat $* 3 | 4 | -------------------------------------------------------------------------------- /bin/codenames.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ## Prints the codenames of all tagged JGroups versions 4 | 5 | TMPFILE=/tmp/versions.txt 6 | CODENAME=codename 7 | VER=./conf/JGROUPS_VERSION.properties 8 | 9 | if [[ -z "${JGROUPS_HOME}" ]]; 10 | then echo "$JGROUPS_HOME not set" ; exit 1 11 | fi 12 | 13 | cd $JGROUPS_HOME 14 | 15 | for i in $(git tag) 16 | do 17 | git show $i:$VER >>$TMPFILE 2>&1 18 | done 19 | 20 | for i in $(git branch --format='%(refname:short)') 21 | do 22 | git show $i:$VER >>$TMPFILE 2>&1 23 | done 24 | 25 | cat $TMPFILE | grep $CODENAME | grep -v fatal | sort | uniq 26 | 27 | 28 | cd - 29 | rm -f $TMPFILE 30 | -------------------------------------------------------------------------------- /bin/compile.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ## Creates a native image using the GraalVM compiler (needs to be on the path) 4 | 5 | LIB=`dirname $0`/../lib 6 | CLASSES=`dirname $0`/../classes 7 | CONF=`dirname $0`/../conf 8 | CLASSPATH="$CLASSES:$LIB/*" 9 | 10 | OPTIONS="$OPTIONS --no-fallback" 11 | OPTIONS="$OPTIONS -Dgraal.CompilationFailureAction=Diagnose" 12 | 13 | #OPTIONS="$OPTIONS --debug-attach=*:8000" 14 | 15 | OPTIONS="$OPTIONS --initialize-at-build-time=" 16 | OPTIONS="$OPTIONS -Dlog4j2.disable.jmx=true" ## Prevents log4j2 from creating an MBeanServer 17 | 18 | #OPTIONS="$OPTIONS --initialize-at-run-time=com.sun.jmx.mbeanserver.JmxMBeanServer" 19 | 20 | #OPTIONS="$OPTIONS --initialize-at-run-time=org.jgroups.protocols.FD_SOCK" 21 | 22 | native-image -cp $CLASSPATH $OPTIONS $* -------------------------------------------------------------------------------- /bin/context-switches.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ## Measures context switches of the given program(s). Requires jps, top and tr 4 | 5 | process=java 6 | 7 | if [ -z "$1" ] 8 | then 9 | echo "No argument supplied, process=$process" 10 | else 11 | process=$1 12 | fi 13 | 14 | pids=`jps |grep ${process}|cut -d ' ' -f1|awk '{print "-pid " $1}' | tr '\n' ' '` 15 | 16 | top -o CSW -c a -stats pid,cpu,command,threads,csw ${pids} -------------------------------------------------------------------------------- /bin/count-tests.sh: -------------------------------------------------------------------------------- 1 | 2 | # Author: Bela Ban 3 | 4 | #!/bin/bash 5 | 6 | JG=$HOME/JGroups 7 | 8 | `dirname $0`/jgroups.sh org.jgroups.util.CountTests $* -------------------------------------------------------------------------------- /bin/draw: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | `dirname $0`/jgroups.sh org.jgroups.demos.Draw $* 3 | 4 | -------------------------------------------------------------------------------- /bin/draw.bat: -------------------------------------------------------------------------------- 1 | @rem Convenience launcher for the Draw demo (contributed by Laran Evans lc278@cornell.edu) 2 | 3 | jgroups.bat org.jgroups.demos.Draw %* 4 | -------------------------------------------------------------------------------- /bin/dump_jdbc.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | jgroups.sh org.jgroups.protocols.JDBC_PING $* -------------------------------------------------------------------------------- /bin/echo.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | jgroups.sh org.jgroups.demos.EchoServer $* -------------------------------------------------------------------------------- /bin/gaps.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | java org.jgroups.tests.CheckGaps $* 3 | -------------------------------------------------------------------------------- /bin/gen-profiling.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ## Generates a byteman script for profile data 4 | 5 | # Add classpath of classes for which to generate rules, e.g.: 6 | # java -cp "/Users/bela/IspnPerfTest/target/libs/*" org.jgroups.util.GenerateProfilingScript $* 7 | 8 | java org.jgroups.util.GenerateProfilingScript $* -------------------------------------------------------------------------------- /bin/gen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | java org.jgroups.util.GenerateGettersAndSetters $* 4 | -------------------------------------------------------------------------------- /bin/gossiprouter.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | `dirname $0`/jgroups.sh org.jgroups.stack.GossipRouter -port 12001 $* 4 | 5 | -------------------------------------------------------------------------------- /bin/jg: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | `dirname $0`/jgroups.sh org.jgroups.demos.$* -------------------------------------------------------------------------------- /bin/jgroups-asprof.sh: -------------------------------------------------------------------------------- 1 | ## Uses async-profiler to measure CPU stats (can be changed) into out.html 2 | ## async-profiler needs to be in a dir called 'async-profiler' in the home dir 3 | 4 | #!/bin/bash 5 | 6 | AP="-agentpath:$HOME/async-profiler/lib/libasyncProfiler.dylib=start,event=cpu,file=out.html" 7 | 8 | jgroups.sh $AP $* 9 | 10 | -------------------------------------------------------------------------------- /bin/jgroups-perf.sh: -------------------------------------------------------------------------------- 1 | ## Uses byteman to measure times for individual protocols (up and down direction) 2 | 3 | #!/bin/bash 4 | 5 | SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) 6 | LIB=`dirname $SCRIPT_DIR`/lib 7 | SCRIPT=`dirname $SCRIPT_DIR`/conf/scripts/ProtPerf/prot-perf.btm 8 | 9 | jgroups.sh -javaagent:$LIB/byteman.jar=script:$SCRIPT $* 10 | -------------------------------------------------------------------------------- /bin/jgroups.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | REM ====================== Script to start JGroups programs ============================== 4 | REM Usage: jgroups.bat demos.Draw -props c:\udp.xml 5 | 6 | REM set the value of JG to the root directory in which JGroups is located 7 | set JG=..\ 8 | 9 | set CP=%JG%\classes\;%JG%\conf\;%JG%\lib\*;%JG%\keystore 10 | 11 | set VMFLAGS=-Xmx500M -Xms500M 12 | 13 | set LOG=-Dlog4j.configurationFile=%JG%\conf\log4j2.xml 14 | 15 | set FLAGS=-Djgroups.bind_addr=site_local 16 | 17 | java -classpath %CP% %LOG% %VMFLAGS% %FLAGS% -Dcom.sun.management.jmxremote %* 18 | -------------------------------------------------------------------------------- /bin/jt: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | `dirname $0`/jgroups.sh org.jgroups.tests.$* -------------------------------------------------------------------------------- /bin/mperf.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | jgroups.sh org.jgroups.tests.perf.MPerf $* -------------------------------------------------------------------------------- /bin/probe.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | REM Discovers all UDP-based members running on a certain mcast address (use -help for help) 4 | REM Probe [-help] [-addr ] [-port ] [-ttl ] [-timeout ] 5 | 6 | 7 | jgroups.bat org.jgroups.tests.Probe %* 8 | -------------------------------------------------------------------------------- /bin/probe.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Discovers all UDP-based members running on a certain mcast address (use -help for help) 4 | # Probe [-help] [-addr ] [-port ] [-ttl ] [-timeout ] 5 | 6 | 7 | `dirname $0`/jgroups.sh org.jgroups.tests.Probe $* 8 | -------------------------------------------------------------------------------- /bin/profile.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | SCRIPT=conf/scripts/profile.btm 5 | 6 | if [ $# -lt 1 ]; 7 | then 8 | echo "profile.sh classname [args]" 9 | fi 10 | 11 | PGM=$1 12 | shift 13 | 14 | bm.sh $PGM $SCRIPT $* 15 | 16 | 17 | -------------------------------------------------------------------------------- /bin/release-perform.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | mvn clean release:perform -Darguments="-DskipTests=true -Dmaven.skip.javadoc=true" 4 | 5 | -------------------------------------------------------------------------------- /bin/release-prepare.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | mvn clean release:prepare -Darguments="-DskipTests=true -Dmaven.skip.javadoc=true" 4 | 5 | -------------------------------------------------------------------------------- /bin/uperf.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | jgroups.sh org.jgroups.tests.perf.UPerf $* -------------------------------------------------------------------------------- /build.properties.template: -------------------------------------------------------------------------------- 1 | # add your own properties in here 2 | 3 | # the network interface (NIC) which will be used by the unit tests, change this to 4 | # the one you want to use. Note that 'localhost' usually resolved to 127.0.0.1, 5 | # which may not work on Linux unless you have a multicast route set up for loopback 6 | jgroups.bind_addr=localhost 7 | jgroups.tcpping.initial_hosts=localhost[7800],localhost[7801] 8 | jgroups.tunnel.gossip_router_hosts=localhost[12001] 9 | jgroups.udp.mcast_addr=224.8.8.8 10 | jgroups.udp.mcast_port=45588 11 | jgroups.udp.ip_ttl=5 12 | # use true for IPv6 and false for IPv4 13 | jgroups.useIPv6=false 14 | 15 | # Override for manual and tutorial generation 16 | asciidoctor-style=./asciidoctor.css 17 | 18 | # Information to publish to Nexus 19 | nexus.url=https://repository.jboss.org/nexus/service/local/staging/deploy/maven2/ 20 | nexus.user=username 21 | nexus.password=password123 22 | 23 | 24 | -------------------------------------------------------------------------------- /build.properties.template.ipv6: -------------------------------------------------------------------------------- 1 | # Example of IPv6 based build.properties 2 | # Replace the IPv6 addresses with your own 3 | 4 | # the network interface (NIC) which will be used by the unit tests, change this to 5 | # the one you want to use. Note that 'localhost' usually resolved to 127.0.0.1, 6 | # which may not work on Linux unless you have a multicast route set up for loopback 7 | jgroups.bind_addr=fe80::21b:21ff:fe07:a3b0%3 8 | jgroups.tcpping.initial_hosts=fe80::21b:21ff:fe07:a3b0%3[7800],fe80::21b:21ff:fe07:a3b0%3[7801] 9 | jgroups.tunnel.gossip_router_hosts=fe80::21b:21ff:fe07:a3b0%3[12001] 10 | jgroups.udp.mcast_addr=ff0e::5:6:7 11 | jgroups.udp.mcast_port=45588 12 | jgroups.udp.ip_ttl=5 13 | # use true for IPv6 and false for IPv4 14 | jgroups.useIPv6=true 15 | 16 | 17 | -------------------------------------------------------------------------------- /conf/JGROUPS_VERSION.properties: -------------------------------------------------------------------------------- 1 | 2 | ## Defines the JGroups version 3 | ## The variables are replaced when being copied to ./classes 4 | jgroups.version=${version} 5 | jgroups.codename=${codename} 6 | -------------------------------------------------------------------------------- /conf/asym-encrypt.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /conf/asym-ssl.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 17 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /conf/auth_X509.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /conf/auth_fixedlist.xml: -------------------------------------------------------------------------------- 1 | 5 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 17 | 18 | -------------------------------------------------------------------------------- /conf/auth_krb5.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /conf/auth_regex.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /conf/comment-test.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | --> 7 | 11 | 13 | 15 | thread_pool.keep_alive_time="30s"/> 16 | 17 | 18 | 20 | 24 | 25 | 26 | 27 | 28 | 30 | 31 | 32 | 34 | min_threshold="0.4"/> 35 | 37 | 38 | 40 | 41 | -------------------------------------------------------------------------------- /conf/echo.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | items: 3 | - apiVersion: apps/v1 4 | kind: Deployment 5 | metadata: 6 | annotations: 7 | labels: 8 | run: echo 9 | name: echo 10 | spec: 11 | replicas: 3 12 | selector: 13 | matchLabels: 14 | run: echo 15 | template: 16 | metadata: 17 | labels: 18 | run: echo 19 | spec: 20 | containers: 21 | - image: belaban/jgrp 22 | resources: 23 | requests: 24 | memory: "1024Mi" 25 | cpu: "1" 26 | limits: 27 | memory: "1Gi" 28 | cpu: "1" 29 | name: echo 30 | command: ["echo.sh"] 31 | env: 32 | - name: jgroups.external_addr 33 | value: "master-0.vrigamon0527.lab.upshift.rdu2.redhat.com" 34 | kind: List 35 | metadata: {} 36 | --- 37 | apiVersion: v1 38 | kind: Service 39 | metadata: 40 | annotations: 41 | service.alpha.kubernetes.io/tolerate-unready-endpoints: "true" 42 | name: echo 43 | labels: 44 | run: echo 45 | spec: 46 | ports: 47 | - name: echo 48 | nodePort: 31000 49 | port: 9000 50 | protocol: TCP 51 | targetPort: 9000 52 | selector: 53 | run: echo 54 | # sessionAffinity: None 55 | sessionAffinity: ClientIP 56 | type: NodePort 57 | 58 | 59 | -------------------------------------------------------------------------------- /conf/encrypt.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 19 | 20 | 21 | 22 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /conf/fast.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 14 | 20 | 21 | 22 | 24 | 25 | 26 | 27 | 28 | 29 | 31 | 32 | 34 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /conf/fork-stacks.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /conf/fork-stacks.xsd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /conf/fork.xml: -------------------------------------------------------------------------------- 1 | 5 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /conf/jg-messages_de.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/belaban/JGroups/844921a1ef5d7dfe1b0a45f7a3e12cd841bdc8f1/conf/jg-messages_de.properties -------------------------------------------------------------------------------- /conf/kerberos/krb5.conf: -------------------------------------------------------------------------------- 1 | [libdefaults] 2 | default_realm = KERBTEST.COM 3 | 4 | [realms] 5 | KERBTEST.COM = { 6 | kdc = 127.0.0.1:60088 7 | kpasswd_server = 127.0.0.1:60088 8 | admin_server = 127.0.0.1:60088 9 | kpasswd_protocol = SET_CHANGE 10 | } 11 | 12 | [domain_realm] 13 | .kerbtest.com = KERBTEST.COM 14 | kerbtest.com = KERBTEST.COM 15 | 16 | [logging] 17 | default = FILE:kdc.log 18 | kdc = FILE:kdc.log 19 | kdc_rotate = { 20 | period = 1d 21 | versions = 10 22 | } 23 | 24 | [appdefaults] 25 | kinit = { 26 | renewable = true 27 | forwardable = true 28 | } 29 | 30 | -------------------------------------------------------------------------------- /conf/kerberos/login.conf: -------------------------------------------------------------------------------- 1 | 2 | JGoupsKrb5TokenSecurityConf { 3 | com.sun.security.auth.module.Krb5LoginModule required 4 | useTicketCache=false; 5 | }; 6 | 7 | -------------------------------------------------------------------------------- /conf/keystore.jks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/belaban/JGroups/844921a1ef5d7dfe1b0a45f7a3e12cd841bdc8f1/conf/keystore.jks -------------------------------------------------------------------------------- /conf/log4j2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /conf/reflection.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "name" : "org.jgroups.protocols.TP", 4 | "fields" : [ 5 | { "name" : "bind_addr", "allowWrite" : true }, 6 | { "name" : "bind_port", "allowWrite" : true}, 7 | { "name" : "thread_pool_enabled", "allowWrite" : true} 8 | ] 9 | }, 10 | { 11 | "name": "org.jgroups.util.ObjectWrapper", 12 | "methods" : [ 13 | { "name" : "", "parameterTypes" : [] } 14 | ] 15 | }, 16 | { 17 | "name": "org.jgroups.tests.perf.PerfUtil$Config", 18 | "methods" : [ 19 | {"name" : "", "parameterTypes": []} 20 | ] 21 | }, 22 | { 23 | "name": "org.jgroups.tests.perf.PerfUtil$Results", 24 | "methods" : [ 25 | {"name" : "", "parameterTypes": []} 26 | ] 27 | }, 28 | { 29 | "name": "org.jgroups.tests.perf.PerfUtil$CustomCall", 30 | "methods" : [ 31 | {"name" : "", "parameterTypes": []} 32 | ] 33 | }, 34 | { 35 | "name": "javax.xml.parsers.DocumentBuilderFactory", 36 | "methods": [ 37 | {"name": "", "parameterTypes": []} 38 | ] 39 | } 40 | ] -------------------------------------------------------------------------------- /conf/relay/bridge-net1-hf.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 13 | 14 | 16 | 17 | 18 | 19 | 20 | 22 | 23 | 25 | 27 | 28 | 30 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /conf/relay/bridge-net1-net2.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 13 | 14 | 16 | 17 | 18 | 19 | 20 | 23 | 24 | 26 | 28 | 29 | 31 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /conf/relay/bridge-net2-net3.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 13 | 14 | 16 | 17 | 18 | 19 | 20 | 23 | 24 | 26 | 28 | 29 | 31 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /conf/relay1.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 11 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /conf/relay2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 11 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /conf/rogue.jks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/belaban/JGroups/844921a1ef5d7dfe1b0a45f7a3e12cd841bdc8f1/conf/rogue.jks -------------------------------------------------------------------------------- /conf/scripts/ASYM_ENCRYPT_BlockTest/testASYM_ENCRYPT_NotBlockingJoin.btm: -------------------------------------------------------------------------------- 1 | 2 | 3 | ## Send unicast message to joiner *before* JOIN-RSP (https://issues.redhat.com/browse/JGRP-2131) 4 | RULE InjectAdditionalUnicast 5 | CLASS GMS 6 | METHOD sendJoinResponse 7 | HELPER org.jgroups.tests.helpers.SendUnicast 8 | AT ENTRY 9 | BIND gms=$0; 10 | dest=$2; 11 | IF TRUE 12 | DO System.out.println("** sending unicast message to " + dest); 13 | sendUnicast(gms, dest); 14 | ENDRULE 15 | 16 | 17 | -------------------------------------------------------------------------------- /conf/scripts/MessageBeforeConnectedTest/testSendingOfMsgsOnUnconnectedChannel.btm: -------------------------------------------------------------------------------- 1 | 2 | 3 | ## Test case for https://issues.redhat.com/browse/JGRP-1545 4 | ## - Join A 5 | ## - Before the channel is set to 'connected', deliver a unicast message to A 6 | ## - A sends a response and the response triggers an exception as the channel is not yet connected 7 | 8 | 9 | 10 | ## After JChannel._preConnect() (which starts the socket listener), we send a unicast message up the stack 11 | 12 | RULE injectUnicastRpc 13 | CLASS JChannel 14 | METHOD _preConnect 15 | HELPER org.jgroups.tests.helpers.MessageBeforeConnectedTestHelper 16 | AT EXIT 17 | IF TRUE 18 | DO sendUnicast($0); 19 | ENDRULE 20 | 21 | -------------------------------------------------------------------------------- /conf/scripts/RingBufferSeqnoTest/testRemoveAndConcurrentAdd.btm: -------------------------------------------------------------------------------- 1 | 2 | ## Changes thread interleaving such that a concurrent add() and remove(nullify) can add 3 | # an element more than once 4 | 5 | RULE Remove1 6 | CLASS RingBufferSeqnoLockless 7 | METHOD remove(boolean) 8 | AT WRITE hd 9 | IF true 10 | DO System.out.println("---> Remover: waiting on \"remove\""); 11 | waitFor("remove"); 12 | System.out.println("---> Remover: was woken up"); 13 | ENDRULE 14 | 15 | RULE Remove2 16 | CLASS RingBufferSeqnoLockless 17 | METHOD remove(boolean) 18 | AT EXIT 19 | IF true 20 | DO System.out.println("---> Remover: signalling \"add\""); 21 | signalWake("add", true); 22 | ENDRULE 23 | 24 | RULE Add 25 | CLASS RingBufferSeqnoLockless 26 | METHOD add(long,java.lang.Object,boolean) 27 | AFTER INVOKE RingBuffer.index(long) 28 | IF !createCountDown("tmp", 4) && countDown("tmp") 29 | DO System.out.println("---> Adder: signaling \"remove\""); 30 | signalWake("remove", true); 31 | System.out.println("---> Adder: waiting for \"add\""); 32 | waitFor("add"); 33 | System.out.println("---> Adder: awoken"); 34 | ENDRULE 35 | 36 | -------------------------------------------------------------------------------- /conf/scripts/SequencerFailoverTest/testResendingVersusNewMessages.btm: -------------------------------------------------------------------------------- 1 | 2 | ## Test case for https://issues.redhat.com/browse/JGRP-1449 (SEQUENCER): 3 | ## - When a coord A fails, we resend messages in the forward-queue that we haven't yet received 4 | ## - If, at the same time, new messages are sent, the old messages in the forward-queue might be received 5 | ## *after* the new ones. JGRP-1449 is supposed to fix that. The fix is that sending of new messages on a view 6 | ## change will be blocked until all messages in the forward-queue have been forwarded successfully. 7 | ## 8 | ## The test case intercepts SEQUENCER.handleViewChange() and starts a thread which sends new messages. 9 | ## We then check the order of message delivery. 10 | 11 | RULE SendNewMessages 12 | CLASS SEQUENCER 13 | METHOD startFlusher 14 | HELPER org.jgroups.tests.helpers.SequencerFailoverTestHelper 15 | AFTER WRITE flushing ALL 16 | BIND local_addr_name=org.jgroups.util.NameCache.get($0.local_addr); 17 | map:java.util.Map=$0.forward_table; 18 | empty=map.isEmpty(); 19 | flushing=$0.flushing 20 | IF flushing && local_addr_name.equals("C") && !empty 21 | DO System.out.println("[byteman] --> sending new messages 2-5"); 22 | sendMessages($0, 2, 5); 23 | ENDRULE 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /conf/scripts/bundler.btm: -------------------------------------------------------------------------------- 1 | 2 | 3 | # Byteman script to profile Bundler implementations 4 | 5 | RULE DiagnosticHandler creation 6 | CLASS ^TP 7 | HELPER org.jgroups.util.BundlerHelper 8 | METHOD handleConnect() 9 | AT ENTRY 10 | BIND tp=$this, diag=tp.getDiagnosticsHandler(); 11 | IF TRUE 12 | DO diagCreated(diag); 13 | ENDRULE 14 | 15 | 16 | ## Bundler.send 17 | RULE Bundler.send() start 18 | INTERFACE org.jgroups.protocols.Bundler 19 | HELPER org.jgroups.util.BundlerHelper 20 | METHOD send 21 | COMPILE 22 | AT ENTRY 23 | BIND msg=$1; 24 | IF TRUE 25 | DO setStartTime(msg); 26 | ENDRULE 27 | 28 | ## BaseBundler.sendSingleMessage 29 | RULE BaseBundler.sendSingleMessage() 30 | CLASS BaseBundler 31 | HELPER org.jgroups.util.BundlerHelper 32 | METHOD sendSingleMessage 33 | COMPILE 34 | AT EXIT 35 | BIND msg=$2; 36 | IF TRUE 37 | DO computeTime("send.single", msg); 38 | ENDRULE 39 | 40 | ## BaseBundler.sendMessageList 41 | RULE BaseBundler.sendMessageList() 42 | CLASS BaseBundler 43 | HELPER org.jgroups.util.BundlerHelper 44 | METHOD sendMessageList 45 | COMPILE 46 | AT EXIT 47 | BIND list=$3; 48 | IF TRUE 49 | DO computeTime("send.multiple", list); 50 | ENDRULE 51 | 52 | ## BaseBundler.sendMessageListArray 53 | RULE BaseBundler.sendMessageListArray() 54 | CLASS BaseBundler 55 | HELPER org.jgroups.util.BundlerHelper 56 | METHOD sendMessageListArray 57 | COMPILE 58 | AT EXIT 59 | BIND list=$3; 60 | IF TRUE 61 | DO computeTime("send.multiple", list); 62 | ENDRULE -------------------------------------------------------------------------------- /conf/scripts/profiled-methods.txt: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | org.jgroups.protocols.TP.doSend 5 | 6 | org.jgroups.protocols.BaseBundler.sendBundledMessages 7 | 8 | org.jgroups.protocols.BaseBundler.sendSingleMessage 9 | 10 | org.jgroups.protocols.BaseBundler.sendMessageList -------------------------------------------------------------------------------- /conf/sequencer.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /conf/sos.cfg: -------------------------------------------------------------------------------- 1 | jmx=TP.thread_pool_,num_rej 2 | jmx=RED.que,avg_,dropped 3 | jmx=MERGE3.num_ 4 | jmx=FD_SOCK.num_sus 5 | jmx=FailureDetection.num_heartbeats,num_suspect 6 | jmx=NAKACK2.xmit_table_undelivered,xmit_table_missing 7 | jmx=UNICAST3.xmit_r,xmit_table_undelivered,xmit_table_missing 8 | op=GMS.printPreviousViews 9 | jmx=UFC.aver,number_of_blo 10 | jmx=MFC.aver,number_of_blo -------------------------------------------------------------------------------- /conf/sym-encrypt.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /conf/tcp-nio-new.xml: -------------------------------------------------------------------------------- 1 | 8 | 12 | 16 | 17 | 20 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /conf/tcp-nio.xml: -------------------------------------------------------------------------------- 1 | 8 | 12 | 16 | 17 | 20 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 30 | 31 | 33 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /conf/tunnel.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 11 | 12 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /conf/udp-new.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 10 | 16 | 17 | 18 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /conf/udp.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 11 | 16 | 17 | 18 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 28 | 29 | 31 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /doc/README: -------------------------------------------------------------------------------- 1 | 2 | JGroups ships as a single JAR file: jgroups-x.y.z.jar. Simply add it to your classpath and start coding! 3 | 4 | The JGroups version can be printed with java -jar jgroups-x.y.z.jar. 5 | 6 | There's a simple draw demo, start 2 or more instances: java -cp jgroups-x.y.z.jar org.jgroups.demos.Draw, and see if 7 | the members find each other. 8 | 9 | The sources for the core classes are in jgroups-sources.jar. 10 | 11 | If you want the complete sources, including unit tests, go to http://www.github.com/belaban/jgroups. 12 | 13 | JGroups is hosted at www.jgroups.org. 14 | 15 | For questions use either the dev or users mailing list. 16 | 17 | Enjoy, 18 | 19 | Bela Ban 20 | -------------------------------------------------------------------------------- /doc/design/ABP.txt: -------------------------------------------------------------------------------- 1 | 2 | 3 | Design of Alternating Bit Protocol (ABP) 4 | ======================================== 5 | 6 | Properties 7 | ---------- 8 | - Reliable message sending from sender A to receiver B 9 | - Tolerates message loss and duplicate messages 10 | - Does *not* tolerate message reordering (c.f. [1], section 22.3) 11 | 12 | 13 | State 14 | ----- 15 | 16 | - bit = 0; 17 | - send-queue; // queue of msgs, client adds at end to send 18 | 19 | 20 | Sender 21 | ------ 22 | 23 | Send msg MSG: 24 | ------------ 25 | - while true: 26 | - If msg=send-queue.peek() == null --> return 27 | - Send MSG(msg, bit) to receiver 28 | - Sleep 29 | 30 | 31 | On reception of ACK(bit) from receiver 32 | -------------------------------------- 33 | - If ACK(bit) == bit: 34 | - bit = ^bit 35 | - send-queue.pop() // removes element from send-queue 36 | 37 | 38 | Receiver 39 | -------- 40 | 41 | On reception of MSG(bit) from sender P 42 | -------------------------------------- 43 | - If MSG(bit) == bit: 44 | - bit = ^bit 45 | - deliver MSG 46 | - Send ACK(^bit) to P 47 | 48 | 49 | 50 | Refs 51 | ---- 52 | 53 | [1] Lynch, Nancy. Distributed Algorithms, Morgan Kaufmann 54 | -------------------------------------------------------------------------------- /doc/design/Bundling.txt: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Message bundling 5 | ================ 6 | 7 | // Author: Bela Ban 8 | 9 | Init: 10 | ----- 11 | 12 | - set start = 0 13 | - set wait_time = 0 14 | - set count = 0 15 | 16 | 17 | On Message: 18 | ----------- 19 | 20 | - if start == 0: 21 | - set start = current time 22 | 23 | - if msg.length + count >= max_bundle_size: 24 | - send all messages 25 | - set count = 0 26 | - set start = current time 27 | 28 | - add message 29 | - set count = count + msg.length 30 | 31 | - compute new wait_time: max_bundle_time - (current time - start) 32 | - if wait_time <= 0: 33 | - send all messages 34 | - Init() 35 | 36 | 37 | On Timeout: 38 | ----------- 39 | 40 | - send all messages 41 | - Init() 42 | 43 | 44 | New implementation (Nov 2005) 45 | ============================= 46 | - done in TP.send(), this way message bundling and using a separate thread for sending 47 | messages are orthogonal issues 48 | 49 | Variables: 50 | ---------- 51 | - queue, queue size 52 | 53 | On send(): 54 | ---------- 55 | - if msg size + queue size >= max_size: 56 | - cancel timer 57 | - bundle and send queued msgs 58 | - clear queue 59 | - add msg to queue 60 | - if timer is not running: start timer 61 | 62 | On timer timeout: 63 | ----------------- 64 | - bundle and send queued msgs (if any) 65 | - clear queue 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | -------------------------------------------------------------------------------- /doc/design/DataCenterReplication.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/belaban/JGroups/844921a1ef5d7dfe1b0a45f7a3e12cd841bdc8f1/doc/design/DataCenterReplication.png -------------------------------------------------------------------------------- /doc/design/JoinAndStateTransfer.txt: -------------------------------------------------------------------------------- 1 | Implementation of JChannel.connect() with state transfer - https://issues.redhat.com/browse/JGRP-236 2 | ----------------------------------------------- 3 | 4 | There are essentially three major different implementations possibilites for new JChannel.connect with state 5 | transfer. 6 | 7 | Solution A: 8 | 9 | - implement state transfer within CoordGmsImpl.handleJoin running on ViewHandler thread 10 | - tightly ties state transfer to CoordGmsImpl and further bloats CoordGmsImpl.handleJoin 11 | - can we even keep ViewHandler thread so busy? Possibly run state transfer on a new thread spawned 12 | from CoordGmsImpl.handleJoin? 13 | 14 | Solution B: 15 | 16 | - listen for SUSPEND_OK in STATE_TRANSFER (flush succeded/cluster is quiet) at coordinator 17 | - add additional info to SUSPEND_OK so we know the joining member 18 | - do state transfer on SUSPEND_OK running on stack thread 19 | - use longer flush timeout for large states or periodically update timout to notify it of large transfer? 20 | 21 | Solution C: 22 | 23 | - initiate state transfer within JChannel.connect() after connect_promise is set 24 | - call JChannel.startFlush() and JChannel.stopFlush() 25 | - we do extra flush in this case 26 | 27 | 28 | 29 | Solution C is the most viable option for regular state transfer with flush. startFlush() and stopFlush() will be 30 | exposed on JChannel level and will be called by initiator of state transfer. Nice and clean solution. However, if 31 | we employ solution C for new JChannel.connect method the overhead of extra flush does not seem acceptable? 32 | -------------------------------------------------------------------------------- /doc/design/LargeClusters.txt: -------------------------------------------------------------------------------- 1 | 2 | 3 | Considerations for large clusters 4 | ================================= 5 | 6 | Author: Bela Ban 7 | JIRA: https://issues.redhat.com/browse/JGRP-100 8 | 9 | 10 | Discovery 11 | --------- 12 | 13 | 14 | 15 | ConcurrentHashMap 16 | ----------------- 17 | 18 | CCHMs have a default initial capacity (16), load factor (0.75) and concurrency level (16). These are OK for most 19 | scenarios, but we have to investigate whether these values are sufficient for 1000 node clusters. 20 | 21 | When for example 1000 threads from different senders access the same CCHM, we need to make sure we don't have high 22 | contention, ie. by spreading a 1000 senders over 16 buckets. 23 | 24 | Investigate whether we should add CCHM initial sizes, load factors and concurrency levels as properties. 25 | 26 | With ergonomics [1], we could for example set bucket sizes for CCHMs dynamically, e.g. based on cluster size. 27 | 28 | 29 | 30 | [1] https://issues.redhat.com/browse/JGRP-1037 31 | 32 | 33 | Misc 34 | ---- 35 | 36 | - MERGE2: num_initial_members in Discovery should be large, so that we detect partitions sooner -------------------------------------------------------------------------------- /doc/design/NullDestAddresses.txt: -------------------------------------------------------------------------------- 1 | 2 | Nulling of destination addresses for optimized marshalling 3 | ========================================================== 4 | 5 | Author: Bela Ban 6 | Date: Aug 26 2005 7 | 8 | When we marshall a message (org.jgroups.BaseMessage), we can transmit a null value for the destination, because 9 | the receiver can determine the destination: 10 | - for UDP: if received on the multicast receive socket, the destination is the multicast address (same as null) 11 | if received on the unicast receive socket, the destination is the local_addr (ourself) 12 | - for TCP: we use the MULTICAST byet sent with the message when unmarshalling the message: 13 | - if true, we leave the deatination null (= multicast destination) 14 | - if not set, we set the destination to the address passed to use from the ConnectionTable 15 | 16 | This requires that when marshalling a message, we send a multicast byte with each Message (or once for bundled msgs) 17 | based on the destination address! 18 | 19 | Note that we *cannot* modify the destination address in the message itself, otherwise retransmissions might fail! 20 | 21 | -------------------------------------------------------------------------------- /doc/design/NullingSrcAddresses.txt: -------------------------------------------------------------------------------- 1 | 2 | Loopback adaptor issues on Windows 3 | ---------------------------------- 4 | 5 | JIRA: https://issues.redhat.com/browse/JGRP-79 6 | 7 | On Windows, when a loopback adaptor is created, we can associate multiple (virtual) IP 8 | addresses with it, e.g. 10.0.0.1 and 10.0.0.2. 9 | 10 | However, when we have a member M1 bound to 10.0.0.1, and another member M2 bound to 10.0.0.2, and 11 | bind_to_all_interfaces is set to true, then it was observed that - regardless of the bind address - 12 | the sender's address in a DatagramPacket received was always 10.0.0.1 (the first address assigned)! 13 | 14 | Therefore, members would never find each other. 15 | 16 | The reason this shows up now (in 2.2.8) is that as an optimization, we *don't* send the src address 17 | in the Message anymore, so we can save a few bytes, but we null the src address, and set it to the sender's 18 | address when we *receive* the packet. 19 | This can be disabled by setting null_src_addresses to false (default is true) 20 | -------------------------------------------------------------------------------- /doc/design/RACKSPACE_PING.txt: -------------------------------------------------------------------------------- 1 | Design of RACKSPACE_PING 2 | ======================== 3 | 4 | Author: Gustavo Fernandes 5 | 6 | 7 | Goal 8 | ---- 9 | 10 | RACKSPACE_PING is a discovery protocol which persist files in Rackspace Cloud Files Service 11 | 12 | http://www.rackspace.co.uk/cloud-hosting/cloud-products/cloud-files/ 13 | 14 | 15 | Usage 16 | ----- 17 | 18 | It's necessary to provide 3 properties in order to authenticate and use the service: 19 | 20 | * username: the Rackspace's account login 21 | * apiKey: the Rackspace API key associated with the account 22 | * region: either UK or US, the current existing rackspace locations 23 | 24 | 25 | Design 26 | ------ 27 | 28 | As it happens with FILE_PING, this protocol also creates a root folder, also known as container in Rackspace terminology. 29 | PingData is stored as objects, the equivalent of a file in Rackspace, but since there's no support for true hierarchical 30 | folders, the file names also contains the path. An example of a cluster structure in Rackspace would be: 31 | 32 | - jgroups 33 | - ChatCluster/e215bbe0-778c-dd28-f27b-0211619ddb2d 34 | - ChatCluster/b6d7bd8d-c054-2346-55a2-a0a37df6c443 35 | 36 | 37 | Where 'jgroups' is the root container and each of the children are files belonging to the 'ChatCluster' channel. 38 | 39 | Communication with Rackspace is done via an internal ReST client. The client authenticates with RackSpace and obtain an 40 | auth token and an assigned URL used to do all subsequent file related operations. When the auth token expires after 24h, 41 | the client automatically obtains a new token. 42 | 43 | When a node leaves the channel, a shutdown hook is in place to delete the associated ping data. 44 | -------------------------------------------------------------------------------- /doc/design/RELAY.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/belaban/JGroups/844921a1ef5d7dfe1b0a45f7a3e12cd841bdc8f1/doc/design/RELAY.png -------------------------------------------------------------------------------- /doc/design/STABLE.txt: -------------------------------------------------------------------------------- 1 | 2 | STABLE 3 | ====== 4 | 5 | Author: Bela Ban 6 | Date: May 29 2007 7 | 8 | Goal: to purge messages delivered by all members 9 | 10 | 11 | Vars 12 | ---- 13 | - digest: used to reconcile all STABLE messages, re-initialized on STABILITY message (with digest from NAKACK) 14 | - votes: list of members from whom we have received STABLE messages. Reset on STABILITY message 15 | 16 | Initialization 17 | -------------- 18 | - Set digest from NAKACK 19 | 20 | When the timer expires or max_bytes have been received 21 | ------------------------------------------------------ 22 | - Send STABLE message 23 | 24 | Sending of STABLE message 25 | ------------------------- 26 | - Get the current digest (from NAKACK) using the GET_DIGEST_STABLE event 27 | - Send the STABLE message to group 28 | 29 | On reception of STABLE message from P 30 | ------------------------------------- 31 | - If P already present in votes: discard 32 | - Else: 33 | - Update digest 34 | - Add P to votes 35 | - If votes from all members: 36 | - Send STABILITY message 37 | 38 | On reception of STABILITY message 39 | --------------------------------- 40 | - Pass STABLE event down to NAKACK to purge messages on which every member agreed that they have been delivered 41 | - Set digest from NAKACK 42 | - Clear votes 43 | 44 | 45 | View change 46 | ----------- 47 | - Set digest from NAKACK 48 | - Clear votes 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /doc/design/UNICAST.txt: -------------------------------------------------------------------------------- 1 | 2 | UNICAST and membership 3 | ====================== 4 | 5 | Author: Bela Ban 6 | Date: Aug 10 2006 7 | 8 | 9 | Sending a unicast message to P 10 | ------------------------------ 11 | - When sending the first unicast message to a member P, its seqno is 1 (meaning this is the first message) 12 | - The message is added to the AckSenderWindow, which keeps resending the message until 13 | it is acked by P, or P leaves the group (or crashes) 14 | 15 | 16 | View change 17 | ----------- 18 | When a member P leaves, the connection for P is removed from the connection table and added to previous_members 19 | 20 | 21 | Receiving a unicast message from P 22 | ---------------------------------- 23 | - When receiving a message from P: 24 | - If there is no entry for P in the connection table: 25 | - If the message has seqno=1: 26 | - Create a new entry for P in the connection table 27 | - Add the message to the entry for P (AckReceiverWindow) and ack it back to P 28 | - Else: 29 | - Discard the message and do *not* ack it! This is necessary, so P keeps retransmitting it! 30 | - Else: 31 | - Add the message to the entry for P (AckReceiverWindow) and ack it back to P 32 | 33 | -------------------------------------------------------------------------------- /doc/manual/images/Architecture.fig: -------------------------------------------------------------------------------- 1 | #FIG 3.2 Produced by xfig version 3.2.5 2 | Landscape 3 | Center 4 | Inches 5 | Letter 6 | 100.00 7 | Single 8 | -2 9 | 1200 2 10 | 6 675 600 4575 5475 11 | 2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 12 | 1125 3825 3225 3825 3225 4425 1125 4425 1125 3825 13 | 2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 14 | 1125 3150 3225 3150 3225 3750 1125 3750 1125 3150 15 | 2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 16 | 1125 2475 3225 2475 3225 3075 1125 3075 1125 2475 17 | # UDP 18 | 2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 19 | 1125 4500 3225 4500 3225 5100 1125 5100 1125 4500 20 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 2 21 | 2175 5100 2175 5475 22 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 2 23 | 675 5475 3675 5475 24 | 2 4 0 1 0 7 50 -1 -1 0.000 0 0 7 0 0 5 25 | 2550 1725 2550 1200 750 1200 750 1725 2550 1725 26 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 7 27 | 675 1125 2700 1125 2700 1725 3600 1725 3600 600 675 600 28 | 675 1125 29 | 2 4 0 1 0 7 50 -1 -1 0.000 0 0 7 0 0 5 30 | 3600 2400 3600 1800 750 1800 750 2400 3600 2400 31 | 4 0 0 50 -1 18 14 0.0000 4 180 525 1875 4875 UDP\001 32 | 4 0 0 50 -1 18 14 0.0000 4 180 705 1875 4200 FRAG\001 33 | 4 0 0 50 -1 18 14 0.0000 4 180 900 1875 3525 MERGE\001 34 | 4 0 0 50 -1 18 14 0.0000 4 180 555 1875 2925 GMS\001 35 | 4 0 0 50 -1 18 14 0.0000 4 180 1095 1650 2175 JChannel\001 36 | 4 0 0 50 0 18 14 0.0000 4 180 960 3600 5400 Network\001 37 | 4 0 0 50 -1 18 14 0.0000 4 225 1305 1650 975 Application\001 38 | 4 0 0 50 -1 18 13 0.0000 4 210 1620 900 1575 Building blocks\001 39 | -6 40 | -------------------------------------------------------------------------------- /doc/manual/images/Architecture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/belaban/JGroups/844921a1ef5d7dfe1b0a45f7a3e12cd841bdc8f1/doc/manual/images/Architecture.png -------------------------------------------------------------------------------- /doc/manual/images/ChannelStates.fig: -------------------------------------------------------------------------------- 1 | #FIG 3.2 Produced by xfig version 3.2.5 2 | Landscape 3 | Center 4 | Inches 5 | Letter 6 | 100.00 7 | Single 8 | -2 9 | 1200 2 10 | 5 1 0 1 0 7 100 0 -1 0.000 0 0 1 0 3918.750 2850.000 2850 1125 4050 825 5100 1200 11 | 0 0 1.00 60.00 120.00 12 | 5 1 0 1 0 7 100 0 -1 0.000 0 0 1 0 3938.985 -144.431 5100 1950 3975 2250 2925 2025 13 | 0 0 1.00 60.00 120.00 14 | 5 1 0 1 0 7 100 0 -1 0.000 0 1 1 0 4234.520 2491.142 2400 2250 2700 3525 3525 4200 15 | 0 0 1.00 60.00 120.00 16 | 5 1 2 1 0 7 100 0 -1 3.000 0 0 1 0 4172.873 2668.484 5700 2250 5550 3450 4575 4200 17 | 0 0 1.00 60.00 120.00 18 | 1 3 0 1 0 7 100 0 -1 0.000 1 0.0000 2400 1575 636 636 2400 1575 2850 2025 19 | 1 3 0 1 0 7 100 0 -1 0.000 1 0.0000 4050 4575 636 636 4050 4575 4500 5025 20 | 1 3 0 1 0 7 50 0 -1 0.000 1 0.0000 5625 1575 636 636 5625 1575 6075 2025 21 | 2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2 22 | 0 0 1.00 60.00 120.00 23 | 450 1650 1725 1650 24 | 4 0 0 50 0 18 14 0.0000 4 180 1515 1725 1875 unconnected\001 25 | 4 0 0 50 0 18 14 0.0000 4 180 1215 5025 1725 connected\001 26 | 4 0 0 50 0 18 14 0.0000 4 225 765 5700 3525 close()\001 27 | 4 0 0 50 0 18 14 0.0000 4 225 1425 3375 2550 disconnect()\001 28 | 4 0 0 50 0 18 14 0.0000 4 225 765 1725 3525 close()\001 29 | 4 0 0 50 0 18 14 0.0000 4 180 765 3675 4650 closed\001 30 | 4 0 0 50 0 18 14 0.0000 4 225 1080 3450 600 connect()\001 31 | 4 0 0 50 0 18 14 0.0000 4 180 1680 75 1575 create channel\001 32 | -------------------------------------------------------------------------------- /doc/manual/images/ChannelStates.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/belaban/JGroups/844921a1ef5d7dfe1b0a45f7a3e12cd841bdc8f1/doc/manual/images/ChannelStates.png -------------------------------------------------------------------------------- /doc/manual/images/DrawScreenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/belaban/JGroups/844921a1ef5d7dfe1b0a45f7a3e12cd841bdc8f1/doc/manual/images/DrawScreenshot.png -------------------------------------------------------------------------------- /doc/manual/images/ForkArchitecture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/belaban/JGroups/844921a1ef5d7dfe1b0a45f7a3e12cd841bdc8f1/doc/manual/images/ForkArchitecture.png -------------------------------------------------------------------------------- /doc/manual/images/Message.fig: -------------------------------------------------------------------------------- 1 | #FIG 3.2 Produced by xfig version 3.2.5 2 | Landscape 3 | Center 4 | Inches 5 | Letter 6 | 100.00 7 | Single 8 | -2 9 | 1200 2 10 | 6 525 375 6450 2400 11 | 2 2 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 12 | 600 450 6375 450 6375 1950 600 1950 600 450 13 | 2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 14 | 1350 450 1350 1950 15 | 2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 16 | 2025 450 2025 1950 17 | 2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 18 | 3150 450 3150 1950 19 | 4 0 0 50 -1 18 14 0.0000 4 180 495 675 2325 dest\001 20 | 4 0 0 50 -1 18 14 0.0000 4 135 360 1425 2325 src\001 21 | 4 0 0 50 -1 18 14 0.0000 4 180 930 2175 2325 headers\001 22 | 4 0 0 50 -1 18 14 0.0000 4 240 915 4425 2325 payload\001 23 | -6 24 | -------------------------------------------------------------------------------- /doc/manual/images/Message.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/belaban/JGroups/844921a1ef5d7dfe1b0a45f7a3e12cd841bdc8f1/doc/manual/images/Message.png -------------------------------------------------------------------------------- /doc/manual/images/RELAY.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/belaban/JGroups/844921a1ef5d7dfe1b0a45f7a3e12cd841bdc8f1/doc/manual/images/RELAY.png -------------------------------------------------------------------------------- /doc/manual/images/StompArchitecture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/belaban/JGroups/844921a1ef5d7dfe1b0a45f7a3e12cd841bdc8f1/doc/manual/images/StompArchitecture.png -------------------------------------------------------------------------------- /doc/manual/images/StompProtocol.fig: -------------------------------------------------------------------------------- 1 | #FIG 3.2 Produced by xfig version 3.2.5 2 | Landscape 3 | Center 4 | Inches 5 | Letter 6 | 100.00 7 | Single 8 | -2 9 | 1200 2 10 | 2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 11 | 4950 2025 7575 2025 7575 2850 4950 2850 4950 2025 12 | 2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 13 | 4950 2925 7575 2925 7575 3750 4950 3750 4950 2925 14 | 2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 15 | 4950 3825 7575 3825 7575 4650 4950 4650 4950 3825 16 | 2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 17 | 4950 4725 7575 4725 7575 5550 4950 5550 4950 4725 18 | 2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 19 | 4950 5625 7575 5625 7575 6450 4950 6450 4950 5625 20 | 2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 21 | 4950 6525 7575 6525 7575 7350 4950 7350 4950 6525 22 | 2 4 0 1 0 7 50 -1 -1 0.000 0 0 7 0 0 5 23 | 8325 7800 8325 1650 4425 1650 4425 7800 8325 7800 24 | 2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 2 25 | 1 1 3.00 60.00 120.00 26 | 2400 2400 4800 2400 27 | 4 0 0 50 -1 16 18 0.0000 4 285 1290 5625 7050 Transport\001 28 | 4 0 0 50 -1 16 18 0.0000 4 225 1065 5775 2550 STOMP\001 29 | 4 0 0 50 -1 16 18 0.0000 4 225 1230 5625 4425 NAKACK\001 30 | 4 0 0 50 -1 16 18 0.0000 4 225 840 5700 3525 FRAG\001 31 | 4 0 0 50 -1 16 18 0.0000 4 225 750 5625 6150 PING\001 32 | 4 0 0 50 -1 16 18 0.0000 4 285 1095 5625 5250 FD_ALL\001 33 | 4 0 0 50 -1 16 18 0.0000 4 225 600 3375 2325 TCP\001 34 | 4 0 0 50 -1 16 18 0.0000 4 225 1995 300 2475 STOMP clients\001 35 | -------------------------------------------------------------------------------- /doc/manual/images/StompProtocol.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/belaban/JGroups/844921a1ef5d7dfe1b0a45f7a3e12cd841bdc8f1/doc/manual/images/StompProtocol.png -------------------------------------------------------------------------------- /doc/manual/images/TransportDetails.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/belaban/JGroups/844921a1ef5d7dfe1b0a45f7a3e12cd841bdc8f1/doc/manual/images/TransportDetails.png -------------------------------------------------------------------------------- /doc/manual/images/Tunneling.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/belaban/JGroups/844921a1ef5d7dfe1b0a45f7a3e12cd841bdc8f1/doc/manual/images/Tunneling.png -------------------------------------------------------------------------------- /doc/manual/images/icons/README: -------------------------------------------------------------------------------- 1 | Replaced the plain DocBook XSL admonition icons with Jimmac's DocBook 2 | icons (http://jimmac.musichall.cz/ikony.php3). I dropped transparency 3 | from the Jimmac icons to get round MS IE and FOP PNG incompatibilies. 4 | 5 | Stuart Rackham 6 | -------------------------------------------------------------------------------- /doc/manual/images/icons/callouts/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/belaban/JGroups/844921a1ef5d7dfe1b0a45f7a3e12cd841bdc8f1/doc/manual/images/icons/callouts/1.png -------------------------------------------------------------------------------- /doc/manual/images/icons/callouts/10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/belaban/JGroups/844921a1ef5d7dfe1b0a45f7a3e12cd841bdc8f1/doc/manual/images/icons/callouts/10.png -------------------------------------------------------------------------------- /doc/manual/images/icons/callouts/11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/belaban/JGroups/844921a1ef5d7dfe1b0a45f7a3e12cd841bdc8f1/doc/manual/images/icons/callouts/11.png -------------------------------------------------------------------------------- /doc/manual/images/icons/callouts/12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/belaban/JGroups/844921a1ef5d7dfe1b0a45f7a3e12cd841bdc8f1/doc/manual/images/icons/callouts/12.png -------------------------------------------------------------------------------- /doc/manual/images/icons/callouts/13.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/belaban/JGroups/844921a1ef5d7dfe1b0a45f7a3e12cd841bdc8f1/doc/manual/images/icons/callouts/13.png -------------------------------------------------------------------------------- /doc/manual/images/icons/callouts/14.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/belaban/JGroups/844921a1ef5d7dfe1b0a45f7a3e12cd841bdc8f1/doc/manual/images/icons/callouts/14.png -------------------------------------------------------------------------------- /doc/manual/images/icons/callouts/15.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/belaban/JGroups/844921a1ef5d7dfe1b0a45f7a3e12cd841bdc8f1/doc/manual/images/icons/callouts/15.png -------------------------------------------------------------------------------- /doc/manual/images/icons/callouts/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/belaban/JGroups/844921a1ef5d7dfe1b0a45f7a3e12cd841bdc8f1/doc/manual/images/icons/callouts/2.png -------------------------------------------------------------------------------- /doc/manual/images/icons/callouts/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/belaban/JGroups/844921a1ef5d7dfe1b0a45f7a3e12cd841bdc8f1/doc/manual/images/icons/callouts/3.png -------------------------------------------------------------------------------- /doc/manual/images/icons/callouts/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/belaban/JGroups/844921a1ef5d7dfe1b0a45f7a3e12cd841bdc8f1/doc/manual/images/icons/callouts/4.png -------------------------------------------------------------------------------- /doc/manual/images/icons/callouts/5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/belaban/JGroups/844921a1ef5d7dfe1b0a45f7a3e12cd841bdc8f1/doc/manual/images/icons/callouts/5.png -------------------------------------------------------------------------------- /doc/manual/images/icons/callouts/6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/belaban/JGroups/844921a1ef5d7dfe1b0a45f7a3e12cd841bdc8f1/doc/manual/images/icons/callouts/6.png -------------------------------------------------------------------------------- /doc/manual/images/icons/callouts/7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/belaban/JGroups/844921a1ef5d7dfe1b0a45f7a3e12cd841bdc8f1/doc/manual/images/icons/callouts/7.png -------------------------------------------------------------------------------- /doc/manual/images/icons/callouts/8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/belaban/JGroups/844921a1ef5d7dfe1b0a45f7a3e12cd841bdc8f1/doc/manual/images/icons/callouts/8.png -------------------------------------------------------------------------------- /doc/manual/images/icons/callouts/9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/belaban/JGroups/844921a1ef5d7dfe1b0a45f7a3e12cd841bdc8f1/doc/manual/images/icons/callouts/9.png -------------------------------------------------------------------------------- /doc/manual/images/icons/caution.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/belaban/JGroups/844921a1ef5d7dfe1b0a45f7a3e12cd841bdc8f1/doc/manual/images/icons/caution.png -------------------------------------------------------------------------------- /doc/manual/images/icons/example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/belaban/JGroups/844921a1ef5d7dfe1b0a45f7a3e12cd841bdc8f1/doc/manual/images/icons/example.png -------------------------------------------------------------------------------- /doc/manual/images/icons/home.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/belaban/JGroups/844921a1ef5d7dfe1b0a45f7a3e12cd841bdc8f1/doc/manual/images/icons/home.png -------------------------------------------------------------------------------- /doc/manual/images/icons/important.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/belaban/JGroups/844921a1ef5d7dfe1b0a45f7a3e12cd841bdc8f1/doc/manual/images/icons/important.png -------------------------------------------------------------------------------- /doc/manual/images/icons/next.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/belaban/JGroups/844921a1ef5d7dfe1b0a45f7a3e12cd841bdc8f1/doc/manual/images/icons/next.png -------------------------------------------------------------------------------- /doc/manual/images/icons/note.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/belaban/JGroups/844921a1ef5d7dfe1b0a45f7a3e12cd841bdc8f1/doc/manual/images/icons/note.png -------------------------------------------------------------------------------- /doc/manual/images/icons/prev.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/belaban/JGroups/844921a1ef5d7dfe1b0a45f7a3e12cd841bdc8f1/doc/manual/images/icons/prev.png -------------------------------------------------------------------------------- /doc/manual/images/icons/tip.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/belaban/JGroups/844921a1ef5d7dfe1b0a45f7a3e12cd841bdc8f1/doc/manual/images/icons/tip.png -------------------------------------------------------------------------------- /doc/manual/images/icons/up.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/belaban/JGroups/844921a1ef5d7dfe1b0a45f7a3e12cd841bdc8f1/doc/manual/images/icons/up.png -------------------------------------------------------------------------------- /doc/manual/images/icons/warning.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/belaban/JGroups/844921a1ef5d7dfe1b0a45f7a3e12cd841bdc8f1/doc/manual/images/icons/warning.png -------------------------------------------------------------------------------- /doc/manual/images/network.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/belaban/JGroups/844921a1ef5d7dfe1b0a45f7a3e12cd841bdc8f1/doc/manual/images/network.png -------------------------------------------------------------------------------- /doc/manual/images/wireshark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/belaban/JGroups/844921a1ef5d7dfe1b0a45f7a3e12cd841bdc8f1/doc/manual/images/wireshark.png -------------------------------------------------------------------------------- /doc/tutorial/images/DrawScreenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/belaban/JGroups/844921a1ef5d7dfe1b0a45f7a3e12cd841bdc8f1/doc/tutorial/images/DrawScreenshot.png -------------------------------------------------------------------------------- /doc/tutorial/tutorial.adoc: -------------------------------------------------------------------------------- 1 | = The JGroups tutorial 2 | :author: Bela Ban 3 | :toc: 4 | :icons: 5 | :homepage: http://www.jgroups.org 6 | :source-highlighter: pygments 7 | 8 | Copyright Red Hat 1998 - 2035 9 | 10 | This document is licensed under the 11 | http://creativecommons.org/licenses/by-sa/3.0/us/legalcode["Creative Commons Attribution-ShareAlike (CC-BY-SA) 3.0"] 12 | license. 13 | 14 | 15 | .About the tutorial 16 | This is a short tutorial on how to install JGroups and write a simple application. The goal is to show how to 17 | configure JGroups and how to write a simple application showing the major methods of the API. 18 | 19 | Bela Ban, Kreuzlingen, Switzerland, Nov 2019 20 | 21 | // Push titles down one level. 22 | //:leveloffset: 1 23 | 24 | include::installation.adoc["Installation"] 25 | 26 | include::sampleapp.adoc["Sample application"] 27 | 28 | // Return to normal title levels. 29 | //:leveloffset: 0 30 | 31 | -------------------------------------------------------------------------------- /ivy.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /src/org/jgroups/ChannelListener.java: -------------------------------------------------------------------------------- 1 | package org.jgroups; 2 | 3 | /** 4 | * Allows a listener to be notified when an important channel lifecycle event occurs. 5 | *

6 | * 7 | * Usually clients do not need to implement ChannelListener interface. However, this interface can 8 | * useful in scenarios when an application opens multiple channels and needs to tracks major 9 | * lifecycle events on those channels from a single location or in scenarios when channel is wrapped 10 | * by JGroups building block installed on top of a channel (RpcDispatcher etc) while a client needs 11 | * to be notified about major channel lifecycle events. 12 | * 13 | * @see JChannel#addChannelListener(ChannelListener) 14 | * @see JChannel#removeChannelListener(ChannelListener) 15 | * @see JChannel#clearChannelListeners() 16 | * 17 | * @author Bela Ban 18 | * @since 2.0 19 | * 20 | */ 21 | public interface ChannelListener { 22 | 23 | /** 24 | * Channel has been connected notification callback 25 | * 26 | * @param channel the channel that has been connected 27 | */ 28 | default void channelConnected(JChannel channel) {} 29 | 30 | /** 31 | * Channel has been disconnected notification callback 32 | * 33 | * @param channel the disconnected channel 34 | */ 35 | default void channelDisconnected(JChannel channel) {} 36 | 37 | /** 38 | * Channel has been closed notification callback 39 | * 40 | * @param channel the closed channel 41 | */ 42 | default void channelClosed(JChannel channel) {} 43 | } 44 | -------------------------------------------------------------------------------- /src/org/jgroups/Constructable.java: -------------------------------------------------------------------------------- 1 | package org.jgroups; 2 | 3 | import java.util.function.Supplier; 4 | 5 | /** 6 | * Interface returning a supplier which can be called to create an instance 7 | * @author Bela Ban 8 | * @since 4.0 9 | */ 10 | public interface Constructable { 11 | /** Creates an instance of the class implementing this interface */ 12 | Supplier create(); 13 | } 14 | -------------------------------------------------------------------------------- /src/org/jgroups/Header.java: -------------------------------------------------------------------------------- 1 | 2 | package org.jgroups; 3 | 4 | import org.jgroups.util.SizeStreamable; 5 | 6 | /** 7 | * Header is a JGroups internal base class for all JGroups headers. Client normally do not need to 8 | * interact with headers unless they are developing their custom protocols. 9 | * 10 | * @author Bela Ban 11 | * @since 2.0 12 | */ 13 | public abstract class Header implements SizeStreamable, Constructable

{ 14 | /** The ID of the protocol which added a header to a message. Set externally, e.g. by {@link BaseMessage#putHeader(short,Header)} */ 15 | protected short prot_id; 16 | 17 | public short getProtId() {return prot_id;} 18 | public Header setProtId(short id) {this.prot_id=id; return this;} 19 | 20 | /** Returns the magic-ID. If defined in jg-magic-map.xml, the IDs need to be the same */ 21 | public abstract short getMagicId(); 22 | 23 | public String toString() { 24 | return '[' + getClass().getSimpleName() + "]"; 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/org/jgroups/Lifecycle.java: -------------------------------------------------------------------------------- 1 | package org.jgroups; 2 | 3 | /** 4 | * Interface that defines lifecycle methods. Used by protocols and components 5 | * @author Bela Ban 6 | * @since 5.2 7 | */ 8 | public interface Lifecycle { 9 | 10 | /** 11 | * Called after an instance has been created and before it is started. 12 | * @exception Exception Thrown if the instance cannot be initialized successfully. 13 | */ 14 | default void init() throws Exception {} 15 | 16 | /** 17 | * This method is called after an instance has been initialized. Starts work. 18 | * @exception Exception Thrown if the instance cannot be started successfully. 19 | */ 20 | default void start() throws Exception {} 21 | 22 | /** 23 | * Called before an instance is stopped; stops work. 24 | */ 25 | default void stop() {} 26 | 27 | 28 | /** 29 | * Called after an instance has been stopped. Cleans up resources 30 | */ 31 | default void destroy() {} 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/org/jgroups/NullAddress.java: -------------------------------------------------------------------------------- 1 | package org.jgroups; 2 | 3 | import java.io.DataInput; 4 | import java.io.DataOutput; 5 | import java.io.IOException; 6 | 7 | public class NullAddress implements Address { 8 | @Override 9 | public int compareTo(Address that) { 10 | if (that instanceof NullAddress) { 11 | return 0; 12 | } else { 13 | return -1; 14 | } 15 | } 16 | 17 | public boolean equals(Object obj) { 18 | return obj instanceof NullAddress; 19 | } 20 | 21 | @Override 22 | public int serializedSize() { 23 | return 0; 24 | } 25 | 26 | @Override 27 | public void writeTo(DataOutput out) throws IOException { 28 | 29 | } 30 | 31 | @Override 32 | public void readFrom(DataInput in) throws IOException, ClassNotFoundException { 33 | 34 | } 35 | 36 | public String toString() { 37 | return "null"; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/org/jgroups/PhysicalAddress.java: -------------------------------------------------------------------------------- 1 | package org.jgroups; 2 | 3 | import org.jgroups.util.UUID; 4 | 5 | import java.net.InetAddress; 6 | import java.net.InetSocketAddress; 7 | import java.net.SocketAddress; 8 | 9 | /** 10 | * Represents a physical (as opposed to logical) address 11 | * 12 | * @see UUID 13 | * @since 2.6 14 | * @author Bela Ban 15 | */ 16 | public interface PhysicalAddress extends Address { 17 | String printIpAddress(); 18 | default SocketAddress getSocketAddress() {return new InetSocketAddress(getIpAddress(), getPort());} 19 | InetAddress getIpAddress(); 20 | int getPort(); 21 | } 22 | -------------------------------------------------------------------------------- /src/org/jgroups/StateTransferException.java: -------------------------------------------------------------------------------- 1 | package org.jgroups; 2 | 3 | /** 4 | * {@code StateTransferException} is thrown to indicate a failure of a state transfer between 5 | * cluster members. 6 | *

7 | * 8 | * @author Vladimir Blagojevic 9 | * @since 2.6 10 | * 11 | */ 12 | public class StateTransferException extends Exception { 13 | private static final long serialVersionUID=-4070956583392020498L; 14 | 15 | public StateTransferException(){ 16 | } 17 | 18 | public StateTransferException(String reason){ 19 | super(reason); 20 | } 21 | 22 | public StateTransferException(String reason,Throwable cause) { 23 | super(reason, cause); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/org/jgroups/SuspectedException.java: -------------------------------------------------------------------------------- 1 | 2 | package org.jgroups; 3 | 4 | /** 5 | * Thrown if a message is sent to a suspected member. 6 | * 7 | * @since 2.0 8 | * @author Bela Ban 9 | */ 10 | public class SuspectedException extends Exception { 11 | final Object suspect; 12 | 13 | private static final long serialVersionUID=-6663279911010545655L; 14 | 15 | public SuspectedException() {this.suspect=null;} 16 | public SuspectedException(Object suspect) {this.suspect=suspect;} 17 | 18 | public String toString() {return "SuspectedException";} 19 | } 20 | -------------------------------------------------------------------------------- /src/org/jgroups/UnreachableException.java: -------------------------------------------------------------------------------- 1 | package org.jgroups; 2 | 3 | /** 4 | * Thrown if member in different site cannot be contacted; used by RELAY2 5 | * 6 | * @since 3.2 7 | * @author Bela Ban 8 | */ 9 | public class UnreachableException extends RuntimeException { 10 | private static final long serialVersionUID=3370509508879095097L; 11 | protected final Address member; 12 | 13 | public UnreachableException(Address member) { 14 | super("UnreachableException"); 15 | this.member=member; 16 | } 17 | 18 | public UnreachableException(String msg, Address member) { 19 | super(msg); 20 | this.member=member; 21 | } 22 | 23 | 24 | public String toString() { 25 | return getMessage() + ": member=" + member; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/org/jgroups/UpHandler.java: -------------------------------------------------------------------------------- 1 | 2 | package org.jgroups; 3 | 4 | import org.jgroups.util.MessageBatch; 5 | 6 | /** 7 | * Provides a hook to hijack all events received by a certain channel which has installed this UpHandler.

8 | * Client usually never need to implement this interface and it is mostly used by JGroups building blocks. 9 | * @since 2.0 10 | * @author Bela Ban 11 | */ 12 | public interface UpHandler { 13 | 14 | UpHandler setLocalAddress(Address a); 15 | 16 | Object up(Event evt); 17 | 18 | Object up(Message msg); 19 | 20 | default void up(MessageBatch batch) { 21 | for(Message msg: batch) { 22 | try { 23 | up(msg); 24 | } 25 | catch(Throwable ignored) { 26 | } 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/org/jgroups/annotations/Component.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.annotations; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | 9 | /** 10 | * Tags components inside of protocols. Used to generate the schema, configure a component via XML and expose 11 | * attributes/operations via JMX or probe. See https://issues.redhat.com/browse/JGRP-2567 for details 12 | * @author Bela Ban 13 | * @since 5.2 14 | */ 15 | @Retention(RetentionPolicy.RUNTIME) 16 | @Target( { ElementType.METHOD, ElementType.FIELD }) 17 | public @interface Component { 18 | 19 | String name() default ""; 20 | 21 | String description() default ""; 22 | 23 | String deprecatedMessage() default ""; 24 | } 25 | 26 | 27 | -------------------------------------------------------------------------------- /src/org/jgroups/annotations/Experimental.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.annotations; 2 | 3 | import java.lang.annotation.Target; 4 | import java.lang.annotation.ElementType; 5 | import java.lang.annotation.Retention; 6 | import java.lang.annotation.RetentionPolicy; 7 | 8 | /** 9 | * Elements annotated with this annotation are experimental and may get removed from the distribution at any time 10 | * @author Bela Ban 11 | */ 12 | @Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD, ElementType.PACKAGE}) 13 | @Retention(RetentionPolicy.RUNTIME) 14 | public @interface Experimental { 15 | String comment() default ""; 16 | } 17 | -------------------------------------------------------------------------------- /src/org/jgroups/annotations/GuardedBy.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.annotations; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * Copyright (c) 2005 Brian Goetz and Tim Peierls 10 | * Released under the Creative Commons Attribution License 11 | * (http://creativecommons.org/licenses/by/2.5) 12 | * Official home: http://www.jcip.net 13 | * 14 | * Adopted from Java Concurrency in Practice. This annotation defines the monitor that protects the variable 15 | * annotated by @GuardedBy, e.g. @GuardedBy("lock") or @GuardedBy("this") 16 | * @author Bela Ban 17 | */ 18 | @Target({ElementType.FIELD, ElementType.METHOD}) 19 | @Retention(RetentionPolicy.SOURCE) 20 | public @interface GuardedBy { 21 | String value(); 22 | } 23 | -------------------------------------------------------------------------------- /src/org/jgroups/annotations/Immutable.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.annotations; 2 | 3 | import java.lang.annotation.Target; 4 | import java.lang.annotation.ElementType; 5 | import java.lang.annotation.Retention; 6 | import java.lang.annotation.RetentionPolicy; 7 | 8 | /** 9 | * Copyright (c) 2005 Brian Goetz and Tim Peierls 10 | * Released under the Creative Commons Attribution License 11 | * (http://creativecommons.org/licenses/by/2.5) 12 | * Official home: http://www.jcip.net 13 | * 14 | * Adopted from Java Concurrency in Practice. This annotation defines an immutable class, ie. a class whose 15 | * instances cannot be modified after creation 16 | * @author Bela Ban 17 | */ 18 | @Target({ElementType.TYPE}) 19 | @Retention(RetentionPolicy.SOURCE) 20 | public @interface Immutable { 21 | } 22 | -------------------------------------------------------------------------------- /src/org/jgroups/annotations/LocalAddress.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.annotations; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * This is an assertion, checked at startup time. It ensures that the field this annotation is on is (1) an InetAddress 10 | * and (2) a valid address on a local network interface 11 | * @author Bela Ban 12 | * @since 2.11.2 13 | */ 14 | @Retention(RetentionPolicy.RUNTIME) 15 | @Target(ElementType.FIELD) 16 | public @interface LocalAddress { 17 | } 18 | 19 | -------------------------------------------------------------------------------- /src/org/jgroups/annotations/MBean.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.annotations; 2 | import java.lang.annotation.*; 3 | 4 | /** 5 | * Optional annotation that exposes all public methods in the class hierarchy (excluding Object) as MBean operations. 6 | * All methods are exposed if and only if exposeAll attribute is true.
7 | * 8 | * If a more fine grained MBean attribute and operation exposure is needed, do not use @MBean annotation but annotate 9 | * fields and public methods directly using @ManagedOperation and @ManagedAttribute annotations. 10 | * @author Chris Mills 11 | */ 12 | 13 | @Retention(RetentionPolicy.RUNTIME) 14 | @Target( { ElementType.TYPE }) 15 | @Inherited 16 | public @interface MBean { 17 | String objectName() default ""; 18 | boolean exposeAll() default false; 19 | String description() default ""; 20 | } 21 | -------------------------------------------------------------------------------- /src/org/jgroups/annotations/ManagedAttribute.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.annotations; 2 | 3 | import org.jgroups.conf.AttributeType; 4 | 5 | import java.lang.annotation.ElementType; 6 | import java.lang.annotation.Retention; 7 | import java.lang.annotation.RetentionPolicy; 8 | import java.lang.annotation.Target; 9 | import java.util.concurrent.TimeUnit; 10 | 11 | /** 12 | * Indicates that a public method or a field (any visibility) in 13 | * an MBean class defines an MBean attribute. This annotation can 14 | * be applied to either a field or a public setter and/or getter 15 | * method of a public class that is itself is optionally annotated 16 | * with an @MBean annotation, or inherits such an annotation from 17 | * a superclass. 18 | * 19 | * @author Chris Mills 20 | */ 21 | 22 | @Retention(RetentionPolicy.RUNTIME) 23 | @Target( { ElementType.METHOD, ElementType.FIELD }) 24 | public @interface ManagedAttribute { 25 | String description() default ""; 26 | 27 | String name() default ""; 28 | 29 | boolean writable() default false; 30 | 31 | /* Defines the type, used for pretty printing */ 32 | AttributeType type() default AttributeType.UNDEFINED; 33 | 34 | /** Only used if type is TIME */ 35 | TimeUnit unit() default TimeUnit.MILLISECONDS; 36 | } 37 | -------------------------------------------------------------------------------- /src/org/jgroups/annotations/ManagedOperation.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.annotations; 2 | 3 | import java.lang.annotation.*; 4 | 5 | /** 6 | * Indicates that a method in an MBean class defines an MBean 7 | * operation. @ManagedOperation annotation can be applied to a 8 | * public method of a public class that is itself optionally 9 | * annotated with an @MBean annotation, or inherits such an 10 | * annotation from a superclass. 11 | * 12 | * @author Chris Mills 13 | */ 14 | 15 | 16 | @Retention(RetentionPolicy.RUNTIME) 17 | @Target( { ElementType.METHOD }) 18 | public @interface ManagedOperation { 19 | String description() default ""; 20 | } 21 | -------------------------------------------------------------------------------- /src/org/jgroups/annotations/RecommendedForUpgrade.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.annotations; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * Protocols annotated with this annotation should upgrade to a newer version (e.g. UNICAST -> UNICAST3) 10 | * @author Bela Ban 11 | */ 12 | @Target({ElementType.TYPE}) 13 | @Retention(RetentionPolicy.RUNTIME) 14 | public @interface RecommendedForUpgrade { 15 | } 16 | -------------------------------------------------------------------------------- /src/org/jgroups/annotations/Unsupported.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.annotations; 2 | 3 | import java.lang.annotation.Target; 4 | import java.lang.annotation.ElementType; 5 | import java.lang.annotation.Retention; 6 | import java.lang.annotation.RetentionPolicy; 7 | 8 | /** 9 | * Elements annotated with this annotation are unsupported and may get removed from the distribution at any time 10 | * @author Bela Ban 11 | */ 12 | @Target({ElementType.TYPE, ElementType.METHOD, ElementType.PACKAGE}) 13 | @Retention(RetentionPolicy.RUNTIME) 14 | public @interface Unsupported { 15 | String comment() default ""; 16 | } 17 | -------------------------------------------------------------------------------- /src/org/jgroups/annotations/XmlAttribute.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.annotations; 2 | 3 | 4 | import java.lang.annotation.ElementType; 5 | import java.lang.annotation.Retention; 6 | import java.lang.annotation.RetentionPolicy; 7 | import java.lang.annotation.Target; 8 | 9 | /** 10 | * Annotation to add attributes to the schema created by {@link org.jgroups.util.XMLSchemaGenerator}. Example:
11 | *

12 |  * {@literal @}XmlAttribute(attrs={"auth_value", "demo_token})
13 |  * 
14 | * This results in the following schema fragment: 15 | *
16 |  *     <xs:attribute name="auth_value" type="xs:string"/>
17 |        <xs:attribute name="demo_token" type="xs:string"/>
18 |  * 
19 | * @author Bela Ban 20 | * @since 3.5 21 | */ 22 | @Retention(value=RetentionPolicy.RUNTIME) 23 | @Target(value=ElementType.TYPE) 24 | public @interface XmlAttribute { 25 | String[] attrs() default {}; 26 | } 27 | -------------------------------------------------------------------------------- /src/org/jgroups/annotations/XmlElement.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.annotations; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * Annotation to generate an element in the schema created by {@link org.jgroups.util.XMLSchemaGenerator}. Example:

10 | *

11 |  * {@literal @}XmlElement(name="fork-stacks" type="ForkStacksType")
12 |  * 
13 | * This results in the following schema fragment: 14 | *
15 |  *     <xs:element name="fork-stacks" type="ForkStacksType"/>
16 |  * 
17 | * @author Bela Ban 18 | * @since 3.5 19 | */ 20 | @Retention(value=RetentionPolicy.RUNTIME) 21 | @Target(value=ElementType.TYPE) 22 | public @interface XmlElement { 23 | String name(); 24 | String type(); 25 | } 26 | -------------------------------------------------------------------------------- /src/org/jgroups/annotations/XmlInclude.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.annotations; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * Used to include other schemas by {@link org.jgroups.util.XMLSchemaGenerator}. Example: 10 | *
11 |  *     {@literal @}XmlInclude(schema="relay.xsd",type=Type.IMPORT,namespace="urn:jgroups:relay:1.0",alias="relay")
12 |  * 
13 | * results in the following include in the schema element: 14 | *
15 |  *     <xs:schema... xmlns:relay="urn:jgroups:relay:1.0" />
16 |  *     ...
17 |  *     <xs:import schemaLocation="fork-stacks.xsd" namespace="urn:jgroups:relay:1.0" />
18 |  * 
19 | * @author Bela Ban 20 | * @since 3.5 21 | */ 22 | @Retention(value=RetentionPolicy.RUNTIME) 23 | @Target(value=ElementType.TYPE) 24 | public @interface XmlInclude { 25 | Type type() default Type.INCLUDE; 26 | String[] schema() default {}; 27 | String namespace() default ""; // only used if type == IMPORT 28 | String alias() default ""; // only used if type == IMPORT 29 | 30 | enum Type {INCLUDE, IMPORT, EMBED}; 31 | } 32 | -------------------------------------------------------------------------------- /src/org/jgroups/blocks/MethodInvoker.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.blocks; 2 | 3 | /** 4 | * Can be used by {@link RpcDispatcher} / {@link MethodCall} to invoke a method against a given target object 5 | * @author Bela Ban 6 | * @since 4.1.0 7 | */ 8 | public interface MethodInvoker { 9 | 10 | /** 11 | * An implementation invokes a method associated with a given ID and the given args against a target object 12 | * @param target The object against which to invoke the method 13 | * @param method_id The ID of the method. The implementation must assign unique IDs and associate them somehow 14 | * with a method to invoke 15 | * @param args The arguments of the invocation 16 | * @return The result. It may be null if a method returns void 17 | * @throws Exception Thrown if the invocation threw an exception. The real exception may be wrapped in an 18 | * {@link java.lang.reflect.InvocationTargetException}. 19 | */ 20 | Object invoke(Object target, short method_id, Object[] args) throws Exception; 21 | } 22 | -------------------------------------------------------------------------------- /src/org/jgroups/blocks/MethodLookup.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.blocks; 2 | 3 | import java.lang.reflect.Method; 4 | 5 | /** 6 | * @author Bela Ban 7 | */ 8 | public interface MethodLookup { 9 | Method findMethod(short id); 10 | } 11 | -------------------------------------------------------------------------------- /src/org/jgroups/blocks/ReplicatedMap.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.blocks; 2 | 3 | import java.util.Map; 4 | import java.util.concurrent.ConcurrentMap; 5 | 6 | /** 7 | * @author Bela Ban 8 | */ 9 | public interface ReplicatedMap extends ConcurrentMap { 10 | V _put(K key, V value); 11 | 12 | void _putAll(Map map); 13 | 14 | void _clear(); 15 | 16 | V _remove(K key); 17 | 18 | V _putIfAbsent(K key, V value); 19 | 20 | boolean _remove(K key, V value); 21 | 22 | boolean _replace(K key, V oldValue, V newValue); 23 | 24 | V _replace(K key, V value); 25 | } 26 | -------------------------------------------------------------------------------- /src/org/jgroups/blocks/RequestHandler.java: -------------------------------------------------------------------------------- 1 | 2 | package org.jgroups.blocks; 3 | 4 | 5 | import org.jgroups.Message; 6 | 7 | 8 | public interface RequestHandler { 9 | 10 | /** 11 | * Processes a request synchronously, ie. on the thread invoking this handler 12 | * @param msg the message containing the request 13 | * @return the object, rceeived as result, or null (void method) 14 | */ 15 | Object handle(Message msg) throws Exception; 16 | 17 | /** 18 | * Processes a request asynchronously. This could be done (for example) by dispatching this to a thread pool. 19 | * When done, if a response is needed (e.g. in case of a sync RPC), {@link Response#send(Object,boolean)} should 20 | * be called. 21 | * @param request The request 22 | * @param response The response implementation. Contains information needed to send the reply (e.g. a request ID). 23 | * If no response is required, e.g. because this is an asynchronous RPC, then response will be null. 24 | * @throws Exception If an exception is thrown (e.g. in case of an issue submitting the request to a thread pool, 25 | * the exception will be taken as return value and will be sent as a response. In this case, 26 | * {@link Response#send(Object,boolean)} must not be called 27 | */ 28 | default void handle(Message request, Response response) throws Exception { 29 | throw new UnsupportedOperationException(); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/org/jgroups/blocks/ResponseMode.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.blocks; 2 | 3 | /** 4 | * Enum capturing the various response modes for RPCs 5 | * @author Bela Ban 6 | * @since 3.0 7 | */ 8 | public enum ResponseMode { 9 | /** Returns the first response received */ 10 | GET_FIRST, 11 | 12 | /** return all responses */ 13 | GET_ALL, 14 | 15 | /** return no response (async call) */ 16 | GET_NONE 17 | } 18 | -------------------------------------------------------------------------------- /src/org/jgroups/blocks/RspFilter.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.blocks; 2 | 3 | import org.jgroups.Address; 4 | 5 | /** 6 | * Interface defining when a group request is done. This allows for termination of a group request based on 7 | * logic implemented by the caller. Example: caller uses mode GET_FIRST plus a RspFilter implementation. Here, the 8 | * request will not return (assuming timeout is 0) when the first response has been received, but when the filter 9 | * passed 10 | * @author Bela Ban 11 | */ 12 | public interface RspFilter { 13 | 14 | 15 | /** 16 | * Determines whether a response from a given sender should be added to the response list of the request 17 | * @param response The response (usually a serializable value), may also be a Throwable 18 | * @param sender The sender of response 19 | * @return True if we should add the response to the response list ({@link org.jgroups.util.RspList}) of a request, 20 | * otherwise false. In the latter case, we don't add the response to the response list. 21 | */ 22 | boolean isAcceptable(Object response, Address sender); 23 | 24 | /** 25 | * Right after calling {@link #isAcceptable(Object, org.jgroups.Address)}, this method is called to see whether 26 | * we are done with the request and can unblock the caller 27 | * @return False if the request is done, otherwise true 28 | */ 29 | boolean needMoreResponses(); 30 | } 31 | -------------------------------------------------------------------------------- /src/org/jgroups/blocks/atomic/BaseCounter.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.blocks.atomic; 2 | 3 | /** 4 | * Base interface for all counters 5 | * 6 | * @author Bela Ban 7 | * @since 5.2 8 | */ 9 | public interface BaseCounter { 10 | 11 | /** 12 | * @return The counter's name. 13 | */ 14 | String getName(); 15 | 16 | /** 17 | * Returns a {@link SyncCounter} wrapper for this instance. If this counter is already synchronous, then this 18 | * counter instance is returned (no-op) 19 | * 20 | * @return The {@link SyncCounter} instance; 21 | */ 22 | SyncCounter sync(); 23 | 24 | /** 25 | * Returns an {@link AsyncCounter} wrapper for this instance. If this counter is already asynchronous, then 26 | * this counter instance is returned (no-op) 27 | * 28 | * @return The {@link AsyncCounter} instance. 29 | */ 30 | AsyncCounter async(); 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/org/jgroups/blocks/atomic/Counter.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.blocks.atomic; 2 | 3 | /** 4 | * @author Bela Ban 5 | * @since 3.0.0 6 | * @deprecated Since 5.2 and to be removed in a future version. Use {@link SyncCounter} instead. 7 | */ 8 | @Deprecated 9 | public interface Counter extends SyncCounter { 10 | 11 | @Override 12 | default long compareAndSwap(long expect, long update) { 13 | // throw exception by default to keep backwards compatibility 14 | throw new UnsupportedOperationException(); 15 | } 16 | 17 | @Override 18 | default AsyncCounter async() { 19 | // throw exception by default to keep backwards compatibility 20 | throw new UnsupportedOperationException(); 21 | } 22 | } 23 | 24 | -------------------------------------------------------------------------------- /src/org/jgroups/blocks/atomic/CounterFunction.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.blocks.atomic; 2 | 3 | import org.jgroups.util.Streamable; 4 | 5 | import java.util.function.Function; 6 | 7 | /** 8 | * A function to update {@link AsyncCounter} or {@link SyncCounter}. 9 | * 10 | * The {@link CounterView} contains a view of the counter's value where this function is able to modify. 11 | * 12 | * @author Pedro Ruivo 13 | * @since 5.2 14 | * @see CounterView 15 | * @see Streamable 16 | */ 17 | public interface CounterFunction extends Function, Streamable { 18 | } 19 | -------------------------------------------------------------------------------- /src/org/jgroups/blocks/atomic/CounterView.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.blocks.atomic; 2 | 3 | /** 4 | * A view representing the counter's state. 5 | * 6 | * @author Pedro Ruivo 7 | * @see CounterFunction 8 | * @since 5.2 9 | */ 10 | public interface CounterView { 11 | 12 | /** 13 | * @return The counter's value. 14 | */ 15 | long get(); 16 | 17 | /** 18 | * Sets the counter's value. 19 | * 20 | * @param value The new value. 21 | */ 22 | void set(long value); 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/org/jgroups/blocks/cs/Client.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.blocks.cs; 2 | 3 | import org.jgroups.Address; 4 | 5 | import java.nio.ByteBuffer; 6 | 7 | /** 8 | * Defines common operations for clients (TCP or NIO) 9 | * @author Bela Ban 10 | * @since 3.6.5 11 | */ 12 | public interface Client { 13 | Address localAddress(); 14 | 15 | Address remoteAddress(); 16 | 17 | boolean isConnected(); 18 | 19 | /** Sends data to the remote server. The server's address must have been set before. */ 20 | void send(byte[] data, int offset, int length) throws Exception; 21 | 22 | /** Sends data to the remote server. The server's address must have been set before. */ 23 | void send(ByteBuffer data) throws Exception; 24 | } 25 | -------------------------------------------------------------------------------- /src/org/jgroups/blocks/cs/ConnectionListener.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.blocks.cs; 2 | 3 | /** 4 | * @author Bela Ban 5 | * @since 3.6.5 6 | */ 7 | public interface ConnectionListener { 8 | void connectionClosed(Connection conn); 9 | void connectionEstablished(Connection conn); 10 | } 11 | -------------------------------------------------------------------------------- /src/org/jgroups/blocks/cs/ReceiverAdapter.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.blocks.cs; 2 | 3 | import org.jgroups.Address; 4 | 5 | /** 6 | * An impl of {@link Receiver}. Will get removed with the switch to Java 8; instead we'll use a default impl in Receiver 7 | * @author Bela Ban 8 | * @since 3.6.5 9 | */ 10 | public class ReceiverAdapter implements Receiver { 11 | public void receive(Address sender, byte[] buf, int offset, int length) { 12 | 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /src/org/jgroups/blocks/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Provides building blocks that are layered on top of channels. 4 | Most of them do not even need a channel, all they need is a class 5 | that implements interface Transport (channels do). 6 | This enables them to work on any type of group transport that obeys this interface. 7 | Building blocks can be used instead of channels whenever a higher-level interface 8 | is required. Whereas channels are simple socket-like constructs, building blocks 9 | may offer a far more sophisticated interface. In some cases, building blocks offer 10 | access to the underlying channel, so that - if the building block at hand does not 11 | offer a certain functionality - the channel can be accessed directly. 12 | 13 | -------------------------------------------------------------------------------- /src/org/jgroups/conf/AttributeType.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.conf; 2 | 3 | /** 4 | * Defines the type of an attribute exposed by {@link org.jgroups.annotations.ManagedAttribute} or 5 | * {@link org.jgroups.annotations.Property}. This is used to format the output in a more legible way.
6 | * JIRA: https://issues.redhat.com/browse/JGRP-2457. 7 | * @author Bela Ban 8 | * @since 5.0.0 9 | */ 10 | public enum AttributeType { 11 | UNDEFINED, 12 | TIME, 13 | BYTES, 14 | SCALAR 15 | } 16 | -------------------------------------------------------------------------------- /src/org/jgroups/conf/PropertyConverter.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.conf; 2 | 3 | import org.jgroups.annotations.Property; 4 | import org.jgroups.util.StackType; 5 | 6 | /** 7 | * Represents a property converter that takes an input from corresponding field 8 | * in JGroups properties file as a String and converts it to a matching Java 9 | * type. 10 | * 11 | * @see PropertyConverters 12 | * @see Property 13 | * 14 | * @author Vladimir Blagojevic 15 | */ 16 | public interface PropertyConverter { 17 | Object convert(Object obj, Class propertyFieldType, String propertyName, String propertyValue, 18 | boolean check_scope, StackType ip_version) throws Exception; 19 | 20 | default Object convert(Property annotation, Object obj, Class propertyFieldType, String propertyName, String propertyValue, 21 | boolean check_scope, StackType ip_version) throws Exception { 22 | return convert(obj, propertyFieldType, propertyName, propertyValue, check_scope, ip_version); 23 | } 24 | 25 | /** 26 | * Converts the value to a string. The default is to simply invoke Object.toString(), however, some objects need 27 | * to be printed specially, e.g. a long array etc. 28 | * @param value 29 | * @return 30 | */ 31 | String toString(Object value); 32 | 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/org/jgroups/conf/ProtocolStackConfigurator.java: -------------------------------------------------------------------------------- 1 | 2 | package org.jgroups.conf; 3 | 4 | import org.jgroups.stack.Protocol; 5 | import org.jgroups.stack.ProtocolHook; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * @author Filip Hanik (filip@filip.net) 11 | * @author Bela Ban 12 | * @version 1.0 13 | */ 14 | 15 | public interface ProtocolStackConfigurator extends ProtocolHook { 16 | String getProtocolStackString(); 17 | List getProtocolStack(); 18 | 19 | /** 20 | * Invoked after each {@link Protocol} is instantiated and before {@link Protocol#init()} is invoked. 21 | * 22 | * @param prot The protocol that was created. 23 | * @throws Exception If any exception occurred during method invocation. 24 | */ 25 | @Override 26 | default void afterCreation(Protocol prot) throws Exception { 27 | //no-op by default 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/org/jgroups/conf/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Provides ways to configure a protocol stack. 4 | 5 | -------------------------------------------------------------------------------- /src/org/jgroups/demos/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Provides demonstrations of JGroups functionality. 4 | 5 | -------------------------------------------------------------------------------- /src/org/jgroups/fork/ForkProtocol.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.fork; 2 | 3 | import org.jgroups.Event; 4 | import org.jgroups.Message; 5 | import org.jgroups.protocols.FORK; 6 | import org.jgroups.stack.Protocol; 7 | 8 | /** 9 | * Acts as bottom protocol of a fork-stack. Knows about the fork-stack-id and inserts it into the ForkHeader of messages 10 | * sent down the stack 11 | * @author Bela Ban 12 | * @since 3.4 13 | */ 14 | public class ForkProtocol extends Protocol { 15 | protected final String fork_stack_id; 16 | 17 | public ForkProtocol(String fork_stack_id) { 18 | this.fork_stack_id=fork_stack_id; 19 | } 20 | 21 | 22 | public Object down(Event evt) { 23 | switch(evt.getType()) { 24 | case Event.VIEW_CHANGE: 25 | case Event.CONNECT: 26 | case Event.CONNECT_WITH_STATE_TRANSFER: 27 | case Event.DISCONNECT: 28 | return null; // don't propagate further down, this is only important for the main stack 29 | } 30 | return down_prot.down(evt); 31 | } 32 | 33 | public Object down(Message msg) { 34 | FORK.ForkHeader hdr=msg.getHeader(FORK.ID); 35 | if(hdr == null) 36 | msg.putHeader(FORK.ID, hdr=new FORK.ForkHeader(fork_stack_id, null)); 37 | else 38 | hdr.setForkStackId(fork_stack_id); 39 | return down_prot.down(msg); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/org/jgroups/fork/UnknownForkHandler.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.fork; 2 | 3 | import org.jgroups.Message; 4 | 5 | /** 6 | * Allows a user of fork to define the handling of a message for which no fork stack or fork channel exists. 7 | * @author Paul Ferraro 8 | */ 9 | public interface UnknownForkHandler { 10 | 11 | /** 12 | * Handle a message that refers to an unknown fork stack 13 | * @param message an incoming message 14 | * @param forkStackId the identifier of a fork stack 15 | * @return the result of the up handler 16 | */ 17 | Object handleUnknownForkStack(Message message, String forkStackId); 18 | 19 | /** 20 | * Handle a message that refers to an unknown fork channel 21 | * @param message an incoming message 22 | * @param forkChannelId the identifier of a fork channel 23 | * @return the result of the up handler 24 | */ 25 | Object handleUnknownForkChannel(Message message, String forkChannelId); 26 | } 27 | -------------------------------------------------------------------------------- /src/org/jgroups/logging/CustomLogFactory.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.logging; 2 | 3 | /** 4 | * An extension interface allowing to plug in a custom log provider. 5 | */ 6 | public interface CustomLogFactory { 7 | 8 | Log getLog(Class clazz); 9 | 10 | Log getLog(String category); 11 | } 12 | -------------------------------------------------------------------------------- /src/org/jgroups/overview.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | JGroups is a toolkit for reliable group communication. Processes 5 | can join a group, send messages to all members or single members, and 6 | receive messages from members in the group. The system keeps track of 7 | the members in every group, and notifies group members when a new 8 | member joins, or an existing member leaves or crashes. A group is 9 | identified by its name. Groups do not have to be created explicitly; 10 | when a process joins a non-existing group, that group will be created 11 | automatically. Member processes of a group can be located on the same 12 | host, within the same LAN, or across a WAN. A member can be part of 13 | multiple groups. 14 | 15 | -------------------------------------------------------------------------------- /src/org/jgroups/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Provides top-level public JGroups classes such as Channel, Message, etc. 4 | 5 | -------------------------------------------------------------------------------- /src/org/jgroups/protocols/Bundler.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.protocols; 2 | 3 | import org.jgroups.Message; 4 | import org.jgroups.View; 5 | 6 | /** 7 | * Pluggable way to collect messages and send them as batches 8 | * @author Bela Ban 9 | * @since 4.0 10 | */ 11 | public interface Bundler { 12 | 13 | 14 | /** 15 | * Called after creation of the bundler 16 | * @param transport the transport, for further reference 17 | */ 18 | default void init(@SuppressWarnings("UnusedParameters") TP transport) {} 19 | /** Called after {@link #init(TP)} */ 20 | void start(); 21 | void stop(); 22 | void send(Message msg) throws Exception; 23 | @SuppressWarnings("UnusedParameters") 24 | default void viewChange(View view) {} 25 | 26 | /** The number of unsent messages in the bundler */ 27 | int size(); 28 | 29 | /** 30 | * If the bundler has a queue and it should be managed by a queuing discipline (like Random Early Detection), then 31 | * return the number of elements in the queue, else -1. In the latter case, the queue won't be managed.
32 | * This method needs to be fast as it might get called on every message to be sent. 33 | */ 34 | int getQueueSize(); 35 | 36 | /** 37 | * If the bundler implementation supports a capacity (e.g. {@link RingBufferBundler}, then return it, else return -1 38 | */ 39 | default int getCapacity() {return -1;} 40 | 41 | /** Maximum number of bytes for messages to be queued until they are sent */ 42 | int getMaxSize(); 43 | default Bundler setMaxSize(int s) {return this;} 44 | 45 | default void renameThread() {} 46 | 47 | default void resetStats() {} 48 | } 49 | -------------------------------------------------------------------------------- /src/org/jgroups/protocols/CertficateCNMatcher.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.protocols; 2 | 3 | import javax.net.ssl.SSLPeerUnverifiedException; 4 | import javax.net.ssl.SSLSession; 5 | import java.security.Principal; 6 | import java.util.regex.Matcher; 7 | import java.util.regex.Pattern; 8 | 9 | /** 10 | * Sample implementation of {@link org.jgroups.protocols.SSL_KEY_EXCHANGE.SessionVerifier} 11 | * @author Bela Ban 12 | * @since 4.0.6 13 | */ 14 | public class CertficateCNMatcher implements SSL_KEY_EXCHANGE.SessionVerifier { 15 | protected String cn_name; 16 | protected Pattern pattern; 17 | 18 | public void init(String arg) { 19 | cn_name=arg; 20 | pattern=Pattern.compile(cn_name); 21 | } 22 | 23 | public void verify(SSLSession session) throws SecurityException { 24 | Principal principal=null; 25 | try { 26 | principal=session.getPeerPrincipal(); 27 | String name=principal.getName(); 28 | Matcher m=pattern.matcher(name); 29 | boolean find=m.find(); 30 | if(!find) 31 | throw new SecurityException(String.format("pattern '%s' not found in peer certificate '%s'", 32 | cn_name, name)); 33 | else 34 | System.out.printf("** pattern '%s' found in peer certificate '%s'\n", 35 | cn_name, name); 36 | } 37 | catch(SSLPeerUnverifiedException e) { 38 | throw new SecurityException(e); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/org/jgroups/protocols/DETECT_LOOPBACKS.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.protocols; 2 | 3 | import org.jgroups.Message; 4 | import org.jgroups.annotations.MBean; 5 | import org.jgroups.annotations.Property; 6 | import org.jgroups.stack.Protocol; 7 | 8 | import java.util.Objects; 9 | import java.util.concurrent.atomic.AtomicInteger; 10 | 11 | /** 12 | * Detects unicast loopbacks: messages where dest == local address 13 | * @author Bela Ban 14 | * @since 5.1.6 15 | */ 16 | @MBean(description="Detects unicast loopback messages") 17 | public class DETECT_LOOPBACKS extends Protocol { 18 | 19 | @Property(description="Prints to stdout") 20 | protected boolean print_to_stdout=true; 21 | protected final AtomicInteger count=new AtomicInteger(); 22 | 23 | public Object down(Message msg) { 24 | if(Objects.equals(local_addr, msg.getDest())) { 25 | String s=String.format("[%d] %s, headers: %s", count.getAndIncrement(), msg, msg.getHeaders()); 26 | if(print_to_stdout) 27 | System.out.printf("%s\n", s); 28 | else if(log.isTraceEnabled()) 29 | log.trace(s); 30 | } 31 | return down_prot.down(msg); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/org/jgroups/protocols/FcHeader.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.protocols; 2 | 3 | import org.jgroups.Global; 4 | import org.jgroups.Header; 5 | 6 | import java.io.DataInput; 7 | import java.io.DataOutput; 8 | import java.io.IOException; 9 | import java.util.function.Supplier; 10 | 11 | /** 12 | * Header used by various flow control protocols 13 | * @author Bela Ban 14 | */ 15 | public class FcHeader extends Header { 16 | public static final byte REPLENISH=1; 17 | public static final byte CREDIT_REQUEST=2; // the sender of the message is the requester 18 | 19 | byte type=REPLENISH; 20 | 21 | public FcHeader() { 22 | 23 | } 24 | 25 | public FcHeader(byte type) { 26 | this.type=type; 27 | } 28 | 29 | public Supplier create() { 30 | return FcHeader::new; 31 | } 32 | 33 | public short getMagicId() {return 59;} 34 | 35 | @Override 36 | public int serializedSize() { 37 | return Global.BYTE_SIZE; 38 | } 39 | 40 | @Override 41 | public void writeTo(DataOutput out) throws IOException { 42 | out.writeByte(type); 43 | } 44 | 45 | @Override 46 | public void readFrom(DataInput in) throws IOException { 47 | type=in.readByte(); 48 | } 49 | 50 | public String toString() { 51 | switch(type) { 52 | case REPLENISH: 53 | return "REPLENISH"; 54 | case CREDIT_REQUEST: 55 | return "CREDIT_REQUEST"; 56 | default: 57 | return ""; 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/org/jgroups/protocols/Fragmentation.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.protocols; 2 | 3 | import org.jgroups.annotations.MBean; 4 | import org.jgroups.annotations.ManagedAttribute; 5 | import org.jgroups.annotations.Property; 6 | import org.jgroups.conf.AttributeType; 7 | import org.jgroups.stack.Protocol; 8 | 9 | import java.util.concurrent.atomic.LongAdder; 10 | 11 | /** 12 | * Base class for all fragmentation protocols. 13 | * @author Bela Ban 14 | * @since 5.0.0 15 | */ 16 | @MBean(description="Fragments messages larger than fragmentation size into smaller messages") 17 | public class Fragmentation extends Protocol { 18 | 19 | @Property(description="The max number of bytes in a message. Larger messages will be fragmented", 20 | type=AttributeType.BYTES) 21 | protected int frag_size=60000; 22 | protected LongAdder num_frags_sent=new LongAdder(); 23 | protected LongAdder num_frags_received=new LongAdder(); 24 | 25 | 26 | public int getFragSize() {return frag_size;} 27 | public T setFragSize(int f) {this.frag_size=f; return (T)this;} 28 | 29 | @ManagedAttribute(description="Number of sent fragments",type=AttributeType.SCALAR) 30 | public long getNumberOfSentFragments() {return num_frags_sent.sum();} 31 | 32 | @ManagedAttribute(description="Number of received fragments",type=AttributeType.SCALAR) 33 | public long getNumberOfReceivedFragments() {return num_frags_received.sum();} 34 | 35 | public void resetStats() { 36 | super.resetStats(); 37 | num_frags_sent.reset(); 38 | num_frags_received.reset(); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/org/jgroups/protocols/NoBundler.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.protocols; 2 | 3 | import org.jgroups.Message; 4 | import org.jgroups.util.ByteArrayDataOutputStream; 5 | 6 | /** 7 | * Bundler which doesn't bundle :-) Can be used to measure the diff between bundling and non-bundling (e.g. at runtime). 8 | * Not really meant for production. 9 | * @author Bela Ban 10 | * @since 4.0 11 | */ 12 | public class NoBundler extends BaseBundler { 13 | public int size() {return 0;} 14 | public int getQueueSize() { 15 | return -1; 16 | } 17 | 18 | 19 | @Override 20 | public void send(Message msg) throws Exception { 21 | ByteArrayDataOutputStream buffer=new ByteArrayDataOutputStream(msg.size()); 22 | sendSingle(msg.dest(), msg, buffer); 23 | } 24 | 25 | } -------------------------------------------------------------------------------- /src/org/jgroups/protocols/PerfHeader.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.protocols; 2 | 3 | import org.jgroups.Global; 4 | import org.jgroups.Header; 5 | 6 | import java.io.DataInput; 7 | import java.io.DataOutput; 8 | import java.io.IOException; 9 | import java.util.function.Supplier; 10 | 11 | /** 12 | * @author Bela Ban 13 | * @since 5.4.9 14 | */ 15 | public class PerfHeader extends Header { 16 | protected long start_time; // in ns 17 | 18 | public PerfHeader() { 19 | } 20 | 21 | public PerfHeader(long start_time) { 22 | this.start_time=start_time; 23 | } 24 | public short getMagicId() {return 84;} 25 | public Supplier create() { 26 | return PerfHeader::new; 27 | } 28 | 29 | public long startTime() {return start_time;} 30 | 31 | @Override 32 | public int serializedSize() { 33 | return Global.LONG_SIZE; 34 | } 35 | 36 | @Override 37 | public void writeTo(DataOutput out) throws IOException { 38 | out.writeLong(start_time); 39 | } 40 | 41 | @Override 42 | public void readFrom(DataInput in) throws IOException { 43 | start_time=in.readLong(); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/org/jgroups/protocols/ProtPerfHeader.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.protocols; 2 | 3 | import org.jgroups.Header; 4 | 5 | import java.io.DataInput; 6 | import java.io.DataOutput; 7 | import java.io.IOException; 8 | import java.util.function.Supplier; 9 | 10 | /** 11 | * @author Bela Ban 12 | * @since 5.2.7 13 | */ 14 | public class ProtPerfHeader extends Header { 15 | public static final short ID=1505; // dummy protocol ID to get the ProtPerfHeader from a message 16 | 17 | protected long start_down; // us 18 | protected long start_up; // us 19 | 20 | 21 | public ProtPerfHeader() { 22 | } 23 | 24 | public Supplier create() {return ProtPerfHeader::new;} 25 | public short getMagicId() {return 98;} 26 | public int serializedSize() {return 0;} 27 | public long startDown() {return start_down;} 28 | public ProtPerfHeader startDown(long t) {this.start_down=t; return this;} 29 | public long startUp() {return start_up;} 30 | public ProtPerfHeader startUp(long t) {this.start_up=t; return this;} 31 | 32 | 33 | /** The contents of this header is not serialized */ 34 | public void writeTo(DataOutput out) throws IOException { 35 | } 36 | 37 | public void readFrom(DataInput in) throws IOException, ClassNotFoundException { 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/org/jgroups/protocols/SHARED_LOOPBACK_PING.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.protocols; 2 | 3 | import org.jgroups.Address; 4 | import org.jgroups.Event; 5 | import org.jgroups.util.Responses; 6 | 7 | import java.util.List; 8 | 9 | 10 | /** 11 | * Discovery protocol running over {@link SHARED_LOOPBACK} only. Doesn't send discovery requests and responses, but 12 | * fetches discovery information directly from SHARED_LOOPBACK. Used mainly by unit test. 13 | * @author Bela Ban 14 | * @since 3.5 15 | */ 16 | public class SHARED_LOOPBACK_PING extends Discovery { 17 | 18 | public void init() throws Exception { 19 | super.init(); 20 | TP tmp=getTransport(); 21 | if(!(tmp instanceof SHARED_LOOPBACK)) 22 | throw new IllegalStateException("the transport must be " + SHARED_LOOPBACK.class.getSimpleName()); 23 | } 24 | 25 | public boolean isDynamic() { 26 | return true; 27 | } 28 | 29 | 30 | @Override 31 | public void findMembers(List
members, boolean initial_discovery, Responses responses) { 32 | num_discovery_requests++; 33 | List retval=(List)down_prot.down(new Event(Event.GET_PING_DATA, cluster_name)); 34 | if(retval != null) 35 | retval.forEach(data -> responses.addResponse(data, false)); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/org/jgroups/protocols/SenderSendsBundler.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.protocols; 2 | 3 | import org.jgroups.Message; 4 | import org.jgroups.annotations.Experimental; 5 | 6 | import java.util.concurrent.atomic.AtomicInteger; 7 | 8 | /** 9 | * @author Bela Ban 10 | * @since 4.0 11 | */ 12 | @Experimental 13 | public class SenderSendsBundler extends BaseBundler { 14 | protected final AtomicInteger num_senders=new AtomicInteger(0); // current senders adding msgs to the bundler 15 | 16 | public void send(Message msg) throws Exception { 17 | num_senders.incrementAndGet(); 18 | int size=msg.size(); 19 | 20 | lock.lock(); 21 | try { 22 | if(count + size >= max_size) 23 | sendBundledMessages(); 24 | 25 | addMessage(msg, size); 26 | 27 | // at this point, we haven't sent our message yet ! 28 | if(num_senders.decrementAndGet() == 0) // no other sender threads present at this time 29 | sendBundledMessages(); 30 | // else there are other sender threads waiting, so our message will be sent by a different thread 31 | } 32 | finally { 33 | lock.unlock(); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/org/jgroups/protocols/UNBATCH.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.protocols; 2 | 3 | import org.jgroups.Message; 4 | import org.jgroups.annotations.MBean; 5 | import org.jgroups.annotations.Property; 6 | import org.jgroups.stack.Protocol; 7 | import org.jgroups.util.MessageBatch; 8 | 9 | /** 10 | * Intercepts {@link org.jgroups.stack.Protocol#up(MessageBatch)} and passes up each message of a message batch 11 | * as a single message. Mainly to be used in unit tests (https://issues.redhat.com/browse/JGRP-2702). 12 | * @author Bela Ban 13 | * @since 5.2.18 14 | */ 15 | @MBean(description="Passes each message from a MessageBatch up as a single message") 16 | public class UNBATCH extends Protocol { 17 | @Property(description="If enabled, message batches are passed up as single messages, otherwise as batches") 18 | protected boolean enabled=true; 19 | 20 | public boolean enabled() {return enabled;} 21 | public UNBATCH enable(boolean b) {enabled=b; return this;} 22 | 23 | @Override 24 | public void up(MessageBatch batch) { 25 | if(!enabled) { 26 | up_prot.up(batch); 27 | return; 28 | } 29 | for(Message msg: batch) 30 | up_prot.up(msg); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/org/jgroups/protocols/dns/DNSResolver.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.protocols.dns; 2 | 3 | import java.util.List; 4 | 5 | import org.jgroups.Address; 6 | 7 | public interface DNSResolver extends AutoCloseable { 8 | 9 | enum DNSRecordType { 10 | A, SRV 11 | } 12 | 13 | List
resolveIps(String dnsQuery, DNSRecordType recordType); 14 | 15 | @Override 16 | default void close() { 17 | // Do nothing by default 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/org/jgroups/protocols/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Provides implementations of transport protocols which are 4 | responsible for sending and receiving messages to/from the network. 5 | 6 | -------------------------------------------------------------------------------- /src/org/jgroups/protocols/pbcast/MergeData.java: -------------------------------------------------------------------------------- 1 | 2 | package org.jgroups.protocols.pbcast; 3 | 4 | 5 | import org.jgroups.Address; 6 | import org.jgroups.View; 7 | import org.jgroups.util.Digest; 8 | 9 | 10 | /** 11 | * Encapsulates data sent with a MERGE_RSP (handleMergeResponse()) and INSTALL_MERGE_VIEW (handleMergeView()).

12 | * Note that since MergeData is never sent across the network, it doesn't need to be Streamable. 13 | * @author Bela Ban Oct 22 2001 14 | */ 15 | public class MergeData { 16 | protected final Address sender; 17 | protected final boolean merge_rejected; 18 | protected final View view; 19 | protected final Digest digest; 20 | 21 | 22 | public MergeData(Address sender, View view, Digest digest, boolean merge_rejected) { 23 | this.sender=sender; 24 | this.view=view; 25 | this.digest=digest; 26 | this.merge_rejected=merge_rejected; 27 | } 28 | 29 | public MergeData(Address sender, View view, Digest digest) { 30 | this(sender, view, digest, false); 31 | } 32 | 33 | public Address getSender() { 34 | return sender; 35 | } 36 | 37 | public View getView() { 38 | return view; 39 | } 40 | 41 | public Digest getDigest() { 42 | return digest; 43 | } 44 | 45 | 46 | public String toString() { 47 | StringBuilder sb=new StringBuilder("sender=").append(sender); 48 | if(merge_rejected) 49 | sb.append(" (merge_rejected)"); 50 | else 51 | sb.append(", view=").append(view).append(", digest=").append(digest); 52 | return sb.toString(); 53 | } 54 | 55 | 56 | } 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /src/org/jgroups/protocols/relay/RouteStatusListener.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.protocols.relay; 2 | 3 | import org.jgroups.Address; 4 | 5 | /** 6 | * Gets notified when a site comes up or goes down 7 | * @author Bela Ban 8 | * @since 3.4 9 | */ 10 | public interface RouteStatusListener { 11 | /** The sites just came up */ 12 | void sitesUp(String... sites); 13 | /** The sites went down */ 14 | void sitesDown(String... sites); 15 | 16 | /** The sites are unreachable (no route to them) */ 17 | default void sitesUnreachable(String ... sites) { 18 | 19 | } 20 | 21 | /** Sent back to the original sender when the unicast destination is not part of the local cluster (site) */ 22 | default void memberUnreachable(Address member) { 23 | 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/org/jgroups/protocols/relay/SiteAddress.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.protocols.relay; 2 | 3 | import org.jgroups.Address; 4 | 5 | /** 6 | * Address with a site suffix 7 | * @author Bela Ban 8 | * @since 3.2 9 | */ 10 | public interface SiteAddress extends Address { 11 | /** Returns the ID of the site (all sites need to have a unique site ID) */ 12 | String getSite(); 13 | 14 | enum Type { 15 | ALL, // null destination, send to all members of the local cluster 16 | UNICAST, // send to a given member of the local cluster 17 | SM, // send to the site master of a given site 18 | SM_ALL // send to all site masters 19 | } 20 | 21 | /** Temporary kludge to avoid instanceof */ 22 | default Type type() {return Type.UNICAST;} 23 | } 24 | -------------------------------------------------------------------------------- /src/org/jgroups/stack/AddressGenerator.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.stack; 2 | 3 | import org.jgroups.Address; 4 | 5 | /** 6 | * Callback to provide custom addresses. Will be called by {@link org.jgroups.JChannel#connect(String)}. 7 | * @author Bela Ban 8 | * @since 2.12 9 | */ 10 | public interface AddressGenerator { 11 | @Deprecated(since="5.2.15") 12 | Address generateAddress(); 13 | default Address generateAddress(String name) { 14 | return generateAddress(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/org/jgroups/stack/GossipType.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.stack; 2 | 3 | /** 4 | * Types of requests and responses exchanged between GossipRouter and RouterStubs 5 | * @author Bela Ban 6 | * @since 3.6.5 7 | */ 8 | public enum GossipType { 9 | REGISTER, 10 | UNREGISTER, 11 | GET_MBRS, 12 | GET_MBRS_RSP, 13 | MESSAGE, 14 | HEARTBEAT, // request *and* response 15 | SUSPECT, 16 | GET_MBRS_RSP_LAST // the last response 17 | } 18 | -------------------------------------------------------------------------------- /src/org/jgroups/stack/LargestWinningPolicy.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.stack; 2 | 3 | import org.jgroups.Address; 4 | import org.jgroups.Membership; 5 | import org.jgroups.protocols.pbcast.GMS; 6 | 7 | import java.util.ArrayList; 8 | import java.util.Collection; 9 | import java.util.List; 10 | 11 | /** 12 | * Policy which picks the new coordinator in a merge from the largest subview. 13 | * JIRA: https://issues.redhat.com/browse/JGRP-1976 14 | * @author Osamu Nagano 15 | * @since 3.6.7 16 | */ 17 | public class LargestWinningPolicy extends GMS.DefaultMembershipPolicy { 18 | 19 | /** 20 | * Called when a merge happened. The largest subview wins. 21 | */ 22 | public List

getNewMembership(final Collection> subviews) { 23 | ArrayList> aSubviews=new ArrayList<>(subviews); 24 | int sLargest = 0; 25 | int iLargest = 0; 26 | 27 | for (int i = 0; i < aSubviews.size(); i++) { 28 | int size = aSubviews.get(i).size(); 29 | if (size > sLargest) { 30 | sLargest = size; 31 | iLargest = i; 32 | } 33 | } 34 | 35 | Membership mbrs = new Membership(aSubviews.get(iLargest)); 36 | for (int i = 0; i < aSubviews.size(); i++) 37 | if (i != iLargest) 38 | mbrs.add(aSubviews.get(i)); 39 | 40 | return mbrs.getMembers(); 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/org/jgroups/stack/Policy.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.stack; 2 | 3 | /** 4 | * A policy implementation checks that a condition is met or throws an exception if not. A condition could be for 5 | * example the check if a given protocol is present, an attribute is within a given range etc. 6 | *
7 | * Policies are called after {@link Protocol#init()}, so the protocol is full initialized (all attrs and components 8 | * are set). 9 | * @author Bela Ban 10 | * @since 5.2.14 11 | */ 12 | public interface Policy { 13 | /** 14 | * Checks that a condition is met in a given protocol 15 | * @param prot The protocol in which the policy is run 16 | * @throws Exception Thrown if the condition is not met 17 | */ 18 | void check(Protocol prot) throws Exception; 19 | } 20 | -------------------------------------------------------------------------------- /src/org/jgroups/stack/ProtocolHook.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.stack; 2 | 3 | /** 4 | * Provides hook(s) that are called when a protocol has been created 5 | * @author Bela Ban 6 | * @since 3.6.7 7 | */ 8 | public interface ProtocolHook { 9 | /** 10 | * Called after all protocols have been created, connected and its attributes set, but 11 | * before {@link Protocol#init()} is called. The order of calling the hooks is from bottom to top protocol. 12 | * @param prot The protocol that was created. 13 | * @throws Exception Thrown is the method failed. 14 | */ 15 | void afterCreation(Protocol prot) throws Exception; 16 | } 17 | -------------------------------------------------------------------------------- /src/org/jgroups/stack/StateTransferInfo.java: -------------------------------------------------------------------------------- 1 | 2 | package org.jgroups.stack; 3 | 4 | 5 | import org.jgroups.Address; 6 | 7 | 8 | /** 9 | * Contains parameters for state transfer. Exchanged between channel and STATE_TRANSFER 10 | * layer. The state is retrieved from 'target'. If target is null, then the state will be retrieved from the oldest 11 | * member (usually the coordinator). 12 | * @author Bela Ban 13 | */ 14 | public class StateTransferInfo { 15 | public Address target=null; 16 | public long timeout=0; 17 | public byte[] state=null; 18 | 19 | 20 | 21 | public StateTransferInfo() { 22 | } 23 | 24 | public StateTransferInfo(Address target) { 25 | this.target=target; 26 | } 27 | 28 | public StateTransferInfo(Address target, long timeout) { 29 | this.target=target; 30 | this.timeout=timeout; 31 | } 32 | 33 | public StateTransferInfo(Address target, long timeout, byte[] state) { 34 | this.target=target; 35 | this.timeout=timeout; 36 | this.state=state; 37 | } 38 | 39 | 40 | 41 | public StateTransferInfo copy() { 42 | return new StateTransferInfo(target, timeout, state); 43 | } 44 | 45 | 46 | public String toString() { 47 | StringBuilder ret=new StringBuilder(); 48 | ret.append("target=" + target); 49 | if(state != null) 50 | ret.append(", state=" + state.length + " bytes"); 51 | ret.append(", timeout=" + timeout); 52 | return ret.toString(); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/org/jgroups/stack/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Support for managing protocol stacks. 4 | 5 | -------------------------------------------------------------------------------- /src/org/jgroups/util/ArrayIterator.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.util; 2 | 3 | import java.util.Iterator; 4 | import java.util.NoSuchElementException; 5 | 6 | /** 7 | * Iterator over an array of elements of type T. 8 | * @author Bela Ban 9 | * @since 3.4 10 | */ 11 | public class ArrayIterator implements Iterator { 12 | protected int index; 13 | protected final T[] elements; 14 | 15 | public ArrayIterator(T[] elements) { 16 | this.elements=elements; 17 | } 18 | 19 | public boolean hasNext() { 20 | return index < elements.length; 21 | } 22 | 23 | public T next() { 24 | if(index >= elements.length) 25 | throw new NoSuchElementException("index=" + index + ", length=" + elements.length); 26 | return elements[index++]; 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/org/jgroups/util/BoundedHashMap.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.util; 2 | 3 | import java.util.LinkedHashMap; 4 | import java.util.Map; 5 | 6 | /** 7 | * Bounded linked hashmap; used by SEQUENCER 8 | * @author Bela Ban 9 | * @since 3.3 10 | */ 11 | public class BoundedHashMap extends LinkedHashMap { 12 | private static final long serialVersionUID=-5368387761328082187L; 13 | protected final int max_size; 14 | 15 | public BoundedHashMap(int max_size) { 16 | this.max_size=max_size; 17 | } 18 | 19 | protected boolean removeEldestEntry(Map.Entry eldest) { 20 | return size() > max_size; 21 | } 22 | 23 | public boolean add(K key, V val) { 24 | return super.put(key, val) == null; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/org/jgroups/util/BoundedList.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.util; 2 | 3 | import java.util.concurrent.ConcurrentLinkedQueue; 4 | 5 | 6 | /** 7 | * A bounded subclass of LinkedList, oldest elements are removed once max capacity is exceeded. Note that this 8 | * class is not synchronized (like LinkedList). Don't use this for high performance, as size() has a linear cost. But 9 | * in most scenarios, this class is used for maintaining a history, e.g. of digests or views, so perf is not critical. 10 | * @author Bela Ban Nov 20, 2003 11 | */ 12 | public class BoundedList extends ConcurrentLinkedQueue { 13 | int max_capacity=10; 14 | 15 | 16 | public BoundedList() { 17 | super(); 18 | } 19 | 20 | public BoundedList(int size) { 21 | super(); 22 | max_capacity=size; 23 | } 24 | 25 | 26 | /** 27 | * Adds an element at the tail. Removes an object from the head if capacity is exceeded 28 | * @param obj The object to be added 29 | */ 30 | public boolean add(T obj) { 31 | if(obj == null) return false; 32 | while(size() >= max_capacity && size() > 0) { 33 | poll(); 34 | } 35 | return super.add(obj); 36 | } 37 | 38 | public boolean addIfAbsent(T obj) { 39 | return obj != null && !contains(obj) && add(obj); 40 | } 41 | 42 | 43 | 44 | public T removeFromHead() { 45 | return poll(); 46 | } 47 | 48 | 49 | } 50 | -------------------------------------------------------------------------------- /src/org/jgroups/util/CustomRejectionPolicy.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.util; 2 | 3 | import java.util.concurrent.RejectedExecutionHandler; 4 | import java.util.concurrent.ThreadPoolExecutor; 5 | 6 | /** 7 | * // TODO: Document this 8 | * 9 | * @author Radim Vansa <rvansa@redhat.com> 10 | * @since 1/29/13 11 | */ 12 | public class CustomRejectionPolicy implements RejectedExecutionHandler { 13 | public final static String NAME = "custom"; 14 | 15 | private final RejectedExecutionHandler custom; 16 | 17 | public CustomRejectionPolicy(String rejection_policy) { 18 | if (!rejection_policy.toLowerCase().startsWith("custom=")) { 19 | throw new IllegalStateException(rejection_policy); 20 | } 21 | String className = rejection_policy.substring(7); 22 | try { 23 | Class policyClass = Util.loadClass(className, Util.class); 24 | Object policy = policyClass.getDeclaredConstructor().newInstance(); 25 | if (!(policy instanceof RejectedExecutionHandler)) { 26 | throw new IllegalArgumentException(className + " does not implement RejectedExecutionHandler"); 27 | } else { 28 | custom = (RejectedExecutionHandler) policy; 29 | } 30 | } catch (Throwable e) { 31 | throw new RuntimeException("Cannot instantiate rejection policy '" + rejection_policy + "'", e); 32 | } 33 | } 34 | 35 | @Override 36 | public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) { 37 | custom.rejectedExecution(r, executor); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/org/jgroups/util/DirectExecutor.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.util; 2 | 3 | import java.util.concurrent.Executor; 4 | 5 | /** 6 | * @author Bela Ban 7 | */ 8 | public class DirectExecutor implements Executor { 9 | public void execute(Runnable command) { 10 | command.run(); 11 | } 12 | 13 | 14 | } 15 | -------------------------------------------------------------------------------- /src/org/jgroups/util/GetNetworkInterfaces.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.util; 2 | 3 | import java.net.InetAddress; 4 | import java.net.NetworkInterface; 5 | import java.net.SocketException; 6 | import java.util.Enumeration; 7 | 8 | /** 9 | * Lists all network interfaces on a system 10 | * @author Bela Ban Dec 18 11 | * @author 2003 12 | */ 13 | public class GetNetworkInterfaces { 14 | 15 | public static void main(String[] args) throws SocketException { 16 | Enumeration en=NetworkInterface.getNetworkInterfaces(); 17 | while(en.hasMoreElements()) { 18 | NetworkInterface i=en.nextElement(); 19 | System.out.println(i.getName() + ':'); 20 | System.out.println(" \t" + i.getDisplayName()); 21 | for(Enumeration en2=i.getInetAddresses(); en2.hasMoreElements();) { 22 | InetAddress addr=en2.nextElement(); 23 | System.out.println(" \t" + addr + " (" + addr.getHostName() + ')'); 24 | } 25 | System.out.println("---------------------"); 26 | } 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/org/jgroups/util/InputStreamAdapter.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.util; 2 | 3 | import java.io.IOException; 4 | import java.io.InputStream; 5 | 6 | /** 7 | * Extends {@link InputStream} from a {@link ByteArrayDataInputStream}. Methods like flush() and close() are no-ops. 8 | * @author Bela Ban 9 | * @since 3.5 10 | */ 11 | public class InputStreamAdapter extends InputStream { 12 | protected final ByteArrayDataInputStream input; 13 | 14 | public InputStreamAdapter(ByteArrayDataInputStream input) { 15 | this.input=input; 16 | } 17 | 18 | 19 | public int read() throws IOException { 20 | return input.read(); 21 | } 22 | 23 | 24 | public int read(byte[] b) throws IOException { 25 | return read(b, 0, b.length); 26 | } 27 | 28 | public int read(byte[] b, int off, int len) throws IOException { 29 | return input.read(b, off, len); 30 | } 31 | 32 | 33 | public long skip(long n) throws IOException { 34 | return input.skipBytes((int)n); 35 | } 36 | 37 | 38 | public int available() throws IOException { 39 | return input.limit() - input.position(); 40 | } 41 | 42 | 43 | public void close() throws IOException { 44 | ; 45 | } 46 | 47 | 48 | public void reset() throws IOException { 49 | ; 50 | } 51 | 52 | public boolean markSupported() { 53 | return false; 54 | } 55 | 56 | 57 | } 58 | -------------------------------------------------------------------------------- /src/org/jgroups/util/LongSizeStreamable.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.util; 2 | 3 | import java.io.DataInput; 4 | import java.io.DataOutput; 5 | import java.io.IOException; 6 | import java.util.function.LongSupplier; 7 | 8 | /** 9 | * Utility class that implements {@link SizeStreamable} and {@link LongSupplier} to store a {@code long} value. 10 | * 11 | * @author Pedro Ruivo 12 | * @since 5.2 13 | */ 14 | public final class LongSizeStreamable implements SizeStreamable, LongSupplier { 15 | 16 | private long value; 17 | 18 | // for unmarshalling 19 | @SuppressWarnings("unused") 20 | public LongSizeStreamable() { 21 | } 22 | 23 | public LongSizeStreamable(long value) { 24 | this.value = value; 25 | } 26 | 27 | @Override 28 | public int serializedSize() { 29 | return Long.BYTES; 30 | } 31 | 32 | @Override 33 | public void writeTo(DataOutput out) throws IOException { 34 | out.writeLong(value); 35 | } 36 | 37 | @Override 38 | public void readFrom(DataInput in) throws IOException, ClassNotFoundException { 39 | value = in.readLong(); 40 | } 41 | 42 | @Override 43 | public long getAsLong() { 44 | return value; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/org/jgroups/util/LongTuple.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.util; 2 | 3 | /** 4 | * A tuple with a long (primitive) first value 5 | * @author Bela Ban 6 | */ 7 | public class LongTuple { 8 | private final long val1; 9 | private final V val2; 10 | 11 | public LongTuple(long val1, V val2) { 12 | this.val1=val1; 13 | this.val2=val2; 14 | } 15 | 16 | public long getVal1() {return val1;} 17 | public V getVal2() {return val2;} 18 | 19 | public String toString() { 20 | return val1 + " : " + val2; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/org/jgroups/util/MessageCache.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.util; 2 | 3 | import org.jgroups.Address; 4 | import org.jgroups.Message; 5 | 6 | import java.util.Collection; 7 | import java.util.Map; 8 | import java.util.Queue; 9 | import java.util.concurrent.ConcurrentHashMap; 10 | import java.util.concurrent.ConcurrentLinkedQueue; 11 | import java.util.function.Function; 12 | 13 | /** 14 | * A cache associating members and messages 15 | * @author Bela Ban 16 | * @since 5.3.2 17 | */ 18 | public class MessageCache { 19 | protected final Map> map=new ConcurrentHashMap<>(); 20 | protected static final Function> FUNC=__ -> new ConcurrentLinkedQueue<>(); 21 | 22 | public MessageCache add(Address sender, Message msg) { 23 | Queue list=map.computeIfAbsent(sender, FUNC); 24 | list.add(msg); 25 | return this; 26 | } 27 | 28 | public Collection drain(Address sender) { 29 | if(sender == null) 30 | return null; 31 | return map.remove(sender); 32 | } 33 | 34 | public MessageCache clear() { 35 | map.clear(); 36 | return this; 37 | } 38 | 39 | /** Returns a count of all messages */ 40 | public int size() { 41 | return map.values().stream().mapToInt(Collection::size).sum(); 42 | } 43 | 44 | public boolean isEmpty() { 45 | return map.isEmpty(); 46 | } 47 | 48 | public String toString() { 49 | return String.format("%d message(s)", size()); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/org/jgroups/util/MockTransport.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.util; 2 | 3 | import org.jgroups.Message; 4 | import org.jgroups.PhysicalAddress; 5 | import org.jgroups.protocols.NoBundler; 6 | import org.jgroups.protocols.TP; 7 | 8 | /** 9 | * A dummy implementation of {@link TP} 10 | * @author Bela Ban 11 | * @since 5.4 12 | */ 13 | public class MockTransport extends TP { 14 | 15 | public void init() throws Exception { 16 | super.init(); 17 | setBundler(new NoBundler()); 18 | } 19 | public boolean supportsMulticasting() {return true;} 20 | public void sendUnicast(PhysicalAddress dest, byte[] data, int offset, int length) throws Exception {} 21 | public String getInfo() {return null;} 22 | protected PhysicalAddress getPhysicalAddress() {return null;} 23 | public MockTransport cluster(AsciiString s) {this.cluster_name=s; return this;} 24 | 25 | 26 | public Object down(Message msg) { 27 | return null; 28 | } 29 | 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/org/jgroups/util/NoProgressException.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.util; 2 | 3 | /** 4 | * Exception raised when a threadpool rejects jobs but shows no progress. 5 | * 6 | * @author Radim Vansa <rvansa@redhat.com> 7 | * @since 1/30/13 8 | */ 9 | public class NoProgressException extends RuntimeException { 10 | public NoProgressException(String message) { 11 | super(message); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/org/jgroups/util/ObjectInputStreamWithClassloader.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.util; 2 | 3 | import java.io.IOException; 4 | import java.io.InputStream; 5 | import java.io.ObjectInputStream; 6 | import java.io.ObjectStreamClass; 7 | 8 | /** 9 | * Override {@link java.io.ObjectInputStream#resolveClass(java.io.ObjectStreamClass)} using the passed-in 10 | * classloader 11 | * @author Bela Ban 12 | * @since 3.5 13 | */ 14 | public class ObjectInputStreamWithClassloader extends ObjectInputStream { 15 | protected final ClassLoader loader; 16 | 17 | public ObjectInputStreamWithClassloader(InputStream in) throws IOException { 18 | this(in, null); 19 | } 20 | 21 | public ObjectInputStreamWithClassloader(InputStream in, ClassLoader loader) throws IOException { 22 | super(in); 23 | this.loader=loader; 24 | } 25 | 26 | protected ObjectInputStreamWithClassloader() throws IOException, SecurityException { 27 | this((ClassLoader)null); 28 | } 29 | 30 | protected ObjectInputStreamWithClassloader(ClassLoader loader) throws IOException, SecurityException { 31 | this.loader=loader; 32 | } 33 | 34 | @Override 35 | protected Class resolveClass(ObjectStreamClass desc) throws IOException, ClassNotFoundException { 36 | if(loader == null) 37 | return super.resolveClass(desc); 38 | 39 | String name=desc.getName(); 40 | try { 41 | return Class.forName(name, false, loader); 42 | } 43 | catch (ClassNotFoundException ex) { 44 | Class cl=super.resolveClass(desc); 45 | if(cl != null) 46 | return cl; 47 | throw ex; 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/org/jgroups/util/ObjectWrapperPrimitive.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.util; 2 | 3 | import java.io.DataInput; 4 | import java.io.DataOutput; 5 | import java.io.IOException; 6 | 7 | /** 8 | * Wraps a primitive object (e.g. Integer, Boolean, byte[], String etc) 9 | * @author Bela Ban 10 | * @since 5.0.0 11 | */ 12 | public class ObjectWrapperPrimitive implements SizeStreamable { 13 | protected Object obj; 14 | 15 | public ObjectWrapperPrimitive() { 16 | } 17 | 18 | public ObjectWrapperPrimitive(Object obj) { 19 | this.obj=obj; 20 | } 21 | 22 | public T getObject() { 23 | return (T)obj; 24 | } 25 | 26 | public synchronized ObjectWrapperPrimitive setObject(Object obj) { 27 | this.obj=obj; 28 | return this; 29 | } 30 | 31 | public int getLength() { 32 | return Util.sizePrimitive(obj); 33 | } 34 | 35 | public String toString() { 36 | return String.format("%s", obj); 37 | } 38 | 39 | public int serializedSize() { 40 | return Util.sizePrimitive(obj); 41 | } 42 | 43 | public void writeTo(DataOutput out) throws IOException { 44 | Util.primitiveToStream(obj, out); 45 | } 46 | 47 | public void readFrom(DataInput in) throws IOException, ClassNotFoundException { 48 | obj=Util.primitiveFromStream(in); 49 | } 50 | 51 | 52 | } 53 | -------------------------------------------------------------------------------- /src/org/jgroups/util/OneTimeAddressGenerator.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.util; 2 | 3 | import org.jgroups.Address; 4 | import org.jgroups.stack.AddressGenerator; 5 | 6 | /** 7 | * Implementation of {@link org.jgroups.stack.AddressGenerator} which is configured with an initial value, and 8 | * after that random values are generated. 9 | * @author Bela Ban 10 | * @since 3.5 11 | */ 12 | public class OneTimeAddressGenerator implements AddressGenerator { 13 | protected final long initial_val; 14 | protected boolean first=true; 15 | 16 | public OneTimeAddressGenerator(long initial_val) { 17 | this.initial_val=initial_val; 18 | } 19 | 20 | public Address generateAddress() { 21 | if(first) { 22 | first=false; 23 | return new UUID(0, initial_val); 24 | } 25 | return Util.createRandomAddress(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/org/jgroups/util/OutputStreamAdapter.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.util; 2 | 3 | import java.io.IOException; 4 | import java.io.OutputStream; 5 | 6 | /** 7 | * Extends {@link OutputStream} from a {@link ByteArrayDataOutputStream}. Some methods are no-ops. 8 | * @author Bela Ban 9 | * @since 3.5 10 | */ 11 | public class OutputStreamAdapter extends OutputStream { 12 | protected final ByteArrayDataOutputStream output; 13 | 14 | public OutputStreamAdapter(ByteArrayDataOutputStream output) { 15 | this.output=output; 16 | } 17 | 18 | public void write(int b) throws IOException { 19 | output.write(b); 20 | } 21 | 22 | public void write(byte[] b) throws IOException { 23 | output.write(b); 24 | } 25 | 26 | public void write(byte[] b, int off, int len) throws IOException { 27 | output.write(b, off, len); 28 | } 29 | 30 | public void flush() throws IOException { 31 | ; 32 | } 33 | 34 | public void close() throws IOException { 35 | ; 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/org/jgroups/util/PaddedAtomicBoolean.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.util; 2 | 3 | import java.util.concurrent.atomic.AtomicBoolean; 4 | 5 | /** 6 | * @author Bela Ban 7 | * @since 4.0 8 | */ 9 | @SuppressWarnings("serial") 10 | public class PaddedAtomicBoolean extends AtomicBoolean { 11 | protected volatile int i1=1,i2=2,i3=3,i4=4,i5=5,i6=6; 12 | protected volatile int i7=7,i8=8,i9=9,i10=10,i11=11,i12=12,i13=13,i14=14,i15=15,i16=16; 13 | 14 | public PaddedAtomicBoolean(boolean initialValue) { 15 | super(initialValue); 16 | } 17 | 18 | public int sum() { 19 | return i1+i2+i3+i4+i5+i6+i7+i8+i9+i10+i11+i12+i13+i14+i15+i16; 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/org/jgroups/util/PaddedAtomicInteger.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.util; 2 | 3 | import java.util.concurrent.atomic.AtomicInteger; 4 | 5 | /** 6 | * @author Bela Ban 7 | * @since 4.0 8 | */ 9 | @SuppressWarnings("serial") 10 | public class PaddedAtomicInteger extends AtomicInteger { 11 | protected volatile int i1=1,i2=2,i3=3,i4=4,i5=5,i6=6; 12 | protected volatile int i7=7,i8=8,i9=9,i10=10,i11=11,i12=12,i13=13,i14=14; 13 | 14 | public PaddedAtomicInteger(int initialValue) { 15 | super(initialValue); 16 | } 17 | 18 | public int sum() { 19 | return i1+i2+i3+i4+i5+i6+i7+i8+i9+i10+i11+i12+i13+i14; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/org/jgroups/util/PaddedAtomicLong.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.util; 2 | 3 | import java.util.concurrent.atomic.AtomicLong; 4 | 5 | /** 6 | * Copied from http://mechanical-sympathy.blogspot.ch/2011/08/false-sharing-java-7.html. Switch to @Contended once 7 | * it is available. 8 | * @author Bela Ban 9 | * @since 4.0 10 | */ 11 | @SuppressWarnings("serial") 12 | public class PaddedAtomicLong extends AtomicLong { 13 | public volatile long p1=1,p2=2,p3=3,p4=4,p5=5,p6=6,p7=7; 14 | 15 | public long sum() { // prevents optimizing away the fields above 16 | return p1+p2+p3+p4+p5+p6+p7; 17 | } 18 | 19 | public PaddedAtomicLong(long initialValue) { 20 | super(initialValue); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/org/jgroups/util/PassRegularMessagesUpDirectly.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.util; 2 | 3 | import org.jgroups.Message; 4 | 5 | /** 6 | * {@link org.jgroups.stack.MessageProcessingPolicy} which passes regular messages and message batches up directly 7 | * (on the same thread), but passes OOB messages to the thread pool. 8 | * @author Bela Ban 9 | * @since 5.2.14 10 | */ 11 | public class PassRegularMessagesUpDirectly extends SubmitToThreadPool { 12 | 13 | @Override 14 | public boolean loopback(Message msg, boolean oob) { 15 | if(oob) 16 | return super.loopback(msg, oob); 17 | tp.passMessageUp(msg, null, false, msg.getDest() == null, false); 18 | return true; 19 | } 20 | 21 | @Override 22 | public boolean process(Message msg, boolean oob) { 23 | if(oob) 24 | return super.process(msg, oob); 25 | SingleMessageHandler smh=new SingleMessageHandler(msg); 26 | smh.run(); 27 | return true; 28 | } 29 | 30 | @Override 31 | public boolean process(MessageBatch batch, boolean oob) { 32 | if(oob) 33 | return super.process(batch, oob); 34 | BatchHandler bh=new BatchHandler(batch, false); 35 | bh.run(); 36 | return true; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/org/jgroups/util/Range.java: -------------------------------------------------------------------------------- 1 | 2 | package org.jgroups.util; 3 | 4 | 5 | import java.io.DataInput; 6 | import java.io.DataOutput; 7 | import java.io.IOException; 8 | 9 | 10 | public class Range implements SizeStreamable, Comparable { 11 | public long low=-1; // first msg to be retransmitted 12 | public long high=-1; // last msg to be retransmitted 13 | 14 | 15 | 16 | /** For externalization */ 17 | public Range() { 18 | } 19 | 20 | public Range(long low, long high) { 21 | this.low=low; this.high=high; 22 | } 23 | 24 | 25 | public String toString() { 26 | return "[" + low + " : " + high + ']'; 27 | } 28 | 29 | 30 | public int compareTo(Range other) { 31 | if(low == other.low && high == other.high) 32 | return 0; 33 | return low < other.low? -1 : 1; 34 | } 35 | 36 | public int hashCode() { 37 | return (int)low; 38 | } 39 | 40 | public boolean equals(Object obj) { 41 | Range other=(Range)obj; 42 | return compareTo(other) == 0; 43 | } 44 | 45 | 46 | @Override 47 | public void writeTo(DataOutput out) throws IOException { 48 | Bits.writeLongSequence(low, high, out); 49 | } 50 | 51 | @Override 52 | public void readFrom(DataInput in) throws IOException { 53 | long[] seqnos={0,0}; 54 | Bits.readLongSequence(in, seqnos, 0); 55 | low=seqnos[0]; 56 | high=seqnos[1]; 57 | } 58 | 59 | @Override 60 | public int serializedSize() { 61 | return Bits.size(low, high); 62 | } 63 | 64 | 65 | } 66 | -------------------------------------------------------------------------------- /src/org/jgroups/util/Ref.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.util; 2 | 3 | /** 4 | * Keeps a reference to another object 5 | * @author Bela Ban 6 | * @since 5.2 7 | */ 8 | public class Ref { 9 | protected T obj; 10 | 11 | public Ref(T obj) { 12 | this.obj=obj; 13 | } 14 | 15 | public T get() {return obj;} 16 | 17 | public Ref set(T obj) { 18 | this.obj=obj; 19 | return this; 20 | } 21 | 22 | public boolean isSet() {return obj != null;} 23 | 24 | public String toString() { 25 | return String.format("ref<%s>", obj); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/org/jgroups/util/ShutdownRejectedExecutionHandler.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.util; 2 | 3 | import java.util.Objects; 4 | import java.util.concurrent.RejectedExecutionHandler; 5 | import java.util.concurrent.ThreadPoolExecutor; 6 | 7 | 8 | /** 9 | * ShutdownRejectedExecutionHandler is a decorator RejectedExecutionHandler used 10 | * in all JGroups ThreadPoolExecutor(s). Default RejectedExecutionHandler raises 11 | * RuntimeException when a task is submitted to ThreadPoolExecutor that has been 12 | * shutdown. ShutdownRejectedExecutionHandler instead logs only a warning 13 | * message. 14 | * 15 | * @author Vladimir Blagojevic 16 | * @see ThreadPoolExecutor 17 | * @see RejectedExecutionHandler 18 | */ 19 | public class ShutdownRejectedExecutionHandler implements RejectedExecutionHandler { 20 | 21 | RejectedExecutionHandler handler; 22 | 23 | public ShutdownRejectedExecutionHandler(RejectedExecutionHandler handler) { 24 | super(); 25 | this.handler=Objects.requireNonNull(handler); 26 | } 27 | 28 | public RejectedExecutionHandler handler() {return handler;} 29 | 30 | public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) { 31 | if(!executor.isShutdown()) { 32 | handler.rejectedExecution(r, executor); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/org/jgroups/util/SizeStreamable.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.util; 2 | 3 | /** 4 | * Interface implementing Streamable and returning the size of the marshalled object. 5 | * @author Bela Ban 6 | * @since 3.3 7 | */ 8 | public interface SizeStreamable extends Streamable { 9 | /** Returns the size (in bytes) of the marshalled object */ 10 | int serializedSize(); 11 | } 12 | -------------------------------------------------------------------------------- /src/org/jgroups/util/StackType.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.util; 2 | 3 | /** 4 | * @author Bela Ban 5 | */ 6 | public enum StackType { 7 | IPv4, // IPv4-only stack 8 | IPv6, // IPv6-only stack 9 | Dual // both IPv4 and IPv6 stacks available 10 | } 11 | -------------------------------------------------------------------------------- /src/org/jgroups/util/StateTransferResult.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.util; 2 | 3 | /** 4 | * Encapsulates the result of a state transfer. When buffer is set, then this is the result of a state transfer with 5 | * STATE_TRANSFER. When exception is non-null, then an exception occurred. When both fields are null, then the 6 | * (streaming) state transfer was successful. 7 | * @author Bela Ban 8 | * @since 3.0 9 | */ 10 | public class StateTransferResult { 11 | protected final byte[] buffer; // used with STATE_TRANSFER 12 | protected final Throwable exception; // when an exception occurred 13 | 14 | 15 | public StateTransferResult() { 16 | buffer=null; 17 | exception=null; 18 | } 19 | 20 | public StateTransferResult(byte[] buffer) { 21 | this.buffer=buffer; 22 | this.exception=null; 23 | } 24 | 25 | public StateTransferResult(Throwable t) { 26 | this.exception=t; 27 | this.buffer=null; 28 | } 29 | 30 | public boolean hasBuffer() {return buffer != null && buffer.length > 0;} 31 | public boolean hasException() {return exception != null;} 32 | public byte[] getBuffer() {return buffer;} 33 | public Throwable getException() {return exception;} 34 | 35 | public String toString() { 36 | if(buffer != null) 37 | return Util.printBytes(buffer.length); 38 | else if(exception != null) 39 | return exception.toString(); 40 | return "OK"; 41 | } 42 | 43 | 44 | 45 | } 46 | -------------------------------------------------------------------------------- /src/org/jgroups/util/Streamable.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.util; 2 | 3 | import java.io.DataInput; 4 | import java.io.DataOutput; 5 | import java.io.IOException; 6 | 7 | /** 8 | * Implementations of Streamable can add their state directly to the output stream, enabling them to bypass costly 9 | * serialization 10 | * @author Bela Ban 11 | */ 12 | public interface Streamable { 13 | 14 | /** Write the entire state of the current object (including superclasses) to outstream. 15 | * Note that the output stream must not be closed */ 16 | void writeTo(DataOutput out) throws IOException; 17 | 18 | /** Read the state of the current object (including superclasses) from instream 19 | * Note that the input stream must not be closed */ 20 | void readFrom(DataInput in) throws IOException, ClassNotFoundException; 21 | } 22 | -------------------------------------------------------------------------------- /src/org/jgroups/util/TLSClientAuth.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.util; 2 | 3 | /** 4 | * @author Tristan Tarrant 5 | * @since 5.2.15 6 | */ 7 | public enum TLSClientAuth { 8 | NONE, 9 | WANT, 10 | NEED 11 | } 12 | -------------------------------------------------------------------------------- /src/org/jgroups/util/ThreadFactory.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.util; 2 | 3 | public interface ThreadFactory extends java.util.concurrent.ThreadFactory { 4 | Thread newThread(Runnable r, String name); 5 | boolean useVirtualThreads(); 6 | void setPattern(String pattern); 7 | void setIncludeClusterName(boolean includeClusterName); 8 | void setClusterName(String channelName); 9 | void setAddress(String address); 10 | void renameThread(String base_name, Thread thread); 11 | } 12 | -------------------------------------------------------------------------------- /src/org/jgroups/util/Triple.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.util; 2 | 3 | /** 4 | * Holds 3 values, useful when we have a map with a key, but more than 1 value and we don't want to create a separate 5 | * holder object for the values, and don't want to pass the values as a list or array. 6 | * @author Bela Ban 7 | */ 8 | public class Triple { 9 | private V1 val1; 10 | private V2 val2; 11 | private V3 val3; 12 | 13 | public Triple(V1 val1, V2 val2, V3 val3) { 14 | this.val1=val1; 15 | this.val2=val2; 16 | this.val3=val3; 17 | } 18 | 19 | public V1 getVal1() { 20 | return val1; 21 | } 22 | 23 | public void setVal1(V1 val1) { 24 | this.val1=val1; 25 | } 26 | 27 | public V2 getVal2() { 28 | return val2; 29 | } 30 | 31 | public void setVal2(V2 val2) { 32 | this.val2=val2; 33 | } 34 | 35 | public V3 getVal3() { 36 | return val3; 37 | } 38 | 39 | public void setVal3(V3 val3) { 40 | this.val3=val3; 41 | } 42 | 43 | public String toString() { 44 | return val1 + " : " + val2 + " : " + val3; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/org/jgroups/util/Tuple.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.util; 2 | 3 | /** 4 | * Holds 2 values, useful when we have a map with a key, but more than 1 value and we don't want to create a separate 5 | * holder object for the values, and don't want to pass the values as a list or array. 6 | * @author Bela Ban 7 | */ 8 | public class Tuple { 9 | private final V1 val1; 10 | private final V2 val2; 11 | 12 | public Tuple(V1 val1, V2 val2) { 13 | this.val1=val1; 14 | this.val2=val2; 15 | } 16 | 17 | public V1 getVal1() {return val1;} 18 | public V2 getVal2() {return val2;} 19 | 20 | public String toString() { 21 | return String.format("%s: %s", val1, val2); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/org/jgroups/util/UnbatchOOBBatches.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.util; 2 | 3 | import org.jgroups.Message; 4 | import org.jgroups.annotations.Property; 5 | 6 | /** 7 | * Same as {@link MaxOneThreadPerSender}, but for OOB message batches, every message of the batch is passed to the 8 | * thread pool separately (https://issues.redhat.com/browse/JGRP-2800). 9 | * @author Bela Ban 10 | * @since 5.4, 5.3.7 11 | */ 12 | public class UnbatchOOBBatches extends MaxOneThreadPerSender { 13 | 14 | @Property(description="If > 0, then batches > max_size will be unbatched, batches <= max_size will be " + 15 | "sent up. This ensures that no batch will ever be greater than a given size.") 16 | protected int max_size; 17 | 18 | @Override 19 | public boolean process(MessageBatch batch, boolean oob) { 20 | if(!oob) 21 | return super.process(batch, oob); 22 | if(max_size > 0 && batch.size() <= max_size) 23 | return super.process(batch, oob); 24 | AsciiString tmp=batch.clusterName(); 25 | byte[] cname=tmp != null? tmp.chars() : null; 26 | for(Message msg: batch) 27 | tp.getThreadPool().execute(new SingleMessageHandlerWithClusterName(msg, cname)); 28 | batch.clear(); 29 | return true; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/org/jgroups/util/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Provides useful functionality which cannot be assigned to any particular other package. 4 | 5 | -------------------------------------------------------------------------------- /tests/byteman/org/jgroups/tests/helpers/BecomeServerTestHelper.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.tests.helpers; 2 | 3 | import org.jboss.byteman.rule.Rule; 4 | import org.jboss.byteman.rule.helper.Helper; 5 | import org.jgroups.Message; 6 | 7 | import java.util.Queue; 8 | 9 | /** 10 | * @author Bela Ban 11 | * @since 3.3 12 | */ 13 | public class BecomeServerTestHelper extends Helper { 14 | 15 | protected BecomeServerTestHelper(Rule rule) { 16 | super(rule); 17 | } 18 | 19 | /** 20 | * Checks if any of the messages in the list has a non-zero length 21 | * @param list 22 | * @return 23 | */ 24 | public boolean messageReceived(Queue list) { 25 | if(list == null || list.isEmpty()) 26 | return false; 27 | for(Message msg: list) 28 | if(msg.getLength() > 0) 29 | return true; 30 | return false; 31 | } 32 | 33 | public int rv(String rv_name, String ctx) { 34 | traceln(String.format("-- acquiring rendezvous %s (ctx: %s)\n", rv_name, ctx)); 35 | int rc=rendezvous(rv_name); 36 | traceln(String.format("-- acquired rendezvous %s (ctx: %s): rc=%d\n", rv_name, ctx, rc)); 37 | return rc; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /tests/byteman/org/jgroups/tests/helpers/MessageBeforeConnectedTestHelper.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.tests.helpers; 2 | 3 | import org.jboss.byteman.rule.Rule; 4 | import org.jboss.byteman.rule.helper.Helper; 5 | import org.jgroups.BytesMessage; 6 | import org.jgroups.JChannel; 7 | import org.jgroups.Message; 8 | import org.jgroups.protocols.UNICAST3; 9 | import org.jgroups.protocols.UnicastHeader3; 10 | 11 | /** 12 | * @author Bela Ban 13 | * @since 3.3 14 | */ 15 | public class MessageBeforeConnectedTestHelper extends Helper { 16 | 17 | protected MessageBeforeConnectedTestHelper(Rule rule) { 18 | super(rule); 19 | } 20 | 21 | /** 22 | * Sends a unicast message up UNICAST2. Do *NOT* make this method static, or Byteman will not find it! 23 | */ 24 | public void sendUnicast(JChannel ch) throws Exception { 25 | final Message msg=new BytesMessage(ch.getAddress(), "hello-1").setSrc(ch.getAddress()); 26 | 27 | // Add a UNICAST2 header 28 | final UNICAST3 unicast=ch.getProtocolStack().findProtocol(UNICAST3.class); 29 | UnicastHeader3 hdr=UnicastHeader3.createDataHeader(1, (short)1, true); 30 | msg.putHeader(unicast.getId(), hdr); 31 | 32 | new Thread(() -> unicast.down(msg)).start(); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /tests/byteman/org/jgroups/tests/helpers/SendUnicast.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.tests.helpers; 2 | 3 | import org.jgroups.Address; 4 | import org.jgroups.BytesMessage; 5 | import org.jgroups.protocols.pbcast.GMS; 6 | 7 | /** 8 | * @author Bela Ban 9 | * @since 4.0 10 | */ 11 | public class SendUnicast { 12 | public static void sendUnicast(GMS gms, Address dest) { 13 | gms.down(new BytesMessage(dest, "sorry for the interruption :-)")); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /tests/byteman/org/jgroups/tests/helpers/SequencerFailoverTestHelper.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.tests.helpers; 2 | 3 | import org.jboss.byteman.rule.Rule; 4 | import org.jboss.byteman.rule.helper.Helper; 5 | import org.jgroups.BytesMessage; 6 | import org.jgroups.Message; 7 | import org.jgroups.stack.Protocol; 8 | 9 | /** 10 | * @author Bela Ban 11 | * @since 3.1 12 | */ 13 | public class SequencerFailoverTestHelper extends Helper { 14 | 15 | protected SequencerFailoverTestHelper(Rule rule) { 16 | super(rule); 17 | } 18 | 19 | // Do *NOT* make this method static, or else Byteman won't be able to find it! 20 | public void sendMessages(final Protocol prot, final int start, final int end) { 21 | final Thread sender=new Thread(() -> { 22 | for(int i=start; i <= end; i++) { 23 | Message msg=new BytesMessage(null, i); 24 | System.out.println("[" + prot.getValue("local_addr") + "] --> sending message " + i); 25 | prot.down(msg); 26 | } 27 | }); 28 | sender.setName("BytemanSenderThread"); 29 | sender.start(); 30 | try { 31 | sender.join(1000); 32 | } 33 | catch(InterruptedException e) { 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /tests/byteman/org/jgroups/tests/helpers/ServerTestHelper.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.tests.helpers; 2 | 3 | import org.jboss.byteman.rule.Rule; 4 | import org.jboss.byteman.rule.helper.Helper; 5 | import org.jgroups.Address; 6 | import org.jgroups.tests.byteman.ServerTest; 7 | 8 | /** 9 | * @author Bela Ban 10 | * @since 3.3 11 | */ 12 | public class ServerTestHelper extends Helper { 13 | protected ServerTestHelper(Rule rule) { 14 | super(rule); 15 | } 16 | 17 | public static boolean isAddress(Object obj) { 18 | return obj instanceof Address; 19 | } 20 | 21 | public static boolean isA(Object obj) { 22 | return obj.equals(ServerTest.A); 23 | } 24 | public static boolean isB(Object obj) { 25 | return obj.equals(ServerTest.B); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /tests/junit-functional/org/jgroups/protocols/ASYM_ENCRYPT_LeaveTestCbc.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.protocols; 2 | 3 | /** 4 | * Exercise ASYM_ENCRYPT_LeaveTest with CBC mode cipher. 5 | */ 6 | public class ASYM_ENCRYPT_LeaveTestCbc extends ASYM_ENCRYPT_LeaveTest { 7 | @Override protected String symAlgorithm() { return "AES/CBC/PKCS5Padding"; } 8 | @Override protected int symIvLength() { return 16; } 9 | 10 | /** For some obscure TestNG reasons, this method is needed. Remove it and all tests are executed in separate threads, 11 | * which makes the testsuite fail!!! */ 12 | public void dummy2() {} 13 | } 14 | -------------------------------------------------------------------------------- /tests/junit-functional/org/jgroups/protocols/ASYM_ENCRYPT_LeaveTestKeyExchange.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.protocols; 2 | 3 | /** 4 | * Tests graceful leaving of the coordinator and second-in-line in a 10 node cluster with ASYM_ENCRYPT configured. 5 | *
6 | * Reproducer for https://issues.redhat.com/browse/JGRP-2297 7 | * @author Bela Ban 8 | * @since 4.0.12 9 | */ 10 | public class ASYM_ENCRYPT_LeaveTestKeyExchange extends ASYM_ENCRYPT_LeaveTest { 11 | @Override protected boolean useExternalKeyExchange() {return true;} 12 | 13 | /** For some obscure TestNG reasons, this method is needed. Remove it and all tests are executed in separate threads, 14 | * which makes the testsuite fail!!! */ 15 | public void dummy2() {} 16 | } 17 | -------------------------------------------------------------------------------- /tests/junit-functional/org/jgroups/protocols/ASYM_ENCRYPT_LeaveTestKeyExchangeCbc.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.protocols; 2 | 3 | /** 4 | * Exercise ASYM_ENCRYPT_LeaveTestKeyExchange with CBC mode cipher. 5 | */ 6 | public class ASYM_ENCRYPT_LeaveTestKeyExchangeCbc extends ASYM_ENCRYPT_LeaveTestKeyExchange { 7 | @Override protected String symAlgorithm() { return "AES/CBC/PKCS5Padding"; } 8 | @Override protected int symIvLength() { return 16; } 9 | 10 | /** For some obscure TestNG reasons, this method is needed. Remove it and all tests are executed in separate threads, 11 | * which makes the testsuite fail!!! */ 12 | public void dummy3() {} 13 | } 14 | -------------------------------------------------------------------------------- /tests/junit-functional/org/jgroups/protocols/ASYM_ENCRYPT_TestCbc.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.protocols; 2 | 3 | import org.testng.annotations.AfterMethod; 4 | 5 | /** 6 | * Exercise ASYM_ENCRYPT_Test with CBC mode cipher. 7 | */ 8 | public class ASYM_ENCRYPT_TestCbc extends ASYM_ENCRYPT_Test { 9 | 10 | @Override protected String symAlgorithm() { return "AES/CBC/PKCS5Padding"; } 11 | @Override protected int symIvLength() { return 16; } 12 | 13 | /** For some obscure TestNG reasons, this method is needed. Remove it and all tests are executed in separate threads, 14 | * which makes the testsuite fail!!! */ 15 | public void dummy2() {} 16 | 17 | } 18 | -------------------------------------------------------------------------------- /tests/junit-functional/org/jgroups/protocols/ASYM_ENCRYPT_TestKeyExchangeCbc.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.protocols; 2 | 3 | /** 4 | * Exercise ASYM_ENCRYPT_TestKeyExchange with CBC mode cipher. 5 | */ 6 | public class ASYM_ENCRYPT_TestKeyExchangeCbc extends ASYM_ENCRYPT_TestKeyExchange { 7 | 8 | @Override protected String symAlgorithm() { return "AES/CBC/PKCS5Padding"; } 9 | @Override protected int symIvLength() { return 16; } 10 | 11 | /** For some obscure TestNG reasons, this method is needed. Remove it and all tests are executed in separate threads, 12 | * which makes the testsuite fail!!! */ 13 | public void dummy2() {} 14 | 15 | } 16 | -------------------------------------------------------------------------------- /tests/junit-functional/org/jgroups/protocols/AUTHTest.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.protocols; 2 | 3 | 4 | import org.jgroups.Global; 5 | import org.jgroups.auth.FixedMembershipToken; 6 | import org.jgroups.stack.IpAddress; 7 | import org.testng.annotations.Test; 8 | 9 | /** 10 | * A set of tests for the AUTH protocol 11 | * @author Chris Mills 12 | */ 13 | @Test(groups=Global.FUNCTIONAL) 14 | public class AUTHTest { 15 | 16 | public void testFixedMembershipTokenIPv4() throws Exception { 17 | FixedMembershipToken tok=new FixedMembershipToken(); 18 | tok.setMemberList("192.168.1.6,10.1.1.1/7500,localhost/7800"); 19 | assert !tok.isInMembersList(new IpAddress("192.168.1.3", 7500)); 20 | assert !tok.isInMembersList(new IpAddress("10.1.1.1", 7000)); 21 | assert tok.isInMembersList(new IpAddress("10.1.1.1", 7500)); 22 | assert tok.isInMembersList(new IpAddress("192.168.1.6", 7500)); // port is not matched 23 | assert tok.isInMembersList(new IpAddress("192.168.1.6", 0)); // port is not matched 24 | } 25 | 26 | 27 | public void testFixedMembershipTokenIPv6() throws Exception { 28 | FixedMembershipToken tok=new FixedMembershipToken(); 29 | tok.setMemberList("fe80::aa20:66ff:fe11:d346,2a02:120b:2c45:1b70:aa20:66ff:fe11:d346/7500,2a02:120b:2c45:1b70:f474:e6ca:3038:6b5f/7500"); 30 | assert tok.isInMembersList(new IpAddress("2a02:120b:2c45:1b70:f474:e6ca:3038:6b5f", 7500)); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /tests/junit-functional/org/jgroups/protocols/COMPRESS_Test.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.protocols; 2 | 3 | import org.jgroups.BytesMessage; 4 | import org.jgroups.Global; 5 | import org.jgroups.JChannel; 6 | import org.jgroups.Message; 7 | import org.jgroups.util.MyReceiver; 8 | import org.jgroups.util.Util; 9 | import org.testng.annotations.AfterMethod; 10 | import org.testng.annotations.Test; 11 | 12 | /** 13 | * @author Bela Ban 14 | * @since 5.0 15 | */ 16 | @Test(groups=Global.FUNCTIONAL,singleThreaded=true) 17 | public class COMPRESS_Test { 18 | protected JChannel a, b; 19 | protected MyReceiver r1=new MyReceiver().rawMsgs(true), r2=new MyReceiver().rawMsgs(true); 20 | 21 | @AfterMethod 22 | protected void destroy() {Util.close(r2, r1, b, a);} 23 | 24 | 25 | public void testSimpleCompression() throws Exception { 26 | a=create("A").connect(COMPRESS_Test.class.getSimpleName()); 27 | b=create("B").connect(COMPRESS_Test.class.getSimpleName()); 28 | Util.waitUntilAllChannelsHaveSameView(10000, 500, a,b); 29 | a.setReceiver(r1); b.setReceiver(r2); 30 | byte[] array=Util.generateArray(100); 31 | a.send(new BytesMessage(b.getAddress(), array)); 32 | Util.waitUntil(10000, 500, () -> r2.size() > 0); 33 | Message msg=r2.list().get(0); 34 | assert msg.hasPayload() && msg.getLength() == array.length; 35 | Util.verifyArray(msg.getArray()); 36 | } 37 | 38 | 39 | 40 | protected static JChannel create(String name) throws Exception { 41 | return new JChannel(Util.getTestStack(new COMPRESS().setMinSize(50))).name(name); 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /tests/junit-functional/org/jgroups/protocols/ENCRYPTKeystoreTestCbc.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.protocols; 2 | 3 | /** 4 | * Exercise ENCRYPTKeystoreTest with CBC mode cipher. 5 | */ 6 | public class ENCRYPTKeystoreTestCbc extends ENCRYPTKeystoreTest { 7 | @Override protected String symAlgorithm() { return "AES/CBC/PKCS5Padding"; } 8 | @Override protected int symIvLength() { return 16; } 9 | 10 | /** For some obscure TestNG reasons, this method is needed. Remove it and all tests are executed in separate threads, 11 | * which makes the testsuite fail!!! */ 12 | public void dummy2() {} 13 | } 14 | -------------------------------------------------------------------------------- /tests/junit-functional/org/jgroups/protocols/FD_SOCK2_Test.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.protocols; 2 | 3 | import org.jgroups.Global; 4 | import org.jgroups.JChannel; 5 | import org.jgroups.util.Util; 6 | import org.testng.annotations.AfterMethod; 7 | import org.testng.annotations.Test; 8 | 9 | import java.util.logging.Logger; 10 | 11 | /** 12 | * Test for {@link FD_SOCK2} not closing its sockets within the {@link FD_SOCK2#stop()} call and subsequently failing 13 | * when subsequently started again (e.g. triggered by redeploy in WildFly). Reproducible by connecting and disconnecting 14 | * the channel in a loop. Typically happens on a modern machine within seconds. 15 | * 16 | * @author Radoslav Husar 17 | * @see
JGRP-2647 18 | */ 19 | @Test(groups = Global.FUNCTIONAL, singleThreaded = true) 20 | public class FD_SOCK2_Test { 21 | 22 | protected JChannel a; 23 | 24 | public void testSocketClosing() throws Exception { 25 | a = new JChannel(Util.getTestStack( 26 | new FD_SOCK2().setPortRange(1).setOffset(1)) 27 | ).name("A"); 28 | 29 | for (int i = 0; i < 1_000; i++) { 30 | try { 31 | a.connect(FD_SOCK2_Test.class.getSimpleName()); 32 | } catch (Exception e) { 33 | Logger.getLogger(FD_SOCK2_Test.class.getSimpleName()).info(String.format("FD_SOCK2 socket close test failed on run #%d", i)); 34 | throw e; 35 | } 36 | 37 | a.disconnect(); 38 | } 39 | } 40 | 41 | @AfterMethod 42 | protected void destroy() { 43 | Util.close(a); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /tests/junit-functional/org/jgroups/protocols/SYM_ENCRYPT_TestCbc.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.protocols; 2 | 3 | /** 4 | * Exercise SYM_ENCRYPT_Test with CBC mode cipher. 5 | */ 6 | public class SYM_ENCRYPT_TestCbc extends SYM_ENCRYPT_Test { 7 | 8 | @Override protected String symAlgorithm() { return "AES/CBC/PKCS5Padding"; } 9 | @Override protected int symIvLength() { return 16; } 10 | 11 | /** 12 | * For some obscure TestNG reasons, this method is needed. Remove it and all tests are executed in separate threads, 13 | * which makes the testsuite fail!!! 14 | */ 15 | public void dummy2() {} 16 | 17 | } 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /tests/junit-functional/org/jgroups/protocols/TCPPING_Test.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.protocols; 2 | 3 | import org.jgroups.Global; 4 | import org.jgroups.JChannel; 5 | import org.jgroups.stack.IpAddress; 6 | import org.jgroups.util.Util; 7 | import org.testng.annotations.AfterMethod; 8 | import org.testng.annotations.Test; 9 | 10 | import java.net.InetAddress; 11 | import java.net.InetSocketAddress; 12 | import java.util.Collections; 13 | import java.util.List; 14 | 15 | /** 16 | * @author Bela Ban 17 | * @since 4.0.3 18 | */ 19 | @Test(groups=Global.FUNCTIONAL) 20 | public class TCPPING_Test { 21 | protected JChannel ch; 22 | 23 | @AfterMethod protected void destroy() {Util.close(ch);} 24 | 25 | /** Tests https://issues.redhat.com/browse/JGRP-2168 */ 26 | public void testSettingInitialHostsProgrammatically() throws Exception { 27 | TCP transport=new TCP(); 28 | transport.setBindAddress(InetAddress.getLoopbackAddress()); 29 | transport.setBindPort(9800); 30 | TCPPING ping=new TCPPING(); 31 | TCPGOSSIP gossip=new TCPGOSSIP(); 32 | List gossip_router=Collections.singletonList(new InetSocketAddress(InetAddress.getLoopbackAddress(), 12000)); 33 | gossip.setInitialHosts(gossip_router); 34 | ping.setInitialHosts2(Collections.singletonList(new IpAddress(transport.getBindAddress(), transport.getBindPort()))); 35 | ch=new JChannel(transport, ping, gossip); 36 | assert !ping.getInitialHosts().isEmpty() : "No initial hosts!"; 37 | assert !gossip.getInitialHosts().isEmpty(): "no initial hosts!"; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /tests/junit-functional/org/jgroups/tests/BitmapTest.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.tests; 2 | 3 | import org.jgroups.Global; 4 | import org.jgroups.protocols.FD_ALL3; 5 | import org.testng.annotations.Test; 6 | 7 | /** 8 | * Tests {@link org.jgroups.protocols.FD_ALL3.Bitmap} 9 | * @author Bela Ban 10 | * @since 5.0.0 11 | */ 12 | @Test(groups=Global.FUNCTIONAL) 13 | public class BitmapTest { 14 | 15 | public void testIndex() { 16 | FD_ALL3.Bitmap bm=new FD_ALL3.Bitmap(5); 17 | assert bm.getIndex() == 0; 18 | bm.advance(); 19 | assert bm.getIndex() == 1; 20 | } 21 | 22 | public void testNeedsToSuspect() { 23 | FD_ALL3.Bitmap bm=new FD_ALL3.Bitmap(5); 24 | assert !bm.needsToSuspect(); 25 | for(int i=0; i < 4; i++) { 26 | bm.advance(); 27 | assert !bm.needsToSuspect(); 28 | } 29 | assert !bm.needsToSuspect(); 30 | bm.advance(); 31 | assert bm.needsToSuspect(); 32 | bm.set(); 33 | assert !bm.needsToSuspect(); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /tests/junit-functional/org/jgroups/tests/ByteArrayTest.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.tests; 2 | 3 | import org.jgroups.Global; 4 | import org.jgroups.util.ByteArray; 5 | import org.testng.annotations.Test; 6 | 7 | import java.util.Arrays; 8 | 9 | /** 10 | * @author Bela Ban 11 | * @since 5.0.0 12 | */ 13 | @Test(groups=Global.FUNCTIONAL) 14 | public class ByteArrayTest { 15 | protected static final byte[] HELLO="hello world".getBytes(); 16 | 17 | public void testGetBytes() { 18 | ByteArray ba=new ByteArray(HELLO); 19 | byte[] bytes=ba.getBytes(); 20 | assert Arrays.equals(bytes, HELLO); 21 | assert HELLO.hashCode() == bytes.hashCode(); // same memory location 22 | 23 | ba=new ByteArray(HELLO, 0, 5); 24 | bytes=ba.getBytes(); 25 | assert HELLO.hashCode() != bytes.hashCode(); 26 | assert new String(bytes).equals("hello"); 27 | 28 | ba=new ByteArray(HELLO, 6, 5); 29 | bytes=ba.getBytes(); 30 | assert HELLO.hashCode() != bytes.hashCode(); 31 | assert new String(bytes).equals("world"); 32 | 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /tests/junit-functional/org/jgroups/tests/ByteBufferOutputStreamTest.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.tests; 2 | 3 | import org.jgroups.Address; 4 | import org.jgroups.BytesMessage; 5 | import org.jgroups.Global; 6 | import org.jgroups.Message; 7 | import org.jgroups.protocols.pbcast.NakAckHeader2; 8 | import org.jgroups.util.ByteBufferInputStream; 9 | import org.jgroups.util.ByteBufferOutputStream; 10 | import org.jgroups.util.Util; 11 | import org.testng.annotations.Test; 12 | 13 | import java.nio.ByteBuffer; 14 | 15 | /** 16 | * Tests {@link ByteBufferOutputStream} 17 | * @author Bela Ban 18 | * @since 3.5 19 | */ 20 | @Test(groups=Global.FUNCTIONAL) 21 | public class ByteBufferOutputStreamTest { 22 | 23 | public void testConstruction() throws Exception { 24 | Address dest=Util.createRandomAddress("A"); 25 | Message msg=new BytesMessage(dest, "hello world") 26 | .setFlag(Message.Flag.DONT_BUNDLE, Message.Flag.OOB).putHeader((short)22, NakAckHeader2.createMessageHeader(322649)); 27 | int size=msg.size(); 28 | ByteBuffer buf=ByteBuffer.allocate(size); 29 | ByteBufferOutputStream out=new ByteBufferOutputStream(buf); 30 | msg.writeTo(out); 31 | 32 | buf.flip(); 33 | byte[] array=new byte[buf.limit()]; 34 | System.arraycopy(buf.array(), buf.arrayOffset(), array, 0, buf.limit()); 35 | ByteBufferInputStream in=new ByteBufferInputStream(ByteBuffer.wrap(array)); 36 | Message copy=new BytesMessage(); 37 | copy.readFrom(in); 38 | System.out.println("copy = " + copy); 39 | assert msg.getDest() != null && msg.getDest().equals(dest); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /tests/junit-functional/org/jgroups/tests/ClassConfiguratorTest.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.tests; 2 | 3 | import org.jgroups.Global; 4 | import org.jgroups.conf.ClassConfigurator; 5 | import org.jgroups.stack.Protocol; 6 | import org.testng.annotations.Test; 7 | 8 | /** 9 | * @author Bela Ban 10 | * @since 4.0.8 11 | */ 12 | @Test(groups=Global.FUNCTIONAL) 13 | public class ClassConfiguratorTest { 14 | protected static final short ID=512; 15 | 16 | public void testAddProtocol() { 17 | ClassConfigurator.addProtocol(ID, MyProtocol.class); 18 | 19 | short id=ClassConfigurator.getProtocolId(MyProtocol.class); 20 | assert id == ID; 21 | 22 | Class prot_class=ClassConfigurator.getProtocol(ID); 23 | assert prot_class == MyProtocol.class; 24 | } 25 | 26 | 27 | 28 | 29 | protected static class MyProtocol extends Protocol { 30 | public short getId() {return ID;} 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /tests/junit-functional/org/jgroups/tests/CustomProtocolTest.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.tests; 2 | 3 | import org.jgroups.Global; 4 | import org.jgroups.JChannel; 5 | import org.jgroups.protocols.*; 6 | import org.jgroups.protocols.pbcast.GMS; 7 | import org.jgroups.protocols.pbcast.NAKACK2; 8 | import org.jgroups.protocols.pbcast.STABLE; 9 | import org.jgroups.stack.Protocol; 10 | import org.testng.annotations.Test; 11 | 12 | /** 13 | * Tests custom protocol. 14 | * Author: Lenny Phan 15 | */ 16 | public class CustomProtocolTest { 17 | 18 | @Test(groups=Global.FUNCTIONAL) 19 | public static void testMyProtocol() throws Exception { 20 | JChannel channel=new JChannel(new UDP(), 21 | new org.jgroups.tests.CustomProtocolTest.MyProtocol(), 22 | new PING(), 23 | new FD_ALL3(), new VERIFY_SUSPECT(), new NAKACK2(), new UNICAST3(), 24 | new STABLE(), new FRAG2(), new GMS()); 25 | System.out.println("channel = " + channel); 26 | assert true; 27 | } 28 | 29 | 30 | public static class MyProtocol extends Protocol { 31 | 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /tests/junit-functional/org/jgroups/tests/LeaveTest.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.tests; 2 | 3 | import org.jgroups.Global; 4 | import org.jgroups.JChannel; 5 | import org.jgroups.protocols.SHARED_LOOPBACK; 6 | import org.jgroups.protocols.SHARED_LOOPBACK_PING; 7 | import org.jgroups.protocols.UNICAST3; 8 | import org.jgroups.protocols.pbcast.GMS; 9 | import org.jgroups.protocols.pbcast.NAKACK2; 10 | import org.jgroups.protocols.pbcast.STABLE; 11 | import org.testng.annotations.AfterMethod; 12 | import org.testng.annotations.Test; 13 | 14 | /** 15 | * @author Bela Ban 16 | * @since 4.0.19 17 | */ 18 | @Test(groups=Global.ENCRYPT,singleThreaded=true) 19 | public class LeaveTest extends BaseLeaveTest { 20 | 21 | @AfterMethod protected void destroy() { 22 | super.destroy(); 23 | } 24 | 25 | /** For some obscure TestNG reasons, this method is needed. Remove it and all tests are executed in separate threads, 26 | * which makes the testsuite fail!!! */ 27 | public void dummy() {} 28 | 29 | protected JChannel create(String name) throws Exception { 30 | return new JChannel( 31 | new SHARED_LOOPBACK(), 32 | new SHARED_LOOPBACK_PING(), 33 | // omit MERGE3 from the stack -- nodes are leaving gracefully 34 | new NAKACK2().useMcastXmit(false), 35 | new UNICAST3(), 36 | new STABLE(), 37 | new GMS().setJoinTimeout(1000).printLocalAddress(false)) 38 | .name(name); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /tests/junit-functional/org/jgroups/tests/LongMessageTest.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.tests; 2 | 3 | import org.jgroups.Global; 4 | import org.jgroups.LongMessage; 5 | import org.testng.annotations.Test; 6 | 7 | /** 8 | * @author Bela Ban 9 | * @since 5.0.0 10 | */ 11 | @Test(groups=Global.FUNCTIONAL) 12 | public class LongMessageTest extends MessageTestBase { 13 | 14 | public void testConstructor() { 15 | LongMessage msg=new LongMessage().setValue(50); 16 | System.out.println("msg = " + msg); 17 | assert msg.getValue() == 50; 18 | } 19 | 20 | public void testGetUndefinedValue() { 21 | LongMessage msg=new LongMessage(); 22 | long val=msg.getValue(); 23 | assert val == 0; 24 | } 25 | 26 | public void testGetObject() { 27 | LongMessage msg=new LongMessage().setValue(22); 28 | long val=msg.getObject(); 29 | assert val == 22; 30 | } 31 | 32 | public void testSetObject() { 33 | LongMessage msg=new LongMessage(); 34 | msg.setObject(22); 35 | assert msg.getValue() == 22; 36 | msg.setObject(23L); 37 | assert msg.getValue() == 23; 38 | assert msg.getObject() instanceof Long; 39 | } 40 | 41 | public void testSize() throws Exception { 42 | LongMessage msg=new LongMessage().setValue(22); 43 | _testSize(msg); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /tests/junit-functional/org/jgroups/tests/SetPropertyTest.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.tests; 2 | 3 | import org.jgroups.Global; 4 | import org.jgroups.JChannel; 5 | import org.jgroups.protocols.TP; 6 | import org.jgroups.util.Util; 7 | import org.testng.annotations.AfterClass; 8 | import org.testng.annotations.BeforeClass; 9 | import org.testng.annotations.Test; 10 | 11 | /** 12 | * @author Bela Ban 13 | */ 14 | @Test(groups=Global.FUNCTIONAL) 15 | public class SetPropertyTest { 16 | JChannel ch; 17 | 18 | @BeforeClass 19 | void init() throws Exception { 20 | ch=new JChannel(Util.getTestStack()); 21 | } 22 | 23 | @AfterClass 24 | void destroy() { 25 | Util.close(ch); 26 | } 27 | 28 | 29 | public void testSetter() { 30 | TP transport=ch.getProtocolStack().getTransport(); 31 | int port=transport.getBindPort(); 32 | System.out.println("port = " + port); 33 | transport.setBindPort(port +20); 34 | int old_port=port; 35 | port=transport.getBindPort(); 36 | System.out.println("port = " + port); 37 | assert old_port + 20 == port; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /tests/junit-functional/org/jgroups/tests/TupleTest.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.tests; 2 | 3 | import org.jgroups.util.Tuple; 4 | import org.jgroups.Global; 5 | import org.testng.Assert; 6 | import org.testng.annotations.Test; 7 | 8 | import java.util.HashMap; 9 | import java.util.Map; 10 | 11 | /** 12 | * @author Bela Ban 13 | */ 14 | @Test(groups=Global.FUNCTIONAL) 15 | public class TupleTest { 16 | 17 | public static void testCreation() { 18 | Tuple tuple=new Tuple<>("Bela", 322649); 19 | System.out.println("tuple: " + tuple); 20 | Assert.assertEquals("Bela", tuple.getVal1()); 21 | Assert.assertEquals(322649, tuple.getVal2().intValue()); 22 | } 23 | 24 | 25 | 26 | public static void testHashMap() { 27 | Map> map=new HashMap<>(); 28 | map.put(1, new Tuple<>("one",1)); 29 | map.put(2, new Tuple<>("two", 2)); 30 | System.out.println("map: " + map); 31 | Assert.assertEquals("one", map.get(1).getVal1()); 32 | Assert.assertEquals(1, map.get(1).getVal2().intValue()); 33 | Assert.assertEquals("two", map.get(2).getVal1()); 34 | Assert.assertEquals(2, map.get(2).getVal2().intValue()); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /tests/junit-functional/org/jgroups/tests/XmlParseTest.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.tests; 2 | 3 | import org.jgroups.Global; 4 | import org.jgroups.JChannel; 5 | import org.testng.annotations.Test; 6 | 7 | /** 8 | * Tests XML file ./conf/comment-test.xml. This file contains invalid XML, but the JGroups parser is more lenient and 9 | * accepts almost all XML, e.g. nested comments, comments within attributes etc. 10 | * @author Bela Ban 11 | * @since 5.2.15 12 | */ 13 | @Test(groups= Global.FUNCTIONAL) 14 | public class XmlParseTest { 15 | public void testXML() throws Exception { 16 | try(JChannel ch=new JChannel("comment-test.xml").name("X")) { 17 | ch.connect(getClass().getSimpleName()); 18 | assert ch.isConnected(); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /tests/other/org/jgroups/tests/rt/RtReceiver.java: -------------------------------------------------------------------------------- 1 | package org.jgroups.tests.rt; 2 | 3 | /** 4 | * Receives messages from a {@link RtTransport} via a callback. Needs to be registered with {@link RtTransport} 5 | * @author Bela Ban 6 | * @since 4.0 7 | */ 8 | public interface RtReceiver { 9 | 10 | /** 11 | * Called when a message is received. Note that this method may be called by multiple threads concurrently 12 | * @param sender The address of the sender 13 | * @param buf The buffer 14 | * @param offset The offset of the data in the buffer 15 | * @param length The length (bytes) of the data 16 | */ 17 | void receive(Object sender, byte[] buf, int offset, int length); 18 | } 19 | --------------------------------------------------------------------------------