Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
239 commits
Select commit Hold shift + click to select a range
aefb584
Ported to gradle build
Jun 28, 2013
38c3c3d
Merge pull request #24 from divchenko/feature/gradle-build
jhartman Jul 5, 2013
25f4460
FIX: change version back to 0.6.33
Jul 11, 2013
b718e17
Merge pull request #26 from vikstrous/0.6.33
jhartman Jul 11, 2013
11d6c89
Adjusting the norbert tuning parameters affected by the change from m…
Jul 15, 2013
ad21559
Merge remote-tracking branch 'upstream/master'
Jul 15, 2013
37ce05b
Upping the version
Jul 15, 2013
079ebea
Merge pull request #27 from abhinigam/master
jhartman Jul 16, 2013
1977d54
Updating Netty Version in Norbert for USCP 2050
Aug 1, 2013
38bcb5b
Merge pull request #1 from navina/master
jhartman Aug 5, 2013
276fb1f
Upping the version
Aug 5, 2013
92e1a21
Merge pull request #2 from navina/master
navina Aug 5, 2013
44d86ea
Modifying the JMX stats so that they remain unchanged even after mill…
Aug 12, 2013
135ebc2
Adding metrics: active pool size, current pool size, queue time, tota…
Aug 14, 2013
d981f34
Testing push mechanism
Aug 15, 2013
b43b725
Moving queueTime from endRequest to beginRequest, leaving existing la…
Sep 9, 2013
ef742cc
Fixing tests
Sep 9, 2013
f06acf7
Upgrading the version of norbert
Sep 9, 2013
f674813
Part of selective retry commit
Oct 25, 2013
800a3ba
Part of selective retry commit
Oct 25, 2013
cc5af61
Final set of changes for selective retry
Oct 25, 2013
1fe42ec
Version upgrade change
Oct 25, 2013
18efc73
Enhancement to make sure in case the number of errors exceeds thresho…
Oct 25, 2013
c8a4ed3
Enhanced the retry logic to continue beyond the initial timeout to re…
Oct 25, 2013
e082a5c
Removing an extraneous comment
Oct 25, 2013
39d857c
Add support in partitioned factory for specifying selective retry
Oct 25, 2013
c5761ac
Spring/java friendly SelectiveRetry interface
Oct 30, 2013
189cc3e
Bumping up the version due to artifactory issues
Oct 30, 2013
b1ed1e6
Adding logging for selective retry
Oct 30, 2013
dc790a8
Bumping the version
Oct 30, 2013
9da27f9
Upgrading the version of norbert
Nov 1, 2013
4d4f0d6
Fixing requests per second metric
Nov 3, 2013
4d36a5a
Bumping the version
Nov 3, 2013
53824e4
Adding bindByPort method which looks up node configurations in zookeeper
Nov 13, 2013
071bb8a
Merge pull request #3 from linkedin/tworboys-branch
tworboys Nov 14, 2013
a0482ce
Fixing the race condition when we restart after SIGKILL
Nov 16, 2013
a4c343b
Expose duplicatesOk as config and change Future in APIs to FutureList…
Nov 22, 2013
25935a7
Bumping the version up
Nov 22, 2013
e552acd
Hooking up FutureAdapterListener to multiple places
Dec 2, 2013
f254c47
Bumping up the version
Dec 2, 2013
97cea23
Bumped Netty version to fix shutdown hang.
nsabovic Dec 4, 2013
84897ed
Undo protobuf version bump...
nsabovic Dec 4, 2013
0c0f791
Adding hash functions and fixing a load balancer bug
Dec 5, 2013
65f36cb
Merge pull request #4 from linkedin/tworboys-branch
tworboys Dec 6, 2013
df51ea3
Bumping the version
Dec 6, 2013
c7852e5
Adding handling/logging of new zookeeper events. New API for overridi…
Dec 7, 2013
8eb463d
Adding logging/handling of additional zookeeper events. New API which…
Dec 7, 2013
dc57cc1
Fixing the md5 hash function
Dec 10, 2013
601d2f7
Merge pull request #6 from linkedin/tworboys-branch
tworboys Dec 10, 2013
1d3e8c1
Bumping the version
Dec 10, 2013
d82b911
Merge pull request #7 from linkedin/tworboys-branch
tworboys Dec 10, 2013
0c5b147
Allowing bind to work with hostname and port
Dec 19, 2013
7b2d1fa
update gitignore for bin folder and swp files
mavlee Dec 19, 2013
abb0de0
fix documentation to use syntax highlighting
mavlee Dec 19, 2013
1966867
Merge pull request #9 from mavlee/master
mavlee Dec 20, 2013
91ea1c4
Fixing the test case concurrency issue. Test cases share the one sing…
sungjuc Jan 10, 2014
a9f40da
Merge pull request #10 from sungjuc/master
mavlee Jan 11, 2014
d7e5c15
Merge pull request #8 from linkedin/tworboys-branch
tworboys Jan 19, 2014
e90a75a
Fixing inefficiency of default round-robin load balancer for partitio…
sungjuc Jan 23, 2014
87400ea
Merge pull request #11 from sungjuc/master
sungjuc Jan 23, 2014
557805b
Bumping up the version for load balancer fixes.
sungjuc Jan 23, 2014
acd781c
Merge pull request #12 from sungjuc/master
sungjuc Jan 23, 2014
8c2c81b
refactored code to be source compatible with Scala 2.10 and added sup…
cdfreeman Jan 26, 2014
372d7d6
Merge pull request #13 from cdfreeman/cfreeman-branch
Jan 27, 2014
f0f8291
Bumping version number after adding support for scala 2.10.x
Jan 27, 2014
05f596b
Fixing the capability round-robin test cases.
sungjuc Feb 3, 2014
35ab7ed
Merge pull request #14 from sungjuc/master
sungjuc Feb 3, 2014
439e283
Fixing counter incrementing for capability round-robin.
sungjuc Feb 3, 2014
63c50e8
Merge pull request #15 from sungjuc/master
sungjuc Feb 3, 2014
3eb0101
Bumping version after Jo's fixes
Feb 4, 2014
6643f56
bumping version to 0.6.55
Feb 5, 2014
5544436
Merge pull request #16 from jarekr/master
tworboys Feb 5, 2014
db7c50f
Fixing a bug in latest selective retry code
Feb 24, 2014
1d19423
Merge pull request #18 from linkedin/anigam-selectiveRetryStuff
sungjuc Feb 25, 2014
d757308
Bumping up the gradle version
Feb 25, 2014
498dc06
Merge pull request #19 from linkedin/anigam-selectiveRetryStuff
abhinigam Feb 25, 2014
3be1df2
Lock-free version of FutureAdapterListener, Ability to send parameter…
Feb 25, 2014
44df88e
Buming up the version for this checkin
Feb 25, 2014
79bb733
Update MessageExecutorComponent.scala
jhngzhu Feb 27, 2014
f766e01
Bump up gradle version to 0.6.57
jhngzhu Feb 27, 2014
8411d33
Bump up gradle version for fixing the Rum version
jhngzhu Feb 28, 2014
969e268
add rerouting statistics to client statistics
mavlee Mar 3, 2014
95fad25
cross build against scala versions 2.10.3 and 2.8.1
Mar 3, 2014
4a3aaf6
update num nodes marked down statistic
mavlee Mar 4, 2014
3c39c1d
Merge pull request #21 from linkedin/rerouting-sensors
sungjuc Mar 4, 2014
aae0647
incremented gradle version number to 0.6.60
Mar 4, 2014
4c8c824
merging Chriss Freemans pull request: This pull request contains the …
Mar 5, 2014
f03d09f
Merge pull request #22 from cdfreeman/crossbuild
Mar 5, 2014
b00f2fb
Reverting the commit so that I can split it into two
Mar 5, 2014
1647344
Refine the API for selective retry
Mar 6, 2014
6f250bc
Merge pull request #20 from linkedin/anigam-selectiveRetryStuff
sungjuc Mar 6, 2014
3debe7a
Bumping up the gradle version
Mar 6, 2014
7fbbab7
Merge pull request #24 from linkedin/anigam-selectiveRetryStuff
abhinigam Mar 6, 2014
fb2f416
Pushing the lock-free version of FutureAdapterListener
Mar 7, 2014
e35424e
Merge pull request #25 from linkedin/anigam-selectiveRetryStuff
sungjuc Mar 7, 2014
b41cec5
Bumping up the gradle version
Mar 7, 2014
22f7c77
Merge pull request #26 from linkedin/anigam-selectiveRetryStuff
abhinigam Mar 7, 2014
298371e
Deploy Scala version 2.10.3
Mar 19, 2014
2817d34
Merge pull request #27 from linkedin/scala210
mavlee Mar 19, 2014
11fa8b8
Use scala 2.8.1 for sbt
Mar 21, 2014
e9060f3
Merge pull request #28 from linkedin/scala210
sungjuc Mar 21, 2014
fb9c52e
Fan-out controllable load balancer implementation.
sungjuc Mar 22, 2014
bb40ea8
Boilerplate files for ClusteredNetworkClient.
sungjuc Mar 23, 2014
e2b2aa4
ClusteredNetworkClient implementation with fanout controllable APIs.
sungjuc Mar 26, 2014
591c4d5
Refactoring PartitionedNetworkClient to include all features.
sungjuc Mar 29, 2014
27d2ac7
Merge remote branch 'upstream/master'
sungjuc Mar 31, 2014
a87a3db
Fixes based on code review comments.
sungjuc Mar 31, 2014
0abaf4c
Merge pull request #30 from sungjuc/master
sungjuc Apr 4, 2014
7037c92
Bumping up the gradle version
sungjuc Apr 4, 2014
7419431
Merge pull request #31 from sungjuc/master
sungjuc Apr 4, 2014
a89ddf1
Adding shutdown pause for shutting down a netty server
calcu16 Apr 10, 2014
190e84f
Changing raw value to multiplier
calcu16 Apr 10, 2014
3fe11de
Merge pull request #32 from linkedin/acarter-branch
abhinigam Apr 10, 2014
ce8c6e3
Bumping up gradle version
calcu16 Apr 10, 2014
e34e68d
Merge pull request #33 from linkedin/acarter-branch
calcu16 Apr 10, 2014
942952e
Merge pull request #1 from linkedin/master
sungjuc Apr 11, 2014
3ec0f0b
Removing unecessary connection trials and adding loggings of selected…
sungjuc Apr 12, 2014
8d5dcbe
Bumping up version.
sungjuc Apr 12, 2014
7c1568b
Merge pull request #34 from sungjuc/master
sungjuc Apr 12, 2014
09f193d
Removing commented out loggings.
sungjuc Apr 12, 2014
d6d056a
Merge pull request #35 from sungjuc/master
mavlee Apr 12, 2014
9bb2343
Fix the metrics for queue time and total request response time
Apr 14, 2014
563eb3f
Fix the metrics for queue time and total request response time
Apr 14, 2014
5b04380
Merge pull request #36 from linkedin/fixsensors
abhinigam Apr 14, 2014
1fc9c7c
Division-by-zero fix in RoundRobinLoadBalancerFactory when no nodes w…
Dec 3, 2013
1a60774
Java-compat, make sure java-nodes are capabilities aware
Dec 4, 2013
8ff4bd2
Java-network: add sendRequest calls which are capabilities & maxRetry…
Dec 4, 2013
8e1a634
Adding loggings for fanout distribution.
sungjuc Apr 25, 2014
9540a34
Bumping up version.
sungjuc Apr 26, 2014
da1ddd9
Merge pull request #38 from linkedin/joe-branch
mavlee Apr 26, 2014
5aa43a5
Merge pull request #37 from stromnet/java-improvements
abhinigam Apr 29, 2014
f96fb15
Fixing the race condition involving JMX registration, added stuff to …
Apr 29, 2014
fa79790
Bumping up the version of gradle.properties
Apr 29, 2014
1f29f4c
Forgot to include this file in the commit
May 1, 2014
37c5090
Renaming the function to avoid confusion
May 1, 2014
abf0b36
Added the ability to set a timeout in the RequestRunner subclass of
May 9, 2014
140ba4f
Whitespace and function name change as per schos request
May 9, 2014
fe519c0
Merge pull request #40 from rwstephenson/master
sungjuc May 9, 2014
0c8f3c1
Incrementing version
May 9, 2014
8a6c9f6
Whitespace change
May 9, 2014
58dbf7d
Merge pull request #41 from rwstephenson/master
sungjuc May 9, 2014
d3ecf29
Added more granular logging per request to show how much of the request
Jun 10, 2014
3c72c11
Fixing selective retry bug
calcu16 Jun 10, 2014
1050cba
Merge pull request #43 from calcu16/master
abhinigam Jun 10, 2014
2bb0e8d
Fixing null/None issue in selective retry, now passes tests
calcu16 Jun 11, 2014
3338f52
Merge pull request #44 from calcu16/master
abhinigam Jun 11, 2014
d724128
Version bump
calcu16 Jun 11, 2014
6d2e603
Merge pull request #45 from calcu16/master
calcu16 Jun 11, 2014
87695c4
Merge pull request #42 from rwstephenson/master
sungjuc Jun 11, 2014
356f145
Version bump
Jun 11, 2014
fdbb3c6
Merge pull request #46 from rwstephenson/master
mavlee Jun 11, 2014
beeea88
Finished request latency granularity logging
Jun 11, 2014
e862f8f
Version bump
Jun 11, 2014
38eeeeb
Merge pull request #48 from rwstephenson/master
mavlee Jun 11, 2014
9f4a5fb
remove old version of scala from being built
mavlee Jul 2, 2014
9ba14d2
Merge pull request #49 from linkedin/remove_old_scala
mavlee Jul 2, 2014
0e73e64
Initial commit of Dark Canary channel handler.
Aug 4, 2014
49cec75
Three main changes:
Aug 5, 2014
a97acf8
Adding copyright notice to the DarkCanaryChannelHandler.scala file
Aug 5, 2014
5547ef5
Converted the DarkCanaryChannelHandler to be a class instead of an ob…
Aug 6, 2014
a373d87
Restore original version of ClusterIoClientComponent. There was no ne…
Aug 6, 2014
5ea704f
Implement Unit tests for the DarkCanaryChannelHandler and nested clas…
Aug 6, 2014
fb20a61
Version bump
Aug 6, 2014
0d58cd6
Added comments describing the operation of the DarkCanaryChannelHandl…
Aug 6, 2014
9c3f321
Reverting changes to ClientChannelHandler since they have become unne…
Aug 6, 2014
3af774f
Address code review comments:
Aug 7, 2014
503412e
add flow diagram image for use in wiki
mavlee Aug 8, 2014
8fb61dd
Address review board comments:
Aug 8, 2014
d40d657
Cleanup resource leak in ChannelPool
Aug 8, 2014
f3c6b32
Address code review comments:
Aug 8, 2014
b77b24b
Clenup inconsistent vertical whitespaces
Aug 8, 2014
f461b75
Merge pull request #50 from linkedin/dark-canary
Aug 8, 2014
2a170be
Lowering log levels
calcu16 Aug 12, 2014
9c5f5c4
Updating gradle.properties
calcu16 Aug 12, 2014
88ed42c
Merge pull request #51 from calcu16/master
sungjuc Aug 13, 2014
80b750f
Adding comments to clarify cleaner policy in DarkCanaryChannelHandler.
Aug 15, 2014
ff0a944
Bump version
Aug 15, 2014
e9edbc8
Merge pull request #52 from linkedin/dark-canary-fixes
mavlee Aug 15, 2014
ad396a0
Fixing comments in PartitionedNetworkClient.
sungjuc Aug 16, 2014
53a5ca7
Only printing expired message if there are expired entries
calcu16 Aug 18, 2014
b4f7f56
Merge pull request #53 from calcu16/master
Aug 18, 2014
bd7d9e8
Adding feature of sending request to specific cluster.
sungjuc Aug 20, 2014
e50609a
Bumping the version
sungjuc Aug 20, 2014
18ac721
Merge pull request #55 from linkedin/cluster
sungjuc Aug 21, 2014
885641f
Splitting up timeout exception from other exceptions for connection i…
calcu16 Aug 25, 2014
cfcb994
Updating gradle version
calcu16 Aug 25, 2014
af32de1
Merge pull request #56 from calcu16/master
sungjuc Aug 25, 2014
9f0600a
Upgrading netty version in sbt build.
sungjuc Aug 25, 2014
f51da4c
Merge pull request #60 from linkedin/cluster_2
calcu16 Aug 25, 2014
e3a0670
Changing naming from PartitionsIds to PartitionedIds.
sungjuc Aug 26, 2014
66248ad
Adding comments on cluster id based node selection codes.
sungjuc Aug 26, 2014
2d0080d
Changing error message for more descriptive info on single cluster re…
sungjuc Aug 26, 2014
5b6a418
Version bumping up.
sungjuc Aug 26, 2014
2d8b9e5
Merge pull request #61 from linkedin/cluster
sungjuc Aug 26, 2014
f0fd801
Adding cluster id checkings in advacne to cluster centric request wor…
sungjuc Sep 6, 2014
6e01b9a
Bump up version.
sungjuc Sep 6, 2014
40c9ad4
Merge pull request #62 from linkedin/cluster
sungjuc Sep 6, 2014
6da7cdc
Removing stack traces for ConnectTimeoutExceptions
calcu16 Sep 17, 2014
cfceefc
Reusing match variable
calcu16 Sep 17, 2014
2533df2
Merge pull request #63 from calcu16/master
sungjuc Sep 18, 2014
9531549
Added to README, checking if push to GitHub works properly.
ENuge Sep 25, 2014
f5f71a9
Altered the Definign the cluster section to reflect teh fact that Nor…
Oct 2, 2014
ee3344d
Added .gitignore file
Oct 2, 2014
e8cd50a
Removed teh .idea files
Oct 2, 2014
de6ef58
Fixed spelling mistakes
Oct 2, 2014
25d73fd
Fixed another spelling error
Oct 2, 2014
dd8c830
More readme changes to the defigning the cluster section (minor)
Oct 2, 2014
2bf43e2
Merge pull request #1 from ENuge/hwImproveREADME
ENuge Oct 2, 2014
c863ec8
Updated some parts of README
ENuge Oct 6, 2014
5efe405
Update README.md
CSchubert Oct 6, 2014
b21ff15
Updated README, minor style changes.
ENuge Oct 7, 2014
be97e36
Revert "Merge pull request #48 from rwstephenson/master"
Oct 8, 2014
3674e52
Revert "Merge pull request #42 from rwstephenson/master"
Oct 8, 2014
31b08af
Merge pull request #64 from linkedin/stats-rollback
mavlee Oct 8, 2014
e3a1a8f
update version
mavlee Oct 8, 2014
a109954
Unreverting the revert of statistics with memory leak, fixing the bug
Oct 9, 2014
37ed21d
Unreverting the revert of statistics with memory leak, fixing the bug
Oct 9, 2014
5ec81d1
Revert "Unreverting the revert of statistics with memory leak, fixing…
Oct 10, 2014
2054cd2
Removing some debug code
Oct 10, 2014
257f135
Reformatting imports
Oct 10, 2014
cda6d47
Merge pull request #66 from linkedin/memory-leak-fix
Oct 10, 2014
024b103
Re-added whats required to view the new stats
Oct 10, 2014
e710337
Merge pull request #67 from linkedin/memory-leak-fix-ctd
Oct 10, 2014
c9e257e
Update README.md
ENuge Oct 23, 2014
b1efa33
Update README.md
ENuge Oct 23, 2014
9662bd4
Merge pull request #68 from ENuge/eoin_improve_README
sungjuc Oct 24, 2014
b1104c9
Adding a bindOrCreateByUrl method
calcu16 Nov 21, 2014
db1fc85
Bump up gradle.properties
calcu16 Nov 22, 2014
7cbcde3
Exposing the markAvailable parameter when binding by url
calcu16 Dec 2, 2014
d676a50
Merge pull request #71 from calcu16/master
sungjuc Dec 2, 2014
8646852
Allowing nodes that are created to build their own partitions
calcu16 Dec 3, 2014
140de4c
Now builds
calcu16 Dec 3, 2014
efa899d
Merge pull request #72 from calcu16/master
sungjuc Dec 4, 2014
b7e0ae9
Bumping gradle.properties version number
calcu16 Dec 4, 2014
dcdb8f8
Merge pull request #73 from calcu16/master
calcu16 Dec 4, 2014
a96c3ee
Fixing a bug where we were not synchronizing on getting the name of t…
Dec 12, 2014
fea879c
Bumping up the version of gradle.properties
Dec 12, 2014
74213fd
Re-fixing the bug with an added test case.
Dec 15, 2014
699166b
Bumping up the version in gradle.properties
Dec 15, 2014
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
bin/
target/
lib_managed/
src_managed/
project/boot/
project/plugins/project
out/
build/
.idea/
.gradle
*.iml
*.ipr
*.iws
*.swp
328 changes: 201 additions & 127 deletions README.md

