-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* [#156] Share ActorSystem between Scassandra instances. * [#158] Use akka-slf4j to allow logging configuration via slf4j. Also reduce logging on server tests, remove application.conf * Speed up tests by closing Cluster instances quickly. Each test method was delayed in completion for 2 seconds due to the default graceful shutdown wait nature of netty. Since there should be no ongoing activity on the event loop when our tests finish, it is safe to close. * Cache dependencies downloaded via gradle. * Make tests more resilient by bumping timeouts. * Process review feedback. - Add endline to ScassandraServer.scala. - Use Future.sequence instead of for comprehension. - Lower timeouts in tests. - Rename ConnectionsClientBuilder to CurrentClientBuilder to match CurrentClient.
- Loading branch information
Showing
21 changed files
with
248 additions
and
1,439 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
92 changes: 92 additions & 0 deletions
92
server/src/main/scala/org/scassandra/server/ScassandraServer.scala
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
/* | ||
* Copyright (C) 2014 Christopher Batey and Dogan Narinc | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.scassandra.server | ||
|
||
import akka.actor.{PoisonPill, Props, Actor, ActorRef} | ||
import akka.pattern.{ask, pipe} | ||
import akka.util.Timeout | ||
import com.typesafe.scalalogging.LazyLogging | ||
import org.scassandra.server.actors.TcpServer | ||
import org.scassandra.server.priming.{PrimingServer, ActivityLog} | ||
import org.scassandra.server.priming.batch.PrimeBatchStore | ||
import org.scassandra.server.priming.prepared.{CompositePreparedPrimeStore, PrimePreparedMultiStore, PrimePreparedPatternStore, PrimePreparedStore} | ||
import org.scassandra.server.priming.query.PrimeQueryStore | ||
|
||
import scala.concurrent.Future | ||
import scala.util.{Failure, Success, Try} | ||
|
||
/** | ||
* Used to wait on startup of listening http and tcp interfaces. | ||
* @param timeout Up to how long to wait for startup before timing out. | ||
*/ | ||
case class AwaitStartup(timeout: Timeout) | ||
|
||
/** | ||
* Used to shutdown the server by first unbinding the priming and tcp server listeners | ||
* and then sending a {@link PoisonPill} to itself. | ||
* @param timeout Up to how long to wait for shutdown before timing out. | ||
*/ | ||
case class ShutdownServer(timeout: Timeout) | ||
|
||
/** | ||
* Sent to {@link PrimingServer} and {@link TcpServer} instances to indicate that they should | ||
* unbind their listeners and then subsequently shutdown. | ||
*/ | ||
case object Shutdown | ||
|
||
class ScassandraServer(val primedResults: PrimeQueryStore, val binaryListenAddress: String, val binaryPortNumber: Int, val adminListenAddress: String, val adminPortNumber: Int) extends Actor with LazyLogging { | ||
|
||
val primePreparedStore = new PrimePreparedStore | ||
val primePreparedPatternStore = new PrimePreparedPatternStore | ||
val primePreparedMultiStore = new PrimePreparedMultiStore | ||
val primeBatchStore = new PrimeBatchStore | ||
val activityLog = new ActivityLog | ||
val preparedLookup = new CompositePreparedPrimeStore(primePreparedStore, primePreparedPatternStore, primePreparedMultiStore) | ||
val primingReadyListener = context.actorOf(Props(classOf[ServerReadyListener]), "PrimingReadyListener") | ||
val tcpReadyListener = context.actorOf(Props(classOf[ServerReadyListener]), "TcpReadyListener") | ||
val tcpServer = context.actorOf(Props(classOf[TcpServer], binaryListenAddress, binaryPortNumber, primedResults, preparedLookup, primeBatchStore, tcpReadyListener, activityLog), "BinaryTcpListener") | ||
val primingServer = context.actorOf(Props(classOf[PrimingServer], adminListenAddress, adminPortNumber, primedResults, primePreparedStore, | ||
primePreparedPatternStore, primePreparedMultiStore, primeBatchStore, primingReadyListener, activityLog, tcpServer), "PrimingServer") | ||
|
||
override def receive: Receive = { | ||
case AwaitStartup(timeout) => { | ||
implicit val t: Timeout = timeout | ||
import context.dispatcher | ||
|
||
// Create a future that completes when both listeners ready. | ||
val f = Future.sequence( | ||
primingReadyListener ? OnServerReady :: | ||
tcpReadyListener ? OnServerReady :: | ||
Nil | ||
) | ||
|
||
f pipeTo sender | ||
} | ||
case ShutdownServer(timeout) => { | ||
implicit val t: Timeout = timeout | ||
import context.dispatcher | ||
|
||
// Send shutdown message to each sender and on complete send a PoisonPill to self. | ||
val f = Future.sequence( | ||
primingServer ? Shutdown :: | ||
tcpServer ? Shutdown :: | ||
Nil | ||
).map { _ => self ? PoisonPill } | ||
|
||
f pipeTo sender | ||
} | ||
} | ||
} |
42 changes: 0 additions & 42 deletions
42
server/src/main/scala/org/scassandra/server/ServerReadyAwaiter.scala
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.