Skip to content

Commit

Permalink
Merge pull request #505 from mesos/refactor/402-DependenciesUpdate
Browse files Browse the repository at this point in the history
Refactor/402 dependencies update. Looks good and also works for me
  • Loading branch information
sadovnikov committed Feb 22, 2016
2 parents c29c898 + 1065aef commit 9805c4c
Show file tree
Hide file tree
Showing 8 changed files with 120 additions and 78 deletions.
34 changes: 30 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,38 @@ import org.ajoberstar.grgit.Grgit
import org.ajoberstar.grgit.Tag

ext {
mesosVer = "0.25.0"
awaitilityVersion = "1.7.0"
commonsCollectionsVersion = "4.1"
commonsExecVersion = "1.3"
commonsIOVersion = "2.4"
commonsLangVersion = "3.4"
commonsValidatorVersion = "1.5.0"
dockerJavaVersion = "1.4.0"
elasticsearchVersion="2.2.0"
gradleDownloadTaskVersion = "2.1.0"
hamcrestVersion = "1.3"
httpClientVersion = "4.5.1"
imagePrefix = 'mesos'
springBootVersion = "1.2.5.RELEASE"
jcommanderVersion = "1.48"
jodaTimeVersion = "2.9.2"
jsonVersion = "20160212"
junitVersion = "4.12"
log4jVersion = "1.2.17"
mesosVer = "0.25.0"
minimesosVersion = "429943bff3e8af1328acf4c8d487fc63d2e19a48"
springBootVersion = "1.2.5.RELEASE" // Bumping SB version causes Jackson incompatabilities with Docker-Java
unirestVersion = "1.4.8"

webAngularBootstrapVersion = "1.1.2"
webAngularMomentVersion = "0.10.3"
webAngularVersion = "1.5.0"
webBootstrapVersion = "3.3.6"
webFontAwesomeVersion = "4.5.0"
webHighChartsNgVersion = "0.0.11"
webHighChartsVersion = "4.1.5"
webJsonFormatterVersion = "0.4.2"
webMomentJsVersion = "2.11.1"
webRdashUiVersion = "1.0.1"
}