Large diffs are not rendered by default.

48 changes: 48 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
project.ext.isDefaultEnvironment = !project.hasProperty('overrideBuildEnvironment')

File getEnvironmentScript()
{
final File env = file(isDefaultEnvironment ? 'defaultEnvironment.gradle' : project.overrideBuildEnvironment)
assert env.isFile() : "The environment script [$env] does not exists or is not a file."
return env
}

apply from: environmentScript

def getScalaSuffix(scalaVersion) {
return scalaVersion.startsWith('2.10') ? '_2.10' : "_$scalaVersion"
}

subprojects {

// the cross built scala modules share the same source directories so we need to make their output directories unique
buildDir = "${rootProject.buildDir}/$name"

plugins.withType(JavaPlugin) {
project.dependencies {
testCompile externalDependency.junit
}
}

def projectScalaVersion = properties.targetScalaVersions.split(',').find { name.contains(getScalaSuffix(it)) }
ext.scalaVersion = projectScalaVersion ? projectScalaVersion : properties.defaultScalaVersion
ext.scalaSuffix = getScalaSuffix(ext.scalaVersion)

ext.externalDependency = [
'zookeeper':'org.apache.zookeeper:zookeeper:3.3.4',
'protobuf':'com.google.protobuf:protobuf-java:2.4.0a',
'log4j':'log4j:log4j:1.2.17',
'netty':'io.netty:netty:3.7.0.Final',
'slf4jApi':'org.slf4j:slf4j-api:1.7.5',
'slf4jLog4j':'org.slf4j:slf4j-log4j12:1.7.5',
'specs':"org.scala-tools.testing:specs${ext.scalaSuffix}:${ext.scalaSuffix == '_2.10' ? '1.6.9' : '1.6.8'}",
'mockitoAll':'org.mockito:mockito-all:1.8.4',
'cglib':'cglib:cglib:2.1_3',
'objenesis':'org.objenesis:objenesis:1.2',
'scalaCompiler': "org.scala-lang:scala-compiler:${ext.scalaVersion}",
'scalaLibrary': "org.scala-lang:scala-library:${ext.scalaVersion}",
'scalaActors': "org.scala-lang:scala-actors:${ext.scalaVersion}",
'junit':'junit:junit:4.8.1'
];

}
19 changes: 19 additions & 0 deletions cluster/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apply plugin: 'java'
apply plugin: 'scala'

