Skip to content

Commit df4d8b8

Browse files
committed
- Added transaction support
- New resource modeling, with new RESTful endpoints - Some misc refactoring - Additional specifications for missing code coverage
1 parent c6aa3f3 commit df4d8b8

File tree

47 files changed

+2061
-461
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+2061
-461
lines changed

README.md

Lines changed: 39 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ v2.x - CQ 5.6
2525

2626
Active development is on the "master" branch, which is currently the 4.x version line. Security patches and the like are sometimes back-ported to prior versions.
2727

28-
Of course pull-requests are happily accepted for those that would like to submit things like support for AEM 6.0, back-porting features for AEM 5.6, etc.
28+
Of course pull-requests are happily accepted for those that would like to submit things like back-porting features for AEM 5.6, etc.
2929

3030
# Runtime Dependencies
3131

@@ -63,18 +63,38 @@ _For both Windows and Mac : To verify that installation was successful, `protoc
6363

6464
# Running Grabbit #
6565

66-
[This] (grabbit.sh) shell script can be used to initiate grabbit jobs for a given Grabbit configuration and to check the status of those jobs.
66+
[This] (grabbit.sh) shell script can be used to initiate new Grabbit jobs, or monitor existing jobs.
6767

68-
1. Create a configuration file with the path(s) you wish to copy (see "Config Format" section below, you'll also set the server side URL and credentials in this step)
69-
2. Execute the grabbit.sh script (which comes with the codebase, by default lives in the root of the project)
70-
3. Enter the full address for the client instance including port (details for the server instance should be in the config fil you create in step 1)
71-
4. Enter Username for the client instance
72-
5. Enter the Password for the client instance
73-
6. Enter the path to the Grabbit config you created in step. Example of how it will look : !["Grabbit configuration enter example"](assets/GrabbitConfig.png)
74-
7. Once the Grabbit content sync is kicked off, you will get a confirmation of the kicked off jobs like : !["Grabbit confirmation example"](assets/GrabbitComplete.png)
68+
##Getting Started With grabbit.sh
7569

70+
- Run grabbit.sh
71+
- Enter connection details to your Grabbit "client" server (The server you wish to pull content into)
72+
73+
!["Grabbit connection example"](assets/grabbitConnection.png)
74+
75+
##Creating a New Job Request
76+
77+
From the main screen, enter "n" for a new request. Enter an absolute path (from the machine you are running grabbit.sh) to the Grabbit configuration file you wish to use for creating a new request.
78+
See the "Configuration" section for details on how to create these configuration files.
79+
80+
!["New Job"](assets/newJob.png)
81+
82+
After the job request is sent, and started you should see a confirmation screen with the job IDs of all the jobs started, as well as their transaction ID
83+
84+
!["Job Confirmation"](assets/jobKickedOff.png)
85+
86+
##Monitoring
7687

77-
### Config Format
88+
From the main screen, enter "m" to monitor an existing job, or jobs. You will be prompted. If you would like to monitor a group of jobs by their transaction, enter "t". If you would like to monitor a specific jobs, enter "j".
89+
90+
!["Monitor Jobs"](assets/monitor.png)
91+
92+
See "Monitoring / Validating the Content Sync" for information on evaluating the returned information.
93+
94+
95+
### Configuration
96+
97+
Configuration can be developed in both YAML, and JSON formats.
7898

7999
A `JSON` configuration file of following format is used to configure Grabbit.
80100

@@ -115,7 +135,7 @@ A `JSON` configuration file of following format is used to configure Grabbit.
115135
]
116136
}
117137
```
118-
You can also use `YAML` file format to configure Grabbit. The corresponding YAML configuration for the JSON above will look something like -
138+
The corresponding YAML configuration for the JSON above will look something like:
119139
```yaml
120140
# Client Type: author
121141

@@ -142,7 +162,7 @@ pathConfigurations :
142162
path : /content/someContent
143163
-
144164
path : /content/someOtherContent
145-
excludePaths: [ someOtherContent/someExcludeContent ]
165+
excludePaths: [ someExcludeContent ]
146166
-
147167
path : /content/dam/someDamContent
148168
excludePaths :
@@ -209,11 +229,10 @@ Invalid:
209229

210230
# Monitoring / Validating the Content Sync #
211231

212-
You can validate / monitor sync by going to the following URI for each job on your Grabbit Client:
213-
214-
`/grabbit/job/<jobId>.json`
232+
You may choose to use grabbit.sh to monitor your sync, or you can validate/monitor your sync by going to the following URIs:
215233

216-
This will give you the status of a particular job. It has the following format -
234+
`/grabbit/job/<jobId>`
235+
`/grabbit/job/<transactionId>`
217236

218237
A job status is has the following format :
219238

@@ -229,7 +248,8 @@ A job status is has the following format :
229248
"jobExecutionId": "JobExecutionId",
230249
"path": "currentPath",
231250
"startTime": "TimeStamp",
232-
"timeTaken": "TimeInMilliSeconds"
251+
"timeTaken": "TimeInMilliSeconds",
252+
"transactionId": "transactionId"
233253
}
234254
```
235255

