This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2012-10-05 16:20:55,932 | ERROR | akka.actor.ActorSystemImpl | ult-dispatcher-1 | RemoteClientError@akka://CSLWorker@localhost:2000: Error[java.net.ConnectException:Connection refused: no further information | |
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method) | |
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:701) | |
at org.jboss.netty.channel.socket.nio.NioClientSocketPipelineSink$Boss.connect(NioClientSocketPipelineSink.java:404) | |
at org.jboss.netty.channel.socket.nio.NioClientSocketPipelineSink$Boss.processSelectedKeys(NioClientSocketPipelineSink.java:366) | |
at org.jboss.netty.channel.socket.nio.NioClientSocketPipelineSink$Boss.run(NioClientSocketPipelineSink.java:282) | |
at org.jboss.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:102) | |
at org.jboss.netty.util.internal.DeadLockProofWorker$1.run(DeadLockProofWorker.java:42) | |
at java.util.c |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2012-10-05 16:33:59,923 | ERROR | akka.actor.ActorSystemImpl | t-dispatcher-164 | RemoteServerError@akka://CSLServer@localhost:1997] Error[java.io.IOException:An existing connection was forcibly closed by the remote host | |
at sun.nio.ch.SocketDispatcher.read0(Native Method) | |
at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:43) | |
at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:218) | |
at sun.nio.ch.IOUtil.read(IOUtil.java:186) | |
at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:359) | |
at org.jboss.netty.channel.socket.nio.NioWorker.read(NioWorker.java:63) | |
at org.jboss.netty.channel.socket.nio.AbstractNioWorker.processSelectedKeys(AbstractNioWorker.java:385) | |
at org.jboss.netty.channel.socket.nio.AbstractNioWorker.run(AbstractNioWorker.java:256) | |
at org.jboss.netty.channel.socket.nio.NioWorker.run(NioWorker.java:35) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val isWindows = { | |
val osName = System.getProperty("os.name") | |
val isWin = osName.startsWith("Windows") | |
println("os.name=" + osName + " isWindows=" + isWin) | |
isWin | |
} | |
def currentJars: Array[String] = { | |
val classloader = ClassLoader.getSystemClassLoader |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def clusterStatus: ClusterStatus = { | |
val isLeader = leaderLatch.hasLeadership | |
val participants = leaderLatch.getParticipants.asScala | |
val leader = participants.find(_.isLeader).map(_.getId).getOrElse("<none>") | |
ClusterStatus(nodeId, isLeader, leader, participants.map(_.getId)) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def watchLeaderChildren() { | |
curatorFramework.getChildren.usingWatcher( | |
new CuratorWatcher { | |
def process(event: WatchedEvent) { | |
val cs = clusterStatus() | |
// Do something with cluster status (log leadership change, etc) | |
// Re-set watch | |
curatorFramework.getChildren.usingWatcher(this). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def selectLeader() { | |
leaderLatch = new LeaderLatch(curatorFramework, leaderPath, nodeId) | |
leaderLatch.start() | |
// Optional, only if you need notification on cluster changes | |
watchLeaderChildren() | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
startThread("leaderSelection") { | |
while (electingLeader) { | |
selectLeader() | |
electLoop.acquire() | |
if (electingLeader) log.info("Lost connection to Zookeeper - reselecting leader") | |
} | |
} | |
log.info("Waiting for leader to be selected") | |
leaderSelected.acquire() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (clientEnabled) { | |
startThread("leaderSelection") { | |
while (electingLeader) { | |
selectLeader() | |
electLoop.acquire() | |
if (electingLeader) log.info("Lost connection to Zookeeper - reselecting leader") | |
} | |
} | |
log.info("Waiting for leader to be selected") | |
leaderSelected.acquire() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// hosts is in the form host:port,host:port | |
@Value("${zookeeperService.hosts:localhost}") | |
@ManagedGetter @BeanProperty | |
var hosts: String = _ | |
val hostsArr = hosts.split(",") | |
val serversKeyArr = new Array[String](hostsArr.length) | |
val serversValArr = new Array[String](hostsArr.length) | |
for ((server, idx) <- hostsArr.zipWithIndex) { | |
val (host, port) = if (server.contains(":")) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def initialize() { | |
// Embedded server startup here (see part 2) | |
// ... | |
curatorFramework = | |
CuratorFrameworkFactory.newClient( | |
connectString, sessionTimeoutSec*1000, | |
connectionTimeoutSec*1000, new RetryOneTime(1)) | |
curatorFramework.start() |