diff --git a/deployment/sal.yaml b/deployment/sal.yaml index d75bf4a..6b8e675 100644 --- a/deployment/sal.yaml +++ b/deployment/sal.yaml @@ -69,9 +69,9 @@ spec: - name: PWS_URL value: http://158.39.77.68:8880/ - name: PWS_USERNAME - value: admin + value: - name: PWS_PASSWORD - value: admin + value: - name: DB_USERNAME value: root - name: DB_PORT diff --git a/docker/Dockerfile b/docker/Dockerfile index 0e31950..27f6a05 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -27,7 +27,7 @@ ENV DB_URL='jdbc:mariadb://localhost:3306/proactive' ENV DB_PLATFORM='org.hibernate.dialect.MariaDB53Dialect' CMD ["catalina.sh", "jpda", "run"] -#RUN yum install -y nmap-ncat -#RUN chmod +x /usr/local/tomcat/bin/wait_for_db.sh -#CMD ["/bin/bash", "-c", "wait_for_db.sh && catalina.sh jpda run"] +RUN yum install -y nmap-ncat +RUN chmod +x /usr/local/tomcat/bin/wait_for_db.sh +CMD ["/bin/bash", "-c", "wait_for_db.sh && catalina.sh jpda run"] diff --git a/docker/Dockerfile.win b/docker/Dockerfile.win new file mode 100644 index 0000000..0e31950 --- /dev/null +++ b/docker/Dockerfile.win @@ -0,0 +1,33 @@ +FROM tomcat:9.0.68-jdk8-corretto-al2 + +RUN rm -rf ${CATALINA_HOME}/webapps/* +# NOTE: Switch between local or public builded SAL +RUN curl -o /usr/local/tomcat/webapps/sal.war http://repository.activeeon.com/content/groups/proactive/org/ow2/proactive/scheduling-abstraction-layer/13.1.0-SNAPSHOT/scheduling-abstraction-layer-13.1.0-20221027.125525-9.war +COPY sal-service/build/libs/scheduling-abstraction-layer-*.war /usr/local/tomcat/webapps/sal.war + +ENV EXTERNAL_CONFIG_DIR=${CATALINA_HOME}/conf +ENV PROPERTIES_FILENAME='sal' + +ENV PA_HOME=${CATALINA_HOME} + +COPY docker/scheduling-abstraction-layer.xml ${EXTERNAL_CONFIG_DIR}/Catalina/localhost/sal.xml +# NOTE: Please make sure if you set a different `PROPERTIES_FILENAME` to copy your properties file inside the container +COPY docker/sal.application.properties ${EXTERNAL_CONFIG_DIR}/${PROPERTIES_FILENAME}.properties +COPY docker/wait_for_db.sh /usr/local/tomcat/bin + +ENV PWS_URL='http://localhost:8080/' +ENV PWS_USERNAME='admin' +ENV PWS_PASSWORD='admin' + +ENV DB_USERNAME='root' +ENV DB_PASSWORD='' + +ENV DB_DRIVER_CLASSNAME='org.mariadb.jdbc.Driver' +ENV DB_URL='jdbc:mariadb://localhost:3306/proactive' +ENV DB_PLATFORM='org.hibernate.dialect.MariaDB53Dialect' + +CMD ["catalina.sh", "jpda", "run"] +#RUN yum install -y nmap-ncat +#RUN chmod +x /usr/local/tomcat/bin/wait_for_db.sh +#CMD ["/bin/bash", "-c", "wait_for_db.sh && catalina.sh jpda run"] + diff --git a/docker/README.md b/docker/README.md index 9bf2318..e14efc1 100644 --- a/docker/README.md +++ b/docker/README.md @@ -16,7 +16,7 @@ cd ./gradlew spotlessApply clean build --refresh-dependencies -cd +cd rm -f ./artefacts/scheduling-abstraction-layer-13.1.0-SNAPSHOT.war @@ -24,13 +24,12 @@ cp /sal-service/build/libs/scheduling-abstraction-layer-13.1. docker-compose down -docker build -t activeeon/sal:latest -f ./Dockerfile --no-cache . +docker build -t activeeon/sal:test -f ./Dockerfile --no-cache . docker-compose up ``` -> NOTE: Please change and for the correct ones. +> NOTE: Please change `` and `` to the correct ones. In case SAL is built on Windows, use `./Dockerfile.win` instead of `./Dockerfile`. - -Each time the code is modified in , you can simple run this script and it will automatically launch new container with the changes included. +Each time the code is modified in ``, you can run this script and it will automatically launch a new container with the changes included. diff --git a/docker/docker-compose.yaml b/docker/docker-compose.yaml index b4bb937..cbe233f 100644 --- a/docker/docker-compose.yaml +++ b/docker/docker-compose.yaml @@ -1,6 +1,6 @@ services: database: - image: mariadb + image: mariadb #optionaly set specific version e.g. mariadb:10.7 ports: - "3307:3306" networks: @@ -15,9 +15,13 @@ services: timeout: 5s retries: 5 sal: + #Set up image to be used for SAL from https://hub.docker.com/r/activeeon/sal/tags image: activeeon/sal:test build: context: .. + #Set up Dockerfile to be used: + #Dockerfile is used for Jenkins image creation + #Dockerfile.win to be used for local build on Windows dockerfile: ./docker/Dockerfile depends_on: database: @@ -33,6 +37,7 @@ services: - ./scripts:/usr/local/tomcat/scripts environment: PROPERTIES_FILENAME: sal + #Set up connection to ProActive server (PWS) PWS_URL: PWS_USERNAME: PWS_PASSWORD: @@ -49,4 +54,4 @@ services: networks: # The presence of these objects is sufficient to define them - db-tier: {} + db-tier: {} \ No newline at end of file diff --git a/sal-service/src/main/java/org/ow2/proactive/sal/service/util/ConnectionHelper.java b/sal-service/src/main/java/org/ow2/proactive/sal/service/util/ConnectionHelper.java index ac0c5b6..1e3fd85 100644 --- a/sal-service/src/main/java/org/ow2/proactive/sal/service/util/ConnectionHelper.java +++ b/sal-service/src/main/java/org/ow2/proactive/sal/service/util/ConnectionHelper.java @@ -78,7 +78,6 @@ public static JSONObject sendGetRequestAndReturnObjectResponse(URI requestUri) { @SneakyThrows public static JSONArray sendGetArrayRequestAndReturnArrayResponse(URI requestUri) throws IOException { HttpURLConnection connection = null; - BufferedReader br = null; JSONArray result = new JSONArray(); try { @@ -86,11 +85,17 @@ public static JSONArray sendGetArrayRequestAndReturnArrayResponse(URI requestUri connection.setRequestMethod(HttpMethod.GET.toString()); LOGGER.debug("requestUri = {}", requestUri); - br = sendGetRequestAndReturnBufferedResponse(connection); - if (br != null) { - result = new JSONArray(new JSONTokener(br)); + // Check if connection is successfully established + if (connection != null) { + try (BufferedReader br = sendGetRequestAndReturnBufferedResponse(connection)) { + if (br != null) { + result = new JSONArray(new JSONTokener(br)); + } else { + LOGGER.warn("No response received from request to {}", requestUri); + } + } } else { - LOGGER.warn("No response received from request to {}", requestUri); + LOGGER.error("Failed to establish connection to {}", requestUri); } } catch (IOException e) { LOGGER.error("IO exception occurred while making request to {}: {}", requestUri, e.getMessage(), e); @@ -108,13 +113,6 @@ public static JSONArray sendGetArrayRequestAndReturnArrayResponse(URI requestUri e); throw new IOException("Unexpected error occurred", e); // Wrap and throw as IOException } finally { - if (br != null) { - try { - br.close(); - } catch (IOException e) { - LOGGER.warn("Failed to close BufferedReader: {}", e.getMessage(), e); - } - } if (connection != null) { connection.disconnect(); }