From 3f7402ceff99c3cef3fde3f0dc603a5362b33034 Mon Sep 17 00:00:00 2001 From: Peter Vlugter Date: Sat, 19 Jun 2010 17:56:25 +1200 Subject: [PATCH] Removing unused stm classes --- .../src/main/scala/stm/ResultOrFailure.scala | 58 ---------- .../main/scala/stm/TransactionWatcher.scala | 105 ------------------ 2 files changed, 163 deletions(-) delete mode 100644 akka-core/src/main/scala/stm/ResultOrFailure.scala delete mode 100644 akka-core/src/main/scala/stm/TransactionWatcher.scala diff --git a/akka-core/src/main/scala/stm/ResultOrFailure.scala b/akka-core/src/main/scala/stm/ResultOrFailure.scala deleted file mode 100644 index 6ddf8c9751..0000000000 --- a/akka-core/src/main/scala/stm/ResultOrFailure.scala +++ /dev/null @@ -1,58 +0,0 @@ -/** - * Copyright (C) 2009-2010 Scalable Solutions AB - */ - -package se.scalablesolutions.akka.stm - -/** - * Reference that can hold either a typed value or an exception. - * - * Usage: - *
- * scala> ResultOrFailure(1)
- * res0: ResultOrFailure[Int] = ResultOrFailure@a96606
- *
- * scala> res0()
- * res1: Int = 1
- *
- * scala> res0() = 3
- *
- * scala> res0()
- * res3: Int = 3
- *
- * scala> res0() = { println("Hello world"); 3}
- * Hello world
- *
- * scala> res0()
- * res5: Int = 3
- *
- * scala> res0() = error("Lets see what happens here...")
- *
- * scala> res0()
- * java.lang.RuntimeException: Lets see what happens here...
- *      at ResultOrFailure.apply(RefExcept.scala:11)
- *      at .(:6)
- *      at .()
- *      at Re...
- * 
- * - * @author Jonas Bonér - */ -class ResultOrFailure[Payload](payload: Payload, val tx: Option[Transaction]) { - private[this] var contents: Either[Throwable, Payload] = Right(payload) - - def update(value: => Payload) = { - contents = try { Right(value) } catch { case (e : Throwable) => Left(e) } - } - - def apply() = contents match { - case Right(payload) => payload - case Left(e) => throw e - } - - override def toString(): String = "ResultOrFailure[" + contents + "]" -} -object ResultOrFailure { - def apply[Payload](payload: Payload, tx: Option[Transaction]) = new ResultOrFailure(payload, tx) - def apply[AnyRef](tx: Option[Transaction]) = new ResultOrFailure(new Object, tx) -} diff --git a/akka-core/src/main/scala/stm/TransactionWatcher.scala b/akka-core/src/main/scala/stm/TransactionWatcher.scala deleted file mode 100644 index 400bc9b763..0000000000 --- a/akka-core/src/main/scala/stm/TransactionWatcher.scala +++ /dev/null @@ -1,105 +0,0 @@ -/** - * Copyright (C) 2009-2010 Scalable Solutions AB - */ - -package se.scalablesolutions.akka.stm - -/* -import kernel.util.Logging -import org.apache.zookeeper.jmx.ManagedUtil -import org.apache.zookeeper.server.persistence.FileTxnSnapLog -import org.apache.zookeeper.server.{ServerConfig, NIOServerCnxn} -import org.apache.zookeeper.{KeeperException, WatchedEvent, Watcher, ZooKeeper, DataMonitor} -*/ -/** - * @author Jonas Bonér - * -class TransactionWatcher extends Logging with Watcher { - - val SERVER_URL = "localhost" - - val ZOO_KEEPER_URL = SERVER_URL - val ZOO_KEEPER_PORT = 2181 - val znode = "master" - - private[this] val db = new scala.collection.mutable.HashMap[String, String] - - private[this] val zk = new ZooKeeper(ZOO_KEEPER_URL + ":" + ZOO_KEEPER_PORT, 3000, this) - private[this] val dm = new DataMonitor(zk, znode, null, this) - - override def process(event: WatchedEvent) = { - log.debug("New ZooKeeper event: %s", event) - val path = event.getPath(); - if (event.getType == Event.EventType.None) { - // We are are being told that the state of the connection has changed - event.getState match { - case SyncConnected => - // In this particular example we don't need to do anything - // here - watches are automatically re-registered with - // server and any watches triggered while the client was - // disconnected will be delivered (in order of course) - case Expired => - dead = true - listener.closing(KeeperException.Code.SessionExpired) - } - } else { - if (path != null && path.equals(znode)) { - // Something has changed on the node, let's find out - zk.exists(znode, true, this, null) - } - } - if (chainedWatcher ne null) chainedWatcher.process(event); - } - - - - def run: Unit = synchronized { - try { - while (!dm.dead) wait - } catch { - case e: InterruptedException => Thread.currentThread.interrupt - } - } - - def closing(rc: Int): Unit = synchronized { notifyAll() } -} - - */ -object TransactionWatcher { - def main(args: Array[String]): Unit = { - println("Connecting to ZooKeeper...") - //new TransactionWatcher - } -} - - // private[akka] def startZooKeeper = { - // try { - // ManagedUtil.registerLog4jMBeans - // ServerConfig.parse(args) - // } catch { - // case e: JMException => log.warning("Unable to register log4j JMX control: s%", e) - // case e => log.fatal("Error in ZooKeeper config: s%", e) - // } - // val factory = new ZooKeeperServer.Factory() { - // override def createConnectionFactory = new NIOServerCnxn.Factory(ServerConfig.getClientPort) - // override def createServer = { - // val server = new ZooKeeperServer - // val txLog = new FileTxnSnapLog( - // new File(ServerConfig.getDataLogDir), - // new File(ServerConfig.getDataDir)) - // server.setTxnLogFactory(txLog) - // server - // } - // } - // try { - // val zooKeeper = factory.createServer - // zooKeeper.startup - // log.info("ZooKeeper started") - // // TODO: handle clean shutdown as below in separate thread - // // val cnxnFactory = serverFactory.createConnectionFactory - // // cnxnFactory.setZooKeeperServer(zooKeeper) - // // cnxnFactory.join - // // if (zooKeeper.isRunning) zooKeeper.shutdown - // } catch { case e => log.fatal("Unexpected exception: s%",e) } - // } -