├── gradle.properties ├── settings.gradle ├── config ├── zoo.cfg ├── peer.properties ├── server.properties ├── server.xml ├── template.xml ├── peer.xml ├── _bdb.xml ├── _sql.xml ├── _server.xml └── _zookeeper.xml ├── docs ├── images │ ├── bg.png │ ├── p1.jpg │ ├── p2.jpg │ ├── t1.jpg │ ├── t2.jpg │ ├── t3.jpg │ ├── x.png │ ├── icon.png │ ├── logo.png │ ├── arrow.png │ ├── arrow2.png │ ├── arrow3.png │ ├── arrow4.png │ ├── arrow5.png │ ├── arrow6.png │ ├── bg-docs.png │ ├── cross.png │ ├── engine.png │ ├── icon1.png │ ├── icon10.png │ ├── icon2.png │ ├── icon3.png │ ├── icon4.png │ ├── icon5.png │ ├── icon6.png │ ├── icon7.png │ ├── icon8.png │ ├── icon9.png │ ├── icons.png │ ├── logo1.png │ ├── logo2.png │ ├── part1.png │ ├── part11.png │ ├── part2.png │ ├── part21.png │ ├── part212.png │ ├── part3.png │ ├── part31.png │ ├── part4.png │ ├── shadow.png │ ├── shadow1.png │ ├── shadow2.png │ ├── shadow3.png │ ├── title1.png │ ├── title2.png │ ├── title3.png │ ├── title4.png │ ├── bg-orange.png │ ├── icon-doc.png │ ├── icon-doc1.png │ ├── icon-doc2.png │ ├── icon-doc3.png │ ├── icon-doc4.png │ ├── icon-git.png │ ├── indicator.png │ ├── comsat_big.png │ ├── galaxy_big.png │ ├── icon-doc11.png │ ├── icon-doc21.png │ ├── icon-doc31.png │ ├── icon-doc41.png │ ├── icon-email.png │ ├── icon-title.png │ ├── icon_hover.png │ ├── logo-footer.png │ ├── quasar_big.png │ ├── spacebase_sm.png │ ├── download-icon.png │ ├── galaxy_shadow.png │ ├── icon-package1.png │ ├── icon-package2.png │ ├── icon-package3.png │ ├── spacebase_big.png │ ├── inner-head-icon.png │ └── spacebase_big_shadow.png ├── css │ ├── fonts │ │ ├── FairpNarMedIta.eot │ │ ├── FairpNarMedIta.otf │ │ ├── FairpNarMedIta.ttf │ │ └── FairpNarMedIta.woff │ └── pygments │ │ └── linenos.css ├── _plugins │ ├── svg_support.rb │ ├── exclude_toc.filter.rb │ ├── domain_name.filter.rb │ ├── include_external.rb │ ├── sorted_for.rb │ ├── enhanced_kramdown.rb │ └── markdown_converter.rb ├── _config.yml ├── _includes │ ├── top-nav.html │ ├── meta.html │ ├── footer.html │ └── header.html └── _layouts │ └── default.html ├── baselib ├── gradle-test.jar └── high-scale-lib.jar ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── src ├── test │ ├── resources │ │ └── config │ │ │ ├── basepeer.properties │ │ │ ├── peer1.properties │ │ │ ├── peer2.properties │ │ │ ├── peer3.properties │ │ │ ├── server.properties │ │ │ ├── serverWithZkNamespace.properties │ │ │ ├── server.xml │ │ │ ├── serverJG.xml │ │ │ ├── serverZK.xml │ │ │ ├── template.xml │ │ │ ├── peer.xml │ │ │ ├── peerNoServer.xml │ │ │ ├── peerWithJGServer.xml │ │ │ ├── peerWithZKServer.xml │ │ │ ├── _bdb.xml │ │ │ ├── _sql.xml │ │ │ ├── _server.xml │ │ │ └── _zookeeper.xml │ └── java │ │ └── co │ │ └── paralleluniverse │ │ └── galaxy │ │ ├── core │ │ ├── FullCluster.java │ │ ├── NodeInfoMatchers.java │ │ ├── MessageMatcher.java │ │ ├── NodeInfoMatcher.java │ │ ├── MessageMatchers.java │ │ ├── MessageOfType.java │ │ └── NodeInfoPropertyEqual.java │ │ ├── test │ │ ├── CollectionMatchers.java │ │ ├── ClonesArguments.java │ │ └── ThreadTreeLocal.java │ │ ├── netty │ │ ├── MessagePacketMatchers.java │ │ ├── MessagePacketEqualTo.java │ │ └── MessagePacketContains.java │ │ └── zookeeper │ │ └── ZooKeeperDistributedTreeTKB.java └── main │ └── java │ └── co │ └── paralleluniverse │ ├── common │ ├── MonitoringType.java │ ├── collection │ │ ├── LongObjectProcedure.java │ │ ├── ConcurrentMultimapWithCopyOnWriteArrayList.java │ │ ├── ConcurrentMapComplex.java │ │ ├── ConcurrentMultimap.java │ │ ├── ConcurrentLongSet.java │ │ └── LongRange.java │ ├── io │ │ ├── Checksum.java │ │ ├── VersionedPersistable.java │ │ ├── HashFunctionChecksum.java │ │ ├── Persistable.java │ │ ├── Streamable.java │ │ ├── MessageDigestChecksum.java │ │ └── Hasher.java │ ├── logging │ │ └── LoggingUtils.java │ ├── concurrent │ │ ├── CurrentThreadExecutor.java │ │ ├── WithExecutor.java │ │ └── QueueFactory.java │ ├── spring │ │ └── NullBean.java │ └── monitoring │ │ ├── ThreadPoolExecutorMXBean.java │ │ └── Metrics.java │ ├── galaxy │ ├── core │ │ ├── NodeAttached.java │ │ ├── NodeTask.java │ │ ├── MessageReceiver.java │ │ ├── MessageHeader.java │ │ ├── LocalStorageMonitor.java │ │ ├── RootLocker.java │ │ ├── OffHeapLocalStorageMonitor.java │ │ ├── SlaveComm.java │ │ ├── ServerComm.java │ │ ├── CacheStorage.java │ │ ├── BackupMonitor.java │ │ ├── Comm.java │ │ ├── MainMemoryMonitor.java │ │ ├── NodeNotFoundException.java │ │ ├── RefAllocator.java │ │ ├── CacheMonitor.java │ │ ├── Backup.java │ │ ├── CommThread.java │ │ ├── ConfigurableThreadPool.java │ │ ├── RefAllocatorSupport.java │ │ ├── MetricsBackupMonitor.java │ │ └── MetricsMainMemoryMonitor.java │ ├── cluster │ │ ├── ReaderWriter.java │ │ ├── SlaveAddressResolver.java │ │ ├── NodeAddressResolver.java │ │ ├── NodePropertyListener.java │ │ ├── NodeChangeListener.java │ │ ├── SlaveConfigurationListener.java │ │ ├── LifecycleListener.java │ │ └── NodeInfo.java │ ├── monitoring │ │ ├── LocalStorageMXBean.java │ │ ├── PeriodicMXBean.java │ │ ├── MainMemoryMXBean.java │ │ ├── BackupMXBean.java │ │ ├── OffHeapLocalStorageMXBean.java │ │ ├── ClusterMXBean.java │ │ └── Counter.java │ ├── netty │ │ ├── UDPCommMXBean.java │ │ ├── ChannelNodeinfo.java │ │ ├── NettyUtils.java │ │ ├── ChannelAttachedNodeResolver.java │ │ ├── MessageCodec.java │ │ ├── ChannelMessageNodeResolver.java │ │ ├── ChannelNodeAddressResolver.java │ │ ├── UDPCommMonitor.java │ │ ├── MasterNodesFilteringHandler.java │ │ ├── UdpMessagePipelineFactory.java │ │ └── SocketNodeAddressResolver.java │ ├── RefNotFoundException.java │ ├── MessageListener.java │ ├── LineFunction.java │ ├── jgroups │ │ ├── ExtendedChannel.java │ │ ├── JGroupsNodeAddressResolver.java │ │ ├── Channel.java │ │ └── JGroupsConstants.java │ ├── TimeoutException.java │ ├── ItemState.java │ ├── server │ │ ├── MainMemoryDB.java │ │ └── MainMemoryEntry.java │ ├── AbstractCacheListener.java │ ├── StoreTransaction.java │ ├── Cache.java │ └── CacheListener.java │ └── io │ └── serialization │ ├── WriteReplace.java │ ├── ByteArraySerializer.java │ ├── IOStreamSerializer.java │ └── kryo │ ├── ExternalizableKryoSerializer.java │ └── ReferenceSerializer.java ├── .gitignore ├── CONTRIBUTING.md ├── .travis.yml ├── licenses ├── LICENSE.slf4j.txt ├── LICENSE.jzlib.txt ├── LICENSE.asm.txt ├── LICENSE.publicdomain.txt ├── LICENSE.protobuf.txt └── LICENSE.bdb_je.txt ├── log4j.xml └── travis └── post_build.sh /gradle.properties: -------------------------------------------------------------------------------- 1 | APACHE_CURATOR_VERSION = 2.8.0 -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'galaxy' 2 | -------------------------------------------------------------------------------- /config/zoo.cfg: -------------------------------------------------------------------------------- 1 | tickTime=2000 2 | dataDir=/tmp/zookeeper 3 | clientPort=2181 -------------------------------------------------------------------------------- /docs/images/bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/puniverse/galaxy/HEAD/docs/images/bg.png -------------------------------------------------------------------------------- /docs/images/p1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/puniverse/galaxy/HEAD/docs/images/p1.jpg -------------------------------------------------------------------------------- /docs/images/p2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/puniverse/galaxy/HEAD/docs/images/p2.jpg -------------------------------------------------------------------------------- /docs/images/t1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/puniverse/galaxy/HEAD/docs/images/t1.jpg -------------------------------------------------------------------------------- /docs/images/t2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/puniverse/galaxy/HEAD/docs/images/t2.jpg -------------------------------------------------------------------------------- /docs/images/t3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/puniverse/galaxy/HEAD/docs/images/t3.jpg -------------------------------------------------------------------------------- /docs/images/x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/puniverse/galaxy/HEAD/docs/images/x.png -------------------------------------------------------------------------------- /docs/images/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/puniverse/galaxy/HEAD/docs/images/icon.png -------------------------------------------------------------------------------- /docs/images/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/puniverse/galaxy/HEAD/docs/images/logo.png -------------------------------------------------------------------------------- /baselib/gradle-test.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/puniverse/galaxy/HEAD/baselib/gradle-test.jar -------------------------------------------------------------------------------- /docs/images/arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/puniverse/galaxy/HEAD/docs/images/arrow.png -------------------------------------------------------------------------------- /docs/images/arrow2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/puniverse/galaxy/HEAD/docs/images/arrow2.png -------------------------------------------------------------------------------- /docs/images/arrow3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/puniverse/galaxy/HEAD/docs/images/arrow3.png -------------------------------------------------------------------------------- /docs/images/arrow4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/puniverse/galaxy/HEAD/docs/images/arrow4.png -------------------------------------------------------------------------------- /docs/images/arrow5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/puniverse/galaxy/HEAD/docs/images/arrow5.png -------------------------------------------------------------------------------- /docs/images/arrow6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/puniverse/galaxy/HEAD/docs/images/arrow6.png -------------------------------------------------------------------------------- /docs/images/bg-docs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/puniverse/galaxy/HEAD/docs/images/bg-docs.png -------------------------------------------------------------------------------- /docs/images/cross.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/puniverse/galaxy/HEAD/docs/images/cross.png -------------------------------------------------------------------------------- /docs/images/engine.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/puniverse/galaxy/HEAD/docs/images/engine.png -------------------------------------------------------------------------------- /docs/images/icon1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/puniverse/galaxy/HEAD/docs/images/icon1.png -------------------------------------------------------------------------------- /docs/images/icon10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/puniverse/galaxy/HEAD/docs/images/icon10.png -------------------------------------------------------------------------------- /docs/images/icon2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/puniverse/galaxy/HEAD/docs/images/icon2.png -------------------------------------------------------------------------------- /docs/images/icon3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/puniverse/galaxy/HEAD/docs/images/icon3.png -------------------------------------------------------------------------------- /docs/images/icon4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/puniverse/galaxy/HEAD/docs/images/icon4.png -------------------------------------------------------------------------------- /docs/images/icon5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/puniverse/galaxy/HEAD/docs/images/icon5.png -------------------------------------------------------------------------------- /docs/images/icon6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/puniverse/galaxy/HEAD/docs/images/icon6.png -------------------------------------------------------------------------------- /docs/images/icon7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/puniverse/galaxy/HEAD/docs/images/icon7.png -------------------------------------------------------------------------------- /docs/images/icon8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/puniverse/galaxy/HEAD/docs/images/icon8.png -------------------------------------------------------------------------------- /docs/images/icon9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/puniverse/galaxy/HEAD/docs/images/icon9.png -------------------------------------------------------------------------------- /docs/images/icons.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/puniverse/galaxy/HEAD/docs/images/icons.png -------------------------------------------------------------------------------- /docs/images/logo1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/puniverse/galaxy/HEAD/docs/images/logo1.png -------------------------------------------------------------------------------- /docs/images/logo2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/puniverse/galaxy/HEAD/docs/images/logo2.png -------------------------------------------------------------------------------- /docs/images/part1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/puniverse/galaxy/HEAD/docs/images/part1.png -------------------------------------------------------------------------------- /docs/images/part11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/puniverse/galaxy/HEAD/docs/images/part11.png -------------------------------------------------------------------------------- /docs/images/part2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/puniverse/galaxy/HEAD/docs/images/part2.png -------------------------------------------------------------------------------- /docs/images/part21.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/puniverse/galaxy/HEAD/docs/images/part21.png -------------------------------------------------------------------------------- /docs/images/part212.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/puniverse/galaxy/HEAD/docs/images/part212.png -------------------------------------------------------------------------------- /docs/images/part3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/puniverse/galaxy/HEAD/docs/images/part3.png -------------------------------------------------------------------------------- /docs/images/part31.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/puniverse/galaxy/HEAD/docs/images/part31.png -------------------------------------------------------------------------------- /docs/images/part4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/puniverse/galaxy/HEAD/docs/images/part4.png -------------------------------------------------------------------------------- /docs/images/shadow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/puniverse/galaxy/HEAD/docs/images/shadow.png -------------------------------------------------------------------------------- /docs/images/shadow1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/puniverse/galaxy/HEAD/docs/images/shadow1.png -------------------------------------------------------------------------------- /docs/images/shadow2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/puniverse/galaxy/HEAD/docs/images/shadow2.png -------------------------------------------------------------------------------- /docs/images/shadow3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/puniverse/galaxy/HEAD/docs/images/shadow3.png -------------------------------------------------------------------------------- /docs/images/title1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/puniverse/galaxy/HEAD/docs/images/title1.png -------------------------------------------------------------------------------- /docs/images/title2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/puniverse/galaxy/HEAD/docs/images/title2.png -------------------------------------------------------------------------------- /docs/images/title3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/puniverse/galaxy/HEAD/docs/images/title3.png -------------------------------------------------------------------------------- /docs/images/title4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/puniverse/galaxy/HEAD/docs/images/title4.png -------------------------------------------------------------------------------- /docs/images/bg-orange.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/puniverse/galaxy/HEAD/docs/images/bg-orange.png -------------------------------------------------------------------------------- /docs/images/icon-doc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/puniverse/galaxy/HEAD/docs/images/icon-doc.png -------------------------------------------------------------------------------- /docs/images/icon-doc1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/puniverse/galaxy/HEAD/docs/images/icon-doc1.png -------------------------------------------------------------------------------- /docs/images/icon-doc2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/puniverse/galaxy/HEAD/docs/images/icon-doc2.png -------------------------------------------------------------------------------- /docs/images/icon-doc3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/puniverse/galaxy/HEAD/docs/images/icon-doc3.png -------------------------------------------------------------------------------- /docs/images/icon-doc4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/puniverse/galaxy/HEAD/docs/images/icon-doc4.png -------------------------------------------------------------------------------- /docs/images/icon-git.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/puniverse/galaxy/HEAD/docs/images/icon-git.png -------------------------------------------------------------------------------- /docs/images/indicator.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/puniverse/galaxy/HEAD/docs/images/indicator.png -------------------------------------------------------------------------------- /baselib/high-scale-lib.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/puniverse/galaxy/HEAD/baselib/high-scale-lib.jar -------------------------------------------------------------------------------- /docs/images/comsat_big.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/puniverse/galaxy/HEAD/docs/images/comsat_big.png -------------------------------------------------------------------------------- /docs/images/galaxy_big.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/puniverse/galaxy/HEAD/docs/images/galaxy_big.png -------------------------------------------------------------------------------- /docs/images/icon-doc11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/puniverse/galaxy/HEAD/docs/images/icon-doc11.png -------------------------------------------------------------------------------- /docs/images/icon-doc21.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/puniverse/galaxy/HEAD/docs/images/icon-doc21.png -------------------------------------------------------------------------------- /docs/images/icon-doc31.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/puniverse/galaxy/HEAD/docs/images/icon-doc31.png -------------------------------------------------------------------------------- /docs/images/icon-doc41.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/puniverse/galaxy/HEAD/docs/images/icon-doc41.png -------------------------------------------------------------------------------- /docs/images/icon-email.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/puniverse/galaxy/HEAD/docs/images/icon-email.png -------------------------------------------------------------------------------- /docs/images/icon-title.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/puniverse/galaxy/HEAD/docs/images/icon-title.png -------------------------------------------------------------------------------- /docs/images/icon_hover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/puniverse/galaxy/HEAD/docs/images/icon_hover.png -------------------------------------------------------------------------------- /docs/images/logo-footer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/puniverse/galaxy/HEAD/docs/images/logo-footer.png -------------------------------------------------------------------------------- /docs/images/quasar_big.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/puniverse/galaxy/HEAD/docs/images/quasar_big.png -------------------------------------------------------------------------------- /docs/images/spacebase_sm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/puniverse/galaxy/HEAD/docs/images/spacebase_sm.png -------------------------------------------------------------------------------- /docs/images/download-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/puniverse/galaxy/HEAD/docs/images/download-icon.png -------------------------------------------------------------------------------- /docs/images/galaxy_shadow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/puniverse/galaxy/HEAD/docs/images/galaxy_shadow.png -------------------------------------------------------------------------------- /docs/images/icon-package1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/puniverse/galaxy/HEAD/docs/images/icon-package1.png -------------------------------------------------------------------------------- /docs/images/icon-package2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/puniverse/galaxy/HEAD/docs/images/icon-package2.png -------------------------------------------------------------------------------- /docs/images/icon-package3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/puniverse/galaxy/HEAD/docs/images/icon-package3.png -------------------------------------------------------------------------------- /docs/images/spacebase_big.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/puniverse/galaxy/HEAD/docs/images/spacebase_big.png -------------------------------------------------------------------------------- /docs/css/fonts/FairpNarMedIta.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/puniverse/galaxy/HEAD/docs/css/fonts/FairpNarMedIta.eot -------------------------------------------------------------------------------- /docs/css/fonts/FairpNarMedIta.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/puniverse/galaxy/HEAD/docs/css/fonts/FairpNarMedIta.otf -------------------------------------------------------------------------------- /docs/css/fonts/FairpNarMedIta.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/puniverse/galaxy/HEAD/docs/css/fonts/FairpNarMedIta.ttf -------------------------------------------------------------------------------- /docs/images/inner-head-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/puniverse/galaxy/HEAD/docs/images/inner-head-icon.png -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/puniverse/galaxy/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /docs/css/fonts/FairpNarMedIta.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/puniverse/galaxy/HEAD/docs/css/fonts/FairpNarMedIta.woff -------------------------------------------------------------------------------- /docs/images/spacebase_big_shadow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/puniverse/galaxy/HEAD/docs/images/spacebase_big_shadow.png -------------------------------------------------------------------------------- /docs/_plugins/svg_support.rb: -------------------------------------------------------------------------------- 1 | require 'webrick' 2 | include WEBrick 3 | 4 | WEBrick::HTTPUtils::DefaultMimeTypes.store 'svg', 'image/svg+xml' 5 | -------------------------------------------------------------------------------- /config/peer.properties: -------------------------------------------------------------------------------- 1 | 2 | galaxy.nodeId=1 3 | galaxy.port=7051 4 | galaxy.slave_port=8051 5 | galaxy.multicast.address=225.0.0.1 6 | galaxy.multicast.port=7050 7 | -------------------------------------------------------------------------------- /src/test/resources/config/basepeer.properties: -------------------------------------------------------------------------------- 1 | 2 | galaxy.nodeId=1 3 | galaxy.port=7050 4 | galaxy.slave_port=8050 5 | galaxy.multicast.address=225.0.0.1 6 | galaxy.multicast.port=7050 7 | -------------------------------------------------------------------------------- /src/test/resources/config/peer1.properties: -------------------------------------------------------------------------------- 1 | 2 | galaxy.nodeId=1 3 | galaxy.port=7051 4 | galaxy.slave_port=8051 5 | galaxy.multicast.address=225.0.0.1 6 | galaxy.multicast.port=7050 7 | -------------------------------------------------------------------------------- /src/test/resources/config/peer2.properties: -------------------------------------------------------------------------------- 1 | 2 | galaxy.nodeId=2 3 | galaxy.port=7052 4 | galaxy.slave_port=8052 5 | galaxy.multicast.address=225.0.0.1 6 | galaxy.multicast.port=7050 7 | -------------------------------------------------------------------------------- /src/test/resources/config/peer3.properties: -------------------------------------------------------------------------------- 1 | 2 | galaxy.nodeId=3 3 | galaxy.port=7053 4 | galaxy.slave_port=8053 5 | galaxy.multicast.address=225.0.0.1 6 | galaxy.multicast.port=7050 7 | -------------------------------------------------------------------------------- /src/test/resources/config/server.properties: -------------------------------------------------------------------------------- 1 | galaxy.nodeId=0 2 | galaxy.port=9675 3 | #galaxy.slave_port=8050 4 | galaxy.zkServers=127.0.0.1:2181 5 | #galaxy.zkServers=192.168.15.5:2181 6 | -------------------------------------------------------------------------------- /src/test/resources/config/serverWithZkNamespace.properties: -------------------------------------------------------------------------------- 1 | galaxy.nodeId=0 2 | galaxy.port=9675 3 | #galaxy.slave_port=8050 4 | galaxy.zkServers=127.0.0.1:2181 5 | galaxy.zkNamespace=tests 6 | #galaxy.zkServers=192.168.15.5:2181 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | _site/ 3 | /docs/.pygments-cache/ 4 | /docs/javadoc/ 5 | /private/ 6 | /dist/ 7 | /artifacts 8 | /nbproject 9 | build/ 10 | .DS_Store 11 | /nb-build.xml 12 | /catalog.xml 13 | /.gradle/ 14 | /ivy-build.xml 15 | /.nb-gradle/ 16 | /.nb-gradle-properties 17 | -------------------------------------------------------------------------------- /docs/_plugins/exclude_toc.filter.rb: -------------------------------------------------------------------------------- 1 | require 'nokogiri' 2 | 3 | module ExcludeTocFilter 4 | def exclude_toc(html) 5 | doc = Nokogiri::HTML(html) 6 | doc.css('#markdown-toc').remove 7 | doc.to_html 8 | end 9 | end 10 | Liquid::Template.register_filter(ExcludeTocFilter) -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed Sep 03 03:38:19 IDT 2014 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.0-bin.zip 7 | -------------------------------------------------------------------------------- /docs/_config.yml: -------------------------------------------------------------------------------- 1 | markdown: enhanced_kramdown 2 | highligeter: pygments 3 | lsi: false 4 | safe: false 5 | baseurl: /galaxy 6 | 7 | # Site globals used throughout docs. 8 | project: Galaxy 9 | version: 1.4 10 | github: puniverse/galaxy 11 | google_group: "https://groups.google.com/forum/#!forum/galaxy-user" 12 | ga_tracking_id: UA-25007319-2 13 | 14 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | We are happy to receive contributions from the developer community to this free software project. If you make a non-trivial contribution and wish it merged into this project's main repository, you must first agree to and sign this [Contributor's Agreement](https://docs.google.com/a/paralleluniverse.co/forms/d/1U5GinUnRsYbvAP5W3-o11wmRkMmicD_WgRDS6Sy30HA/viewform). We appreciate your effort to making this free software better. 2 | -------------------------------------------------------------------------------- /docs/_plugins/domain_name.filter.rb: -------------------------------------------------------------------------------- 1 | # Strips https?:// from a URL. 2 | # Usage: {{ page.url | domain_name }} 3 | # https://github.com/LawrenceWoodman/domain_name-liquid_filter 4 | 5 | require 'liquid' 6 | 7 | module DomainNameFilter 8 | 9 | # Return the url's domain name 10 | def domain_name(url) 11 | return url.sub(%r{(https?://){0,1}([^/]*)(/.*$){0,1}}i, '\\2\\3') 12 | end 13 | 14 | end 15 | 16 | Liquid::Template.register_filter(DomainNameFilter) 17 | -------------------------------------------------------------------------------- /config/server.properties: -------------------------------------------------------------------------------- 1 | galaxy.nodeId=0 2 | galaxy.port=9675 3 | #galaxy.slave_port=8050 4 | 5 | # To give ZooKeeper galaxy cluster his own working directory use the following property. 6 | # Keep in mind that by default ZooKeeper galaxy cluster will do stuff at "/co.paralleluniverse.galaxy" directory. 7 | # 8 | # Usually its a good practice to separate your galaxy clusters working directories. You might want to have 9 | # one for production and other for tests for example. 10 | #galaxy.zkNamespace=prod 11 | -------------------------------------------------------------------------------- /docs/_includes/top-nav.html: -------------------------------------------------------------------------------- 1 | 2 |
3 |
4 |

