Commit 01fa20f2 authored by Leonardo Menezes's avatar Leonardo Menezes
Browse files

Merge branch 'develop'

parents 1e6eb1bd e8587e51
Loading
Loading
Loading
Loading
+16 −1
Original line number Diff line number Diff line
@@ -37,6 +37,21 @@ It is also possible to avoid the creation of the RUNNING_PID file by setting the
```yaml
pidfile.path = "/dev/null"
```
### Using an alternate configuration file
It is possible to define an alternate configuration file(other than conf/application.conf). This can be achieved in two different ways:

#### -Dconfig.resource
This will pick the specified file from the classpath.
```
bin/cerebro -Dconfig.resource=alternate.conf 
```

#### -Dconfig.file
This will pick the specified file from a directory other than the apps dir.
```
bin/cerebro -Dconfig.fiel=/some/other/dir/alternate.conf 
```


### List of known hosts
A list of predefined hosts can be defined for quicker access by editing conf/application.conf file. If host is password protected, authentication should be also set.
+17 −0
Original line number Diff line number Diff line
package controllers

import models.analysis.{IndexAnalyzers, IndexFields, OpenIndices, Tokens}
import models.ElasticServer

import scala.concurrent.ExecutionContext.Implicits.global

class CatController extends BaseController {

  def get = process { (request, client) =>
    val api = request.get("api")
    client.catRequest(api, ElasticServer(request.host, request.authentication)).map { response =>
      Status(response.status)(response.body)
    }
  }

}
+11 −0
Original line number Diff line number Diff line
@@ -84,4 +84,15 @@ class ClusterOverviewController extends BaseController {
    }
  }

  def relocateShard = process { (request, client) =>
    val index = request.get("index")
    val shard = request.getInt("shard")
    val from = request.get("from")
    val to = request.get("to")
    val server = ElasticServer(request.host, request.authentication)
    client.relocateShard(shard, index, from, to, server).map { response =>
      Status(response.status)(response.body)
    }
  }

}
+26 −0
Original line number Diff line number Diff line
@@ -118,6 +118,26 @@ trait ElasticClient {
    execute(s"${target.host}$path", "GET", None, target.authentication)
  }

  def relocateShard(shard: Int, index: String, from: String, to: String, target: ElasticServer) = {
    val path = "/_cluster/reroute"
    val commands =
      s"""
         |{
         |  "commands": [
         |    {
         |      "move": {
         |        "shard": $shard,
         |        "index": \"$index\",
         |        "from_node": \"$from\",
         |        "to_node": \"$to\"
         |      }
         |    }
         |  ]
         |}
       """.stripMargin
    execute(s"${target.host}$path", "POST", Some(commands), target.authentication)
  }

  def getIndexRecovery(index: String, target: ElasticServer) = {
    val path = s"/$index/_recovery?active_only=true&human=true"
    execute(s"${target.host}$path", "GET", None, target.authentication)
@@ -261,6 +281,12 @@ trait ElasticClient {
    execute(s"${target.host}$path", "PUT", Some(settings.toString), target.authentication)
  }

  // Cat requests
  def catRequest(api: String, target: ElasticServer) = {
    val path = s"/_cat/$api"
    execute(s"${target.host}$path?format=json", "GET", None, target.authentication)
  }

  def executeRequest(method: String, path: String, data: Option[JsValue], target: ElasticServer) =
    execute(s"${target.host}/$path", method, data.map(_.toString), target.authentication)

+4 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ POST /overview/clear_indices_cache @controllers.ClusterOvervi
POST        /overview/refresh_indices                 @controllers.ClusterOverviewController.refreshIndex
POST        /overview/delete_indices                  @controllers.ClusterOverviewController.deleteIndex
POST        /overview/get_shard_stats                 @controllers.ClusterOverviewController.getShardStats
POST        /overview/relocate_shard                  @controllers.ClusterOverviewController.relocateShard

# Navbar module
POST        /navbar                                   @controllers.NavbarController.index
@@ -73,6 +74,9 @@ POST /snapshots/create @controllers.SnapshotsCont
POST        /snapshots/delete                         @controllers.SnapshotsController.delete
POST        /snapshots/restore                        @controllers.SnapshotsController.restore

# Cat module
POST        /cat                                      @controllers.CatController.get

# Map the JS resource paths
GET         /public/*file                             controllers.Assets.at(path="/public", file)
GET         /*file                                    controllers.Assets.versioned(path="/public", file: Asset)
Loading