Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add fossildb #2235

Merged
merged 22 commits into from Jan 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions conf/application.conf
Expand Up @@ -19,6 +19,10 @@ datastore {
uri = "localhost:9000"
secured = false
}
fossildb{
address = "localhost"
port = 7155
}
}

# Defining the listening address:
Expand Down
2 changes: 2 additions & 0 deletions docker-compose.yml
Expand Up @@ -53,6 +53,7 @@ services:
-Djava.net.preferIPv4Stack=true
-Dhttp.address=0.0.0.0
-Dhttp.port=$${PORT}
-Ddatastore.fossildb.address=fossildb-dev
-Dmongodb.uri=$${MONGO_URI}"
environment:
- PORT=9000
Expand All @@ -79,6 +80,7 @@ services:
-Djava.net.preferIPv4Stack=true
-Dhttp.address=0.0.0.0
-Dhttp.port=$${PORT}
-Ddatastore.fossildb.address=fossildb
-Dmongodb.uri=$${MONGO_URI}"
environment:
- MONGO_URI=mongodb://mongo:27017/webknossos-testing
Expand Down
6 changes: 4 additions & 2 deletions project/Dependencies.scala
Expand Up @@ -21,6 +21,8 @@ object Dependencies {
val commonsEmail = "org.apache.commons" % "commons-email" % "1.3.1"
val commonsIo = "commons-io" % "commons-io" % "2.4"
val commonsLang = "org.apache.commons" % "commons-lang3" % "3.1"
val grpc = "io.grpc" % "grpc-netty" % com.trueaccord.scalapb.compiler.Version.grpcJavaVersion
val grpcRuntime = "com.trueaccord.scalapb" %% "scalapb-runtime-grpc" % com.trueaccord.scalapb.compiler.Version.scalapbVersion
val liftBox = "net.liftweb" % "lift-common_2.10" % "2.6-M3"
val liftUtil = "net.liftweb" % "lift-util_2.10" % "3.0-M1"
val log4jApi = "org.apache.logging.log4j" % "log4j-core" % log4jVersion
Expand All @@ -30,7 +32,6 @@ object Dependencies {
val playFramework = "com.typesafe.play" %% "play" % playVersion
val reactiveBson = "org.reactivemongo" %% "reactivemongo-bson-macros" % reactiveVersion
val reactivePlay = "org.reactivemongo" %% "play2-reactivemongo" % reactivePlayVersion
val rocksDB = "org.rocksdb" % "rocksdbjni" % "5.1.2"
val scalaAsync = "org.scala-lang.modules" %% "scala-async" % "0.9.2"
val scalaLogging = "com.typesafe.scala-logging" %% "scala-logging" % "3.4.0"
val scalapbJson = "com.scalableminds" %% "scalapb-json4s" % "0.3.2.0-scm"
Expand Down Expand Up @@ -65,8 +66,9 @@ object Dependencies {
cache,
newrelic,
newrelicApi,
rocksDB,
webknossosWrap,
grpc,
grpcRuntime,
component("play-test")
)

Expand Down
4 changes: 2 additions & 2 deletions project/plugins.sbt
Expand Up @@ -11,6 +11,6 @@ addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.7.0")

addSbtPlugin("com.frugalmechanic" % "fm-sbt-s3-resolver" % "0.9.0")

addSbtPlugin("com.thesamet" % "sbt-protoc" % "0.99.11")
addSbtPlugin("com.thesamet" % "sbt-protoc" % "0.99.12")

libraryDependencies += "com.trueaccord.scalapb" %% "compilerplugin" % "0.6.2"
libraryDependencies += "com.trueaccord.scalapb" %% "compilerplugin" % "0.6.6"

This file was deleted.

This file was deleted.

This file was deleted.

Expand Up @@ -5,35 +5,11 @@ package com.scalableminds.webknossos.datastore.controllers

import javax.inject.Inject

import com.scalableminds.webknossos.datastore.services.{AccessTokenService, UserAccessRequest}
import com.scalableminds.webknossos.datastore.tracings.TracingDataStore
import play.api.Configuration
import play.api.i18n.MessagesApi
import play.api.libs.json.Json
import play.api.mvc.Action

class Application @Inject()(
store: TracingDataStore,
config: Configuration,
val accessTokenService: AccessTokenService,
val messagesApi: MessagesApi
) extends TokenSecuredController {
class Application @Inject()(val messagesApi: MessagesApi) extends Controller {

def health = Action {
implicit request =>
// This is a simple health endpoint that will always return 200 if the server is correctly running
// we might do some more advanced checks of the server in the future
Ok
}
def health = Action { implicit request => Ok }

def backup = TokenSecuredAction(UserAccessRequest.webknossos) {
implicit request =>
val start = System.currentTimeMillis()
logger.info(s"Starting tracing data backup")
store.backup.map { backupInfo =>
val duration = System.currentTimeMillis() - start
logger.info(s"Finished tracing data backup after $duration ms")
Ok(Json.toJson(backupInfo))
}
}
}
Expand Up @@ -6,14 +6,13 @@ package com.scalableminds.webknossos.datastore.controllers
import java.io.FileInputStream

import com.google.protobuf.CodedInputStream
import com.scalableminds.webknossos.datastore.services.{AccessTokenService, UserAccessAnswer, UserAccessRequest}
import com.scalableminds.util.mvc.ExtendedController
import com.scalableminds.util.tools.Fox
import com.scalableminds.webknossos.datastore.services.{AccessTokenService, UserAccessAnswer, UserAccessRequest}
import com.trueaccord.scalapb.{GeneratedMessage, GeneratedMessageCompanion, Message}
import com.typesafe.scalalogging.LazyLogging
import net.liftweb.common.Box
import net.liftweb.util.Helpers.tryo
import play.api.Play
import play.api.libs.concurrent.Execution.Implicits._
import play.api.libs.json.{JsError, Reads}
import play.api.mvc.Results.BadRequest
Expand All @@ -34,13 +33,7 @@ trait TokenSecuredController extends Controller {

case class TokenSecuredAction(accessRequest: UserAccessRequest) extends ActionBuilder[Request] {

val debugModeEnabled = Play.current.configuration.getBoolean("datastore.debugMode").getOrElse(false)

private def hasUserAccess[A](implicit request: Request[A]): Fox[UserAccessAnswer] = {
// TODO RocksDB if (debugModeEnabled && Play.mode(Play.current) != Mode.Prod) {
// return Future.successful(true)
//}

request.getQueryString("token").map { token =>
accessTokenService.hasUserAccess(token, accessRequest)
}.getOrElse(Fox.successful(UserAccessAnswer(false, Some("No access token."))))
Expand Down