Skip to content
This repository was archived by the owner on Jul 22, 2021. It is now read-only.

Commit a24b4ce

Browse files
committed
NIFIREG-260 Rebase capability to support branching workflow
1 parent db19dce commit a24b4ce

40 files changed

+3946
-6
lines changed

nifi-registry-core/nifi-registry-framework/src/main/java/org/apache/nifi/registry/service/alias/RegistryUrlAliasService.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ private static List<Alias> createAliases(NiFiRegistryProperties niFiRegistryProp
9494
}
9595
}
9696

97-
protected RegistryUrlAliasService(List<Alias> aliases) {
97+
public RegistryUrlAliasService(List<Alias> aliases) {
9898
Pattern urlStart = Pattern.compile("^https?://");
9999

100100
this.aliases = new LinkedHashMap<>();
@@ -137,7 +137,7 @@ public void setInternal(VersionedProcessGroup processGroup) {
137137
}
138138
}
139139

140-
protected String getExternal(String url) {
140+
public String getExternal(String url) {
141141
for (Map.Entry<String, String> alias : aliases.entrySet()) {
142142
String internal = alias.getKey();
143143
String external = alias.getValue();
@@ -153,7 +153,7 @@ protected String getExternal(String url) {
153153
return url;
154154
}
155155

156-
protected String getInternal(String url) {
156+
public String getInternal(String url) {
157157
for (Map.Entry<String, String> alias : aliases.entrySet()) {
158158
String internal = alias.getKey();
159159
String external = alias.getValue();

nifi-registry-toolkit/README.md

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616

1717
This submodule is a landing zone for command line utilities that can be used for maintenance/automation of registry actions.
1818

19-
It currently only contains a migration tool for changing flow persistence providers.
20-
2119
## Build
2220

2321
```
@@ -32,4 +30,29 @@ mvn clean install
3230
1. Edit providers-to.xml to reflect what you'd like to migrate to (e.g. git)
3331
1. In registry home as working directory, run persistence-toolkit.sh -t providers-to.xml
3432
1. Rename providers-to.xml -> providers.xml
35-
1. Start registry back up
33+
1. Start registry back up
34+
35+
36+
## Registry rebase (EXPERIMENTAL)
37+
38+
Initial support for rebasing a branched registry's changes on top of the upstream.
39+
40+
### Workflow:
41+
42+
#### Generate diff:
43+
1. "Branch" the upstream registry by shutting it down, copying directory to new location.
44+
1. Start upstream registry back up
45+
1. Configure branched registry with new hostname, registry-aliases.xml to account for new url
46+
1. Point NiFi at the branched registry, make some changes, decide you want to push them upstream
47+
1. Configure conf/branch-nifi-registry-client.properties and conf/upstream-nifi-registry-client.properties to point at the branched, upstream registries
48+
1. Generate a rebase diff
49+
```
50+
bin/rebase-toolkit.sh diff --upstreamPropertiesFile conf/upstream-nifi-registry-client.properties --branchPropertiesFile conf/branch-nifi-registry-client.properties --bucketId BUCKET_UUID --flowId FLOW_UUID --output output.yaml
51+
```
52+
53+
#### Apply upstream:
54+
1. Review output.yaml, opportunity for peer review as well
55+
1. Apply rebase diff
56+
```
57+
bin/rebase-toolkit.sh apply --upstreamPropertiesFile conf/upstream-nifi-registry-client.properties --branchPropertiesFile conf/branch-nifi-registry-client.properties --input output.yaml
58+
```

nifi-registry-toolkit/nifi-registry-toolkit-assembly/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ language governing permissions and limitations under the License. -->
5555
<artifactId>nifi-registry-toolkit-persistence</artifactId>
5656
<version>0.4.0-SNAPSHOT</version>
5757
</dependency>
58+
<dependency>
59+
<groupId>org.apache.nifi.registry</groupId>
60+
<artifactId>nifi-registry-toolkit-rebase</artifactId>
61+
<version>0.4.0-SNAPSHOT</version>
62+
</dependency>
5863
<dependency>
5964
<groupId>org.slf4j</groupId>
6065
<artifactId>slf4j-api</artifactId>

nifi-registry-toolkit/nifi-registry-toolkit-assembly/src/main/assembly/dependencies.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@
4545
<outputDirectory>classpath/</outputDirectory>
4646
<fileMode>0600</fileMode>
4747
</fileSet>
48+
<fileSet>
49+
<directory>${project.basedir}/src/main/resources/conf</directory>
50+
<outputDirectory>conf/</outputDirectory>
51+
<fileMode>0600</fileMode>
52+
</fileSet>
4853
</fileSets>
4954
<files>
5055
<file>
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
@echo off
2+
rem
3+
rem Licensed to the Apache Software Foundation (ASF) under one or more
4+
rem contributor license agreements. See the NOTICE file distributed with
5+
rem this work for additional information regarding copyright ownership.
6+
rem The ASF licenses this file to You under the Apache License, Version 2.0
7+
rem (the "License"); you may not use this file except in compliance with
8+
rem the License. You may obtain a copy of the License at
9+
rem
10+
rem http://www.apache.org/licenses/LICENSE-2.0
11+
rem
12+
rem Unless required by applicable law or agreed to in writing, software
13+
rem distributed under the License is distributed on an "AS IS" BASIS,
14+
rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
rem See the License for the specific language governing permissions and
16+
rem limitations under the License.
17+
rem
18+
19+
rem Use JAVA_HOME if it's set; otherwise, just use java
20+
21+
if "%JAVA_HOME%" == "" goto noJavaHome
22+
if not exist "%JAVA_HOME%\bin\java.exe" goto noJavaHome
23+
set JAVA_EXE=%JAVA_HOME%\bin\java.exe
24+
goto startConfig
25+
26+
:noJavaHome
27+
echo The JAVA_HOME environment variable is not defined correctly. 1>&2
28+
echo Instead the PATH will be used to find the java executable. 1>&2
29+
echo. 1>&2
30+
set JAVA_EXE=java
31+
goto startConfig
32+
33+
:startConfig
34+
set LIB_DIR=%~dp0..\classpath;%~dp0..\lib
35+
36+
if "%JAVA_OPTS%" == "" set JAVA_OPTS=-Xms12m -Xmx24m
37+
38+
SET JAVA_PARAMS=-cp %LIB_DIR%\* %JAVA_OPTS% org.apache.nifi.registry.toolkit.rebase.RecursiveRebase
39+
40+
cmd.exe /C ""%JAVA_EXE%" %JAVA_PARAMS% %* ""
41+
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
#!/bin/sh
2+
#
3+
# Licensed to the Apache Software Foundation (ASF) under one or more
4+
# contributor license agreements. See the NOTICE file distributed with
5+
# this work for additional information regarding copyright ownership.
6+
# The ASF licenses this file to You under the Apache License, Version 2.0
7+
# (the "License"); you may not use this file except in compliance with
8+
# the License. You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
#
18+
#
19+
20+
# Script structure inspired from Apache Karaf and other Apache projects with similar startup approaches
21+
22+
SCRIPT_DIR=$(dirname "$0")
23+
SCRIPT_NAME=$(basename "$0")
24+
NIFI_REGISTRY_TOOLKIT_HOME=$(cd "${SCRIPT_DIR}" && cd .. && pwd)
25+
PROGNAME=$(basename "$0")
26+
27+
28+
warn() {
29+
echo "${PROGNAME}: $*" > /dev/stderr
30+
}
31+
32+
die() {
33+
warn "$*"
34+
exit 1
35+
}
36+
37+
detectOS() {
38+
# OS specific support (must be 'true' or 'false').
39+
cygwin=false;
40+
aix=false;
41+
os400=false;
42+
darwin=false;
43+
case "$(uname)" in
44+
CYGWIN*)
45+
cygwin=true
46+
;;
47+
AIX*)
48+
aix=true
49+
;;
50+
OS400*)
51+
os400=true
52+
;;
53+
Darwin)
54+
darwin=true
55+
;;
56+
esac
57+
# For AIX, set an environment variable
58+
if ${aix}; then
59+
export LDR_CNTRL=MAXDATA=0xB0000000@DSA
60+
echo ${LDR_CNTRL} > /dev/stderr
61+
fi
62+
}
63+
64+
locateJava() {
65+
# Setup the Java Virtual Machine
66+
if $cygwin ; then
67+
[ -n "${JAVA}" ] && JAVA=$(cygpath --unix "${JAVA}")
68+
[ -n "${JAVA_HOME}" ] && JAVA_HOME=$(cygpath --unix "${JAVA_HOME}")
69+
fi
70+
71+
if [ "x${JAVA}" = "x" ] && [ -r /etc/gentoo-release ] ; then
72+
JAVA_HOME=$(java-config --jre-home)
73+
fi
74+
if [ "x${JAVA}" = "x" ]; then
75+
if [ "x${JAVA_HOME}" != "x" ]; then
76+
if [ ! -d "${JAVA_HOME}" ]; then
77+
die "JAVA_HOME is not valid: ${JAVA_HOME}"
78+
fi
79+
JAVA="${JAVA_HOME}/bin/java"
80+
else
81+
warn "JAVA_HOME not set; results may vary"
82+
JAVA=$(type java)
83+
JAVA=$(expr "${JAVA}" : '.* \(/.*\)$')
84+
if [ "x${JAVA}" = "x" ]; then
85+
die "java command not found"
86+
fi
87+
fi
88+
fi
89+
}
90+
91+
init() {
92+
# Determine if there is special OS handling we must perform
93+
detectOS
94+
95+
# Locate the Java VM to execute
96+
locateJava "$1"
97+
}
98+
99+
run() {
100+
LIBS="${NIFI_REGISTRY_TOOLKIT_HOME}/lib/*"
101+
102+
sudo_cmd_prefix=""
103+
if $cygwin; then
104+
NIFI_REGISTRY_TOOLKIT_HOME=$(cygpath --path --windows "${NIFI_REGISTRY_TOOLKIT_HOME}")
105+
CLASSPATH="$NIFI_REGISTRY_TOOLKIT_HOME/classpath;$(cygpath --path --windows "${LIBS}")"
106+
else
107+
CLASSPATH="$NIFI_REGISTRY_TOOLKIT_HOME/classpath:${LIBS}"
108+
fi
109+
110+
export JAVA_HOME="$JAVA_HOME"
111+
export NIFI_REGISTRY_TOOLKIT_HOME="$NIFI_REGISTRY_TOOLKIT_HOME"
112+
113+
umask 0077
114+
echo "$CLASSPATH" > /dev/stderr
115+
exec "${JAVA}" -cp "${CLASSPATH}" ${JAVA_OPTS:--Xms12m -Xmx256m} org.apache.nifi.registry.toolkit.rebase.RecursiveRebase "$@"
116+
}
117+
118+
119+
init "$1"
120+
run "$@"
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one or more
3+
# contributor license agreements. See the NOTICE file distributed with
4+
# this work for additional information regarding copyright ownership.
5+
# The ASF licenses this file to You under the Apache License, Version 2.0
6+
# (the "License"); you may not use this file except in compliance with
7+
# the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
18+
# nifi.registry.web.http.host=http://branch-registry.local:18080
19+
# nifi.registry.web.https.host=https://branch-registry.local:18443
20+
21+
# nifi.registry.external.url=http://branch-registry.local:18080
22+
23+
# client security properties #
24+
# nifi.registry.security.keystore=./conf/branch-keystore.jks
25+
# nifi.registry.security.keystoreType=JKS
26+
# nifi.registry.security.keystorePasswd=password
27+
# nifi.registry.security.keyPasswd=password
28+
# nifi.registry.security.truststore=./conf/branch-truststore.jks
29+
# nifi.registry.security.truststoreType=JKS
30+
# nifi.registry.security.truststorePasswd=password
31+
# nifi.registry.client.read.timeout=60 s
32+
# nifi.registry.client.connect.timeout=60 s
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one or more
3+
# contributor license agreements. See the NOTICE file distributed with
4+
# this work for additional information regarding copyright ownership.
5+
# The ASF licenses this file to You under the Apache License, Version 2.0
6+
# (the "License"); you may not use this file except in compliance with
7+
# the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
18+
# nifi.registry.web.http.host=http://upstream-registry.local:18080
19+
# nifi.registry.web.https.host=https://upstream-registry.local:18443
20+
21+
# nifi.registry.external.url=http://upstream-registry.local:18080
22+
23+
# client security properties #
24+
# nifi.registry.security.keystore=./conf/upstream-keystore.jks
25+
# nifi.registry.security.keystoreType=JKS
26+
# nifi.registry.security.keystorePasswd=password
27+
# nifi.registry.security.keyPasswd=password
28+
# nifi.registry.security.truststore=./conf/upstream-truststore.jks
29+
# nifi.registry.security.truststoreType=JKS
30+
# nifi.registry.security.truststorePasswd=password
31+
# nifi.registry.client.read.timeout=60 s
32+
# nifi.registry.client.connect.timeout=60 s

0 commit comments

Comments
 (0)