@@ -240,9 +260,10 @@ Couple of points worth noting here:
240260

241261
If `exitCode` returns as `UNKNOWN`, that means the job is still running and you should check for its status again.
242262

263+
243264
__Sample of a real Grabbit Job status__
244265

245-
![alt text](assets/ExampleGrabbitStatus.jpg)
266+
![alt text](assets/jobStatus.png)
246267

247268
Two loggers are predefined for Grabbit. One for Grabbit Server and the other for Grabbit Client.
248269
They are [batch-server.log](grabbit/src/main/content/SLING-INF/content/apps/grabbit/config/org.apache.sling.commons.log.LogManager.factory.config-com.twcable.grabbit.server.batch.xml) and [batch-client.log](grabbit/src/main/content/SLING-INF/content/apps/grabbit/config/org.apache.sling.commons.log.LogManager.factory.config-com.twcable.grabbit.client.batch.xml) respectively.

assets/ExampleGrabbitStatus.jpg

-140 KB
Binary file not shown.

assets/GrabbitComplete.png

-14.8 KB
Binary file not shown.

assets/GrabbitConfig.png

-20.3 KB
Binary file not shown.

assets/grabbitConnection.png

48.1 KB
Loading

assets/jobKickedOff.png

49.3 KB
Loading

assets/jobStatus.png

106 KB
Loading

assets/monitor.png

17.5 KB
Loading

assets/newJob.png

48.6 KB
Loading

grabbit.sh

Lines changed: 85 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,78 @@ SET_RED=$(tput setaf 1)
1515

1616
#### Constants
1717

18-
GRABBIT_URL="/grabbit/job"
18+
GRABBIT_JOB="/grabbit/job"
19+
GRABBIT_TRANSACTION="/grabbit/transaction"
20+
21+
22+
rm -f /tmp/grabbit
23+
rm -f /tmp/grabbit_headers
24+
25+
function newGrabbitRequest() {
26+
echo
27+
echo "Enter path to your Grabbit Configuration file"
28+
read configpath
29+
clear
30+
echo $SET_YELLOW
31+
echo "Processing....."
32+
echo $SET_NO_COLOR
33+
curl -s -f -X PUT --data-binary "@$configpath" -u $username:$password -D /tmp/grabbit_headers $client$GRABBIT_JOB > /tmp/grabbit
34+
RSP_CODE=$?
35+
if [ $RSP_CODE -ne 0 ]; then
36+
clear
37+
echo $SET_RED
38+
echo "~~~~~~~~~Failure~~~~~~~~~~~~~"
39+
echo
40+
echo "Something went wrong when processing the given config."
41+
echo
42+
echo "cURL, the transfer library used by this shell received an error code of $RSP_CODE. See https://curl.haxx.se/libcurl/c/libcurl-errors.html for debugging."
43+
echo "If this doesn't help, please check the client log for more details."
44+
exit 1
45+
fi
46+
clear
47+
echo "~~~~~~~~~~~Jobs kicked off ~~~~~~~~~~~~~"
48+
echo
49+
echo "Transaction ID: ${SET_BLUE}$(cat /tmp/grabbit_headers | grep GRABBIT_TRANSACTION_ID | sed -e 's/GRABBIT_TRANSACTION_ID: //')${SET_NO_COLOR}"
50+
echo "Job IDs: ${SET_GREEN}$(cat /tmp/grabbit | sed -e 's/\]//' -e 's/\[//' -e 's/,/ /g')${SET_NO_COLOR}"
51+
echo
52+
echo "~~~~~Client configuration : Client : $client Config: $configpath ~~~~~"
53+
}
54+
55+
function monitorStatus {
56+
while true; do
57+
echo
58+
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
59+
echo "Enter \"j\" for job status, \"t\" for transaction status, or \"q\" to quit"
60+
read selection
61+
if [ "$selection" == "q" ]; then
62+
exit 0;
63+
elif [ "$selection" == "j" ]; then
64+
while true; do
65+
echo "Enter jobID to access status of a job, \"all\" to access all jobs, or \"b\" to go back"
66+
read selection
67+
if [ "$selection" == "b" ]; then
68+
break
69+
fi
70+
statusJson=`curl -s -u $username:$password --request GET $client$GRABBIT_JOB"/"$selection.json`
71+
echo
72+
echo "Status for JobId [$selection] is :"
73+
echo "$statusJson" | python -m json.tool
74+
done
75+
elif [ "$selection" == "t" ]; then
76+
echo "Enter transactionID to access transaction status, or \"b\" to go back"
77+
read selection
78+
if [ "$selection" == "b" ]; then
79+
break
80+
fi
81+
statusJson=`curl -s -u $username:$password --request GET $client$GRABBIT_TRANSACTION"/"$selection.json`
82+
echo
83+
echo "Status for transaction [$selection] is :"
84+
echo "$statusJson" | python -m json.tool
85+
else
86+
echo "Invalid selection"
87+
fi
88+
done
89+
}
1990