dependencies {
compile externalDependency.scalaLibrary
compile externalDependency.zookeeper
compile externalDependency.protobuf
compile externalDependency.log4j
if (scalaVersion.startsWith('2.10')) {
compile externalDependency.scalaActors
}

testCompile externalDependency.specs
testCompile externalDependency.mockitoAll
testCompile externalDependency.cglib
testCompile externalDependency.objenesis
testCompile externalDependency.junit
}

Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import jmx.JMX.MBean
import jmx.JMX
import logging.Logging
import zookeeper.ZooKeeperClusterClient
import java.net.InetAddress

/**
* ClusterClient companion object provides factory methods for creating a <code>ClusterClient</code> instance.
Expand Down Expand Up @@ -115,6 +116,21 @@ trait ClusterClient extends Logging {
}
}

/**
* Returns the next node id that isn't taken
*
* @return the current list of nodes
* @throws ClusterDisconnectedException thrown if the cluster is not connected when the method is called
*/
def nextNodeId: Int = {
val ns = nodes
if (ns.size == 0) {
0
} else {
ns.map(_.id).max + 1
}
}

/**
* Looks up the node with the specified id.
*
Expand All @@ -125,6 +141,68 @@ trait ClusterClient extends Logging {
*/
def nodeWithId(nodeId: Int): Option[Node] = nodeWith(_.id == nodeId)

