-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[runtime && dist]Configuration and packaging modifications (#165)
Configuration and packaging modifications
- Loading branch information
1 parent
0008e78
commit b1a4b90
Showing
10 changed files
with
308 additions
and
15 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
81 changes: 81 additions & 0 deletions
81
.../java/org/apache/rocketmq/eventbridge/adapter/storage/rocketmq/runtimer/ConfigLoader.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,81 @@ | ||
/* | ||
* 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.rocketmq.eventbridge.adapter.storage.rocketmq.runtimer; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
import org.apache.commons.lang3.StringUtils; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.core.io.support.PropertiesLoaderUtils; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.io.IOException; | ||
import java.util.Properties; | ||
|
||
/** | ||
* support loading from runtime.properties and spring properties | ||
*/ | ||
@Component | ||
@Slf4j | ||
public class ConfigLoader { | ||
|
||
@Autowired | ||
private PropertiesResolveService propertiesResolveService; | ||
|
||
private Properties properties; | ||
|
||
public ConfigLoader() { | ||
try { | ||
this.properties = PropertiesLoaderUtils.loadAllProperties("runtime.properties"); | ||
} catch (IOException e) { | ||
log.warn("init runtime properties failed ", e); | ||
} | ||
} | ||
|
||
public String getString(String name, String defaultValue){ | ||
String result = getValue(name); | ||
if (StringUtils.isBlank(result)) { | ||
result = defaultValue; | ||
} | ||
log.debug("Load property '" + name + "' = " + result); | ||
return result; | ||
} | ||
|
||
public String getString(String name){ | ||
String result = getValue(name); | ||
log.debug("Load property '" + name + "' = " + result); | ||
return result; | ||
} | ||
|
||
private String getValue(String name){ | ||
if (StringUtils.isBlank(name)) { | ||
return null; | ||
} | ||
String value = null; | ||
try { | ||
if (propertiesResolveService != null) { | ||
value = propertiesResolveService.getPropertiesValue(name); | ||
} | ||
} catch (IllegalArgumentException e) { | ||
log.warn("Failed load property '" + name + "' from spring."); | ||
} | ||
if (properties != null && StringUtils.isBlank((value))) { | ||
value = properties.getProperty(name); | ||
} | ||
return value; | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
...ache/rocketmq/eventbridge/adapter/storage/rocketmq/runtimer/PropertiesResolveService.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,50 @@ | ||
/* | ||
* 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.rocketmq.eventbridge.adapter.storage.rocketmq.runtimer; | ||
|
||
import org.apache.rocketmq.eventbridge.config.CommonConstants; | ||
import org.springframework.context.EmbeddedValueResolverAware; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.core.PriorityOrdered; | ||
import org.springframework.util.StringValueResolver; | ||
|
||
/** | ||
* spring props load service | ||
*/ | ||
@Configuration | ||
public class PropertiesResolveService implements EmbeddedValueResolverAware, PriorityOrdered { | ||
|
||
private StringValueResolver stringValueResolver; | ||
|
||
@Override | ||
public void setEmbeddedValueResolver(StringValueResolver resolver) { | ||
stringValueResolver = resolver; | ||
} | ||
|
||
public String getPropertiesValue(String name) { | ||
if (!name.contains(CommonConstants.V_PREFIXE)) { | ||
name = CommonConstants.V_PREFIXE + name + CommonConstants.V_POSTFIX; | ||
} | ||
return stringValueResolver.resolveStringValue(name); | ||
} | ||
|
||
@Override | ||
public int getOrder() { | ||
return PriorityOrdered.HIGHEST_PRECEDENCE; | ||
} | ||
} |
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
23 changes: 23 additions & 0 deletions
23
common/src/main/java/org/apache/rocketmq/eventbridge/config/CommonConstants.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,23 @@ | ||
/* | ||
* 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.rocketmq.eventbridge.config; | ||
|
||
public interface CommonConstants { | ||
String V_PREFIXE = "${"; | ||
|
||
String V_POSTFIX = "}"; | ||
} |
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
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,51 @@ | ||
# | ||
# 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 eclipse-temurin:8-jdk-centos7 AS builder | ||
|
||
RUN set -eux \ | ||
&& yum -y update \ | ||
&& yum -y install curl gnupg unzip \ | ||
&& yum clean all -y | ||
|
||
ENV EVENTBRIDGE_USER=apps \ | ||
EVENTBRIDGE_HOME=/home/apps/rocketmq-eventbridge \ | ||
EVENTBRIDGE_LOG_DIR=/home/apps/logs \ | ||
EVENTBRIDGE_LOG_FILE=/home/apps/logs/rocketmq-eventbridge.log | ||
|
||
RUN set -x \ | ||
&& adduser "$EVENTBRIDGE_USER" \ | ||
&& mkdir -p "$EVENTBRIDGE_LOG_DIR" \ | ||
&& touch "$EVENTBRIDGE_LOG_FILE" | ||
|
||
WORKDIR /home/apps | ||
ARG version | ||
# Rocketmq eventbridge version | ||
ENV ROCKETMQ_EVENTBRIDGE_VERSION ${version} | ||
|
||
ADD rocketmq-eventbridge-dist-${ROCKETMQ_EVENTBRIDGE_VERSION}.zip /home/apps | ||
RUN cd /home/apps && unzip rocketmq-eventbridge-dist-${ROCKETMQ_EVENTBRIDGE_VERSION}.zip && rm -rf rocketmq-eventbridge-dist-${ROCKETMQ_EVENTBRIDGE_VERSION}.zip | ||
|
||
RUN chown -R "$EVENTBRIDGE_USER:$EVENTBRIDGE_USER" "$EVENTBRIDGE_HOME" "$EVENTBRIDGE_LOG_DIR" | ||
COPY docker-entrypoint.sh /home/apps/rocketmq-eventbridge/bin | ||
RUN chmod 755 /home/apps/rocketmq-eventbridge/bin/docker-entrypoint.sh | ||
|
||
EXPOSE 8083 7001 7002 | ||
USER apps | ||
WORKDIR /home/apps/rocketmq-eventbridge | ||
|
||
ENTRYPOINT ["./bin/docker-entrypoint.sh"] |
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,55 @@ | ||
#!/usr/bin/env 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. | ||
|
||
checkVersion() { | ||
echo "Version = $1" | ||
echo $1 |grep -E "^[0-9]+\.[0-9]+\.[0-9]+" > /dev/null | ||
if [ $? = 0 ]; then | ||
return 1 | ||
fi | ||
|
||
echo "Version $1 illegal, it should be X.X.X format(e.g. 4.5.0), please check released versions in 'https://archive.apache.org/dist/rocketmq/'" | ||
exit -1 | ||
} | ||
|
||
checkZipFile() { | ||
|
||
file="../dist/target/rocketmq-eventbridge-dist-${ROCKETMQ_EVENTBRIDGE_VERSION}.zip" | ||
|
||
if [ -e "$file" ]; then | ||
return 1 | ||
fi | ||
|
||
echo "the installation package rocketmq-eventbridge-dist-${ROCKETMQ_EVENTBRIDGE_VERSION}.zip does not exist in dist/target, please check released package" | ||
exit -1 | ||
} | ||
|
||
if [ $# -lt 1 ]; then | ||
echo -e "Usage: sh $0 Version" | ||
exit -1 | ||
fi | ||
ROCKETMQ_EVENTBRIDGE_VERSION=$1 | ||
checkVersion $ROCKETMQ_EVENTBRIDGE_VERSION | ||
checkZipFile | ||
# copy package to docker directory | ||
cp ../dist/target/rocketmq-eventbridge-dist-${ROCKETMQ_EVENTBRIDGE_VERSION}.zip ./ | ||
|
||
# Build rocketmq-eventbridge | ||
|
||
docker build --no-cache -f Dockerfile -t apache/rocketmq-eventbridge:${ROCKETMQ_EVENTBRIDGE_VERSION} --build-arg version=${ROCKETMQ_EVENTBRIDGE_VERSION} . | ||
rm -rf rocketmq-eventbridge-dist-${ROCKETMQ_EVENTBRIDGE_VERSION}.zip | ||
|
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,26 @@ | ||
#!/usr/bin/env 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 -e | ||
|
||
START_EVENTBRIDGE="./bin/eventbridge.sh start" | ||
echo "${START_EVENTBRIDGE}" && source ${START_EVENTBRIDGE} | ||
|
||
START_CMD="tail -f /home/apps/logs/rocketmq-eventbridge.log" | ||
#START_TEST="tail -f /etc/hosts" | ||
#echo "${START_TEST}" && exec ${START_TEST} | ||
echo "${START_CMD}" && exec ${START_CMD} |
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