<commit_before>/*
 * Copyright (C) 2012 <NAME>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package org.openmole.misc.replication

import com.thoughtworks.xstream.XStream
import java.io.File
import scala.io.Source
import scala.slick.driver.H2Driver.simple._

object DBServerInfo {
  val base = {
    val dir = Option(System.getenv("OPENMOLE_HOME")) match {
      case Some(path) ⇒ new File(path)
      case None       ⇒ new File(System.getProperty("user.home"), ".openmole")
    }
    dir.mkdirs
    dir
  }

  val dbName = "replica"
  val dbInfoName = "replica.info"
  val dbLock = "replica.lock"

  lazy val xstream = new XStream

  def load(f: File) = {
    val src = Source.fromFile(f)
    try xstream.fromXML(src.mkString).asInstanceOf[DBServerInfo]
    finally src.close
  }

  def dbLockFile = new File(base, dbLock)
  def dbFile = new File(base, dbName)
  def dbInfoFile = new File(base, dbInfoName)
  def urlDBPath = s"$dbName;MV_STORE=FALSE;MVCC=TRUE;"

}

case class DBServerInfo(port: Int, user: String, password: String)<commit_msg>Implent machine specific dbname to work on nfs shared fs.<commit_after>/*
 * Copyright (C) 2012 <NAME>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package org.openmole.misc.replication

import com.thoughtworks.xstream.XStream
import java.io.File
import scala.io.Source
import scala.slick.driver.H2Driver.simple._
import java.net._

import scala.util.Try

object DBServerInfo {
  val base = {
    val dir = Option(System.getenv("OPENMOLE_HOME")) match {
      case Some(path) ⇒ new File(path)
      case None       ⇒ new File(System.getProperty("user.home"), ".openmole")
    }
    dir.mkdirs
    dir
  }

  def hostName =
   Try { InetAddress.getLocalHost().getHostName() }.getOrElse("localhost")

  val dbName = s"replica-$hostName"
  val dbInfoName = s"$dbName.info"
  val dbLock = s"$dbName.lock"

  lazy val xstream = new XStream

  def load(f: File) = {
    val src = Source.fromFile(f)
    try xstream.fromXML(src.mkString).asInstanceOf[DBServerInfo]
    finally src.close
  }

  def dbLockFile = new File(base, dbLock)
  def dbFile = new File(base, dbName)
  def dbInfoFile = new File(base, dbInfoName)
  def urlDBPath = s"$dbName;MV_STORE=FALSE;MVCC=TRUE;"

}

case class DBServerInfo(port: Int, user: String, password: String)
{'fraction_non_alphanumeric': 0.09517004858531009, 'fraction_numerical': 0.003429551300371535, 'mean_word_length': 3.6728971962616823, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7397642', 'n_tokens_mistral': 1108, 'n_tokens_neox': 1096, 'n_words': 387}