allprojects {
Expand Down Expand Up @@ -99,7 +127,6 @@ subprojects {
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
}

apply plugin: 'maven-publish'
apply plugin: 'sonar-runner'
apply plugin: 'java'
apply plugin: 'jacoco'
Expand Down Expand Up @@ -196,7 +223,6 @@ subprojects {
}
}
}
project.publish.dependsOn "publishDockerImageWith$uppercasedName"
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions commons/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ task taskCopyFilesForDocker(type: Copy) {


dependencies {
compile "com.beust:jcommander:1.48"
compile "log4j:log4j:1.2.16"
compile "org.apache.commons:commons-exec:1.3"
compile "org.apache.commons:commons-lang3:3.4"
compile "org.json:json:20151123"
compile "com.beust:jcommander:${jcommanderVersion}"
compile "log4j:log4j:${log4jVersion}"
compile "org.apache.commons:commons-exec:${commonsExecVersion}"
compile "org.apache.commons:commons-lang3:${commonsLangVersion}"
compile "org.json:json:${jsonVersion}"

testCompile "commons-validator:commons-validator:1.5.0"
testCompile "commons-validator:commons-validator:${commonsValidatorVersion}"
}
100 changes: 56 additions & 44 deletions scheduler/build.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
apply plugin: 'application'
apply plugin: 'spring-boot'
apply plugin: "application"
apply plugin: "spring-boot"

mainClassName = "org.apache.mesos.elasticsearch.scheduler.Main"
ext {
imageName = imagePrefix + '/elasticsearch-scheduler'
imageName = imagePrefix + "/elasticsearch-scheduler"
}

buildscript {
Expand All @@ -12,7 +12,7 @@ buildscript {
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
classpath 'de.undercouch:gradle-download-task:2.1.0'
classpath "de.undercouch:gradle-download-task:${gradleDownloadTaskVersion}"
}
}
repositories {
Expand All @@ -25,55 +25,60 @@ configurations {
}
dependencies {

compile project(':commons')
compile project(":commons")

compile("org.springframework.boot:spring-boot-starter-web:${springBootVersion}")
compile("org.springframework.boot:spring-boot-starter-log4j:${springBootVersion}")
compile "commons-io:commons-io:2.4"
compile 'org.apache.commons:commons-collections4:4.0'
compile 'commons-lang:commons-lang:2.6'
compile "log4j:log4j:1.2.17"
compile 'org.apache.httpcomponents:httpclient:4.5'
compile "com.beust:jcommander:1.48"

compile 'org.webjars:angularjs:1.4.1'
compile 'org.webjars.bower:angular-route:1.4.1'
compile 'org.webjars.bower:angular-resource:1.4.1'
compile 'org.webjars.bower:angular-bootstrap:0.13.0'
compile 'org.webjars:bootstrap:3.3.5'
compile 'org.webjars:font-awesome:4.3.0'
compile 'org.webjars.bower:rdash-ui:1.0.1'
compile 'org.webjars:momentjs:2.10.3'
compile 'org.webjars:angular-moment:0.10.1'
compile 'org.webjars.bower:json-formatter:0.2.7'
compile 'org.webjars.bower:hightcharts:4.1.5'
compile "org.webjars.bower:highcharts-ng:0.0.8"
compile 'com.jayway.awaitility:awaitility:1.6.3'
compile 'com.mashape.unirest:unirest-java:1.4.5'
compile "commons-io:commons-io:${commonsIOVersion}"
compile "org.apache.commons:commons-collections4:${commonsCollectionsVersion}"
compile "org.apache.commons:commons-lang3:${commonsLangVersion}"
compile "log4j:log4j:${log4jVersion}"
compile "org.apache.httpcomponents:httpclient:${httpClientVersion}"
compile "com.beust:jcommander:${jcommanderVersion}"
compile "com.jayway.awaitility:awaitility:${awaitilityVersion}"
compile "com.mashape.unirest:unirest-java:${unirestVersion}"

compile "org.webjars:angularjs:${webAngularVersion}"
compile "org.webjars.bower:angular-route:${webAngularVersion}"
compile "org.webjars.bower:angular-resource:${webAngularVersion}"
compile "org.webjars.bower:angular-bootstrap:${webAngularBootstrapVersion}"
compile "org.webjars:bootstrap:${webBootstrapVersion}"
compile "org.webjars:font-awesome:${webFontAwesomeVersion}"
compile "org.webjars.bower:rdash-ui:${webRdashUiVersion}"
compile "org.webjars:momentjs:${webMomentJsVersion}"
compile "org.webjars:angular-moment:${webAngularMomentVersion}"
compile "org.webjars.bower:json-formatter:${webJsonFormatterVersion}"
compile "org.webjars.bower:hightcharts:${webHighChartsVersion}"
compile "org.webjars.bower:highcharts-ng:${webHighChartsNgVersion}"


testCompile("org.springframework.boot:spring-boot-starter-test:${springBootVersion}")
testCompile 'org.hamcrest:hamcrest-core:1.3'
testCompile 'joda-time:joda-time:2.3'
testCompile 'com.mashape.unirest:unirest-java:1.4.5'
testCompile "org.hamcrest:hamcrest-core:${hamcrestVersion}"
testCompile "joda-time:joda-time:${jodaTimeVersion}"
testCompile "com.mashape.unirest:unirest-java:${unirestVersion}"

}

jar {
dependsOn 'getElasticsearchTarball'
dependsOn "getElasticsearchTarball", "packageDependencies"
baseName = "elasticsearch-mesos-scheduler"
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } } // Include dependencies
from files("build/internalClasses")
manifest {
attributes(
'Main-Class' : mainClassName,
'Implementation-Version' : project.version
"Main-Class": mainClassName,
"Implementation-Version": project.version
)
}
}