/**
* Looks up the node with with the specified port for the machine which is running this code.
*
* @param port the port of the current hostname of the node to find
*
* @return <code>Some</code> with the node if found, otherwise <code>None</code>
* @throws ClusterDisconnectedException thrown if the cluster is not connected when the method is called
*/
def myNodeByPort(port: Int): Option[Node] = {
val url = InetAddress.getLocalHost.getCanonicalHostName
val node = nodeByUrl(url, port)
if(node == None) {
log.warn("No node could be found for this machine's URL and port: %s:%d".format(url, port))
}
node
}

/**
* Looks up the node with with the specified url and port.
*
* @param hostname the hostname of the node to find
* @param port the id of the node to find
*
* @return <code>Some</code> with the node if found, otherwise <code>None</code>
* @throws ClusterDisconnectedException thrown if the cluster is not connected when the method is called
*/
def nodeByUrl(hostname:String, port:Int) = nodeWith(_.url == hostname + ":" + port)

/**
* Adds a node to the cluster metadata, picks an id above all other ids
*
* @param url the url to be used to send requests to the node
*
* @return the newly added node
* @throws ClusterDisconnectedException thrown if the cluster is disconnected when the method is called
* @throws InvalidNodeException thrown if there is an error adding the new node to the cluster metadata
*/
def addNodeByUrl(hostname: String, port:Int, partitionBuilder:Option[Int => Set[Int]] = None): Node = {
val url = hostname + ":" + port
var id = nextNodeId
var node: Node = null
val pbuilder = partitionBuilder match {
case Some(f) => f
case None => {_:Int => Set.empty[Int]}
}
while (node == null) {
try {
node = addNode(id, url, pbuilder(id))
} catch {
case _:InvalidNodeException =>
}
val nid = nextNodeId
if (nid == id) {
/* there was a problem with the id, try one last time and return that error */
node = addNode(id, url, pbuilder(id))
}
id = nid
}
node
}