2091
clear
2192
echo $SET_BLUE
@@ -26,51 +97,23 @@ echo $SET_NO_COLOR
2697

2798
echo "Enter Client [http(s)://server:port] to initiate Grabbit request "
2899
read client
29-
30100
echo
31101
echo "Client Username :"
32-
read -s username
102+
read -s username
33103
echo
34104
echo "Client Password :"
35-
read -s password
105+
read -s password
36106

37-
echo
38-
echo "Enter path to your Grabbit Configuration file"
39-
read configpath
40-
41-
rm -f /tmp/grabbit
42-
# Kick off Grabbit jobs
43-
clear
44-
echo $SET_YELLOW
45-
echo "Processing....."
46-
echo $SET_NO_COLOR
47-
curl -s -f -X PUT --data-binary "@$configpath" -u $username:$password $client$GRABBIT_URL > /tmp/grabbit
48-
if [ $? -eq 22 ]; then
49-
clear
50-
echo $SET_RED
51-
echo "~~~~~~~~~Failure~~~~~~~~~~~~~"
52-
echo
53-
echo "Something went wrong when processing the given config. Please check the client log for more details."
54-
echo
55-
exit 1
56-
fi
57-
clear
58-
echo "~~~~~~~~~~~Jobs kicked off ~~~~~~~~~~~~~"
59-
echo
60-
echo "Job IDs: ${SET_GREEN}$(cat /tmp/grabbit | sed -e 's/\]//' -e 's/\[//' -e 's/,/ /g')${SET_NO_COLOR}"
61-
echo
62-
echo "~~~~~Client configuration : Client : $client Config: $configpath ~~~~~"
63-
# Monitor Job Status
64107
while true; do
65-
echo
66-
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
67-
read -p "Enter Job ID or \"all\" to get job status or enter 'q' to quit: " id
68-
if [ "$id" == "q" ]; then
69-
exit 0;
70-
fi
71-
statusJson=`curl -s -u $username:$password --request GET $client$GRABBIT_URL"/"$id.json`
72-
echo
73-
echo "Status for JobId [$id] is :"
74-
echo "$statusJson" | python -m json.tool
75-
108+
echo "Enter \"n\" for new job request, \"m\" to monitor, or \"q\" to quit"
109+
read selection
110+
if [ "$selection" == "n" ]; then
111+
newGrabbitRequest
112+
elif [ "$selection" == "m" ]; then
113+
monitorStatus
114+
elif [ "$selection" == "q" ]; then
115+
exit 0;
116+
else
117+
echo "Invalid selection"
118+
fi
76119
done

0 commit comments

Comments
 (0)