publishing {
publications {
mavenJava(MavenPublication) {
from components.java
task packageDependencies {
dependsOn "classes"
inputs.files configurations.compile
outputs.dir "build/internalClasses"
doLast {
copy {
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } } // Include dependencies
into "build/internalClasses"
}
}
}
Expand All @@ -89,22 +94,29 @@ task taskCopyFilesForDocker(type: Copy) {
}

task copyJar(type: Copy) {
dependsOn 'bootRepackage'
from "build/libs/elasticsearch-mesos-scheduler-${project.version}.jar"
into 'build/docker'
dependsOn "bootRepackage"
from "build/libs/elasticsearch-mesos-scheduler-${project.version}-withDependencies.jar"
into "build/docker"
rename { String fileName ->
fileName.replace("-${project.version}", "")
fileName.replace("-${project.version}-withDependencies", "")
}
}

task copyShellScript(type: Copy) {
from "start-scheduler.sh"
into 'build/docker'
into "build/docker"
}

import de.undercouch.gradle.tasks.download.Download
task getElasticsearchTarball(type: Download) {
src "https://download.elasticsearch.org/elasticsearch/release/org/elasticsearch/distribution/tar/elasticsearch/" + "$elasticsearchVersion" + "/elasticsearch-" + "$elasticsearchVersion" + ".tar.gz"
dest new File(buildDir, './resources/main/public/elasticsearch.tar.gz')
dest new File(buildDir, "./resources/main/public/elasticsearch.tar.gz")
onlyIfNewer true
}
}

distTar.enabled = false
distZip.enabled = false