/**
* Adds a node to the cluster metadata.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ trait ZooKeeperClusterManagerComponent extends ClusterManagerComponent {
//synchronization is not needed between this method
case class NodeChildrenChanged(path: String) extends ZooKeeperMessage
case class NodeDataChanged(path: String) extends ZooKeeperMessage
case class NodeDeleted(path: String) extends ZooKeeperMessage
case class NodeCreated(path: String) extends ZooKeeperMessage
}

class ZooKeeperClusterManager(connectString: String, sessionTimeout: Int, serviceName: String)
Expand Down Expand Up @@ -90,6 +92,19 @@ trait ZooKeeperClusterManagerComponent extends ClusterManagerComponent {
handleCapabilityMemberChanged(path)
}

case NodeDeleted(path) => if (path.equals(MEMBERSHIP_NODE) || path.equals(AVAILABILITY_NODE)) {
//zookeeper data corrupted
log.fatal("Received a zookeeper corruption message")
} else if (path.startsWith(MEMBERSHIP_NODE) || path.startsWith(AVAILABILITY_NODE)) {
log.info("Received an event where a node was deleted:%s".format(path))
} else {
log.error("Node deleted unexpectedly %s".format(path))
}

case NodeCreated(path) => {
log.error("Received an unexpected create event:%s".format(path))
}

case m => log.error("Received unknown message: %s".format(m))
}
}
Expand Down Expand Up @@ -461,6 +476,10 @@ trait ZooKeeperClusterManagerComponent extends ClusterManagerComponent {
case EventType.NodeChildrenChanged => zooKeeperManager ! NodeChildrenChanged(event.getPath)

case EventType.NodeDataChanged => zooKeeperManager ! NodeDataChanged(event.getPath)

case EventType.NodeCreated => zooKeeperManager ! NodeCreated(event.getPath)

case EventType.NodeDeleted => zooKeeperManager ! NodeDeleted(event.getPath)
}
}

Expand Down
Loading