-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Suman BN
committed
Nov 4, 2016
1 parent
8a8a5f5
commit bc0bc9d
Showing
15 changed files
with
1,230 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#Copyright 2016 ANI Technologies Pvt. Ltd. | ||
# | ||
#Licensed under the Apache License, Version 2.0 (the "License"); | ||
#you may not use this file except in compliance with the License. | ||
#You may obtain a copy of the License at | ||
# | ||
#http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
#Unless required by applicable law or agreed to in writing, software | ||
#distributed under the License is distributed on an "AS IS" BASIS, | ||
#WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
#See the License for the specific language governing permissions and | ||
#limitations under the License. | ||
|
||
FROM ubuntu:14.04 | ||
MAINTAINER [email protected] | ||
|
||
RUN apt-get update --fix-missing \ | ||
&& apt-get install -y --no-install-recommends software-properties-common \ | ||
&& add-apt-repository ppa:webupd8team/java \ | ||
&& gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 \ | ||
&& apt-get update \ | ||
&& echo debconf shared/accepted-oracle-license-v1-1 select true | debconf-set-selections \ | ||
&& echo debconf shared/accepted-oracle-license-v1-1 seen true | debconf-set-selections \ | ||
&& apt-get install -y --no-install-recommends oracle-java8-installer \ | ||
&& apt-get clean \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
EXPOSE 17000 | ||
|
||
VOLUME /var/log/fabric-manager | ||
|
||
COPY target/fabric-manager*.jar fabric-manager.jar | ||
COPY target/classes/docker-compose-config.yml docker-compose-config.yml | ||
|
||
CMD sh -c "sleep 20 ; java -jar -Xms${JAVA_PROCESS_MIN_HEAP} -Xmx${JAVA_PROCESS_MAX_HEAP} -XX:+${GC_ALGO} -Dfile.encoding=utf-8 fabric-manager.jar server ${CONFIG_ENV}-config.yml" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
#Copyright 2016 ANI Technologies Pvt. Ltd. | ||
# | ||
#Licensed under the Apache License, Version 2.0 (the "License"); | ||
#you may not use this file except in compliance with the License. | ||
#You may obtain a copy of the License at | ||
# | ||
#http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
#Unless required by applicable law or agreed to in writing, software | ||
#distributed under the License is distributed on an "AS IS" BASIS, | ||
#WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
#See the License for the specific language governing permissions and | ||
#limitations under the License. | ||
|
||
# Zookeeper compose | ||
zookeeper: | ||
image: garland/zookeeper | ||
ports: | ||
- "2181:2181" | ||
- "2888:2888" | ||
- "3888:3888" | ||
|
||
# MySQL compose | ||
mysql: | ||
image: mysql/mysql-server:latest | ||
environment: | ||
- MYSQL_ROOT_PASSWORD=password | ||
- MYSQL_DATABASE=fabric_manager | ||
ports: | ||
- "3306:3306" | ||
|
||
# Artifactory compose | ||
artifactory: | ||
image: mattgruter/artifactory | ||
ports: | ||
- "8080:8080" | ||
|
||
# OpenTSDB compose | ||
opentsdb: | ||
image: petergrace/opentsdb-docker:latest | ||
ports: | ||
- "4242:4242" | ||
- "60030:60030" | ||
|
||
# Fabric-Manager compose | ||
fabricmanager: | ||
build: . | ||
ports: | ||
- "18000:18000" | ||
volumes: | ||
- /var/log/fabricmanager | ||
# link to zk, artifact, es | ||
links: | ||
- zookeeper | ||
- mysql | ||
- artifactory | ||
- opentsdb | ||
# enviroment valiables | ||
environment: | ||
- FABRIC_MANAGER_CONNECTION_STRING=_fabric-manager._tcp.marathon.mesos. | ||
- ARTIFACTORY_URL=http://artifactory:8080/artifactory | ||
- MARATHON_ENDPOINT=http://localhost:8080/ | ||
- MIN_CPU=0.5 | ||
- MIN_MEMORY=512 | ||
- ALPHA=0.5 | ||
- EXECUTOR_DOCKER_IMAGE=localhost:9002/fabric-executor:0.0.1 | ||
- METRICS_ENABLED=false | ||
- OPENTSDB_URL=opentsdb:4242 | ||
- OPENTSDB_APP_NAME=fabric-manager | ||
- OPENTSDB_NAMESPACE=fabric | ||
- OPENTSDB_PLATFORM=fabric | ||
- OPENTSDB_PERIOD_IN_SEC=30 | ||
- ZK_CONNECTION_STRING=zookeeper:2181 | ||
- SERVICE_NAME=fabric-manager | ||
- SERVICE_NAMESPACE=fabric | ||
- SERVICE_ENV=dcos | ||
- HOST=192.168.99.100 | ||
- PORT_18000=18000 | ||
- LOG_LEVEL=INFO | ||
- HIBERNATE_LOG_LEVEL=ERROR | ||
- DB_USER=root | ||
- DB_PASSWORD=password | ||
- DB_URL=jdbc:mysql://mysql:3306/fabric_manager?autoReconnect=true | ||
- DB_MAX_WAIT_FOR_CONNECTION=1s | ||
- DB_MIN_SIZE=8 | ||
- DB_MAX_SIZE=32 | ||
- DB_CHECK_CONNECTION_WHILE_IDLE=false | ||
- DB_AUTO_EXPORT_DDL_TO_DATABASE=update | ||
- DB_SHOW_SQL=false | ||
- GC_ALGO=UseG1GC | ||
- JAVA_PROCESS_MIN_HEAP=1g | ||
- JAVA_PROCESS_MAX_HEAP=1g | ||
- CONFIG_ENV=docker-compose |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
...c-manager/src/main/java/com/olacabs/fabric/manager/converter/ExecutorConfigConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* Copyright 2016 ANI Technologies Pvt. Ltd. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.olacabs.fabric.manager.converter; | ||
|
||
import com.fasterxml.jackson.core.JsonProcessingException; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.olacabs.fabric.manager.bean.ExecutorConfig; | ||
import com.olacabs.fabric.manager.exception.FabricManagerException; | ||
import lombok.extern.slf4j.Slf4j; | ||
|
||
import javax.persistence.AttributeConverter; | ||
import javax.persistence.Converter; | ||
import java.io.IOException; | ||
|
||
/** | ||
* Executor config converter . | ||
*/ | ||
@Converter | ||
@Slf4j | ||
public class ExecutorConfigConverter implements AttributeConverter<ExecutorConfig, String> { | ||
|
||
private final ObjectMapper mapper; | ||
|
||
public ExecutorConfigConverter() { | ||
this(new ObjectMapper()); | ||
} | ||
|
||
public ExecutorConfigConverter(final ObjectMapper mapper) { | ||
this.mapper = mapper; | ||
} | ||
|
||
@Override | ||
public String convertToDatabaseColumn(final ExecutorConfig object) { | ||
try { | ||
return mapper.writeValueAsString(object); | ||
} catch (final JsonProcessingException e) { | ||
log.error("Unable to parse component source - {}", e.getMessage(), e); | ||
throw new FabricManagerException(e); | ||
} | ||
} | ||
|
||
@Override | ||
public ExecutorConfig convertToEntityAttribute(final String source) { | ||
try { | ||
return mapper.readValue(source, ExecutorConfig.class); | ||
} catch (final IOException e) { | ||
log.error("Unable to parse ExecutorConfig source - {}", e.getMessage(), e); | ||
throw new FabricManagerException(e); | ||
} | ||
} | ||
} |
65 changes: 65 additions & 0 deletions
65
...c-manager/src/main/java/com/olacabs/fabric/manager/converter/RuntimeOptionsConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* Copyright 2016 ANI Technologies Pvt. Ltd. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.olacabs.fabric.manager.converter; | ||
|
||
import com.fasterxml.jackson.core.JsonProcessingException; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.olacabs.fabric.manager.bean.RuntimeOptions; | ||
import com.olacabs.fabric.manager.exception.FabricManagerException; | ||
import lombok.extern.slf4j.Slf4j; | ||
|
||
import javax.persistence.AttributeConverter; | ||
import javax.persistence.Converter; | ||
import java.io.IOException; | ||
|
||
/** | ||
* Todo . | ||
*/ | ||
@Converter | ||
@Slf4j | ||
public class RuntimeOptionsConverter implements AttributeConverter<RuntimeOptions, String> { | ||
|
||
private final ObjectMapper mapper; | ||
|
||
public RuntimeOptionsConverter() { | ||
this(new ObjectMapper()); | ||
} | ||
|
||
public RuntimeOptionsConverter(final ObjectMapper mapper) { | ||
this.mapper = mapper; | ||
} | ||
|
||
@Override | ||
public String convertToDatabaseColumn(final RuntimeOptions object) { | ||
try { | ||
return mapper.writeValueAsString(object); | ||
} catch (final JsonProcessingException e) { | ||
log.error("Unable to parse component source - {}", e.getMessage(), e); | ||
throw new FabricManagerException(e); | ||
} | ||
} | ||
|
||
@Override | ||
public RuntimeOptions convertToEntityAttribute(final String runtimeOptions) { | ||
try { | ||
return mapper.readValue(runtimeOptions, RuntimeOptions.class); | ||
} catch (final IOException e) { | ||
log.error("Unable to parse RuntimeOptions source - {}", e.getMessage(), e); | ||
throw new FabricManagerException(e); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
...anager/src/main/java/com/olacabs/fabric/manager/exception/mapper/HttpExceptionMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* Copyright 2016 ANI Technologies Pvt. Ltd. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.olacabs.fabric.manager.exception.mapper; | ||
|
||
import com.google.common.collect.ImmutableList; | ||
import com.google.common.collect.ImmutableMap; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.apache.http.client.HttpResponseException; | ||
|
||
import javax.ws.rs.core.Response; | ||
import javax.ws.rs.ext.ExceptionMapper; | ||
|
||
/** | ||
* Todo . | ||
*/ | ||
@Slf4j | ||
public class HttpExceptionMapper implements ExceptionMapper<HttpResponseException> { | ||
|
||
@Override | ||
public Response toResponse(final HttpResponseException e) { | ||
|
||
final Response defaultResponse = | ||
Response.serverError().entity(ImmutableMap.of("errors", ImmutableList.of(e.getMessage()))).build(); | ||
|
||
log.error("Error - {}", e.getMessage()); | ||
|
||
if (e instanceof groovyx.net.http.HttpResponseException) { | ||
return Response.status(e.getStatusCode()) | ||
.entity(ImmutableMap.of("errors", ImmutableList.of(e.getMessage()))).build(); | ||
} | ||
log.error("Stack trace - ", e); | ||
return defaultResponse; | ||
} | ||
} |
Oops, something went wrong.