documentation

5 |

{{site.project}}

6 | View on Github 7 | API 8 | File a bug 9 | Discuss 10 |
11 |
12 | 13 | -------------------------------------------------------------------------------- /docs/_plugins/include_external.rb: -------------------------------------------------------------------------------- 1 | module Jekyll 2 | class IncludeExternal < Liquid::Tag 3 | 4 | def initialize(tag_name, text, tokens) 5 | @text = text 6 | 7 | begin 8 | f = File.new(@text.strip, "r") 9 | @output = f.read() 10 | rescue => e 11 | @output = "
IncludeExternal error: #{e}
" 12 | ensure 13 | f.close unless f.nil? 14 | end 15 | 16 | super 17 | end 18 | 19 | def render(context) 20 | @output 21 | end 22 | end 23 | end 24 | 25 | Liquid::Template.register_tag('include_external', Jekyll::IncludeExternal) 26 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: java 2 | install: gradle -q assemble 3 | script: set -o pipefail; gradle -i check | sed 's/\e\[?.*?[\@-~]//g' 4 | jdk: 5 | - oraclejdk7 6 | - oraclejdk8 7 | branches: 8 | except: 9 | - gh-pages 10 | env: 11 | global: 12 | - secure: "Tmj51N8U7Ya20r1+Y0s1zwG5PV/TsKC3/ycpavk34bJ8na7MRE/ZPI57x7IRNElowOf3LRMcapWjHS0BkoxUKnUTfoP0H1cpqlgjoOHSdoVOZ+aeQKca4CRNe7CSKZVPj2zRMtlerDtNxXpa7i63ZDlWWP/L61uTbBqf4Bu8d5c=" 13 | - DOCS_BRANCH="1.4" 14 | - GEN_APIDOCS="gradle javadoc" 15 | 16 | after_success: 17 | - chmod a+x travis/post_build.sh 18 | - ./travis/post_build.sh 19 | 20 | notifications: 21 | slack: puniverse:OsnbakHrYeTcLyalVgtUeI4F 22 | -------------------------------------------------------------------------------- /src/main/java/co/paralleluniverse/common/MonitoringType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2014, Parallel Universe Software Co. All rights reserved. 3 | * 4 | * This program and the accompanying materials are dual-licensed under 5 | * either the terms of the Eclipse Public License v1.0 as published by 6 | * the Eclipse Foundation 7 | * 8 | * or (per the licensee's choosing) 9 | * 10 | * under the terms of the GNU Lesser General Public License version 3.0 11 | * as published by the Free Software Foundation. 12 | */ 13 | package co.paralleluniverse.common; 14 | 15 | /** 16 | * 17 | */ 18 | public enum MonitoringType { 19 | JMX, METRICS 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/co/paralleluniverse/common/collection/LongObjectProcedure.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2015, Parallel Universe Software Co. All rights reserved. 3 | * 4 | * This program and the accompanying materials are dual-licensed under 5 | * either the terms of the Eclipse Public License v1.0 as published by 6 | * the Eclipse Foundation 7 | * 8 | * or (per the licensee's choosing) 9 | * 10 | * under the terms of the GNU Lesser General Public License version 3.0 11 | * as published by the Free Software Foundation. 12 | */ 13 | package co.paralleluniverse.common.collection; 14 | 15 | public interface LongObjectProcedure { 16 | boolean execute(long x, T y); 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/co/paralleluniverse/galaxy/core/NodeAttached.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Galaxy 3 | * Copyright (c) 2012-2014, Parallel Universe Software Co. All rights reserved. 4 | * 5 | * This program and the accompanying materials are dual-licensed under 6 | * either the terms of the Eclipse Public License v1.0 as published by 7 | * the Eclipse Foundation 8 | * 9 | * or (per the licensee's choosing) 10 | * 11 | * under the terms of the GNU Lesser General Public License version 3.0 12 | * as published by the Free Software Foundation. 13 | */ 14 | package co.paralleluniverse.galaxy.core; 15 | 16 | /** 17 | * 18 | * @author pron 19 | */ 20 | public interface NodeAttached { 21 | short getNode(); 22 | } 23 | -------------------------------------------------------------------------------- /docs/_plugins/sorted_for.rb: -------------------------------------------------------------------------------- 1 | module Jekyll 2 | class SortedForTag < Liquid::For 3 | def render(context) 4 | sorted_collection = context[@collection_name].dup 5 | sorted_collection.reject! { |i| i.to_liquid[@attributes['sort_by']].nil? } 6 | sorted_collection.sort_by! { |i| i.to_liquid[@attributes['sort_by']] } 7 | 8 | sorted_collection_name = "#{@collection_name}_sorted".sub('.', '_') 9 | context[sorted_collection_name] = sorted_collection 10 | @collection_name = sorted_collection_name 11 | 12 | super 13 | end 14 | 15 | def end_tag 16 | 'endsorted_for' 17 | end 18 | end 19 | end 20 | 21 | Liquid::Template.register_tag('sorted_for', Jekyll::SortedForTag) -------------------------------------------------------------------------------- /src/main/java/co/paralleluniverse/galaxy/core/NodeTask.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Galaxy 3 | * Copyright (c) 2012-2014, Parallel Universe Software Co. All rights reserved. 4 | * 5 | * This program and the accompanying materials are dual-licensed under 6 | * either the terms of the Eclipse Public License v1.0 as published by 7 | * the Eclipse Foundation 8 | * 9 | * or (per the licensee's choosing) 10 | * 11 | * under the terms of the GNU Lesser General Public License version 3.0 12 | * as published by the Free Software Foundation. 13 | */ 14 | package co.paralleluniverse.galaxy.core; 15 | 16 | /** 17 | * 18 | * @author pron 19 | */ 20 | public interface NodeTask extends Runnable, NodeAttached { 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/co/paralleluniverse/io/serialization/WriteReplace.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2014, Parallel Universe Software Co. All rights reserved. 3 | * 4 | * This program and the accompanying materials are dual-licensed under 5 | * either the terms of the Eclipse Public License v1.0 as published by 6 | * the Eclipse Foundation 7 | * 8 | * or (per the licensee's choosing) 9 | * 10 | * under the terms of the GNU Lesser General Public License version 3.0 11 | * as published by the Free Software Foundation. 12 | */ 13 | package co.paralleluniverse.io.serialization; 14 | 15 | /** 16 | * 17 | * @author pron 18 | */ 19 | public interface WriteReplace { 20 | Object writeReplace(Object obj); 21 | } 22 | -------------------------------------------------------------------------------- /docs/_layouts/default.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | {% include head.html %} 5 | 6 | 7 | ֿ{% include header.html %} 8 | 9 |
10 |
11 |
12 | 15 | 16 |
17 |
18 | {{content}} 19 |
20 |
21 |
22 |
23 |
24 | 25 | {% include top-nav.html %} 26 | 27 | {% include footer.html %} 28 | 29 | 30 | -------------------------------------------------------------------------------- /src/main/java/co/paralleluniverse/galaxy/core/MessageReceiver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Galaxy 3 | * Copyright (c) 2012-2014, Parallel Universe Software Co. All rights reserved. 4 | * 5 | * This program and the accompanying materials are dual-licensed under 6 | * either the terms of the Eclipse Public License v1.0 as published by 7 | * the Eclipse Foundation 8 | * 9 | * or (per the licensee's choosing) 10 | * 11 | * under the terms of the GNU Lesser General Public License version 3.0 12 | * as published by the Free Software Foundation. 13 | */ 14 | package co.paralleluniverse.galaxy.core; 15 | 16 | /** 17 | * 18 | * @author pron 19 | */ 20 | public interface MessageReceiver { 21 | void receive(Message message); 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/co/paralleluniverse/galaxy/core/MessageHeader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Galaxy 3 | * Copyright (c) 2012-2014, Parallel Universe Software Co. All rights reserved. 4 | * 5 | * This program and the accompanying materials are dual-licensed under 6 | * either the terms of the Eclipse Public License v1.0 as published by 7 | * the Eclipse Foundation 8 | * 9 | * or (per the licensee's choosing) 10 | * 11 | * under the terms of the GNU Lesser General Public License version 3.0 12 | * as published by the Free Software Foundation. 13 | */ 14 | package co.paralleluniverse.galaxy.core; 15 | 16 | /** 17 | * 18 | * @author pron 19 | */ 20 | public class MessageHeader { 21 | short fromNode; 22 | short toNode; 23 | long transaction; 24 | } 25 | -------------------------------------------------------------------------------- /config/server.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /src/main/java/co/paralleluniverse/galaxy/core/LocalStorageMonitor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Galaxy 3 | * Copyright (c) 2012-2014, Parallel Universe Software Co. All rights reserved. 4 | * 5 | * This program and the accompanying materials are dual-licensed under 6 | * either the terms of the Eclipse Public License v1.0 as published by 7 | * the Eclipse Foundation 8 | * 9 | * or (per the licensee's choosing) 10 | * 11 | * under the terms of the GNU Lesser General Public License version 3.0 12 | * as published by the Free Software Foundation. 13 | */ 14 | package co.paralleluniverse.galaxy.core; 15 | 16 | /** 17 | * 18 | * @author pron 19 | */ 20 | interface LocalStorageMonitor { 21 | void allocated(int size); 22 | void deallocated(int size); 23 | } 24 | -------------------------------------------------------------------------------- /src/test/resources/config/server.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /src/test/resources/config/serverJG.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /src/test/resources/config/serverZK.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /src/main/java/co/paralleluniverse/galaxy/core/RootLocker.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Galaxy 3 | * Copyright (c) 2012-2014, Parallel Universe Software Co. All rights reserved. 4 | * 5 | * This program and the accompanying materials are dual-licensed under 6 | * either the terms of the Eclipse Public License v1.0 as published by 7 | * the Eclipse Foundation 8 | * 9 | * or (per the licensee's choosing) 10 | * 11 | * under the terms of the GNU Lesser General Public License version 3.0 12 | * as published by the Free Software Foundation. 13 | */ 14 | package co.paralleluniverse.galaxy.core; 15 | 16 | /** 17 | * 18 | * @author pron 19 | */ 20 | public interface RootLocker { 21 | 22 | Object lockRoot(int id); 23 | 24 | void unlockRoot(Object lock); 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/co/paralleluniverse/galaxy/cluster/ReaderWriter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Galaxy 3 | * Copyright (c) 2012-2014, Parallel Universe Software Co. All rights reserved. 4 | * 5 | * This program and the accompanying materials are dual-licensed under 6 | * either the terms of the Eclipse Public License v1.0 as published by 7 | * the Eclipse Foundation 8 | * 9 | * or (per the licensee's choosing) 10 | * 11 | * under the terms of the GNU Lesser General Public License version 3.0 12 | * as published by the Free Software Foundation. 13 | */ 14 | package co.paralleluniverse.galaxy.cluster; 15 | 16 | /** 17 | * Reads and writes values from/to the cluster configuration. 18 | */ 19 | public interface ReaderWriter { 20 | T read(byte[] data); 21 | byte[] write(T value); 22 | } 23 | -------------------------------------------------------------------------------- /docs/css/pygments/linenos.css: -------------------------------------------------------------------------------- 1 | .highlight pre { 2 | font-family: "Inconsolata", Monaco, Courier, monospace; 3 | font-size: .65em; 4 | border: 1px solid #efefef; 5 | border-left: 2em solid #efefef; 6 | position: relative; 7 | margin: 1em 0; 8 | } 9 | .highlight pre code { 10 | counter-reset: linenumbers; 11 | position: relative; 12 | overflow: auto; 13 | } 14 | 15 | .highlight pre code > span:before { 16 | font-size: .9em; 17 | color: #aaa; 18 | content: counter(linenumbers); 19 | counter-increment: linenumbers; 20 | left: -5.5ex; 21 | position: absolute; 22 | text-align: right; 23 | width: 3.5ex; 24 | -webkit-touch-callout: none; 25 | -webkit-user-select: none; 26 | -khtml-user-select: none; 27 | -moz-user-select: none; 28 | -ms-user-select: none; 29 | user-select: none; 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/co/paralleluniverse/galaxy/core/OffHeapLocalStorageMonitor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Galaxy 3 | * Copyright (c) 2012-2014, Parallel Universe Software Co. All rights reserved. 4 | * 5 | * This program and the accompanying materials are dual-licensed under 6 | * either the terms of the Eclipse Public License v1.0 as published by 7 | * the Eclipse Foundation 8 | * 9 | * or (per the licensee's choosing) 10 | * 11 | * under the terms of the GNU Lesser General Public License version 3.0 12 | * as published by the Free Software Foundation. 13 | */ 14 | package co.paralleluniverse.galaxy.core; 15 | 16 | /** 17 | * 18 | * @author pron 19 | */ 20 | interface OffHeapLocalStorageMonitor { 21 | void allocated(int bin, int size); 22 | void deallocated(int bin, int size); 23 | } 24 | -------------------------------------------------------------------------------- /docs/_includes/meta.html: -------------------------------------------------------------------------------- 1 | 2 | {% if page.title and page.description %} 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | {% endif %} -------------------------------------------------------------------------------- /src/main/java/co/paralleluniverse/galaxy/cluster/SlaveAddressResolver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Galaxy 3 | * Copyright (c) 2012-2014, Parallel Universe Software Co. All rights reserved. 4 | * 5 | * This program and the accompanying materials are dual-licensed under 6 | * either the terms of the Eclipse Public License v1.0 as published by 7 | * the Eclipse Foundation 8 | * 9 | * or (per the licensee's choosing) 10 | * 11 | * under the terms of the GNU Lesser General Public License version 3.0 12 | * as published by the Free Software Foundation. 13 | */ 14 | package co.paralleluniverse.galaxy.cluster; 15 | 16 | /** 17 | * 18 | */ 19 | public interface SlaveAddressResolver
{ 20 | 21 | NodeInfo getNode(Address address); 22 | 23 | Address getAddress(String nodeName); 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/co/paralleluniverse/galaxy/core/SlaveComm.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Galaxy 3 | * Copyright (c) 2012-2014, Parallel Universe Software Co. All rights reserved. 4 | * 5 | * This program and the accompanying materials are dual-licensed under 6 | * either the terms of the Eclipse Public License v1.0 as published by 7 | * the Eclipse Foundation 8 | * 9 | * or (per the licensee's choosing) 10 | * 11 | * under the terms of the GNU Lesser General Public License version 3.0 12 | * as published by the Free Software Foundation. 13 | */ 14 | package co.paralleluniverse.galaxy.core; 15 | 16 | 17 | /** 18 | * 19 | * @author pron 20 | */ 21 | public interface SlaveComm { 22 | void setBackup(Backup backup); 23 | 24 | boolean send(Message message) throws NodeNotFoundException; 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/co/paralleluniverse/galaxy/monitoring/LocalStorageMXBean.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Galaxy 3 | * Copyright (c) 2012-2014, Parallel Universe Software Co. All rights reserved. 4 | * 5 | * This program and the accompanying materials are dual-licensed under 6 | * either the terms of the Eclipse Public License v1.0 as published by 7 | * the Eclipse Foundation 8 | * 9 | * or (per the licensee's choosing) 10 | * 11 | * under the terms of the GNU Lesser General Public License version 3.0 12 | * as published by the Free Software Foundation. 13 | */ 14 | package co.paralleluniverse.galaxy.monitoring; 15 | 16 | /** 17 | * 18 | * @author pron 19 | */ 20 | public interface LocalStorageMXBean { 21 | long getTotalMemory(); 22 | int getAllocated(); 23 | int getDeallocated(); 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/co/paralleluniverse/io/serialization/ByteArraySerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2014, Parallel Universe Software Co. All rights reserved. 3 | * 4 | * This program and the accompanying materials are dual-licensed under 5 | * either the terms of the Eclipse Public License v1.0 as published by 6 | * the Eclipse Foundation 7 | * 8 | * or (per the licensee's choosing) 9 | * 10 | * under the terms of the GNU Lesser General Public License version 3.0 11 | * as published by the Free Software Foundation. 12 | */ 13 | package co.paralleluniverse.io.serialization; 14 | 15 | /** 16 | * 17 | * @author pron 18 | */ 19 | public interface ByteArraySerializer { 20 | Object read(byte[] buf); 21 | 22 | Object read(byte[] buf, int offset); 23 | 24 | byte[] write(Object object); 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/co/paralleluniverse/galaxy/netty/UDPCommMXBean.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Galaxy 3 | * Copyright (c) 2012-2014, Parallel Universe Software Co. All rights reserved. 4 | * 5 | * This program and the accompanying materials are dual-licensed under 6 | * either the terms of the Eclipse Public License v1.0 as published by 7 | * the Eclipse Foundation 8 | * 9 | * or (per the licensee's choosing) 10 | * 11 | * under the terms of the GNU Lesser General Public License version 3.0 12 | * as published by the Free Software Foundation. 13 | */ 14 | package co.paralleluniverse.galaxy.netty; 15 | 16 | import java.util.Map; 17 | 18 | /** 19 | * 20 | * @author pron 21 | */ 22 | public interface UDPCommMXBean { 23 | int getBroadcastQueueLength(); 24 | 25 | Map getPeerQueuesLengths(); 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/co/paralleluniverse/galaxy/monitoring/PeriodicMXBean.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Galaxy 3 | * Copyright (c) 2012-2014, Parallel Universe Software Co. All rights reserved. 4 | * 5 | * This program and the accompanying materials are dual-licensed under 6 | * either the terms of the Eclipse Public License v1.0 as published by 7 | * the Eclipse Foundation 8 | * 9 | * or (per the licensee's choosing) 10 | * 11 | * under the terms of the GNU Lesser General Public License version 3.0 12 | * as published by the Free Software Foundation. 13 | */ 14 | package co.paralleluniverse.galaxy.monitoring; 15 | 16 | /** 17 | * 18 | * @author pron 19 | */ 20 | public interface PeriodicMXBean { 21 | 22 | boolean isUpdates(); 23 | 24 | void setUpdates(boolean value); 25 | 26 | void startUpdates(); 27 | 28 | void stopUpdates(); 29 | } 30 | -------------------------------------------------------------------------------- /docs/_includes/footer.html: -------------------------------------------------------------------------------- 1 | 15 | -------------------------------------------------------------------------------- /src/main/java/co/paralleluniverse/galaxy/core/ServerComm.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Galaxy 3 | * Copyright (c) 2012-2014, Parallel Universe Software Co. All rights reserved. 4 | * 5 | * This program and the accompanying materials are dual-licensed under 6 | * either the terms of the Eclipse Public License v1.0 as published by 7 | * the Eclipse Foundation 8 | * 9 | * or (per the licensee's choosing) 10 | * 11 | * under the terms of the GNU Lesser General Public License version 3.0 12 | * as published by the Free Software Foundation. 13 | */ 14 | package co.paralleluniverse.galaxy.core; 15 | 16 | /** 17 | * A marker interface designating a server comm. Simply used for the sake of Spring auto-wiring, as we don't want it to 18 | * autowire the peer comm in place of the server comm. 19 | * @author pron 20 | */ 21 | public interface ServerComm extends Comm { 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/co/paralleluniverse/galaxy/core/CacheStorage.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Galaxy 3 | * Copyright (c) 2012-2014, Parallel Universe Software Co. All rights reserved. 4 | * 5 | * This program and the accompanying materials are dual-licensed under 6 | * either the terms of the Eclipse Public License v1.0 as published by 7 | * the Eclipse Foundation 8 | * 9 | * or (per the licensee's choosing) 10 | * 11 | * under the terms of the GNU Lesser General Public License version 3.0 12 | * as published by the Free Software Foundation. 13 | */ 14 | package co.paralleluniverse.galaxy.core; 15 | 16 | import java.nio.ByteBuffer; 17 | 18 | /** 19 | * 20 | * @author pron 21 | */ 22 | public interface CacheStorage { 23 | 24 | ByteBuffer allocateStorage(int size); 25 | 26 | void deallocateStorage(long id, ByteBuffer buffer); 27 | 28 | long getTotalAllocatedSize(); 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/co/paralleluniverse/common/io/Checksum.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2014, Parallel Universe Software Co. All rights reserved. 3 | * 4 | * This program and the accompanying materials are dual-licensed under 5 | * either the terms of the Eclipse Public License v1.0 as published by 6 | * the Eclipse Foundation 7 | * 8 | * or (per the licensee's choosing) 9 | * 10 | * under the terms of the GNU Lesser General Public License version 3.0 11 | * as published by the Free Software Foundation. 12 | */ 13 | package co.paralleluniverse.common.io; 14 | 15 | import java.nio.ByteBuffer; 16 | 17 | /** 18 | * 19 | * @author pron 20 | */ 21 | public interface Checksum { 22 | void reset(); 23 | 24 | void update(byte b); 25 | 26 | void update(byte[] array); 27 | 28 | void update(ByteBuffer buffer); 29 | 30 | byte[] getChecksum(); 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/co/paralleluniverse/galaxy/RefNotFoundException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Galaxy 3 | * Copyright (c) 2012-2014, Parallel Universe Software Co. All rights reserved. 4 | * 5 | * This program and the accompanying materials are dual-licensed under 6 | * either the terms of the Eclipse Public License v1.0 as published by 7 | * the Eclipse Foundation 8 | * 9 | * or (per the licensee's choosing) 10 | * 11 | * under the terms of the GNU Lesser General Public License version 3.0 12 | * as published by the Free Software Foundation. 13 | */ 14 | package co.paralleluniverse.galaxy; 15 | 16 | /** 17 | * Thrown when an item ref was not found in the grid. 18 | */ 19 | public class RefNotFoundException extends RuntimeException { 20 | public RefNotFoundException(long ref) { 21 | super("Reference " + Long.toHexString(ref) + " was not found (probably deleted)!"); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/co/paralleluniverse/galaxy/monitoring/MainMemoryMXBean.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Galaxy 3 | * Copyright (c) 2012-2014, Parallel Universe Software Co. All rights reserved. 4 | * 5 | * This program and the accompanying materials are dual-licensed under 6 | * either the terms of the Eclipse Public License v1.0 as published by 7 | * the Eclipse Foundation 8 | * 9 | * or (per the licensee's choosing) 10 | * 11 | * under the terms of the GNU Lesser General Public License version 3.0 12 | * as published by the Free Software Foundation. 13 | */ 14 | package co.paralleluniverse.galaxy.monitoring; 15 | 16 | /** 17 | * 18 | * @author pron 19 | */ 20 | public interface MainMemoryMXBean { 21 | int getObjectsServed(); 22 | 23 | int getOwnerWrites(); 24 | 25 | int getOwnersServed(); 26 | 27 | int getTransactions(); 28 | 29 | int getWrites(); 30 | 31 | int getAllocations(); 32 | } 33 | -------------------------------------------------------------------------------- /config/template.xml: -------------------------------------------------------------------------------- 1 | 2 | 14 | 15 | -------------------------------------------------------------------------------- /src/main/java/co/paralleluniverse/io/serialization/IOStreamSerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2014, Parallel Universe Software Co. All rights reserved. 3 | * 4 | * This program and the accompanying materials are dual-licensed under 5 | * either the terms of the Eclipse Public License v1.0 as published by 6 | * the Eclipse Foundation 7 | * 8 | * or (per the licensee's choosing) 9 | * 10 | * under the terms of the GNU Lesser General Public License version 3.0 11 | * as published by the Free Software Foundation. 12 | */ 13 | package co.paralleluniverse.io.serialization; 14 | 15 | import java.io.IOException; 16 | import java.io.InputStream; 17 | import java.io.OutputStream; 18 | 19 | /** 20 | * 21 | * @author pron 22 | */ 23 | public interface IOStreamSerializer { 24 | Object read(InputStream is) throws IOException; 25 | 26 | void write(OutputStream os, Object object) throws IOException; 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/co/paralleluniverse/galaxy/core/BackupMonitor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Galaxy 3 | * Copyright (c) 2012-2014, Parallel Universe Software Co. All rights reserved. 4 | * 5 | * This program and the accompanying materials are dual-licensed under 6 | * either the terms of the Eclipse Public License v1.0 as published by 7 | * the Eclipse Foundation 8 | * 9 | * or (per the licensee's choosing) 10 | * 11 | * under the terms of the GNU Lesser General Public License version 3.0 12 | * as published by the Free Software Foundation. 13 | */ 14 | package co.paralleluniverse.galaxy.core; 15 | 16 | /** 17 | * 18 | * @author pron 19 | */ 20 | interface BackupMonitor { 21 | void addBackups(int num); 22 | 23 | void addReplicationBackup(int num); 24 | 25 | void addBackupPacket(); 26 | 27 | void addSlaveAckTime(long nanos); 28 | 29 | void addServerAckTime(long nanos); 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/co/paralleluniverse/galaxy/monitoring/BackupMXBean.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Galaxy 3 | * Copyright (c) 2012-2014, Parallel Universe Software Co. All rights reserved. 4 | * 5 | * This program and the accompanying materials are dual-licensed under 6 | * either the terms of the Eclipse Public License v1.0 as published by 7 | * the Eclipse Foundation 8 | * 9 | * or (per the licensee's choosing) 10 | * 11 | * under the terms of the GNU Lesser General Public License version 3.0 12 | * as published by the Free Software Foundation. 13 | */ 14 | package co.paralleluniverse.galaxy.monitoring; 15 | 16 | /** 17 | * 18 | * @author pron 19 | */ 20 | public interface BackupMXBean { 21 | long getAvgServerAckTimeMicros(); 22 | 23 | long getAvgSlavesAckTimeMicros(); 24 | 25 | int getBackupPackets(); 26 | 27 | int getBackups(); 28 | 29 | int getReplicationBackups(); 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/co/paralleluniverse/galaxy/cluster/NodeAddressResolver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Galaxy 3 | * Copyright (c) 2012-2014, Parallel Universe Software Co. All rights reserved. 4 | * 5 | * This program and the accompanying materials are dual-licensed under 6 | * either the terms of the Eclipse Public License v1.0 as published by 7 | * the Eclipse Foundation 8 | * 9 | * or (per the licensee's choosing) 10 | * 11 | * under the terms of the GNU Lesser General Public License version 3.0 12 | * as published by the Free Software Foundation. 13 | */ 14 | package co.paralleluniverse.galaxy.cluster; 15 | 16 | /** 17 | * 18 | * @author pron 19 | */ 20 | public interface NodeAddressResolver
{ 21 | 22 | short getNodeId(Address address); 23 | 24 | /** 25 | * Returns the address of the master node with the given ID. 26 | */ 27 | Address getNodeAddress(short id); 28 | } 29 | -------------------------------------------------------------------------------- /src/test/resources/config/template.xml: -------------------------------------------------------------------------------- 1 | 2 | 14 | 15 | -------------------------------------------------------------------------------- /src/main/java/co/paralleluniverse/galaxy/core/Comm.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Galaxy 3 | * Copyright (c) 2012-2014, Parallel Universe Software Co. All rights reserved. 4 | * 5 | * This program and the accompanying materials are dual-licensed under 6 | * either the terms of the Eclipse Public License v1.0 as published by 7 | * the Eclipse Foundation 8 | * 9 | * or (per the licensee's choosing) 10 | * 11 | * under the terms of the GNU Lesser General Public License version 3.0 12 | * as published by the Free Software Foundation. 13 | */ 14 | package co.paralleluniverse.galaxy.core; 15 | 16 | 17 | /** 18 | * don't send or receive anything from a client until a response for the last message has been received 19 | * @author pron 20 | */ 21 | public interface Comm { 22 | public static final short SERVER = 0; 23 | 24 | void setReceiver(MessageReceiver receiver); 25 | 26 | void send(Message message) throws NodeNotFoundException; 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/co/paralleluniverse/common/logging/LoggingUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2014, Parallel Universe Software Co. All rights reserved. 3 | * 4 | * This program and the accompanying materials are dual-licensed under 5 | * either the terms of the Eclipse Public License v1.0 as published by 6 | * the Eclipse Foundation 7 | * 8 | * or (per the licensee's choosing) 9 | * 10 | * under the terms of the GNU Lesser General Public License version 3.0 11 | * as published by the Free Software Foundation. 12 | */ 13 | package co.paralleluniverse.common.logging; 14 | 15 | /** 16 | * 17 | * @author pron 18 | */ 19 | public final class LoggingUtils { 20 | public static String hex(long num) { 21 | return Long.toHexString(num); 22 | } 23 | 24 | public static String hex(int num) { 25 | return Integer.toHexString(num); 26 | } 27 | 28 | private LoggingUtils() { 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/co/paralleluniverse/galaxy/monitoring/OffHeapLocalStorageMXBean.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Galaxy 3 | * Copyright (c) 2012-2014, Parallel Universe Software Co. All rights reserved. 4 | * 5 | * This program and the accompanying materials are dual-licensed under 6 | * either the terms of the Eclipse Public License v1.0 as published by 7 | * the Eclipse Foundation 8 | * 9 | * or (per the licensee's choosing) 10 | * 11 | * under the terms of the GNU Lesser General Public License version 3.0 12 | * as published by the Free Software Foundation. 13 | */ 14 | package co.paralleluniverse.galaxy.monitoring; 15 | 16 | import java.util.Map; 17 | 18 | /** 19 | * 20 | * @author pron 21 | */ 22 | public interface OffHeapLocalStorageMXBean extends LocalStorageMXBean { 23 | Map getBinsTotalMemory(); 24 | 25 | Map getBinsAllocated(); 26 | 27 | Map getBinsDeallocated(); 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/co/paralleluniverse/galaxy/core/MainMemoryMonitor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Galaxy 3 | * Copyright (c) 2012-2014, Parallel Universe Software Co. All rights reserved. 4 | * 5 | * This program and the accompanying materials are dual-licensed under 6 | * either the terms of the Eclipse Public License v1.0 as published by 7 | * the Eclipse Foundation 8 | * 9 | * or (per the licensee's choosing) 10 | * 11 | * under the terms of the GNU Lesser General Public License version 3.0 12 | * as published by the Free Software Foundation. 13 | */ 14 | package co.paralleluniverse.galaxy.core; 15 | 16 | /** 17 | * 18 | * @author pron 19 | */ 20 | interface MainMemoryMonitor { 21 | void setMonitoredObject(Object obj); 22 | 23 | void addObjectServed(); 24 | 25 | void addOwnerServed(); 26 | 27 | void addOwnerWrite(); 28 | 29 | void addTransaction(int numWrites); 30 | 31 | void addAllocation(int count); 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/co/paralleluniverse/galaxy/core/NodeNotFoundException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Galaxy 3 | * Copyright (c) 2012-2014, Parallel Universe Software Co. All rights reserved. 4 | * 5 | * This program and the accompanying materials are dual-licensed under 6 | * either the terms of the Eclipse Public License v1.0 as published by 7 | * the Eclipse Foundation 8 | * 9 | * or (per the licensee's choosing) 10 | * 11 | * under the terms of the GNU Lesser General Public License version 3.0 12 | * as published by the Free Software Foundation. 13 | */ 14 | package co.paralleluniverse.galaxy.core; 15 | 16 | /** 17 | * 18 | * @author pron 19 | */ 20 | public class NodeNotFoundException extends Exception { 21 | private final short node; 22 | 23 | public NodeNotFoundException(short node) { 24 | super("Node " + node + " not found."); 25 | this.node = node; 26 | } 27 | 28 | public short getNode() { 29 | return node; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/co/paralleluniverse/galaxy/netty/ChannelNodeinfo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Galaxy 3 | * Copyright (c) 2012-2014, Parallel Universe Software Co. All rights reserved. 4 | * 5 | * This program and the accompanying materials are dual-licensed under 6 | * either the terms of the Eclipse Public License v1.0 as published by 7 | * the Eclipse Foundation 8 | * 9 | * or (per the licensee's choosing) 10 | * 11 | * under the terms of the GNU Lesser General Public License version 3.0 12 | * as published by the Free Software Foundation. 13 | */ 14 | package co.paralleluniverse.galaxy.netty; 15 | 16 | import co.paralleluniverse.galaxy.cluster.NodeInfo; 17 | import org.jboss.netty.channel.ChannelLocal; 18 | 19 | /** 20 | * 21 | * @author pron 22 | */ 23 | class ChannelNodeInfo { 24 | // TODO - remove this class and use channel attachment when Netty 4 arrives. 25 | public static final ChannelLocal nodeInfo = new ChannelLocal(); 26 | } 27 | -------------------------------------------------------------------------------- /config/peer.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /src/main/java/co/paralleluniverse/common/concurrent/CurrentThreadExecutor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2014, Parallel Universe Software Co. All rights reserved. 3 | * 4 | * This program and the accompanying materials are dual-licensed under 5 | * either the terms of the Eclipse Public License v1.0 as published by 6 | * the Eclipse Foundation 7 | * 8 | * or (per the licensee's choosing) 9 | * 10 | * under the terms of the GNU Lesser General Public License version 3.0 11 | * as published by the Free Software Foundation. 12 | */ 13 | package co.paralleluniverse.common.concurrent; 14 | 15 | import java.util.concurrent.Executor; 16 | 17 | /** 18 | * 19 | * @author pron 20 | */ 21 | public class CurrentThreadExecutor implements Executor { 22 | public static final CurrentThreadExecutor instance = new CurrentThreadExecutor(); 23 | 24 | private CurrentThreadExecutor() { 25 | } 26 | 27 | @Override 28 | public void execute(Runnable command) { 29 | command.run(); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/test/resources/config/peer.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /src/test/resources/config/peerNoServer.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /src/test/resources/config/peerWithJGServer.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /src/test/resources/config/peerWithZKServer.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /src/main/java/co/paralleluniverse/galaxy/MessageListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Galaxy 3 | * Copyright (c) 2012-2014, Parallel Universe Software Co. All rights reserved. 4 | * 5 | * This program and the accompanying materials are dual-licensed under 6 | * either the terms of the Eclipse Public License v1.0 as published by 7 | * the Eclipse Foundation 8 | * 9 | * or (per the licensee's choosing) 10 | * 11 | * under the terms of the GNU Lesser General Public License version 3.0 12 | * as published by the Free Software Foundation. 13 | */ 14 | package co.paralleluniverse.galaxy; 15 | 16 | /** 17 | * A listener for messages sent in the grid. 18 | * 19 | * @see Messenger 20 | */ 21 | public interface MessageListener { 22 | /** 23 | * Called when a message has been received. 24 | * 25 | * @param fromNode The cluster node ID of the node that originated the message. 26 | * @param message The message's contents. 27 | */ 28 | void messageReceived(short fromNode, byte[] message); 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/co/paralleluniverse/common/concurrent/WithExecutor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2014, Parallel Universe Software Co. All rights reserved. 3 | * 4 | * This program and the accompanying materials are dual-licensed under 5 | * either the terms of the Eclipse Public License v1.0 as published by 6 | * the Eclipse Foundation 7 | * 8 | * or (per the licensee's choosing) 9 | * 10 | * under the terms of the GNU Lesser General Public License version 3.0 11 | * as published by the Free Software Foundation. 12 | */ 13 | package co.paralleluniverse.common.concurrent; 14 | 15 | import java.util.concurrent.Executor; 16 | 17 | /** 18 | * An object implementing this interface (usually a listener) requests that all of its methods invoked be invoked through the executor. 19 | */ 20 | public interface WithExecutor { 21 | /** 22 | * Returns the executor on which to run the object's methods. 23 | * @return The executor on which to run the object's methods. 24 | */ 25 | Executor getExecutor(); 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/co/paralleluniverse/common/spring/NullBean.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2014, Parallel Universe Software Co. All rights reserved. 3 | * 4 | * This program and the accompanying materials are dual-licensed under 5 | * either the terms of the Eclipse Public License v1.0 as published by 6 | * the Eclipse Foundation 7 | * 8 | * or (per the licensee's choosing) 9 | * 10 | * under the terms of the GNU Lesser General Public License version 3.0 11 | * as published by the Free Software Foundation. 12 | */ 13 | package co.paralleluniverse.common.spring; 14 | 15 | import org.springframework.beans.factory.FactoryBean; 16 | 17 | /** 18 | * 19 | * @author pron 20 | */ 21 | public class NullBean implements FactoryBean { 22 | 23 | @Override 24 | public Void getObject() throws Exception { 25 | return null; 26 | } 27 | 28 | @Override 29 | public Class getObjectType() { 30 | return null; 31 | } 32 | 33 | @Override 34 | public boolean isSingleton() { 35 | return true; 36 | } 37 | } -------------------------------------------------------------------------------- /src/main/java/co/paralleluniverse/galaxy/LineFunction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Galaxy 3 | * Copyright (c) 2012-2014, Parallel Universe Software Co. All rights reserved. 4 | * 5 | * This program and the accompanying materials are dual-licensed under 6 | * either the terms of the Eclipse Public License v1.0 as published by 7 | * the Eclipse Foundation 8 | * 9 | * or (per the licensee's choosing) 10 | * 11 | * under the terms of the GNU Lesser General Public License version 3.0 12 | * as published by the Free Software Foundation. 13 | */ 14 | package co.paralleluniverse.galaxy; 15 | 16 | import java.nio.ByteBuffer; 17 | 18 | public interface LineFunction extends java.io.Serializable { 19 | public interface LineAccess extends java.io.Serializable { 20 | ByteBuffer getForRead(); 21 | 22 | /** 23 | * @param size If size is {@code -1}, buffer is retained, and not flipped after the function is invoked. 24 | * @return 25 | */ 26 | ByteBuffer getForWrite(int size); 27 | } 28 | 29 | T invoke(LineAccess lineAccess); 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/co/paralleluniverse/galaxy/jgroups/ExtendedChannel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Galaxy 3 | * Copyright (c) 2012-2014, Parallel Universe Software Co. All rights reserved. 4 | * 5 | * This program and the accompanying materials are dual-licensed under 6 | * either the terms of the Eclipse Public License v1.0 as published by 7 | * the Eclipse Foundation 8 | * 9 | * or (per the licensee's choosing) 10 | * 11 | * under the terms of the GNU Lesser General Public License version 3.0 12 | * as published by the Free Software Foundation. 13 | */ 14 | package co.paralleluniverse.galaxy.jgroups; 15 | 16 | import org.jgroups.Address; 17 | 18 | /** 19 | * 20 | * @author pron 21 | */ 22 | public interface ExtendedChannel extends Channel { 23 | 24 | void send(Address dst, byte[] buf, int offset, int length) throws Exception; 25 | 26 | void send(Address dst, byte[] buf) throws Exception; 27 | 28 | void send(Address dst, Object obj) throws Exception; 29 | 30 | String getViewAsString(); 31 | 32 | String getAddressAsUUID(); 33 | 34 | String getAddressAsString(); 35 | } 36 | -------------------------------------------------------------------------------- /docs/_includes/header.html: -------------------------------------------------------------------------------- 1 |
2 |
3 | 4 | 19 |
20 |
21 | -------------------------------------------------------------------------------- /src/main/java/co/paralleluniverse/galaxy/TimeoutException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Galaxy 3 | * Copyright (c) 2012-2014, Parallel Universe Software Co. All rights reserved. 4 | * 5 | * This program and the accompanying materials are dual-licensed under 6 | * either the terms of the Eclipse Public License v1.0 as published by 7 | * the Eclipse Foundation 8 | * 9 | * or (per the licensee's choosing) 10 | * 11 | * under the terms of the GNU Lesser General Public License version 3.0 12 | * as published by the Free Software Foundation. 13 | */ 14 | package co.paralleluniverse.galaxy; 15 | 16 | /** 17 | * Thrown when an operation has timed-out. 18 | */ 19 | public class TimeoutException extends Exception { 20 | 21 | public TimeoutException(Throwable cause) { 22 | super(cause); 23 | } 24 | 25 | public TimeoutException(String message) { 26 | super(message); 27 | } 28 | 29 | public TimeoutException(String message, Throwable cause) { 30 | super(message, cause); 31 | } 32 | 33 | public TimeoutException() { 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /config/_bdb.xml: -------------------------------------------------------------------------------- 1 | 2 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/main/java/co/paralleluniverse/galaxy/ItemState.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Galaxy 3 | * Copyright (c) 2012-2014, Parallel Universe Software Co. All rights reserved. 4 | * 5 | * This program and the accompanying materials are dual-licensed under 6 | * either the terms of the Eclipse Public License v1.0 as published by 7 | * the Eclipse Foundation 8 | * 9 | * or (per the licensee's choosing) 10 | * 11 | * under the terms of the GNU Lesser General Public License version 3.0 12 | * as published by the Free Software Foundation. 13 | */ 14 | package co.paralleluniverse.galaxy; 15 | 16 | /** 17 | * Represents the state of an item in the Galaxy local store. 18 | */ 19 | public enum ItemState { 20 | /** 21 | * Item is not found in this node, or may be stale. 22 | */ 23 | INVALID, 24 | 25 | /** 26 | * Item is shared by this node, but is owned by another. 27 | */ 28 | SHARED, 29 | 30 | /** 31 | * Item is owned by this node. 32 | */ 33 | OWNED; 34 | 35 | public boolean isLessThan(ItemState other) { 36 | return compareTo(other) < 0; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/test/java/co/paralleluniverse/galaxy/core/FullCluster.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Galaxy 3 | * Copyright (C) 2012 Parallel Universe Software Co. 4 | * 5 | * This file is part of Galaxy. 6 | * 7 | * Galaxy is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as 9 | * published by the Free Software Foundation, either version 3 of 10 | * the License, or (at your option) any later version. 11 | * 12 | * Galaxy is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with Galaxy. If not, see . 19 | */ 20 | package co.paralleluniverse.galaxy.core; 21 | 22 | import co.paralleluniverse.galaxy.Cluster; 23 | 24 | /** 25 | * 26 | * @author pron 27 | */ 28 | public interface FullCluster extends Cluster, RefAllocator, RootLocker { 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/co/paralleluniverse/galaxy/cluster/NodePropertyListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Galaxy 3 | * Copyright (c) 2012-2014, Parallel Universe Software Co. All rights reserved. 4 | * 5 | * This program and the accompanying materials are dual-licensed under 6 | * either the terms of the Eclipse Public License v1.0 as published by 7 | * the Eclipse Foundation 8 | * 9 | * or (per the licensee's choosing) 10 | * 11 | * under the terms of the GNU Lesser General Public License version 3.0 12 | * as published by the Free Software Foundation. 13 | */ 14 | package co.paralleluniverse.galaxy.cluster; 15 | 16 | /** 17 | * A listener for node-property change events. 18 | */ 19 | public interface NodePropertyListener { 20 | /** 21 | * Invoked when the node's property has been added, changed or removed. 22 | * @param node The node whose property has been modified. 23 | * @param property The name of the modified property. 24 | * @param value The new value of the property. If the property has been removed, this will be {@code null}. 25 | */ 26 | void propertyChanged(NodeInfo node, String property, Object value); 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/co/paralleluniverse/galaxy/monitoring/ClusterMXBean.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Galaxy 3 | * Copyright (c) 2012-2014, Parallel Universe Software Co. All rights reserved. 4 | * 5 | * This program and the accompanying materials are dual-licensed under 6 | * either the terms of the Eclipse Public License v1.0 as published by 7 | * the Eclipse Foundation 8 | * 9 | * or (per the licensee's choosing) 10 | * 11 | * under the terms of the GNU Lesser General Public License version 3.0 12 | * as published by the Free Software Foundation. 13 | */ 14 | package co.paralleluniverse.galaxy.monitoring; 15 | 16 | import java.util.List; 17 | import java.util.SortedMap; 18 | 19 | /** 20 | * 21 | * @author pron 22 | */ 23 | public interface ClusterMXBean { 24 | SortedMap getMyNodeInfo(); 25 | 26 | boolean isOnline(); 27 | 28 | boolean isMaster(); 29 | 30 | void shutdown(); 31 | 32 | boolean hasServer(); 33 | 34 | List> getNodes(); 35 | 36 | SortedMap getMyMaster(); 37 | 38 | List> getMySlaves(); 39 | } 40 | -------------------------------------------------------------------------------- /src/test/resources/config/_bdb.xml: -------------------------------------------------------------------------------- 1 | 2 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /src/main/java/co/paralleluniverse/galaxy/core/RefAllocator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Galaxy 3 | * Copyright (c) 2012-2014, Parallel Universe Software Co. All rights reserved. 4 | * 5 | * This program and the accompanying materials are dual-licensed under 6 | * either the terms of the Eclipse Public License v1.0 as published by 7 | * the Eclipse Foundation 8 | * 9 | * or (per the licensee's choosing) 10 | * 11 | * under the terms of the GNU Lesser General Public License version 3.0 12 | * as published by the Free Software Foundation. 13 | */ 14 | package co.paralleluniverse.galaxy.core; 15 | 16 | import java.util.Collection; 17 | 18 | /** 19 | * 20 | * @author pron 21 | */ 22 | public interface RefAllocator { 23 | void allocateRefs(int count); 24 | 25 | void addRefAllocationsListener(RefAllocationsListener listener); 26 | 27 | void removeRefAllocationsListener(RefAllocationsListener listener); 28 | 29 | Collection getRefAllocationsListeners(); 30 | 31 | interface RefAllocationsListener { 32 | void counterReady(); 33 | 34 | void refsAllocated(long start, int num); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/co/paralleluniverse/common/monitoring/ThreadPoolExecutorMXBean.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2014, Parallel Universe Software Co. All rights reserved. 3 | * 4 | * This program and the accompanying materials are dual-licensed under 5 | * either the terms of the Eclipse Public License v1.0 as published by 6 | * the Eclipse Foundation 7 | * 8 | * or (per the licensee's choosing) 9 | * 10 | * under the terms of the GNU Lesser General Public License version 3.0 11 | * as published by the Free Software Foundation. 12 | */ 13 | package co.paralleluniverse.common.monitoring; 14 | 15 | /** 16 | * 17 | * @author pron 18 | */ 19 | public interface ThreadPoolExecutorMXBean { 20 | 21 | boolean isTerminating(); 22 | 23 | boolean isTerminated(); 24 | 25 | boolean isShutdown(); 26 | 27 | long getTaskCount(); 28 | 29 | String getRejectedExecutionHandler(); 30 | 31 | int getPoolSize(); 32 | 33 | int getMaximumPoolSize(); 34 | 35 | int getLargestPoolSize(); 36 | 37 | long getKeepAliveTime(); 38 | 39 | int getCorePoolSize(); 40 | 41 | long getCompletedTaskCount(); 42 | 43 | int getActiveCount(); 44 | 45 | int getQueuedTasks(); 46 | } 47 | -------------------------------------------------------------------------------- /licenses/LICENSE.slf4j.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2004-2011 QOS.ch 2 | All rights reserved. 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining 5 | a copy of this software and associated documentation files (the 6 | "Software"), to deal in the Software without restriction, including 7 | without limitation the rights to use, copy, modify, merge, publish, 8 | distribute, sublicense, and/or sell copies of the Software, and to 9 | permit persons to whom the Software is furnished to do so, subject to 10 | the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be 13 | included in all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 19 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 20 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 21 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /src/main/java/co/paralleluniverse/galaxy/cluster/NodeChangeListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Galaxy 3 | * Copyright (c) 2012-2014, Parallel Universe Software Co. All rights reserved. 4 | * 5 | * This program and the accompanying materials are dual-licensed under 6 | * either the terms of the Eclipse Public License v1.0 as published by 7 | * the Eclipse Foundation 8 | * 9 | * or (per the licensee's choosing) 10 | * 11 | * under the terms of the GNU Lesser General Public License version 3.0 12 | * as published by the Free Software Foundation. 13 | */ 14 | package co.paralleluniverse.galaxy.cluster; 15 | 16 | /** 17 | * A a listener for events relating nodes joining and leaving the cluster. 18 | */ 19 | public interface NodeChangeListener { 20 | /** 21 | * Invoked when a new node (group) has joined the cluster. 22 | * @param id The node (group) ID. 23 | */ 24 | void nodeAdded(short id); 25 | 26 | /** 27 | * Invoked when a node group's master has changed. 28 | * @param id The node (group) ID. 29 | */ 30 | void nodeSwitched(short id); 31 | 32 | /** 33 | * Invoked when a node (group) has left the cluster. 34 | * @param id The node (group) ID. 35 | */ 36 | void nodeRemoved(short id); 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/co/paralleluniverse/common/io/VersionedPersistable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2014, Parallel Universe Software Co. All rights reserved. 3 | * 4 | * This program and the accompanying materials are dual-licensed under 5 | * either the terms of the Eclipse Public License v1.0 as published by 6 | * the Eclipse Foundation 7 | * 8 | * or (per the licensee's choosing) 9 | * 10 | * under the terms of the GNU Lesser General Public License version 3.0 11 | * as published by the Free Software Foundation. 12 | */ 13 | package co.paralleluniverse.common.io; 14 | 15 | import java.nio.ByteBuffer; 16 | 17 | /** 18 | * A {@link Persistable} that is used by some persistence service that provides automatic versioning. 19 | */ 20 | public interface VersionedPersistable extends Persistable { 21 | /** 22 | * Reads the object from the given {@link ByteBuffer}.
23 | * Upon return from this method, the buffer's {@link ByteBuffer#position() position} will have advanced past the read data. 24 | * 25 | * @param version The version of the object's persisted data. 26 | * @param buffer The buffer from which the object is to be read. 27 | */ 28 | void read(long version, ByteBuffer buffer); 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/co/paralleluniverse/galaxy/netty/NettyUtils.java: -------------------------------------------------------------------------------- 1 | package co.paralleluniverse.galaxy.netty; 2 | 3 | import org.jboss.netty.util.ThreadNameDeterminer; 4 | 5 | import java.util.concurrent.ThreadPoolExecutor; 6 | 7 | /** 8 | * Some constants used for configuring netty thread pools. 9 | * 10 | * @author s.stupin 11 | */ 12 | public class NettyUtils { 13 | /** 14 | * Copy of {@link org.jboss.netty.channel.socket.nio.SelectorUtil#DEFAULT_IO_THREADS} 15 | */ 16 | public static final int DEFAULT_IO_THREADS = Runtime.getRuntime().availableProcessors() * 2; 17 | /** 18 | * Copy of {@link org.jboss.netty.channel.socket.nio.NioClientSocketChannelFactory#DEFAULT_BOSS_COUNT} 19 | */ 20 | public static final int DEFAULT_BOSS_COUNT = 1; 21 | 22 | public static final ThreadNameDeterminer KEEP_UNCHANGED_DETERMINER = new ThreadNameDeterminer() { 23 | @Override 24 | public String determineThreadName(String currentThreadName, String proposedThreadName) throws Exception { 25 | return currentThreadName; 26 | } 27 | }; 28 | 29 | public static int getWorkerCount(ThreadPoolExecutor workerExecutor) { 30 | return Math.min(workerExecutor.getMaximumPoolSize(), DEFAULT_IO_THREADS); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/co/paralleluniverse/galaxy/server/MainMemoryDB.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Galaxy 3 | * Copyright (c) 2012-2014, Parallel Universe Software Co. All rights reserved. 4 | * 5 | * This program and the accompanying materials are dual-licensed under 6 | * either the terms of the Eclipse Public License v1.0 as published by 7 | * the Eclipse Foundation 8 | * 9 | * or (per the licensee's choosing) 10 | * 11 | * under the terms of the GNU Lesser General Public License version 3.0 12 | * as published by the Free Software Foundation. 13 | */ 14 | package co.paralleluniverse.galaxy.server; 15 | 16 | /** 17 | * 18 | * @author pron 19 | */ 20 | public interface MainMemoryDB { 21 | short casOwner(long id, short oldNode, short newNode); 22 | void removeOwner(short node); 23 | 24 | Object beginTransaction(); 25 | void commit(Object txn); 26 | void abort(Object txn); 27 | void write(long id, short owner, long version, byte[] data, Object txn); 28 | MainMemoryEntry read(long id); 29 | 30 | void delete(long id, Object txn); 31 | 32 | void allocate(short owner, long start, int num); 33 | short findAllocation(long ref); 34 | 35 | long getMaxId(); 36 | void close(); 37 | void dump(java.io.PrintStream ps); 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/co/paralleluniverse/common/concurrent/QueueFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2014, Parallel Universe Software Co. All rights reserved. 3 | * 4 | * This program and the accompanying materials are dual-licensed under 5 | * either the terms of the Eclipse Public License v1.0 as published by 6 | * the Eclipse Foundation 7 | * 8 | * or (per the licensee's choosing) 9 | * 10 | * under the terms of the GNU Lesser General Public License version 3.0 11 | * as published by the Free Software Foundation. 12 | */ 13 | package co.paralleluniverse.common.concurrent; 14 | 15 | import java.util.concurrent.ArrayBlockingQueue; 16 | import java.util.concurrent.BlockingQueue; 17 | import java.util.concurrent.LinkedTransferQueue; 18 | import java.util.concurrent.SynchronousQueue; 19 | 20 | 21 | /** 22 | * 23 | * @author pron 24 | */ 25 | public final class QueueFactory{ 26 | 27 | private QueueFactory() { 28 | } 29 | 30 | public static BlockingQueue getInstance(int maxSize) { 31 | if(maxSize == 0) 32 | return new SynchronousQueue(); 33 | else if(maxSize > 0) 34 | return new ArrayBlockingQueue(maxSize); 35 | else 36 | return new LinkedTransferQueue(); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/co/paralleluniverse/common/collection/ConcurrentMultimapWithCopyOnWriteArrayList.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2014, Parallel Universe Software Co. All rights reserved. 3 | * 4 | * This program and the accompanying materials are dual-licensed under 5 | * either the terms of the Eclipse Public License v1.0 as published by 6 | * the Eclipse Foundation 7 | * 8 | * or (per the licensee's choosing) 9 | * 10 | * under the terms of the GNU Lesser General Public License version 3.0 11 | * as published by the Free Software Foundation. 12 | */ 13 | package co.paralleluniverse.common.collection; 14 | 15 | import java.util.Collections; 16 | import java.util.List; 17 | import java.util.concurrent.CopyOnWriteArrayList; 18 | import org.cliffc.high_scale_lib.NonBlockingHashMap; 19 | 20 | /** 21 | * 22 | * @author pron 23 | */ 24 | public class ConcurrentMultimapWithCopyOnWriteArrayList extends ConcurrentMultimap> { 25 | public ConcurrentMultimapWithCopyOnWriteArrayList() { 26 | super(new NonBlockingHashMap>(), (List) Collections.EMPTY_LIST); 27 | } 28 | 29 | @Override 30 | protected List allocateElement() { 31 | return new CopyOnWriteArrayList(); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /log4j.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /src/main/java/co/paralleluniverse/galaxy/jgroups/JGroupsNodeAddressResolver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Galaxy 3 | * Copyright (c) 2012-2014, Parallel Universe Software Co. All rights reserved. 4 | * 5 | * This program and the accompanying materials are dual-licensed under 6 | * either the terms of the Eclipse Public License v1.0 as published by 7 | * the Eclipse Foundation 8 | * 9 | * or (per the licensee's choosing) 10 | * 11 | * under the terms of the GNU Lesser General Public License version 3.0 12 | * as published by the Free Software Foundation. 13 | */ 14 | package co.paralleluniverse.galaxy.jgroups; 15 | 16 | import co.paralleluniverse.galaxy.Cluster; 17 | import co.paralleluniverse.galaxy.cluster.AbstractNodeAddressResolver; 18 | import co.paralleluniverse.galaxy.cluster.NodeInfo; 19 | import org.jgroups.Address; 20 | 21 | /** 22 | * 23 | * @author pron 24 | */ 25 | class JGroupsNodeAddressResolver extends AbstractNodeAddressResolver
{ 26 | 27 | public JGroupsNodeAddressResolver(Cluster cluster) { 28 | super(cluster); 29 | init(); 30 | } 31 | 32 | @Override 33 | protected Address getAddress(NodeInfo node) { 34 | return (Address)node.get(JGroupsConstants.JGROUPS_ADDRESS); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/co/paralleluniverse/galaxy/core/CacheMonitor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Galaxy 3 | * Copyright (c) 2012-2014, Parallel Universe Software Co. All rights reserved. 4 | * 5 | * This program and the accompanying materials are dual-licensed under 6 | * either the terms of the Eclipse Public License v1.0 as published by 7 | * the Eclipse Foundation 8 | * 9 | * or (per the licensee's choosing) 10 | * 11 | * under the terms of the GNU Lesser General Public License version 3.0 12 | * as published by the Free Software Foundation. 13 | */ 14 | package co.paralleluniverse.galaxy.core; 15 | 16 | /** 17 | * 18 | * @author pron 19 | */ 20 | interface CacheMonitor { 21 | void setMonitoredObject(Object obj); 22 | 23 | void addMessageReceived(Message.Type msg); 24 | 25 | void addMessageSent(Message.Type msg); 26 | 27 | void addMessageHandlingDelay(int numDelayed, long totalDelayNanos, MessageDelayReason reason); 28 | 29 | void addOp(Op.Type type, long durationMicroSeconds); 30 | 31 | void addHit(); 32 | 33 | void addStaleHit(); 34 | 35 | void addMiss(); 36 | 37 | void addInvalidate(int num); 38 | 39 | void addStalePurge(int num); 40 | 41 | enum MessageDelayReason { 42 | LOCK, BACKUP, OTHER 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/test/java/co/paralleluniverse/galaxy/core/NodeInfoMatchers.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Galaxy 3 | * Copyright (C) 2012 Parallel Universe Software Co. 4 | * 5 | * This file is part of Galaxy. 6 | * 7 | * Galaxy is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as 9 | * published by the Free Software Foundation, either version 3 of 10 | * the License, or (at your option) any later version. 11 | * 12 | * Galaxy is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with Galaxy. If not, see . 19 | */ 20 | package co.paralleluniverse.galaxy.core; 21 | 22 | import co.paralleluniverse.galaxy.cluster.NodeInfo; 23 | import org.hamcrest.Matcher; 24 | 25 | /** 26 | * 27 | * @author pron 28 | */ 29 | final class NodeInfoMatchers { 30 | public static Matcher withPropertyEqualTo(String property, Object value) { 31 | return new NodeInfoPropertyEqual(property, value); 32 | } 33 | 34 | private NodeInfoMatchers() { 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/co/paralleluniverse/galaxy/monitoring/Counter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Galaxy 3 | * Copyright (c) 2012-2014, Parallel Universe Software Co. All rights reserved. 4 | * 5 | * This program and the accompanying materials are dual-licensed under 6 | * either the terms of the Eclipse Public License v1.0 as published by 7 | * the Eclipse Foundation 8 | * 9 | * or (per the licensee's choosing) 10 | * 11 | * under the terms of the GNU Lesser General Public License version 3.0 12 | * as published by the Free Software Foundation. 13 | */ 14 | package co.paralleluniverse.galaxy.monitoring; 15 | 16 | import java.util.concurrent.atomic.AtomicLong; 17 | import org.cliffc.high_scale_lib.ConcurrentAutoTable; 18 | 19 | /** 20 | * 21 | * @author pron 22 | */ 23 | public class Counter { 24 | private final ConcurrentAutoTable cat = new ConcurrentAutoTable(); 25 | //private final AtomicLong al = new AtomicLong(); 26 | 27 | public void reset() { 28 | cat.set(0); 29 | //al.set(0); 30 | } 31 | 32 | public void inc() { 33 | cat.increment(); 34 | //al.incrementAndGet(); 35 | } 36 | 37 | public void add(long val) { 38 | cat.add(val); 39 | //al.addAndGet(val); 40 | } 41 | 42 | public long get() { 43 | return cat.get(); 44 | //return al.get(); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/test/java/co/paralleluniverse/galaxy/test/CollectionMatchers.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Galaxy 3 | * Copyright (C) 2012 Parallel Universe Software Co. 4 | * 5 | * This file is part of Galaxy. 6 | * 7 | * Galaxy is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as 9 | * published by the Free Software Foundation, either version 3 of 10 | * the License, or (at your option) any later version. 11 | * 12 | * Galaxy is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with Galaxy. If not, see . 19 | */ 20 | package co.paralleluniverse.galaxy.test; 21 | 22 | import java.util.Collection; 23 | import org.hamcrest.Matcher; 24 | import org.hamcrest.collection.*; 25 | 26 | /** 27 | * 28 | * @author pron 29 | */ 30 | public class CollectionMatchers { 31 | public static Matcher> empty() { 32 | return IsEmptyCollection.empty(); 33 | } 34 | 35 | private CollectionMatchers() { 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/co/paralleluniverse/galaxy/AbstractCacheListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Galaxy 3 | * Copyright (c) 2012-2014, Parallel Universe Software Co. All rights reserved. 4 | * 5 | * This program and the accompanying materials are dual-licensed under 6 | * either the terms of the Eclipse Public License v1.0 as published by 7 | * the Eclipse Foundation 8 | * 9 | * or (per the licensee's choosing) 10 | * 11 | * under the terms of the GNU Lesser General Public License version 3.0 12 | * as published by the Free Software Foundation. 13 | */ 14 | package co.paralleluniverse.galaxy; 15 | 16 | import java.nio.ByteBuffer; 17 | 18 | /** 19 | * An empty (no-op) implementation of {@link CacheListener}. 20 | */ 21 | public abstract class AbstractCacheListener implements CacheListener { 22 | 23 | @Override 24 | public void invalidated(Cache cache, long id) { 25 | } 26 | 27 | @Override 28 | public void received(Cache cache, long id, long version, ByteBuffer data) { 29 | } 30 | 31 | @Override 32 | public void evicted(Cache cache, long id) { 33 | } 34 | 35 | @Override 36 | public void killed(Cache cache, long id) { 37 | } 38 | 39 | @Override 40 | public void messageReceived(byte[] message) { 41 | throw new RuntimeException("Received unexpected message (" + message.length + " bytes)"); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/co/paralleluniverse/galaxy/cluster/SlaveConfigurationListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Galaxy 3 | * Copyright (c) 2012-2014, Parallel Universe Software Co. All rights reserved. 4 | * 5 | * This program and the accompanying materials are dual-licensed under 6 | * either the terms of the Eclipse Public License v1.0 as published by 7 | * the Eclipse Foundation 8 | * 9 | * or (per the licensee's choosing) 10 | * 11 | * under the terms of the GNU Lesser General Public License version 3.0 12 | * as published by the Free Software Foundation. 13 | */ 14 | package co.paralleluniverse.galaxy.cluster; 15 | 16 | /** 17 | * A listener for events relating to this master-slaves node group configuration. 18 | */ 19 | public interface SlaveConfigurationListener { 20 | /** 21 | * Invoked when this (slave) node has got a new master. 22 | * @param node The new master node. 23 | */ 24 | void newMaster(NodeInfo node); 25 | 26 | /** 27 | * Invoked when a new slave was added to this (master) node's group. 28 | * @param node The new slave. 29 | */ 30 | void slaveAdded(NodeInfo node); 31 | 32 | /** 33 | * Invoked when a slave has left this (master) node's group (it's gone offline). 34 | * @param node The offline slave. 35 | */ 36 | void slaveRemoved(NodeInfo node); 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/co/paralleluniverse/galaxy/StoreTransaction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Galaxy 3 | * Copyright (c) 2012-2014, Parallel Universe Software Co. All rights reserved. 4 | * 5 | * This program and the accompanying materials are dual-licensed under 6 | * either the terms of the Eclipse Public License v1.0 as published by 7 | * the Eclipse Foundation 8 | * 9 | * or (per the licensee's choosing) 10 | * 11 | * under the terms of the GNU Lesser General Public License version 3.0 12 | * as published by the Free Software Foundation. 13 | */ 14 | package co.paralleluniverse.galaxy; 15 | 16 | import java.util.Iterator; 17 | 18 | /** 19 | * Represents a grid data-store transaction. 20 | * @see Store#beginTransaction() 21 | */ 22 | public abstract class StoreTransaction implements Iterable { 23 | /** 24 | * Returns an iterator over all item IDs participating in the transaction. 25 | * @return An iterator over all item IDs participating in the transaction. 26 | */ 27 | @Override 28 | public abstract Iterator iterator(); 29 | 30 | /** 31 | * Tests whether a given item participates in this transaction. 32 | * @param id The item ID. 33 | * @return {@code true} id the item participates in the transaction; {@code false} otherwise. 34 | */ 35 | public abstract boolean contains(long id); 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/co/paralleluniverse/galaxy/netty/ChannelAttachedNodeResolver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Galaxy 3 | * Copyright (c) 2012-2014, Parallel Universe Software Co. All rights reserved. 4 | * 5 | * This program and the accompanying materials are dual-licensed under 6 | * either the terms of the Eclipse Public License v1.0 as published by 7 | * the Eclipse Foundation 8 | * 9 | * or (per the licensee's choosing) 10 | * 11 | * under the terms of the GNU Lesser General Public License version 3.0 12 | * as published by the Free Software Foundation. 13 | */ 14 | package co.paralleluniverse.galaxy.netty; 15 | 16 | import co.paralleluniverse.galaxy.cluster.NodeInfo; 17 | import java.net.SocketAddress; 18 | import org.jboss.netty.channel.Channel; 19 | import org.jboss.netty.channel.ChannelHandler; 20 | import org.jboss.netty.channel.ChannelHandlerContext; 21 | 22 | /** 23 | * 24 | * @author pron 25 | */ 26 | @ChannelHandler.Sharable 27 | public class ChannelAttachedNodeResolver extends ChannelMessageNodeResolver { 28 | @Override 29 | protected short getNodeId(ChannelHandlerContext ctx, SocketAddress address) { 30 | final Channel channel = ctx.getChannel(); 31 | //final SocketAddress address = channel.getRemoteAddress(); 32 | NodeInfo node = ChannelNodeInfo.nodeInfo.get(channel); 33 | assert node != null; 34 | return node.getNodeId(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/test/java/co/paralleluniverse/galaxy/core/MessageMatcher.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Galaxy 3 | * Copyright (C) 2012 Parallel Universe Software Co. 4 | * 5 | * This file is part of Galaxy. 6 | * 7 | * Galaxy is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as 9 | * published by the Free Software Foundation, either version 3 of 10 | * the License, or (at your option) any later version. 11 | * 12 | * Galaxy is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with Galaxy. If not, see . 19 | */ 20 | 21 | package co.paralleluniverse.galaxy.core; 22 | 23 | import org.hamcrest.Description; 24 | import org.hamcrest.TypeSafeMatcher; 25 | 26 | /** 27 | * 28 | * @author pron 29 | */ 30 | abstract class MessageMatcher extends TypeSafeMatcher{ 31 | 32 | protected final Message message; 33 | 34 | public MessageMatcher(Message message) { 35 | this.message = message; 36 | } 37 | 38 | @Override 39 | public void describeTo(Description description) { 40 | description.appendText(message.toString()); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/co/paralleluniverse/galaxy/Cache.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Galaxy 3 | * Copyright (c) 2012-2014, Parallel Universe Software Co. All rights reserved. 4 | * 5 | * This program and the accompanying materials are dual-licensed under 6 | * either the terms of the Eclipse Public License v1.0 as published by 7 | * the Eclipse Foundation 8 | * 9 | * or (per the licensee's choosing) 10 | * 11 | * under the terms of the GNU Lesser General Public License version 3.0 12 | * as published by the Free Software Foundation. 13 | */ 14 | package co.paralleluniverse.galaxy; 15 | 16 | /** 17 | * 18 | * @author pron 19 | */ 20 | public interface Cache { 21 | /** 22 | * Sets a listener listening for local cache events on the given item. 23 | * 24 | * @param id The item's ID. 25 | * @param listener The listener. 26 | */ 27 | void setListener(long id, CacheListener listener); 28 | 29 | /** 30 | * Sets a listener listening for local cache events on the given item if absent. 31 | * 32 | * @param id The item's ID. 33 | * @param listener The listener. 34 | * @return The given listener if it was set or the existing one otherwise. 35 | */ 36 | CacheListener setListenerIfAbsent(long id, CacheListener listener); 37 | 38 | /** 39 | * @param id The item's ID. 40 | * @return The cacheListener of this line 41 | */ 42 | CacheListener getListener(long id); 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/co/paralleluniverse/galaxy/core/Backup.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Galaxy 3 | * Copyright (c) 2012-2014, Parallel Universe Software Co. All rights reserved. 4 | * 5 | * This program and the accompanying materials are dual-licensed under 6 | * either the terms of the Eclipse Public License v1.0 as published by 7 | * the Eclipse Foundation 8 | * 9 | * or (per the licensee's choosing) 10 | * 11 | * under the terms of the GNU Lesser General Public License version 3.0 12 | * as published by the Free Software Foundation. 13 | */ 14 | package co.paralleluniverse.galaxy.core; 15 | 16 | import co.paralleluniverse.galaxy.core.Message.BACKUP; 17 | import java.util.Iterator; 18 | 19 | /** 20 | * 21 | * @author pron 22 | */ 23 | public interface Backup { 24 | 25 | void setCache(Cache cache); 26 | 27 | boolean startBackup(); 28 | 29 | /** 30 | * Must be called by the cache when the line is synchronized, and under a read-lock (i.e. between startBackup and endBackup) 31 | * 32 | * @param id 33 | * @param version 34 | */ 35 | void backup(long id, long version); 36 | 37 | void endBackup(boolean locked); 38 | 39 | boolean inv(long id, short owner); 40 | 41 | void flush(); 42 | 43 | Iterator iterOwned(); 44 | 45 | void receive(Message message); 46 | 47 | void slavesAck(long id); 48 | 49 | void slavesInvAck(long id); 50 | 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/co/paralleluniverse/galaxy/cluster/LifecycleListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Galaxy 3 | * Copyright (c) 2012-2014, Parallel Universe Software Co. All rights reserved. 4 | * 5 | * This program and the accompanying materials are dual-licensed under 6 | * either the terms of the Eclipse Public License v1.0 as published by 7 | * the Eclipse Foundation 8 | * 9 | * or (per the licensee's choosing) 10 | * 11 | * under the terms of the GNU Lesser General Public License version 3.0 12 | * as published by the Free Software Foundation. 13 | */ 14 | package co.paralleluniverse.galaxy.cluster; 15 | 16 | /** 17 | * A listener for lifecycle events. 18 | */ 19 | public interface LifecycleListener { 20 | /** 21 | * Invoked when this node has joined the cluster, but before it has gone online. 22 | */ 23 | void joinedCluster(); 24 | 25 | /** 26 | * Invoked when this node is online, i.e. operational and visible to the cluster. 27 | * @param master {@code true} if this node is a master, {@code false} if it's a slave. 28 | */ 29 | void online(boolean master); 30 | 31 | /** 32 | * Invoked when this node is taken offline, i.e. shuts down. An offline node cannot go back online until the JVM has been restarted. 33 | */ 34 | void offline(); 35 | 36 | /** 37 | * Invoked when this (formerly) slave node has now become the master. 38 | */ 39 | void switchToMaster(); 40 | } 41 | -------------------------------------------------------------------------------- /docs/_plugins/enhanced_kramdown.rb: -------------------------------------------------------------------------------- 1 | require 'kramdown' 2 | require 'pygments' 3 | require 'typogruby' 4 | 5 | module Kramdown 6 | module Converter 7 | class Pygs < Html 8 | def convert_codeblock(el, indent) 9 | attr = el.attr.dup 10 | lang = extract_code_language!(attr) 11 | if lang 12 | add_code_tags( 13 | Pygments.highlight(el.value, 14 | :lexer => lang, 15 | :options => { :encoding => 'utf-8', :linespans => 'line' }) 16 | ) 17 | else 18 | "
#{el.value}
" 19 | end 20 | end 21 | 22 | def add_code_tags(code) 23 | code = code.sub(/
/,'
')
24 |         code = code.sub(/<\/pre>/,"
") 25 | end 26 | end 27 | end 28 | end 29 | 30 | class Hash 31 | def symbolize_keys! 32 | keys.each do |key| 33 | self[(key.to_sym rescue key) || key] = delete(key) 34 | end 35 | self 36 | end 37 | 38 | def symbolize_keys 39 | dup.symbolize_keys! 40 | end 41 | end 42 | 43 | module Jekyll 44 | module Converters 45 | class Markdown 46 | class EnhancedKramdownParser 47 | def initialize(config) 48 | @config = config 49 | end 50 | 51 | def convert(content) 52 | html = Kramdown::Document.new(content, @config["kramdown"].symbolize_keys).to_pygs 53 | return Typogruby.improve(html) 54 | end 55 | end 56 | end 57 | end 58 | end -------------------------------------------------------------------------------- /docs/_plugins/markdown_converter.rb: -------------------------------------------------------------------------------- 1 | module Jekyll 2 | module Converters 3 | class Markdown < Converter 4 | safe true 5 | 6 | # pygments_prefix "\n" 7 | # pygments_suffix "\n" 8 | # for jekyll 2.0.3 9 | highlighter_prefix "\n" 10 | highlighter_suffix "\n" 11 | 12 | def setup 13 | return if @setup 14 | @parser = case @config['markdown'] 15 | when 'redcarpet' 16 | RedcarpetParser.new @config 17 | when 'kramdown' 18 | KramdownParser.new @config 19 | when 'rdiscount' 20 | RDiscountParser.new @config 21 | when 'maruku' 22 | MarukuParser.new @config 23 | when 'enhanced_kramdown' 24 | EnhancedKramdownParser.new @config 25 | else 26 | STDERR.puts "Invalid Markdown processor: #{@config['markdown']}" 27 | STDERR.puts " Valid options are [ maruku | rdiscount | kramdown | enhanced_kramdown ]" 28 | raise FatalException.new("Invalid Markdown process: #{@config['markdown']}") 29 | end 30 | @setup = true 31 | end 32 | 33 | def matches(ext) 34 | rgx = '(' + @config['markdown_ext'].gsub(',','|') +')' 35 | ext =~ Regexp.new(rgx, Regexp::IGNORECASE) 36 | end 37 | 38 | def output_ext(ext) 39 | ".html" 40 | end 41 | 42 | def convert(content) 43 | setup 44 | @parser.convert(content) 45 | end 46 | end 47 | end 48 | end -------------------------------------------------------------------------------- /src/test/java/co/paralleluniverse/galaxy/core/NodeInfoMatcher.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Galaxy 3 | * Copyright (C) 2012 Parallel Universe Software Co. 4 | * 5 | * This file is part of Galaxy. 6 | * 7 | * Galaxy is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as 9 | * published by the Free Software Foundation, either version 3 of 10 | * the License, or (at your option) any later version. 11 | * 12 | * Galaxy is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with Galaxy. If not, see . 19 | */ 20 | package co.paralleluniverse.galaxy.core; 21 | 22 | import co.paralleluniverse.galaxy.cluster.NodeInfo; 23 | import org.hamcrest.Description; 24 | import org.hamcrest.TypeSafeMatcher; 25 | 26 | /** 27 | * 28 | * @author pron 29 | */ 30 | abstract class NodeInfoMatcher extends TypeSafeMatcher { 31 | 32 | protected final NodeInfo nodeInfo; 33 | 34 | public NodeInfoMatcher(NodeInfo nodeInfo) { 35 | this.nodeInfo = nodeInfo; 36 | } 37 | 38 | @Override 39 | public void describeTo(Description description) { 40 | description.appendText(nodeInfo.toString()); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/test/java/co/paralleluniverse/galaxy/netty/MessagePacketMatchers.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Galaxy 3 | * Copyright (C) 2012 Parallel Universe Software Co. 4 | * 5 | * This file is part of Galaxy. 6 | * 7 | * Galaxy is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as 9 | * published by the Free Software Foundation, either version 3 of 10 | * the License, or (at your option) any later version. 11 | * 12 | * Galaxy is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with Galaxy. If not, see . 19 | */ 20 | package co.paralleluniverse.galaxy.netty; 21 | 22 | import co.paralleluniverse.galaxy.core.Message; 23 | import org.hamcrest.Matcher; 24 | 25 | /** 26 | * 27 | * @author pron 28 | */ 29 | public class MessagePacketMatchers { 30 | public static Matcher packetThatContains(Message m) { 31 | return new MessagePacketContains(m); 32 | } 33 | 34 | public static Matcher equalTo(MessagePacket p) { 35 | return new MessagePacketEqualTo(p); 36 | } 37 | 38 | private MessagePacketMatchers() { 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/co/paralleluniverse/galaxy/core/CommThread.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Galaxy 3 | * Copyright (c) 2012-2014, Parallel Universe Software Co. All rights reserved. 4 | * 5 | * This program and the accompanying materials are dual-licensed under 6 | * either the terms of the Eclipse Public License v1.0 as published by 7 | * the Eclipse Foundation 8 | * 9 | * or (per the licensee's choosing) 10 | * 11 | * under the terms of the GNU Lesser General Public License version 3.0 12 | * as published by the Free Software Foundation. 13 | */ 14 | package co.paralleluniverse.galaxy.core; 15 | 16 | /** 17 | * 18 | * @author pron 19 | */ 20 | public class CommThread extends Thread { 21 | 22 | public CommThread(ThreadGroup group, Runnable target, String name, long stackSize) { 23 | super(group, target, name, stackSize); 24 | } 25 | 26 | public CommThread(ThreadGroup group, Runnable target, String name) { 27 | super(group, target, name); 28 | } 29 | 30 | public CommThread(Runnable target, String name) { 31 | super(target, name); 32 | } 33 | 34 | public CommThread(ThreadGroup group, String name) { 35 | super(group, name); 36 | } 37 | 38 | public CommThread(String name) { 39 | super(name); 40 | } 41 | 42 | public CommThread(ThreadGroup group, Runnable target) { 43 | super(group, target); 44 | } 45 | 46 | public CommThread(Runnable target) { 47 | super(target); 48 | } 49 | 50 | public CommThread() { 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /src/test/java/co/paralleluniverse/galaxy/core/MessageMatchers.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Galaxy 3 | * Copyright (C) 2012 Parallel Universe Software Co. 4 | * 5 | * This file is part of Galaxy. 6 | * 7 | * Galaxy is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as 9 | * published by the Free Software Foundation, either version 3 of 10 | * the License, or (at your option) any later version. 11 | * 12 | * Galaxy is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with Galaxy. If not, see . 19 | */ 20 | package co.paralleluniverse.galaxy.core; 21 | 22 | import org.hamcrest.Matcher; 23 | 24 | /** 25 | * 26 | * @author pron 27 | */ 28 | public final class MessageMatchers { 29 | public static Matcher ofType(Message.Type type) { 30 | return new MessageOfType(type); 31 | } 32 | 33 | public static Matcher equalTo(Message message) { 34 | return new MessageEqualTo(message); 35 | } 36 | 37 | public static Matcher deepEqualTo(Message message) { 38 | return new MessageDeepEqualTo(message); 39 | } 40 | 41 | private MessageMatchers() { 42 | 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/co/paralleluniverse/galaxy/cluster/NodeInfo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Galaxy 3 | * Copyright (c) 2012-2014, Parallel Universe Software Co. All rights reserved. 4 | * 5 | * This program and the accompanying materials are dual-licensed under 6 | * either the terms of the Eclipse Public License v1.0 as published by 7 | * the Eclipse Foundation 8 | * 9 | * or (per the licensee's choosing) 10 | * 11 | * under the terms of the GNU Lesser General Public License version 3.0 12 | * as published by the Free Software Foundation. 13 | */ 14 | package co.paralleluniverse.galaxy.cluster; 15 | 16 | import java.util.Collection; 17 | 18 | /** 19 | * Provides information about a cluster node. 20 | */ 21 | public interface NodeInfo { 22 | /** 23 | * Returns the node's cluster-wide unique name. 24 | * @return The node's name. 25 | */ 26 | String getName(); 27 | 28 | /** 29 | * Returns the node's ID. ID's are a master and all its slave nodes share the same ID. 30 | * @return The node's ID. 31 | */ 32 | short getNodeId(); 33 | 34 | /** 35 | * Returns a given property of the node. 36 | * @param property The name of the property whose value we want. 37 | * @return The property's value. 38 | */ 39 | Object get(String property); 40 | 41 | /** 42 | * Returns a collection of all of this node's property names. 43 | * @return A collection of all of this node's property names. 44 | */ 45 | Collection getProperties(); 46 | } 47 | -------------------------------------------------------------------------------- /config/_sql.xml: -------------------------------------------------------------------------------- 1 | 2 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /licenses/LICENSE.jzlib.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2000,2001,2002,2003,2004 ymnk, JCraft,Inc. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are met: 5 | 6 | 1. Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | 9 | 2. Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in 11 | the documentation and/or other materials provided with the distribution. 12 | 13 | 3. The names of the authors may not be used to endorse or promote products 14 | derived from this software without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 17 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 18 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, 19 | INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 22 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 23 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 24 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 25 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | -------------------------------------------------------------------------------- /src/test/resources/config/_sql.xml: -------------------------------------------------------------------------------- 1 | 2 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /src/main/java/co/paralleluniverse/common/io/HashFunctionChecksum.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2014, Parallel Universe Software Co. All rights reserved. 3 | * 4 | * This program and the accompanying materials are dual-licensed under 5 | * either the terms of the Eclipse Public License v1.0 as published by 6 | * the Eclipse Foundation 7 | * 8 | * or (per the licensee's choosing) 9 | * 10 | * under the terms of the GNU Lesser General Public License version 3.0 11 | * as published by the Free Software Foundation. 12 | */ 13 | package co.paralleluniverse.common.io; 14 | 15 | import com.google.common.hash.HashFunction; 16 | import com.google.common.hash.Hasher; 17 | import java.nio.ByteBuffer; 18 | 19 | /** 20 | * 21 | * @author pron 22 | */ 23 | public class HashFunctionChecksum implements Checksum { 24 | private final HashFunction hf; 25 | private Hasher hasher; 26 | 27 | public HashFunctionChecksum(HashFunction hf) { 28 | this.hf = hf; 29 | reset(); 30 | } 31 | 32 | @Override 33 | public void reset() { 34 | this.hasher = hf.newHasher(); 35 | } 36 | 37 | @Override 38 | public void update(byte b) { 39 | hasher.putByte(b); 40 | } 41 | 42 | @Override 43 | public void update(byte[] array) { 44 | hasher.putBytes(array); 45 | } 46 | 47 | @Override 48 | public void update(ByteBuffer buffer) { 49 | hasher.putBytes(ByteBufferUtil.toByteArray(buffer)); 50 | } 51 | 52 | @Override 53 | public byte[] getChecksum() { 54 | return hasher.hash().asBytes(); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/co/paralleluniverse/galaxy/server/MainMemoryEntry.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Galaxy 3 | * Copyright (c) 2012-2014, Parallel Universe Software Co. All rights reserved. 4 | * 5 | * This program and the accompanying materials are dual-licensed under 6 | * either the terms of the Eclipse Public License v1.0 as published by 7 | * the Eclipse Foundation 8 | * 9 | * or (per the licensee's choosing) 10 | * 11 | * under the terms of the GNU Lesser General Public License version 3.0 12 | * as published by the Free Software Foundation. 13 | */ 14 | package co.paralleluniverse.galaxy.server; 15 | 16 | import co.paralleluniverse.galaxy.berkeleydb.BerkeleyDB; 17 | import com.google.common.primitives.Longs; 18 | 19 | /** 20 | * 21 | * @author pron 22 | */ 23 | public class MainMemoryEntry { 24 | public final long version; 25 | public final byte[] data; 26 | 27 | public MainMemoryEntry(long version, byte[] data) { 28 | this.version = version; 29 | this.data = data; 30 | } 31 | 32 | public MainMemoryEntry(byte[] buffer) { 33 | this.version = Longs.fromByteArray(buffer); 34 | this.data = new byte[buffer.length - (Longs.BYTES)]; 35 | System.arraycopy(buffer, Longs.BYTES, data, 0, data.length); 36 | } 37 | 38 | public byte[] toByteArray() { 39 | final byte[] buffer = new byte[Longs.BYTES + (data != null ? data.length : 0)]; 40 | BerkeleyDB.toByteArray(version, buffer); 41 | if (data != null) 42 | System.arraycopy(data, 0, buffer, Longs.BYTES, data.length); 43 | return buffer; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/test/java/co/paralleluniverse/galaxy/core/MessageOfType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Galaxy 3 | * Copyright (C) 2012 Parallel Universe Software Co. 4 | * 5 | * This file is part of Galaxy. 6 | * 7 | * Galaxy is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as 9 | * published by the Free Software Foundation, either version 3 of 10 | * the License, or (at your option) any later version. 11 | * 12 | * Galaxy is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with Galaxy. If not, see . 19 | */ 20 | package co.paralleluniverse.galaxy.core; 21 | 22 | import org.hamcrest.Description; 23 | import org.hamcrest.TypeSafeMatcher; 24 | 25 | /** 26 | * 27 | * @author pron 28 | */ 29 | public class MessageOfType extends TypeSafeMatcher { 30 | private final Message.Type type; 31 | 32 | public MessageOfType(Message.Type type) { 33 | this.type = type; 34 | } 35 | 36 | @Override 37 | public boolean matchesSafely(Message item) { 38 | return item != null && item.getType() == type; 39 | } 40 | 41 | @Override 42 | public void describeTo(Description description) { 43 | description.appendText(type.name()); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/co/paralleluniverse/common/io/Persistable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2014, Parallel Universe Software Co. All rights reserved. 3 | * 4 | * This program and the accompanying materials are dual-licensed under 5 | * either the terms of the Eclipse Public License v1.0 as published by 6 | * the Eclipse Foundation 7 | * 8 | * or (per the licensee's choosing) 9 | * 10 | * under the terms of the GNU Lesser General Public License version 3.0 11 | * as published by the Free Software Foundation. 12 | */ 13 | package co.paralleluniverse.common.io; 14 | 15 | import java.nio.ByteBuffer; 16 | 17 | /** 18 | * This interface marks an object that can be persisted to a {@link ByteBuffer}. 19 | */ 20 | public interface Persistable { 21 | /** 22 | * Returns the size in bytes of the object's persisted form. 23 | * @return The size in bytes of the object's persisted form. 24 | */ 25 | int size(); 26 | 27 | /** 28 | * Writes the object to the given {@link ByteBuffer}.
29 | * Upon return from this method, the buffer's {@link ByteBuffer#position() position} will have advanced past the written data. 30 | * @param buffer The buffer to which the object is to be written. 31 | */ 32 | void write(ByteBuffer buffer); 33 | 34 | /** 35 | * Reads the object from the given {@link ByteBuffer}.
36 | * Upon return from this method, the buffer's {@link ByteBuffer#position() position} will have advanced past the read data. 37 | * @param buffer The buffer from which the object is to be read. 38 | */ 39 | void read(ByteBuffer buffer); 40 | } 41 | -------------------------------------------------------------------------------- /licenses/LICENSE.asm.txt: -------------------------------------------------------------------------------- 1 | ASM: a very small and fast Java bytecode manipulation framework 2 | Copyright (c) 2000-2005 INRIA, France Telecom 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions 7 | are met: 8 | 1. Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | 2. Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | 3. Neither the name of the copyright holders nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 21 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 27 | THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /src/main/java/co/paralleluniverse/galaxy/netty/MessageCodec.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Galaxy 3 | * Copyright (c) 2012-2014, Parallel Universe Software Co. All rights reserved. 4 | * 5 | * This program and the accompanying materials are dual-licensed under 6 | * either the terms of the Eclipse Public License v1.0 as published by 7 | * the Eclipse Foundation 8 | * 9 | * or (per the licensee's choosing) 10 | * 11 | * under the terms of the GNU Lesser General Public License version 3.0 12 | * as published by the Free Software Foundation. 13 | */ 14 | package co.paralleluniverse.galaxy.netty; 15 | 16 | import co.paralleluniverse.galaxy.core.Message; 17 | import java.nio.ByteBuffer; 18 | import org.jboss.netty.buffer.ChannelBuffer; 19 | import org.jboss.netty.buffer.ChannelBuffers; 20 | import org.jboss.netty.channel.Channel; 21 | import org.jboss.netty.channel.ChannelHandler; 22 | import org.jboss.netty.channel.ChannelHandlerContext; 23 | 24 | /** 25 | * 26 | * @author pron 27 | */ 28 | @ChannelHandler.Sharable 29 | public class MessageCodec extends OneToOneCodec { 30 | @Override 31 | protected Object encode(ChannelHandlerContext ctx, Channel channel, Object msg) throws Exception { 32 | final Message message = (Message) msg; 33 | final ByteBuffer[] buffers = message.toByteBuffers(); 34 | return ChannelBuffers.wrappedBuffer(buffers); 35 | } 36 | 37 | @Override 38 | protected Object decode(ChannelHandlerContext ctx, Channel channel, Object msg) throws Exception { 39 | final ChannelBuffer buffer = (ChannelBuffer) msg; 40 | final Message message = Message.fromByteBuffer(buffer.toByteBuffer()); 41 | return message; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/co/paralleluniverse/galaxy/jgroups/Channel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Galaxy 3 | * Copyright (c) 2012-2014, Parallel Universe Software Co. All rights reserved. 4 | * 5 | * This program and the accompanying materials are dual-licensed under 6 | * either the terms of the Eclipse Public License v1.0 as published by 7 | * the Eclipse Foundation 8 | * 9 | * or (per the licensee's choosing) 10 | * 11 | * under the terms of the GNU Lesser General Public License version 3.0 12 | * as published by the Free Software Foundation. 13 | */ 14 | package co.paralleluniverse.galaxy.jgroups; 15 | 16 | import org.jgroups.Address; 17 | import org.jgroups.ChannelListener; 18 | import org.jgroups.Message; 19 | import org.jgroups.Receiver; 20 | import org.jgroups.View; 21 | import org.jgroups.stack.Protocol; 22 | 23 | /** 24 | * 25 | * @author pron 26 | */ 27 | public interface Channel { 28 | 29 | Address getAddress(); 30 | 31 | String getClusterName(); 32 | 33 | String getName(Address member); 34 | 35 | String getName(); 36 | 37 | void getState(Address target, long timeout, boolean useFlushIfPresent) throws Exception; 38 | 39 | View getView(); 40 | 41 | boolean isConnected(); 42 | 43 | boolean isOpen(); 44 | 45 | void send(Message msg) throws Exception; 46 | 47 | void setReceiver(Receiver r); 48 | 49 | Receiver getReceiver(); 50 | 51 | void removeChannelListener(ChannelListener listener); 52 | 53 | void addChannelListener(ChannelListener listener); 54 | 55 | void setDiscardOwnMessages(boolean flag); 56 | 57 | boolean getDiscardOwnMessages(); 58 | 59 | boolean hasProtocol(Class protocolType); 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/co/paralleluniverse/galaxy/netty/ChannelMessageNodeResolver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Galaxy 3 | * Copyright (c) 2012-2014, Parallel Universe Software Co. All rights reserved. 4 | * 5 | * This program and the accompanying materials are dual-licensed under 6 | * either the terms of the Eclipse Public License v1.0 as published by 7 | * the Eclipse Foundation 8 | * 9 | * or (per the licensee's choosing) 10 | * 11 | * under the terms of the GNU Lesser General Public License version 3.0 12 | * as published by the Free Software Foundation. 13 | */ 14 | package co.paralleluniverse.galaxy.netty; 15 | 16 | import co.paralleluniverse.galaxy.core.Message; 17 | import java.net.SocketAddress; 18 | import org.jboss.netty.channel.ChannelHandler; 19 | import org.jboss.netty.channel.ChannelHandlerContext; 20 | import org.jboss.netty.channel.MessageEvent; 21 | import org.jboss.netty.channel.SimpleChannelUpstreamHandler; 22 | 23 | /** 24 | * 25 | * @author pron 26 | */ 27 | @ChannelHandler.Sharable 28 | public abstract class ChannelMessageNodeResolver extends SimpleChannelUpstreamHandler { 29 | @Override 30 | public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception { 31 | final short nodeId = getNodeId(ctx, e.getRemoteAddress()); 32 | if (e.getMessage() instanceof Message) 33 | ((Message) e.getMessage()).setNode(nodeId); 34 | else if (e.getMessage() instanceof MessagePacket) 35 | ((MessagePacket) e.getMessage()).setNode(nodeId); 36 | ctx.sendUpstream(e); 37 | } 38 | 39 | protected abstract short getNodeId(ChannelHandlerContext ctx, SocketAddress address); 40 | } 41 | -------------------------------------------------------------------------------- /licenses/LICENSE.publicdomain.txt: -------------------------------------------------------------------------------- 1 | The person or persons who have associated work with this document (the 2 | "Dedicator" or "Certifier") hereby either (a) certifies that, to the best of 3 | his knowledge, the work of authorship identified is in the public domain of 4 | the country from which the work is published, or (b) hereby dedicates whatever 5 | copyright the dedicators holds in the work of authorship identified below (the 6 | "Work") to the public domain. A certifier, moreover, dedicates any copyright 7 | interest he may have in the associated work, and for these purposes, is 8 | described as a "dedicator" below. 9 | 10 | A certifier has taken reasonable steps to verify the copyright status of this 11 | work. Certifier recognizes that his good faith efforts may not shield him from 12 | liability if in fact the work certified is not in the public domain. 13 | 14 | Dedicator makes this dedication for the benefit of the public at large and to 15 | the detriment of the Dedicator's heirs and successors. Dedicator intends this 16 | dedication to be an overt act of relinquishment in perpetuate of all present 17 | and future rights under copyright law, whether vested or contingent, in the 18 | Work. Dedicator understands that such relinquishment of all rights includes 19 | the relinquishment of all rights to enforce (by lawsuit or otherwise) those 20 | copyrights in the Work. 21 | 22 | Dedicator recognizes that, once placed in the public domain, the Work may be 23 | freely reproduced, distributed, transmitted, used, modified, built upon, or 24 | otherwise exploited by anyone for any purpose, commercial or non-commercial, 25 | and in any way, including by methods that have not yet been invented or 26 | conceived. 27 | -------------------------------------------------------------------------------- /src/main/java/co/paralleluniverse/common/io/Streamable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2014, Parallel Universe Software Co. All rights reserved. 3 | * 4 | * This program and the accompanying materials are dual-licensed under 5 | * either the terms of the Eclipse Public License v1.0 as published by 6 | * the Eclipse Foundation 7 | * 8 | * or (per the licensee's choosing) 9 | * 10 | * under the terms of the GNU Lesser General Public License version 3.0 11 | * as published by the Free Software Foundation. 12 | */ 13 | package co.paralleluniverse.common.io; 14 | 15 | import java.io.DataInput; 16 | import java.io.DataOutput; 17 | import java.io.IOException; 18 | 19 | /** 20 | * This interface marks an object that can be serialized to a data stream. It is similar in function to {@link java.io.Serializable}, 21 | * except that the serialization is handled explicitely by the object. 22 | */ 23 | public interface Streamable { 24 | /** 25 | * Returns the size in bytes of the object's serialized form. 26 | * @return The size in bytes of the object's serialized form. 27 | */ 28 | int size(); 29 | 30 | /** 31 | * Serializes the object into the given {@link DataOutput}, 32 | * @param out A {@link DataOutput} into which the object is to be serialized. 33 | * @throws IOException 34 | */ 35 | void write(DataOutput out) throws IOException; 36 | 37 | /** 38 | * Reads the object's contents from the given {@link DataInput}. 39 | * @param in A {@link DataInput} from which the object's contents are to be read. 40 | * @throws IOException 41 | */ 42 | void read(DataInput in) throws IOException; 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/co/paralleluniverse/common/collection/ConcurrentMapComplex.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2014, Parallel Universe Software Co. All rights reserved. 3 | * 4 | * This program and the accompanying materials are dual-licensed under 5 | * either the terms of the Eclipse Public License v1.0 as published by 6 | * the Eclipse Foundation 7 | * 8 | * or (per the licensee's choosing) 9 | * 10 | * under the terms of the GNU Lesser General Public License version 3.0 11 | * as published by the Free Software Foundation. 12 | */ 13 | package co.paralleluniverse.common.collection; 14 | 15 | import java.util.concurrent.ConcurrentHashMap; 16 | import java.util.concurrent.ConcurrentMap; 17 | 18 | /** 19 | * 20 | * @author pron 21 | */ 22 | public abstract class ConcurrentMapComplex { 23 | protected final ConcurrentMap map; 24 | 25 | public ConcurrentMapComplex(ConcurrentMap map) { 26 | this.map = map; 27 | } 28 | 29 | public ConcurrentMapComplex() { 30 | this.map = new ConcurrentHashMap(); 31 | } 32 | 33 | public V getOrAllocate(K key) { 34 | V coll = map.get(key); 35 | if (coll == null) { 36 | coll = allocateElement(); 37 | V tmp = map.putIfAbsent(key, coll); 38 | if (tmp != null) 39 | coll = tmp; 40 | } 41 | return coll; 42 | } 43 | 44 | public V get(K key) { 45 | final V value = map.get(key); 46 | return value != null ? value : emptyElement(); 47 | } 48 | 49 | public void remove(K key) { 50 | map.remove(key); 51 | } 52 | 53 | protected abstract V allocateElement(); 54 | 55 | protected abstract V emptyElement(); 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/co/paralleluniverse/common/io/MessageDigestChecksum.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2014, Parallel Universe Software Co. All rights reserved. 3 | * 4 | * This program and the accompanying materials are dual-licensed under 5 | * either the terms of the Eclipse Public License v1.0 as published by 6 | * the Eclipse Foundation 7 | * 8 | * or (per the licensee's choosing) 9 | * 10 | * under the terms of the GNU Lesser General Public License version 3.0 11 | * as published by the Free Software Foundation. 12 | */ 13 | package co.paralleluniverse.common.io; 14 | 15 | import java.nio.ByteBuffer; 16 | import java.security.MessageDigest; 17 | import java.security.NoSuchAlgorithmException; 18 | 19 | /** 20 | * 21 | * @author pron 22 | */ 23 | public class MessageDigestChecksum implements Checksum { 24 | final MessageDigest md; 25 | 26 | public MessageDigestChecksum(String algorithm) { 27 | try { 28 | md = MessageDigest.getInstance(algorithm); 29 | } catch (NoSuchAlgorithmException ex) { 30 | throw new RuntimeException(ex); 31 | } 32 | } 33 | 34 | @Override 35 | public void reset() { 36 | md.reset(); 37 | } 38 | 39 | @Override 40 | public void update(byte b) { 41 | md.update(b); 42 | } 43 | 44 | @Override 45 | public void update(byte[] array) { 46 | md.update(array); 47 | } 48 | 49 | @Override 50 | public void update(ByteBuffer buffer) { 51 | md.update(buffer); 52 | } 53 | 54 | @Override 55 | public byte[] getChecksum() { 56 | throw new UnsupportedOperationException("Not supported yet."); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/co/paralleluniverse/galaxy/netty/ChannelNodeAddressResolver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Galaxy 3 | * Copyright (c) 2012-2014, Parallel Universe Software Co. All rights reserved. 4 | * 5 | * This program and the accompanying materials are dual-licensed under 6 | * either the terms of the Eclipse Public License v1.0 as published by 7 | * the Eclipse Foundation 8 | * 9 | * or (per the licensee's choosing) 10 | * 11 | * under the terms of the GNU Lesser General Public License version 3.0 12 | * as published by the Free Software Foundation. 13 | */ 14 | package co.paralleluniverse.galaxy.netty; 15 | 16 | import co.paralleluniverse.galaxy.cluster.NodeAddressResolver; 17 | import java.net.InetSocketAddress; 18 | import java.net.SocketAddress; 19 | import org.jboss.netty.channel.ChannelHandler; 20 | import org.jboss.netty.channel.ChannelHandlerContext; 21 | 22 | /** 23 | * 24 | * @author pron 25 | */ 26 | @ChannelHandler.Sharable 27 | public class ChannelNodeAddressResolver extends ChannelMessageNodeResolver { 28 | private final NodeAddressResolver addressResolver; 29 | 30 | public ChannelNodeAddressResolver(NodeAddressResolver addressResolver) { 31 | this.addressResolver = addressResolver; 32 | } 33 | 34 | @Override 35 | protected short getNodeId(ChannelHandlerContext ctx, SocketAddress address) { 36 | Short node = null; 37 | try { 38 | node = addressResolver.getNodeId((InetSocketAddress) address); 39 | } catch (Exception e) { 40 | } 41 | if (node == null) 42 | throw new RuntimeException("Node not found for address " + address); 43 | return node; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/co/paralleluniverse/galaxy/netty/UDPCommMonitor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Galaxy 3 | * Copyright (c) 2012-2014, Parallel Universe Software Co. All rights reserved. 4 | * 5 | * This program and the accompanying materials are dual-licensed under 6 | * either the terms of the Eclipse Public License v1.0 as published by 7 | * the Eclipse Foundation 8 | * 9 | * or (per the licensee's choosing) 10 | * 11 | * under the terms of the GNU Lesser General Public License version 3.0 12 | * as published by the Free Software Foundation. 13 | */ 14 | package co.paralleluniverse.galaxy.netty; 15 | 16 | import co.paralleluniverse.common.monitoring.Monitor; 17 | import java.util.HashMap; 18 | import java.util.Map; 19 | 20 | /** 21 | * 22 | * @author pron 23 | */ 24 | class UDPCommMonitor extends Monitor implements UDPCommMXBean { 25 | 26 | public UDPCommMonitor(String name, UDPComm monitored) { 27 | super("co.paralleluniverse.galaxy.netty:type=UDPComm,name=" + name, monitored); 28 | } 29 | 30 | @Override 31 | public int getBroadcastQueueLength() { 32 | final UDPComm comm = getMonitored(); 33 | if (comm == null) 34 | return -1; 35 | return comm.getBroadcastPeer().getQueueLength(); 36 | } 37 | 38 | @Override 39 | public Map getPeerQueuesLengths() { 40 | final UDPComm comm = getMonitored(); 41 | if (comm == null) 42 | return null; 43 | final Map lengths = new HashMap(comm.getPeers().size()); 44 | for (Map.Entry entry : comm.getPeers().entrySet()) 45 | lengths.put(entry.getKey(), entry.getValue().getQueueLength()); 46 | return lengths; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/co/paralleluniverse/galaxy/core/ConfigurableThreadPool.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Galaxy 3 | * Copyright (c) 2012-2014, Parallel Universe Software Co. All rights reserved. 4 | * 5 | * This program and the accompanying materials are dual-licensed under 6 | * either the terms of the Eclipse Public License v1.0 as published by 7 | * the Eclipse Foundation 8 | * 9 | * or (per the licensee's choosing) 10 | * 11 | * under the terms of the GNU Lesser General Public License version 3.0 12 | * as published by the Free Software Foundation. 13 | */ 14 | package co.paralleluniverse.galaxy.core; 15 | 16 | import java.beans.ConstructorProperties; 17 | import java.util.concurrent.ArrayBlockingQueue; 18 | import java.util.concurrent.BlockingQueue; 19 | import java.util.concurrent.LinkedTransferQueue; 20 | import java.util.concurrent.SynchronousQueue; 21 | import java.util.concurrent.ThreadPoolExecutor; 22 | import java.util.concurrent.TimeUnit; 23 | 24 | /** 25 | * 26 | * @author pron 27 | */ 28 | public class ConfigurableThreadPool extends ThreadPoolExecutor { 29 | @ConstructorProperties({"corePoolSize", "maximumPoolSize", "keepAliveMillis", "maxQueueSize"}) 30 | public ConfigurableThreadPool(int corePoolSize, int maximumPoolSize, long keepAliveMillis, int maxQueueSize) { 31 | super(corePoolSize, maximumPoolSize, keepAliveMillis, TimeUnit.MILLISECONDS, makeQueue(maxQueueSize)); 32 | } 33 | 34 | private static BlockingQueue makeQueue(int maxSize) { 35 | if(maxSize == 0) 36 | return new SynchronousQueue(); 37 | else if(maxSize > 0) 38 | return new ArrayBlockingQueue(maxSize); 39 | else 40 | return new LinkedTransferQueue(); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/co/paralleluniverse/io/serialization/kryo/ExternalizableKryoSerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2014, Parallel Universe Software Co. All rights reserved. 3 | * 4 | * This program and the accompanying materials are dual-licensed under 5 | * either the terms of the Eclipse Public License v1.0 as published by 6 | * the Eclipse Foundation 7 | * 8 | * or (per the licensee's choosing) 9 | * 10 | * under the terms of the GNU Lesser General Public License version 3.0 11 | * as published by the Free Software Foundation. 12 | */ 13 | package co.paralleluniverse.io.serialization.kryo; 14 | 15 | import com.esotericsoftware.kryo.Kryo; 16 | import com.esotericsoftware.kryo.io.Input; 17 | import com.esotericsoftware.kryo.io.Output; 18 | import java.io.Externalizable; 19 | import java.io.IOException; 20 | 21 | /** 22 | * 23 | * @author pron 24 | */ 25 | public class ExternalizableKryoSerializer extends com.esotericsoftware.kryo.Serializer { 26 | private static final KryoSerializer ks = new KryoSerializer(); 27 | 28 | @Override 29 | public void write(Kryo kryo, Output output, T obj) { 30 | try { 31 | obj.writeExternal(KryoUtil.asObjectOutput(output, kryo)); 32 | } catch (IOException e) { 33 | throw new AssertionError(e); 34 | } 35 | } 36 | 37 | @Override 38 | public T read(Kryo kryo, Input input, Class type) { 39 | try { 40 | T obj = kryo.newInstance(type); 41 | obj.readExternal(KryoUtil.asObjectInput(input, kryo)); 42 | return obj; 43 | } catch (IOException e) { 44 | throw new AssertionError(e); 45 | } catch (ClassNotFoundException e) { 46 | throw new Error(e); 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/co/paralleluniverse/galaxy/netty/MasterNodesFilteringHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Galaxy 3 | * Copyright (c) 2012-2014, Parallel Universe Software Co. All rights reserved. 4 | * 5 | * This program and the accompanying materials are dual-licensed under 6 | * either the terms of the Eclipse Public License v1.0 as published by 7 | * the Eclipse Foundation 8 | * 9 | * or (per the licensee's choosing) 10 | * 11 | * under the terms of the GNU Lesser General Public License version 3.0 12 | * as published by the Free Software Foundation. 13 | */ 14 | package co.paralleluniverse.galaxy.netty; 15 | 16 | import co.paralleluniverse.galaxy.cluster.NodeAddressResolver; 17 | import java.net.InetSocketAddress; 18 | import java.net.SocketAddress; 19 | import org.jboss.netty.channel.ChannelEvent; 20 | import org.jboss.netty.channel.ChannelHandlerContext; 21 | import org.slf4j.Logger; 22 | import org.slf4j.LoggerFactory; 23 | 24 | /** 25 | * 26 | * @author pron 27 | */ 28 | public class MasterNodesFilteringHandler extends IpFilteringHandler { 29 | private static final Logger LOG = LoggerFactory.getLogger(MasterNodesFilteringHandler.class); 30 | private final NodeAddressResolver addressHandler; 31 | 32 | public MasterNodesFilteringHandler(NodeAddressResolver addressHandler) { 33 | this.addressHandler = addressHandler; 34 | } 35 | 36 | @Override 37 | protected boolean accept(ChannelHandlerContext ctx, ChannelEvent e, InetSocketAddress inetSocketAddress) throws Exception { 38 | final boolean res = addressHandler.getNodeId(inetSocketAddress) >= 0; 39 | if(!res) 40 | LOG.warn("Rejecting connection from {} - unknown node.", ctx.getChannel()); 41 | return res; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /licenses/LICENSE.protobuf.txt: -------------------------------------------------------------------------------- 1 | Copyright 2008, Google Inc. 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above 11 | copyright notice, this list of conditions and the following disclaimer 12 | in the documentation and/or other materials provided with the 13 | distribution. 14 | * Neither the name of Google Inc. nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | Code generated by the Protocol Buffer compiler is owned by the owner 31 | of the input file used when generating it. This code is not 32 | standalone and requires a support library to be linked with it. This 33 | support library is itself covered by the above license. -------------------------------------------------------------------------------- /src/main/java/co/paralleluniverse/galaxy/core/RefAllocatorSupport.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Galaxy 3 | * Copyright (c) 2012-2014, Parallel Universe Software Co. All rights reserved. 4 | * 5 | * This program and the accompanying materials are dual-licensed under 6 | * either the terms of the Eclipse Public License v1.0 as published by 7 | * the Eclipse Foundation 8 | * 9 | * or (per the licensee's choosing) 10 | * 11 | * under the terms of the GNU Lesser General Public License version 3.0 12 | * as published by the Free Software Foundation. 13 | */ 14 | package co.paralleluniverse.galaxy.core; 15 | 16 | import co.paralleluniverse.galaxy.core.RefAllocator.RefAllocationsListener; 17 | import java.util.Collection; 18 | import java.util.List; 19 | import java.util.concurrent.CopyOnWriteArrayList; 20 | 21 | /** 22 | * 23 | * @author pron 24 | */ 25 | public class RefAllocatorSupport { 26 | private final List refAllocationListeners = new CopyOnWriteArrayList(); 27 | 28 | public void addRefAllocationsListener(RefAllocationsListener listener) { 29 | refAllocationListeners.add(listener); 30 | } 31 | 32 | public void removeRefAllocationsListener(RefAllocationsListener listener) { 33 | refAllocationListeners.remove(listener); 34 | } 35 | 36 | public Collection getRefAllocationListeners() { 37 | return refAllocationListeners; 38 | } 39 | 40 | public void fireCounterReady() { 41 | for (RefAllocationsListener listener : refAllocationListeners) 42 | listener.counterReady(); 43 | } 44 | 45 | public void fireRefsAllocated(long start, int num) { 46 | for (RefAllocationsListener listener : refAllocationListeners) 47 | listener.refsAllocated(start, num); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/co/paralleluniverse/common/collection/ConcurrentMultimap.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2014, Parallel Universe Software Co. All rights reserved. 3 | * 4 | * This program and the accompanying materials are dual-licensed under 5 | * either the terms of the Eclipse Public License v1.0 as published by 6 | * the Eclipse Foundation 7 | * 8 | * or (per the licensee's choosing) 9 | * 10 | * under the terms of the GNU Lesser General Public License version 3.0 11 | * as published by the Free Software Foundation. 12 | */ 13 | package co.paralleluniverse.common.collection; 14 | 15 | import java.util.Collection; 16 | import java.util.Set; 17 | import java.util.concurrent.ConcurrentMap; 18 | 19 | /** 20 | * 21 | * @author pron 22 | */ 23 | public abstract class ConcurrentMultimap> extends ConcurrentMapComplex { 24 | private final C emptyCollection; 25 | 26 | public ConcurrentMultimap(ConcurrentMap map, C emptyCollection) { 27 | super(map); 28 | this.emptyCollection = emptyCollection; 29 | } 30 | 31 | public ConcurrentMultimap(C emptyCollection) { 32 | this.emptyCollection = emptyCollection; 33 | } 34 | 35 | @Override 36 | protected C emptyElement() { 37 | return emptyCollection; 38 | } 39 | 40 | public void put(K key, V value) { 41 | getOrAllocate(key).add(value); 42 | } 43 | 44 | public void put(K key, Collection values) { 45 | getOrAllocate(key).addAll(values); 46 | } 47 | 48 | public void remove(K key, V value) { 49 | final C coll = get(key); 50 | if (coll == null) 51 | return; 52 | coll.remove(value); 53 | } 54 | 55 | public Collection values() { 56 | return map.values(); 57 | } 58 | 59 | public Set keySet() { 60 | return map.keySet(); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/co/paralleluniverse/common/collection/ConcurrentLongSet.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2014, Parallel Universe Software Co. All rights reserved. 3 | * 4 | * This program and the accompanying materials are dual-licensed under 5 | * either the terms of the Eclipse Public License v1.0 as published by 6 | * the Eclipse Foundation 7 | * 8 | * or (per the licensee's choosing) 9 | * 10 | * under the terms of the GNU Lesser General Public License version 3.0 11 | * as published by the Free Software Foundation. 12 | */ 13 | package co.paralleluniverse.common.collection; 14 | 15 | import java.util.Set; 16 | import org.cliffc.high_scale_lib.NonBlockingHashMapLong; 17 | 18 | /** 19 | * 20 | * @author pron 21 | */ 22 | public class ConcurrentLongSet { 23 | private static final Object VALUE = new Object(); 24 | private final NonBlockingHashMapLong map = new NonBlockingHashMapLong(); 25 | 26 | public int size() { 27 | return map.size(); 28 | } 29 | 30 | public boolean isEmpty() { 31 | return map.isEmpty(); 32 | } 33 | 34 | public boolean contains(long obj) { 35 | return map.containsKey(obj); 36 | } 37 | 38 | public void clear() { 39 | map.clear(); 40 | } 41 | 42 | public boolean add(long e) { 43 | return map.put(e, VALUE) != null; 44 | } 45 | 46 | public boolean remove(long o) { 47 | return map.remove(o) != null; 48 | } 49 | 50 | public long[] getSnapshotAndClear() { 51 | final Set set = map.keySet(); 52 | final long[] array = new long[set.size()]; 53 | int i=0; 54 | for(NonBlockingHashMapLong.IteratorLong it = (NonBlockingHashMapLong.IteratorLong)set.iterator(); it.hasNext(); ) { 55 | array[i] = it.nextLong(); 56 | it.remove(); 57 | i++; 58 | } 59 | assert i == array.length; 60 | return array; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /config/_server.xml: -------------------------------------------------------------------------------- 1 | 2 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /src/main/java/co/paralleluniverse/galaxy/netty/UdpMessagePipelineFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Galaxy 3 | * Copyright (c) 2012-2014, Parallel Universe Software Co. All rights reserved. 4 | * 5 | * This program and the accompanying materials are dual-licensed under 6 | * either the terms of the Eclipse Public License v1.0 as published by 7 | * the Eclipse Foundation 8 | * 9 | * or (per the licensee's choosing) 10 | * 11 | * under the terms of the GNU Lesser General Public License version 3.0 12 | * as published by the Free Software Foundation. 13 | */ 14 | package co.paralleluniverse.galaxy.netty; 15 | 16 | import java.util.concurrent.Executor; 17 | import org.jboss.netty.channel.ChannelPipeline; 18 | import org.jboss.netty.channel.ChannelPipelineFactory; 19 | import org.jboss.netty.channel.Channels; 20 | import org.jboss.netty.handler.execution.ExecutionHandler; 21 | import org.slf4j.Logger; 22 | 23 | /** 24 | * 25 | * @author pron 26 | */ 27 | class UdpMessagePipelineFactory implements ChannelPipelineFactory { 28 | private final Logger logger; 29 | private final ChannelMessageNodeResolver nodeResolver; 30 | private final Executor executor; 31 | 32 | public UdpMessagePipelineFactory(Logger logger, ChannelNodeAddressResolver nodeResolver, Executor executor) { 33 | this.logger = logger; 34 | this.nodeResolver = nodeResolver; 35 | this.executor = executor; 36 | } 37 | 38 | @Override 39 | public ChannelPipeline getPipeline() throws Exception { 40 | final ChannelPipeline pipeline = Channels.pipeline(); 41 | if(executor != null) 42 | pipeline.addLast("executor", new ExecutionHandler(executor)); 43 | pipeline.addLast("logging", new LoggingHandler(logger)); 44 | // a node resolver must be added before the mesage codec 45 | pipeline.addLast("messageCodec", new MessagePacketCodec()); 46 | pipeline.addLast("nodeResolver", nodeResolver); 47 | 48 | return pipeline; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/test/java/co/paralleluniverse/galaxy/netty/MessagePacketEqualTo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Galaxy 3 | * Copyright (C) 2012 Parallel Universe Software Co. 4 | * 5 | * This file is part of Galaxy. 6 | * 7 | * Galaxy is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as 9 | * published by the Free Software Foundation, either version 3 of 10 | * the License, or (at your option) any later version. 11 | * 12 | * Galaxy is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with Galaxy. If not, see . 19 | */ 20 | package co.paralleluniverse.galaxy.netty; 21 | 22 | import co.paralleluniverse.galaxy.core.MessageEqualTo; 23 | import org.hamcrest.Description; 24 | import org.hamcrest.TypeSafeMatcher; 25 | 26 | /** 27 | * 28 | * @author pron 29 | */ 30 | public class MessagePacketEqualTo extends TypeSafeMatcher { 31 | private final MessagePacket packet; 32 | 33 | public MessagePacketEqualTo(MessagePacket packet) { 34 | this.packet = packet; 35 | } 36 | 37 | @Override 38 | public boolean matchesSafely(MessagePacket item) { 39 | if(packet.getMessages().size() != item.getMessages().size()) 40 | return false; 41 | for(int i=0; i 2 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /src/test/java/co/paralleluniverse/galaxy/test/ClonesArguments.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Galaxy 3 | * Copyright (C) 2012 Parallel Universe Software Co. 4 | * 5 | * This file is part of Galaxy. 6 | * 7 | * Galaxy is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as 9 | * published by the Free Software Foundation, either version 3 of 10 | * the License, or (at your option) any later version. 11 | * 12 | * Galaxy is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with Galaxy. If not, see . 19 | */ 20 | package co.paralleluniverse.galaxy.test; 21 | 22 | import java.lang.reflect.Method; 23 | import org.mockito.internal.stubbing.defaultanswers.ReturnsEmptyValues; 24 | import org.mockito.invocation.InvocationOnMock; 25 | import org.mockito.stubbing.Answer; 26 | 27 | /** 28 | * 29 | * @author pron 30 | */ 31 | public class ClonesArguments implements Answer { 32 | @Override 33 | public Object answer(InvocationOnMock invocation) throws Throwable { 34 | Object[] arguments = invocation.getArguments(); 35 | for (int i = 0; i < arguments.length; i++) { 36 | Object from = arguments[i]; 37 | if (from instanceof Cloneable) { 38 | try { 39 | Method cloneMethod = from.getClass().getMethod("clone"); 40 | Object newInstance = cloneMethod.invoke(from); 41 | arguments[i] = newInstance; 42 | } catch (Exception e) { 43 | // ignore 44 | } 45 | } 46 | } 47 | return new ReturnsEmptyValues().answer(invocation); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /licenses/LICENSE.bdb_je.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2002, 2012 Oracle and/or its affiliates. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions 5 | are met: 6 | 1. Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | 2. Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | 3. Redistributions in any form must be accompanied by information on 12 | how to obtain complete source code for the DB software and any 13 | accompanying software that uses the DB software. The source code 14 | must either be included in the distribution or be available for no 15 | more than the cost of distribution plus a nominal fee, and must be 16 | freely redistributable under reasonable conditions. For an 17 | executable file, complete source code means the source code for all 18 | modules it contains. It does not include source code for modules or 19 | files that typically accompany the major components of the operating 20 | system on which the executable file runs. 21 | 22 | THIS SOFTWARE IS PROVIDED BY ORACLE ``AS IS'' AND ANY EXPRESS OR 23 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 24 | WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR 25 | NON-INFRINGEMENT, ARE DISCLAIMED. IN NO EVENT SHALL ORACLE BE LIABLE 26 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 27 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 28 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 29 | BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 30 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 31 | OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 32 | IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /src/test/java/co/paralleluniverse/galaxy/netty/MessagePacketContains.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Galaxy 3 | * Copyright (C) 2012 Parallel Universe Software Co. 4 | * 5 | * This file is part of Galaxy. 6 | * 7 | * Galaxy is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as 9 | * published by the Free Software Foundation, either version 3 of 10 | * the License, or (at your option) any later version. 11 | * 12 | * Galaxy is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with Galaxy. If not, see . 19 | */ 20 | package co.paralleluniverse.galaxy.netty; 21 | 22 | import co.paralleluniverse.galaxy.core.Message; 23 | import co.paralleluniverse.galaxy.core.MessageEqualTo; 24 | import org.hamcrest.Description; 25 | import org.hamcrest.Matcher; 26 | import org.hamcrest.TypeSafeMatcher; 27 | 28 | /** 29 | * 30 | * @author pron 31 | */ 32 | public class MessagePacketContains extends TypeSafeMatcher { 33 | private final Message message; 34 | private final Matcher messageMatcher; 35 | 36 | public MessagePacketContains(Message message) { 37 | this.message = message; 38 | messageMatcher = new MessageEqualTo(message); 39 | } 40 | 41 | @Override 42 | public boolean matchesSafely(MessagePacket item) { 43 | for(Message m : item.getMessages()) { 44 | if(messageMatcher.matches(m)) 45 | return true; 46 | } 47 | return false; 48 | //return item.contains(message); 49 | } 50 | 51 | @Override 52 | public void describeTo(Description description) { 53 | description.appendText(message.toString()); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/test/java/co/paralleluniverse/galaxy/zookeeper/ZooKeeperDistributedTreeTKB.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Galaxy 3 | * Copyright (C) 2012 Parallel Universe Software Co. 4 | * 5 | * This file is part of Galaxy. 6 | * 7 | * Galaxy is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as 9 | * published by the Free Software Foundation, either version 3 of 10 | * the License, or (at your option) any later version. 11 | * 12 | * Galaxy is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with Galaxy. If not, see . 19 | */ 20 | package co.paralleluniverse.galaxy.zookeeper; 21 | 22 | import co.paralleluniverse.galaxy.cluster.DistributedTreeTKB; 23 | import java.util.Random; 24 | import org.apache.curator.framework.CuratorFramework; 25 | import org.apache.curator.framework.CuratorFrameworkFactory; 26 | import org.apache.curator.retry.ExponentialBackoffRetry; 27 | import org.junit.Test; 28 | 29 | /** 30 | * 31 | * @author pron 32 | */ 33 | public class ZooKeeperDistributedTreeTKB { 34 | public static void main(String[] args) throws Exception { 35 | try (CuratorFramework client = CuratorFrameworkFactory.builder().connectString("127.0.0.1:2181"). 36 | sessionTimeoutMs(1500).connectionTimeoutMs(1000).retryPolicy(new ExponentialBackoffRetry(20, 20)). 37 | defaultData(new byte[0]).build()) { 38 | client.start(); 39 | final String me = "node-" + Long.toHexString(new Random().nextLong()); 40 | new DistributedTreeTKB(new ZooKeeperDistributedTree(client), me).run(); 41 | } 42 | } 43 | 44 | // @Test 45 | public void hello() throws Exception { 46 | main(new String[]{}); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/test/java/co/paralleluniverse/galaxy/test/ThreadTreeLocal.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Galaxy 3 | * Copyright (C) 2012 Parallel Universe Software Co. 4 | * 5 | * This file is part of Galaxy. 6 | * 7 | * Galaxy is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as 9 | * published by the Free Software Foundation, either version 3 of 10 | * the License, or (at your option) any later version. 11 | * 12 | * Galaxy is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with Galaxy. If not, see . 19 | */ 20 | package co.paralleluniverse.galaxy.test; 21 | 22 | import java.util.IdentityHashMap; 23 | import java.util.Map; 24 | 25 | /** 26 | * 27 | * @author pron 28 | */ 29 | public class ThreadTreeLocal { 30 | private static final InheritableThreadLocal> threadTreeLocalMap = new InheritableThreadLocal>() { 31 | 32 | @Override 33 | protected Map initialValue() { 34 | return new IdentityHashMap(); 35 | } 36 | }; 37 | 38 | public T get() { 39 | Map map = getMap(); 40 | if (map.containsKey(this)) 41 | return (T) map.get(this); 42 | else 43 | return setInitialValue(); 44 | } 45 | 46 | public void set(T value) { 47 | getMap().put(this, value); 48 | } 49 | 50 | protected T initialValue() { 51 | return null; 52 | } 53 | 54 | private T setInitialValue() { 55 | T value = initialValue(); 56 | 57 | getMap().put(this, value); 58 | return value; 59 | } 60 | 61 | private Map getMap() { 62 | return threadTreeLocalMap.get(); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/co/paralleluniverse/galaxy/CacheListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Galaxy 3 | * Copyright (c) 2012-2014, Parallel Universe Software Co. All rights reserved. 4 | * 5 | * This program and the accompanying materials are dual-licensed under 6 | * either the terms of the Eclipse Public License v1.0 as published by 7 | * the Eclipse Foundation 8 | * 9 | * or (per the licensee's choosing) 10 | * 11 | * under the terms of the GNU Lesser General Public License version 3.0 12 | * as published by the Free Software Foundation. 13 | */ 14 | package co.paralleluniverse.galaxy; 15 | 16 | import java.nio.ByteBuffer; 17 | 18 | /** 19 | * A listener for local cache events. 20 | */ 21 | public interface CacheListener { 22 | /** 23 | * The data item has been invalidated - probably requested exclusively by another node, or, possibly, deleted. 24 | * @param id The item's ID. 25 | */ 26 | void invalidated(Cache cache, long id); 27 | 28 | /** 29 | * The data item has been updated by another node. This is the opposite of the {@link #invalidated(Cache, long) invalidated} event. This method is not called when the item is 30 | * modified locally by a {@link Store#set(long, byte[], StoreTransaction) set()}. 31 | * 32 | * @param id The item's ID. 33 | * @param version The item's version. 34 | * @param data The item's contents. 35 | */ 36 | void received(Cache cache, long id, long version, ByteBuffer data); 37 | 38 | /** 39 | * The data item has been evicted from the local cache. Only items not owned by the local node can be evicted. 40 | * @param id The item's ID. 41 | */ 42 | void evicted(Cache cache, long id); 43 | 44 | /** 45 | * The data item belonged to a node that has died (without slave replacement) 46 | * @param id The item's ID. 47 | */ 48 | void killed(Cache cache, long id); 49 | 50 | /** 51 | * Called when a message has been received. 52 | * 53 | * @param message The message's contents. 54 | */ 55 | void messageReceived(byte[] message); 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/co/paralleluniverse/galaxy/netty/SocketNodeAddressResolver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Galaxy 3 | * Copyright (c) 2012-2014, Parallel Universe Software Co. All rights reserved. 4 | * 5 | * This program and the accompanying materials are dual-licensed under 6 | * either the terms of the Eclipse Public License v1.0 as published by 7 | * the Eclipse Foundation 8 | * 9 | * or (per the licensee's choosing) 10 | * 11 | * under the terms of the GNU Lesser General Public License version 3.0 12 | * as published by the Free Software Foundation. 13 | */ 14 | package co.paralleluniverse.galaxy.netty; 15 | 16 | import co.paralleluniverse.galaxy.Cluster; 17 | import co.paralleluniverse.galaxy.cluster.AbstractNodeAddressResolver; 18 | import co.paralleluniverse.galaxy.cluster.NodeInfo; 19 | import java.net.InetAddress; 20 | import java.net.InetSocketAddress; 21 | import org.slf4j.Logger; 22 | import org.slf4j.LoggerFactory; 23 | 24 | /** 25 | * 26 | * @author pron 27 | */ 28 | public class SocketNodeAddressResolver extends AbstractNodeAddressResolver { 29 | private static final Logger LOG = LoggerFactory.getLogger(SocketNodeAddressResolver.class); 30 | private final String portProperty; 31 | 32 | public SocketNodeAddressResolver(Cluster cluster, String portProperty) { 33 | super(cluster); 34 | this.portProperty = portProperty; 35 | init(); 36 | } 37 | 38 | @Override 39 | protected InetSocketAddress getAddress(NodeInfo node) { 40 | final InetAddress address = (InetAddress) node.get(IpConstants.IP_ADDRESS); 41 | final Integer port = (Integer) node.get(portProperty); 42 | if (address == null || port == null) { 43 | if (address == null) 44 | LOG.warn("Socket address (property {}) not set for node {}", IpConstants.IP_ADDRESS, node); 45 | if (port == null) 46 | LOG.warn("Socket port (property {}) not set for node {}", portProperty, node); 47 | return null; 48 | } 49 | InetSocketAddress socket = new InetSocketAddress(address, port); 50 | return socket; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /travis/post_build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | start=$(date +%s) 3 | echo -e "Current repo: $TRAVIS_REPO_SLUG Commit: $TRAVIS_COMMIT\n" 4 | 5 | email="info@paralleluniverse.co" 6 | username="PU Bot" 7 | site_dir=docs/_site 8 | 9 | function error_exit 10 | { 11 | echo -e "\e[01;31m$1\e[00m" 1>&2 12 | exit 1 13 | } 14 | 15 | if [ "$TRAVIS_BRANCH" == "$DOCS_BRANCH" ]; then 16 | echo -e "Installing Jekyll...\n" 17 | gem install kramdown 18 | gem install jekyll 19 | gem install typogruby 20 | gem install nokogiri 21 | 22 | if [ ! -z "$GEN_APIDOCS" ]; then 23 | echo -e "Generating API docs...\n" 24 | echo -e "Running: $GEN_APIDOCS\n" 25 | eval $GEN_APIDOCS 26 | fi 27 | 28 | # build site 29 | echo -e "Building Jekyll site...\n" 30 | cd docs 31 | jekyll build || error_exit "Error building Jekyll site" 32 | cd .. 33 | 34 | echo -e "Updating gh-pages...\n" 35 | # Any command that using GH_OAUTH_TOKEN must pipe the output to /dev/null to not expose your oauth token 36 | git submodule add -b gh-pages https://${GH_OAUTH_TOKEN}@github.com/$TRAVIS_REPO_SLUG site > /dev/null 2>&1 37 | cd site 38 | git checkout gh-pages || git checkout -b gh-pages 39 | git rm -r . 40 | cp -R ../$site_dir/* . 41 | cp ../$site_dir/.* . 42 | touch .nojekyll 43 | git add -f . 44 | git config user.email $email 45 | git config user.name $username 46 | git commit -am "Travis build $TRAVIS_BUILD_NUMBER, commit $TRAVIS_COMMIT, pushed to gh-pages" 47 | # Any command that using GH_OAUTH_TOKEN must pipe the output to /dev/null to not expose your oauth token 48 | git push https://${GH_OAUTH_TOKEN}@github.com/$TRAVIS_REPO_SLUG HEAD:gh-pages > /dev/null 2>&1 || error_exit "Error updating gh-pages" 49 | 50 | #git checkout -B gh-pages 51 | #git add -f dist/. 52 | #git commit -q -m "Travis build $TRAVIS_BUILD_NUMBER pushed to gh-pages" 53 | #git push -fq upstream gh-pages 2> /dev/null || error_exit "Error updating gh-pages" 54 | 55 | echo -e "Finished updating gh-pages\n" 56 | fi 57 | 58 | end=$(date +%s) 59 | elapsed=$(( $end - $start )) 60 | minutes=$(( $elapsed / 60 )) 61 | seconds=$(( $elapsed % 60 )) 62 | echo "Post-build process finished in $minutes minute(s) and $seconds seconds" -------------------------------------------------------------------------------- /src/main/java/co/paralleluniverse/galaxy/core/MetricsBackupMonitor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Galaxy 3 | * Copyright (c) 2012-2014, Parallel Universe Software Co. All rights reserved. 4 | * 5 | * This program and the accompanying materials are dual-licensed under 6 | * either the terms of the Eclipse Public License v1.0 as published by 7 | * the Eclipse Foundation 8 | * 9 | * or (per the licensee's choosing) 10 | * 11 | * under the terms of the GNU Lesser General Public License version 3.0 12 | * as published by the Free Software Foundation. 13 | */ 14 | package co.paralleluniverse.galaxy.core; 15 | 16 | import co.paralleluniverse.common.monitoring.Metrics; 17 | import com.codahale.metrics.Meter; 18 | import com.codahale.metrics.MetricRegistry; 19 | import com.codahale.metrics.Timer; 20 | import java.util.concurrent.TimeUnit; 21 | 22 | /** 23 | * 24 | * @author pron 25 | */ 26 | public class MetricsBackupMonitor implements BackupMonitor { 27 | private final Meter backups = Metrics.meter(metric("backups")); 28 | private final Meter replicationBackups = Metrics.meter(metric("replicationBackups")); 29 | private final Meter backupPackets = Metrics.meter(metric("backupPacketsSent")); 30 | private final Timer slavesAckTime = Metrics.timer(metric("slavesAckTime")); 31 | private final Timer serverAckTime = Metrics.timer(metric("serverAckTime")); 32 | 33 | protected final String metric(String name) { 34 | return MetricRegistry.name("co.paralleluniverse", "galaxy", "Cache", name); 35 | } 36 | @Override 37 | public void addReplicationBackup(int num) { 38 | replicationBackups.mark(num); 39 | } 40 | 41 | @Override 42 | public void addBackups(int num) { 43 | backups.mark(num); 44 | } 45 | 46 | @Override 47 | public void addBackupPacket() { 48 | backupPackets.mark(); 49 | } 50 | 51 | @Override 52 | public void addSlaveAckTime(long nanos) { 53 | slavesAckTime.update(nanos, TimeUnit.NANOSECONDS); 54 | } 55 | 56 | @Override 57 | public void addServerAckTime(long nanos) { 58 | serverAckTime.update(nanos, TimeUnit.NANOSECONDS); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /config/_zookeeper.xml: -------------------------------------------------------------------------------- 1 | 2 | 14 | 15 | 16 | 17 | 18 | 19 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /src/main/java/co/paralleluniverse/common/monitoring/Metrics.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2014, Parallel Universe Software Co. All rights reserved. 3 | * 4 | * This program and the accompanying materials are dual-licensed under 5 | * either the terms of the Eclipse Public License v1.0 as published by 6 | * the Eclipse Foundation 7 | * 8 | * or (per the licensee's choosing) 9 | * 10 | * under the terms of the GNU Lesser General Public License version 3.0 11 | * as published by the Free Software Foundation. 12 | */ 13 | package co.paralleluniverse.common.monitoring; 14 | 15 | import com.codahale.metrics.Counter; 16 | import com.codahale.metrics.Histogram; 17 | import com.codahale.metrics.JmxReporter; 18 | import com.codahale.metrics.Meter; 19 | import com.codahale.metrics.Metric; 20 | import com.codahale.metrics.MetricRegistry; 21 | import com.codahale.metrics.MetricSet; 22 | import com.codahale.metrics.Timer; 23 | 24 | /** 25 | * 26 | * @author pron 27 | */ 28 | public class Metrics { 29 | private static final MetricRegistry metrics = new MetricRegistry(); 30 | private static final JmxReporter reporter; 31 | 32 | static { 33 | reporter = JmxReporter.forRegistry(metrics).build(); 34 | reporter.start(); 35 | } 36 | 37 | public static MetricRegistry registry() { 38 | return metrics; 39 | } 40 | 41 | public static T register(String name, T metric) throws IllegalArgumentException { 42 | return metrics.register(name, metric); 43 | } 44 | 45 | public static void registerAll(MetricSet ms) throws IllegalArgumentException { 46 | metrics.registerAll(ms); 47 | } 48 | 49 | public static Counter counter(String name) { 50 | return metrics.counter(name); 51 | } 52 | 53 | public static Histogram histogram(String name) { 54 | return metrics.histogram(name); 55 | } 56 | 57 | public static Meter meter(String name) { 58 | return metrics.meter(name); 59 | } 60 | 61 | public static Timer timer(String name) { 62 | return metrics.timer(name); 63 | } 64 | 65 | public static boolean remove(String name) { 66 | return metrics.remove(name); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /src/main/java/co/paralleluniverse/io/serialization/kryo/ReferenceSerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2014, Parallel Universe Software Co. All rights reserved. 3 | * 4 | * This program and the accompanying materials are dual-licensed under 5 | * either the terms of the Eclipse Public License v1.0 as published by 6 | * the Eclipse Foundation 7 | * 8 | * or (per the licensee's choosing) 9 | * 10 | * under the terms of the GNU Lesser General Public License version 3.0 11 | * as published by the Free Software Foundation. 12 | */ 13 | package co.paralleluniverse.io.serialization.kryo; 14 | 15 | import com.esotericsoftware.kryo.Kryo; 16 | import com.esotericsoftware.kryo.Serializer; 17 | import com.esotericsoftware.kryo.io.Input; 18 | import com.esotericsoftware.kryo.io.Output; 19 | import java.io.NotSerializableException; 20 | import java.lang.ref.PhantomReference; 21 | import java.lang.ref.Reference; 22 | import java.lang.ref.SoftReference; 23 | import java.lang.ref.WeakReference; 24 | 25 | /** 26 | * 27 | * @author pron 28 | */ 29 | class ReferenceSerializer extends Serializer> { 30 | public ReferenceSerializer() { 31 | setImmutable(true); 32 | } 33 | 34 | @Override 35 | public void write(Kryo kryo, Output output, Reference r) { 36 | if (r instanceof PhantomReference) 37 | throw new RuntimeException(new NotSerializableException(r.getClass().getName())); 38 | final boolean strong = !(r instanceof WeakReference || r instanceof SoftReference); 39 | kryo.writeClassAndObject(output, strong ? r.get() : null); 40 | } 41 | 42 | @Override 43 | public Reference read(Kryo kryo, Input input, Class> type) { 44 | assert !PhantomReference.class.isAssignableFrom(type); 45 | final boolean strong = !(WeakReference.class.isAssignableFrom(type) || SoftReference.class.isAssignableFrom(type)); 46 | final Object val = kryo.readClassAndObject(input); 47 | assert val == null || !strong; 48 | try { 49 | return (Reference) type.getConstructor(Object.class).newInstance(val); 50 | } catch (Exception e) { 51 | throw new RuntimeException(e); 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/co/paralleluniverse/common/collection/LongRange.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2014, Parallel Universe Software Co. All rights reserved. 3 | * 4 | * This program and the accompanying materials are dual-licensed under 5 | * either the terms of the Eclipse Public License v1.0 as published by 6 | * the Eclipse Foundation 7 | * 8 | * or (per the licensee's choosing) 9 | * 10 | * under the terms of the GNU Lesser General Public License version 3.0 11 | * as published by the Free Software Foundation. 12 | */ 13 | package co.paralleluniverse.common.collection; 14 | 15 | import it.unimi.dsi.fastutil.longs.AbstractLongCollection; 16 | import it.unimi.dsi.fastutil.longs.AbstractLongIterator; 17 | import it.unimi.dsi.fastutil.longs.LongIterator; 18 | 19 | /** 20 | * 21 | * @author pron 22 | */ 23 | public class LongRange extends AbstractLongCollection { 24 | final long start; 25 | final int length; 26 | 27 | public LongRange(long start, int length) { 28 | this.start = start; 29 | this.length = length; 30 | } 31 | 32 | @Override 33 | public int size() { 34 | return length; 35 | } 36 | 37 | @Override 38 | public LongIterator iterator() { 39 | return new AbstractLongIterator() { 40 | private int nextIndex = 0; 41 | 42 | @Override 43 | public boolean hasNext() { 44 | return nextIndex < length; 45 | } 46 | 47 | @Override 48 | public long nextLong() { 49 | return start + (nextIndex++); 50 | } 51 | 52 | @Override 53 | public void remove() { 54 | throw new UnsupportedOperationException(); 55 | } 56 | }; 57 | } 58 | 59 | @Override 60 | public boolean contains(long entry) { 61 | return (entry >= start && entry < (start + length)); 62 | } 63 | 64 | @Override 65 | public boolean rem(long entry) { 66 | throw new UnsupportedOperationException(); 67 | } 68 | 69 | @Override 70 | public void clear() { 71 | throw new UnsupportedOperationException(); 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /src/test/resources/config/_zookeeper.xml: -------------------------------------------------------------------------------- 1 | 2 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /src/main/java/co/paralleluniverse/common/io/Hasher.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2014, Parallel Universe Software Co. All rights reserved. 3 | * 4 | * This program and the accompanying materials are dual-licensed under 5 | * either the terms of the Eclipse Public License v1.0 as published by 6 | * the Eclipse Foundation 7 | * 8 | * or (per the licensee's choosing) 9 | * 10 | * under the terms of the GNU Lesser General Public License version 3.0 11 | * as published by the Free Software Foundation. 12 | */ 13 | package co.paralleluniverse.common.io; 14 | 15 | import com.google.common.primitives.Longs; 16 | import java.nio.ByteBuffer; 17 | 18 | /** 19 | * Based on Numerical Recipes 7.6.1 20 | * 21 | * @author pron 22 | */ 23 | class Hasher implements Checksum { 24 | private static final long START = 0xBB40E64DA205B064L; 25 | private static final long MULT = 7664345821815920749L; 26 | private static final long[] TABLE = createLookupTable(); 27 | // 28 | private long value; 29 | 30 | public Hasher() { 31 | reset(); 32 | } 33 | 34 | @Override 35 | public final void reset() { 36 | value = START; 37 | } 38 | 39 | @Override 40 | public byte[] getChecksum() { 41 | return Longs.toByteArray(value); 42 | } 43 | 44 | @Override 45 | public void update(byte b) { 46 | value = (value * MULT) ^ TABLE[(int)b & 0xff]; 47 | } 48 | 49 | @Override 50 | public void update(byte[] array) { 51 | for(byte b : array) 52 | update(b); 53 | } 54 | 55 | @Override 56 | public void update(ByteBuffer buffer) { 57 | while(buffer.hasRemaining()) 58 | update(buffer.get()); 59 | } 60 | 61 | private static long[] createLookupTable() { 62 | long[] table = new long[256]; 63 | long h = 0x544B2FBACAAF1684L; 64 | for (int i = 0; i < 256; i++) { 65 | for (int j = 0; j < 31; j++) { 66 | h = (h >>> 7) ^ h; 67 | h = (h << 11) ^ h; 68 | h = (h >>> 10) ^ h; 69 | } 70 | table[i] = h; 71 | } 72 | return table; 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /src/main/java/co/paralleluniverse/galaxy/core/MetricsMainMemoryMonitor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Galaxy 3 | * Copyright (c) 2012-2014, Parallel Universe Software Co. All rights reserved. 4 | * 5 | * This program and the accompanying materials are dual-licensed under 6 | * either the terms of the Eclipse Public License v1.0 as published by 7 | * the Eclipse Foundation 8 | * 9 | * or (per the licensee's choosing) 10 | * 11 | * under the terms of the GNU Lesser General Public License version 3.0 12 | * as published by the Free Software Foundation. 13 | */ 14 | package co.paralleluniverse.galaxy.core; 15 | 16 | import co.paralleluniverse.common.monitoring.Metrics; 17 | import com.codahale.metrics.Meter; 18 | import com.codahale.metrics.MetricRegistry; 19 | 20 | /** 21 | * 22 | * @author pron 23 | */ 24 | class MetricsMainMemoryMonitor implements MainMemoryMonitor { 25 | private final Meter writes = Metrics.meter(metric("writes")); 26 | private final Meter transactions = Metrics.meter(metric("transactions")); 27 | private final Meter objectsServed = Metrics.meter(metric("objectsServed")); 28 | private final Meter ownerWrites = Metrics.meter(metric("ownerWrites")); 29 | private final Meter ownersServed = Metrics.meter(metric("ownersServed")); 30 | private final Meter allocations = Metrics.meter(metric("allocations")); 31 | 32 | protected final String metric(String name) { 33 | return MetricRegistry.name("co.paralleluniverse", "galaxy", "MainMemory", name); 34 | } 35 | 36 | @Override 37 | public void setMonitoredObject(Object obj) { 38 | } 39 | 40 | @Override 41 | public void addObjectServed() { 42 | objectsServed.mark(); 43 | } 44 | 45 | @Override 46 | public void addOwnerServed() { 47 | ownersServed.mark(); 48 | } 49 | 50 | @Override 51 | public void addOwnerWrite() { 52 | ownerWrites.mark(); 53 | } 54 | 55 | @Override 56 | public void addTransaction(int numWrites) { 57 | transactions.mark(); 58 | writes.mark(numWrites); 59 | } 60 | 61 | @Override 62 | public void addAllocation(int count) { 63 | allocations.mark(count); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/main/java/co/paralleluniverse/galaxy/jgroups/JGroupsConstants.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Galaxy 3 | * Copyright (c) 2012-2014, Parallel Universe Software Co. All rights reserved. 4 | * 5 | * This program and the accompanying materials are dual-licensed under 6 | * either the terms of the Eclipse Public License v1.0 as published by 7 | * the Eclipse Foundation 8 | * 9 | * or (per the licensee's choosing) 10 | * 11 | * under the terms of the GNU Lesser General Public License version 3.0 12 | * as published by the Free Software Foundation. 13 | */ 14 | package co.paralleluniverse.galaxy.jgroups; 15 | 16 | import co.paralleluniverse.galaxy.cluster.ReaderWriter; 17 | import com.google.common.base.Throwables; 18 | import java.io.ByteArrayInputStream; 19 | import java.io.ByteArrayOutputStream; 20 | import java.io.DataInputStream; 21 | import java.io.DataOutputStream; 22 | import org.jgroups.Address; 23 | import org.jgroups.util.Util; 24 | 25 | /** 26 | * 27 | * @author pron 28 | */ 29 | final class JGroupsConstants { 30 | public final static String JGROUPS_ADDRESS = "jg_addr"; 31 | 32 | public final static ReaderWriter
JGROUPS_ADDRESS_READER_WRITER = new ReaderWriter
() { 33 | @Override 34 | public Address read(byte[] data) { 35 | try { 36 | return Util.readAddress(new DataInputStream(new ByteArrayInputStream(data))); 37 | } catch (Exception ex) { 38 | throw Throwables.propagate(ex); 39 | } 40 | } 41 | 42 | @Override 43 | public byte[] write(Address value) { 44 | try { 45 | final ByteArrayOutputStream baos = new ByteArrayOutputStream(); 46 | final DataOutputStream dos = new DataOutputStream(baos); 47 | Util.writeAddress((Address) value, dos); 48 | dos.flush(); 49 | return baos.toByteArray(); 50 | } catch (Exception ex) { 51 | throw new RuntimeException(ex); 52 | } 53 | } 54 | }; 55 | 56 | private JGroupsConstants() { 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/test/java/co/paralleluniverse/galaxy/core/NodeInfoPropertyEqual.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Galaxy 3 | * Copyright (C) 2012 Parallel Universe Software Co. 4 | * 5 | * This file is part of Galaxy. 6 | * 7 | * Galaxy is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as 9 | * published by the Free Software Foundation, either version 3 of 10 | * the License, or (at your option) any later version. 11 | * 12 | * Galaxy is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with Galaxy. If not, see . 19 | */ 20 | package co.paralleluniverse.galaxy.core; 21 | 22 | import co.paralleluniverse.galaxy.cluster.NodeInfo; 23 | import org.hamcrest.Description; 24 | import org.hamcrest.TypeSafeMatcher; 25 | 26 | /** 27 | * 28 | * @author pron 29 | */ 30 | class NodeInfoPropertyEqual extends TypeSafeMatcher { 31 | private final String property; 32 | private final Object value; 33 | 34 | public NodeInfoPropertyEqual(String property, Object value) { 35 | super(NodeInfo.class); 36 | this.property = property; 37 | this.value = value; 38 | } 39 | 40 | @Override 41 | public boolean matchesSafely(NodeInfo item) { 42 | if (item == null) 43 | return false; 44 | 45 | if (property.equals("id")) 46 | return new Short(item.getNodeId()).equals(value); 47 | if (property.equals("name")) 48 | return item.getName().equals(value); 49 | 50 | final Object actualValue = item.get(property); 51 | 52 | if (actualValue == value) 53 | return true; 54 | 55 | if (value != null) 56 | return value.equals(actualValue); 57 | return false; 58 | } 59 | 60 | @Override 61 | public void describeTo(Description description) { 62 | description.appendText("property " + property + " is " + value.toString()); 63 | } 64 | } 65 | --------------------------------------------------------------------------------