Skip to content

Instantly share code, notes, and snippets.

@ksahnine
ksahnine / Rame.java
Last active August 29, 2015 14:13
Dropwizard - Objet métier
public class Rame {
private String direction;
private String attente;
public Rame() {
}
public Rame(String direction, String attente) {
this.direction = direction;
@ksahnine
ksahnine / IOExceptionMapper.java
Created January 15, 2015 08:24
Dropwizard - Exception manager
public class IOExceptionMapper implements ExceptionMapper<IOException> {
public Response toResponse(IOException exception) {
return Response.serverError().entity("{ \"message\": \"" + exception.toString() + "\"}").build();
}
}
@ksahnine
ksahnine / TraficRatpResource.java
Last active August 29, 2015 14:13
Dropwizard - Resource
// Imports
@Path("/trafic-ratp")
@Produces(MediaType.APPLICATION_JSON)
public class TraficRatpResource {
private final String urlRatp;
public TraficRatpResource(String urlRatp) {
this.urlRatp = urlRatp;
}
@ksahnine
ksahnine / TraficRatpConfiguration.java
Created January 15, 2015 08:46
Dropwizard - Configuration
public class TraficRatpConfiguration extends Configuration {
@NotEmpty
private String urlRatp;
@JsonProperty
public String getUrlRatp() {
return urlRatp;
}
@JsonProperty
@ksahnine
ksahnine / TraficRatpApplication.java
Last active August 29, 2015 14:13
Dropwizard - Application (bootstrap)
public class TraficRatpApplication extends Application<TraficRatpConfiguration> {
public static void main(String[] args) throws Exception {
new TraficRatpApplication().run(args);
}
@Override
public String getName() {
return "trafic-ratp";
}
@ksahnine
ksahnine / RatpHealthCheck.java
Created January 15, 2015 09:45
Dropwizard - Health check
public class RatpHealthCheck extends HealthCheck {
private String urlRatp;
public RatpHealthCheck(String urlRatp) {
this.urlRatp = urlRatp;
}
@Override
protected Result check() throws Exception {
URL url = new URL(urlRatp);
@ksahnine
ksahnine / trafic-ratp.yml
Created January 16, 2015 08:37
Dropwizard - Config
urlRatp: http://www.ratp.fr/horaires/fr/ratp/metro/prochains_passages/PP
# Logging settings.
logging:
level: INFO
loggers:
fr.inovia.blog: DEBUG
appenders:
- type: console
@ksahnine
ksahnine / Dropwizard - Docker
Created January 20, 2015 15:21
Dropwizard - Construction image Docker
git clone https://github.com/ksahnine/trafic-ratp-dropwizard.git
cd trafic-ratp-dropwizard
mvn package
docker build -t ksahnine/trafic-ratp-dropwizard .
@ksahnine
ksahnine / Dockerfile
Created January 22, 2015 17:41
Dropwizard - Fichier de config sur le FS local
# Build:
# docker build -t ksahnine:trafic-ratp-dropwizard .
#
# Run:
# docker run -t -p 8080:8080 -v ~/conf/dev:/conf ksahnine:trafic-ratp-dropwizard
#
# DOCKER_VERSION 1.4
FROM dockerfile/java:openjdk-7-jdk
MAINTAINER Kadda SAHNINE <kadda.sahnine@inovia-conseil.fr>
@ksahnine
ksahnine / infra_services_playbook.yml
Last active August 29, 2015 14:14
Ansible playbook - Infrastructure Microservices
- hosts: pegase.local
name: "** Frontend **"
gather_facts: True
sudo: yes
tasks:
- name: Installation nginx
pacman: name=nginx state=present
- name: Configuration loadbalancer
template: src=conf/loadbalancer-nginx-{{env}}.conf dest=/etc/nginx/nginx.conf
- name: Redemarrage nginx