Skip to content

Commit

Permalink
Implementing issue apache#2167 : Create a new REST API
Browse files Browse the repository at this point in the history
  • Loading branch information
mattcasters committed Mar 8, 2023
1 parent b832b15 commit ea237a3
Show file tree
Hide file tree
Showing 23 changed files with 1,533 additions and 85 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Expand Up @@ -8,4 +8,5 @@
!/assemblies/web/target
!/assemblies/plugins/dist/target
!/docker
!/rest
!google-key-apache-hop-it.json
@@ -0,0 +1,30 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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 org.apache.hop.core.config;

import java.util.Properties;
import org.apache.hop.metadata.api.IHasHopMetadataProvider;

/** This signals that the implementing class provides a Properties object.
* It also needs to be able to handle metadata providers so that plugins can add/remove providers. */
public interface IRestServicesProvider {
Properties getProperties();

IHasHopMetadataProvider getHasHopMetadataProvider();
}
Expand Up @@ -147,6 +147,8 @@ public enum HopExtensionPoint {

HopImportStart("Executed at the start of the 'hop-import' command line tool"),
HopImportEnd("Executed at the end of the 'hop-import' command line tool"),

HopRestServiceStart("Called during Hop REST services startup"),
;

public String id;
Expand Down
63 changes: 63 additions & 0 deletions docker/Dockerfile.rest
@@ -0,0 +1,63 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you 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 tomcat:10-jdk11-openjdk
LABEL maintainer="Apache Hop Team"
ENV HOP_CONFIG_FOLDER=""
ENV HOP_AES_ENCODER_KEY=""
ENV HOP_AUDIT_FOLDER="${CATALINA_HOME}/webapps/ROOT/audit"
ENV HOP_CONFIG_FOLDER="${CATALINA_HOME}/webapps/ROOT/config"
# specify the hop log level
ENV HOP_LOG_LEVEL="Basic"
# any JRE settings you want to pass on
# The “-XX:+AggressiveHeap” tells the container to use all memory assigned to the container.
# this removed the need to calculate the necessary heap Xmx
ENV HOP_OPTIONS="-Xmx4g"
ENV HOP_PASSWORD_ENCODER_PLUGIN="Hop"
ENV HOP_PLUGIN_BASE_FOLDERS="plugins"
# path to jdbc drivers
ENV HOP_SHARED_JDBC_FOLDER=""
ENV HOP_REST_CONFIG_FOLDER="/config"

# Set TOMCAT start variables
ENV CATALINA_OPTS='${HOP_OPTIONS} \
-DHOP_AES_ENCODER_KEY="${HOP_AES_ENCODER_KEY}" \
-DHOP_AUDIT_FOLDER="${HOP_AUDIT_FOLDER}" \
-DHOP_CONFIG_FOLDER="${HOP_CONFIG_FOLDER}" \
-DHOP_LOG_LEVEL="${HOP_LOG_LEVEL}" \
-DHOP_PASSWORD_ENCODER_PLUGIN="${HOP_PASSWORD_ENCODER_PLUGIN}" \
-DHOP_PLUGIN_BASE_FOLDERS="${HOP_PLUGIN_BASE_FOLDERS}" \
-DHOP_REST_CONFIG_FOLDER="${HOP_REST_CONFIG_FOLDER}" \
-DHOP_SHARED_JDBC_FOLDER="${HOP_SHARED_JDBC_FOLDER}"\'

# Cleanup and create folder
#
RUN rm -rf webapps/*

# Copy resources
#
COPY ./assemblies/plugins/dist/target/plugins "${CATALINA_HOME}"/plugins
COPY ./rest/target/hop-rest*.war "${CATALINA_HOME}"/webapps/hop.war

# Copy the run script
#
COPY ./docker/resources/run-rest.sh /tmp/

RUN mkdir -p "$CATALINA_HOME"/lib/swt/linux/x86_64

CMD ["/bin/bash", "/tmp/run-rest.sh"]
51 changes: 51 additions & 0 deletions docker/create_hop_rest_container.sh
@@ -0,0 +1,51 @@
#!/bin/bash

#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You 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.
#

# set working dir to current location
#
cd "${0%/*}"

REST_TARGET=../rest/target/webapp

# unzip files for docker image
#
unzip -qu ../rest/target/hop-rest*.war -d ${REST_TARGET}
unzip -qu ../assemblies/plugins/dist/target/hop-assemblies-*.zip -d ../assemblies/plugins/dist/target/

# Copy recent changes in libraries.
#
echo "Copying Hop jar files from the target folders."
cp ../core/target/hop-core-*SNAPSHOT.jar ${REST_TARGET}/WEB-INF/lib/
cp ../engine/target/hop-engine-*SNAPSHOT.jar ${REST_TARGET}/WEB-INF/lib
cp ../ui/target/hop-ui-*SNAPSHOT.jar ${REST_TARGET}/WEB-INF/lib/
cp ../rap/target/hop-*SNAPSHOT.jar ${REST_TARGET}/WEB-INF/lib/

# Copy recent changes to a few plugins.
#
cp ../plugins/engines/beam/target/hop-plugins*.jar ../assemblies/plugins/dist/target/plugins/engines/beam/
cp ../plugins/misc/projects/target/hop-plugins*.jar ../assemblies/plugins/dist/target/plugins/misc/projects/

# Build the docker image.
#
docker build ../ -f Dockerfile.rest -t hop-rest # --progress=plain --no-cache

# Cleanup
#
# rm -rf ${REST_TARGET}/
# rm -rf ../assemblies/plugins/dist/target/plugins
58 changes: 0 additions & 58 deletions docker/integration-tests/integration-tests-doris.yaml

This file was deleted.

36 changes: 36 additions & 0 deletions docker/resources/run-rest.sh
@@ -0,0 +1,36 @@
#!/bin/bash
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You 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.
#

log() {
echo `date '+%Y/%m/%d %H:%M:%S'`" - ${1}"
}

#
# Stopping a running hop web container with 'docker stop' is obviously possible.
# Doing it with CTRL-C is just more convenient.
# So we'll start the catalina.sh script in the background and wait until
# we trap SIGINT or SIGTERM. At that point we'll simply stop Tomcat.
#
catalina.sh run &
pid="$!"
log "Running Apache Tomcat / Hop REST with PID ${pid}"
trap "log 'Stopping Tomcat'; catalina.sh stop" SIGINT SIGTERM

while kill -0 $pid > /dev/null 2>&1; do
wait
done

0 comments on commit ea237a3

Please sign in to comment.