bootRepackage {
classifier = "withDependencies"
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.apache.mesos.elasticsearch.scheduler;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import org.apache.mesos.Protos;
import org.apache.mesos.elasticsearch.scheduler.state.FrameworkState;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.apache.mesos.elasticsearch.scheduler.controllers;

import org.apache.commons.lang.math.RandomUtils;
import org.apache.commons.lang3.RandomUtils;
import org.apache.http.HttpHost;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
Expand All @@ -9,7 +9,8 @@
import org.apache.mesos.elasticsearch.scheduler.Task;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.InputStreamResource;
import org.springframework.http.*;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
Expand Down Expand Up @@ -37,7 +38,7 @@ public class SearchProxyController {
public ResponseEntity<InputStreamResource> stats() throws IOException {
Collection<Task> tasks = scheduler.getTasks().values();
Stream<HttpHost> httpHostStream = tasks.stream().map(task -> toHttpHost(task.getClientAddress()));
HttpHost httpHost = httpHostStream.skip(RandomUtils.nextInt(tasks.size())).findAny().get();
HttpHost httpHost = httpHostStream.skip(RandomUtils.nextInt(0, tasks.size())).findAny().get();

HttpResponse esSearchResponse = httpClient.execute(httpHost, new HttpGet("/_cluster/stats"));
InputStreamResource inputStreamResource = new InputStreamResource(esSearchResponse.getEntity().getContent());
Expand All @@ -58,7 +59,7 @@ public ResponseEntity<InputStreamResource> search(@RequestParam("q") String quer
if (elasticSearchHost != null) {
httpHost = httpHostStream.filter(host -> host.toHostString().equalsIgnoreCase(elasticSearchHost)).findAny().get();
} else {
httpHost = httpHostStream.skip(RandomUtils.nextInt(tasks.size())).findAny().get();
httpHost = httpHostStream.skip(RandomUtils.nextInt(0, tasks.size())).findAny().get();
}

HttpResponse esSearchResponse = httpClient.execute(httpHost, new HttpGet("/_search?q=" + URLEncoder.encode(query, "UTF-8")));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,21 @@ public void testSetValid() throws IOException {
verify(state, times(1)).store(any(Variable.class));
}

@SuppressWarnings("unchecked")
@Test(expected = IOException.class)
public void interrupted() throws IOException {
when(state.store(any(Variable.class))).thenThrow(InterruptedException.class);
serializableState.set("test", "Serializable object");
}

@SuppressWarnings("unchecked")
@Test(expected = IOException.class)
public void executionException() throws IOException {
when(state.store(any(Variable.class))).thenThrow(ExecutionException.class);
serializableState.set("test", "Serializable object");
}

@SuppressWarnings("unchecked")
@Test(expected = IOException.class)
public void ioException() throws IOException {
when(state.store(any(Variable.class))).thenThrow(IOException.class);
Expand Down
36 changes: 18 additions & 18 deletions system-test/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apply plugin: 'java'
apply plugin: "java"

repositories {
maven {
Expand All @@ -8,29 +8,29 @@ repositories {

sourceSets {
systemTest {
java.srcDir file('src/main/java')
java.srcDir file('src/systemTest/java')
resources.srcDir file('src/systemTest/resources')
java.srcDir file("src/main/java")
java.srcDir file("src/systemTest/java")
resources.srcDir file("src/systemTest/resources")
}
}

dependencies {

compile project(':scheduler')
compile 'com.github.docker-java:docker-java:1.3.0'
compile 'com.mashape.unirest:unirest-java:1.4.5'
compile 'com.jayway.awaitility:awaitility:1.6.3'
compile 'com.github.ContainerSolutions:minimesos:429943bff3e8af1328acf4c8d487fc63d2e19a48'
compile project(":scheduler")
compile "com.github.docker-java:docker-java:${dockerJavaVersion}"
compile "com.mashape.unirest:unirest-java:${unirestVersion}"
compile "com.jayway.awaitility:awaitility:${awaitilityVersion}"
compile "com.github.ContainerSolutions:minimesos:${minimesosVersion}"

systemTestCompile project(':scheduler')
systemTestCompile 'junit:junit:4.12'
systemTestCompile 'com.github.docker-java:docker-java:1.3.0'
systemTestCompile 'com.mashape.unirest:unirest-java:1.4.5'
systemTestCompile 'com.jayway.awaitility:awaitility:1.6.3'
systemTestCompile 'com.github.ContainerSolutions:minimesos:429943bff3e8af1328acf4c8d487fc63d2e19a48'
systemTestCompile project(":scheduler")
systemTestCompile "junit:junit:${junitVersion}"
systemTestCompile "com.github.docker-java:docker-java:${dockerJavaVersion}"
systemTestCompile "com.mashape.unirest:unirest-java:${unirestVersion}"
systemTestCompile "com.jayway.awaitility:awaitility:${awaitilityVersion}"
systemTestCompile "com.github.ContainerSolutions:minimesos:${minimesosVersion}"
}

task main(type:JavaExec, dependsOn: 'compileJava') {
task main(type: JavaExec, dependsOn: "compileJava") {
main = "org.apache.mesos.elasticsearch.systemtest.Main"
classpath = sourceSets.main.runtimeClasspath
}
Expand All @@ -43,7 +43,7 @@ task systemTest(type: Test) {
dependsOn processTestResources // Copy files to resources
testClassesDir = sourceSets.systemTest.output.classesDir
classpath = sourceSets.systemTest.runtimeClasspath
include '**/*SystemTest*'
include "**/*SystemTest*"
testLogging {
showStandardStreams = true
}
Expand All @@ -58,6 +58,6 @@ task copyTestResources(type: Copy) {
processTestResources.dependsOn copyTestResources

findbugsSystemTest {
excludeFilter file('config/findbugs/excludeFilter.xml')
excludeFilter file("config/findbugs/excludeFilter.xml")
}

Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public void shouldCluster() throws IOException, InterruptedException, UnirestExc
public void shouldHaveCustomSettingsBasedOnPath() throws UnirestException {
final JSONObject root = Unirest.get("http://" + esTasks.getEsHttpAddressList().get(0) + "/_nodes").asJson().getBody().getObject();
final JSONObject nodes = root.getJSONObject("nodes");
final String firstNode = nodes.keys().next();
final String firstNode = nodes.keys().next().toString();

// Test a setting that is not specified by the framework (to test that it is written correctly)
final String pathPlugins = nodes.getJSONObject(firstNode).getJSONObject("settings").getJSONObject("path").getString("plugins");
Expand Down

0 comments on commit 9805c4c

Please sign in to comment.