Skip to content

Commit d6c81b2

Browse files
authored
Merge pull request OpenShiftDemos#9 from siamaksade/master
Clustering enabled
2 parents 5ba2e3a + 2ed4616 commit d6c81b2

File tree

5 files changed

+93
-118
lines changed

5 files changed

+93
-118
lines changed

README.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
tasks-rs: JAX-RS, JPA quickstart
1+
OpenShift Tasks: JAX-RS, JPA quickstart
22
==============================
33
Author: Mike Musgrove
44
Level: Intermediate
@@ -26,26 +26,26 @@ REST Endpoints on OpenShift
2626
* Create task
2727

2828
```
29-
curl -i -u 'redhat:redhat1!' -H "Content-Length: 0" -X POST http://tasks-dev.10.1.2.10.xip.io/tasks/task1
29+
curl -i -u 'redhat:redhat1!' -H "Content-Length: 0" -X POST http://tasks-dev.10.1.2.10.xip.io/ws/tasks/task1
3030
```
3131

3232
* Get a task by id
3333

3434
```
35-
curl -u 'redhat:redhat1!' -H "Accept: application/json" -X GET http://tasks-dev.10.1.2.10.xip.io/tasks/1
35+
curl -u 'redhat:redhat1!' -H "Accept: application/json" -X GET http://tasks-dev.10.1.2.10.xip.io/ws/tasks/1
3636
```
3737

3838
* Get all user tasks
3939

4040
```
4141
42-
curl -u 'redhat:redhat1!' -H "Accept: application/json" -X GET http://tasks-dev.10.1.2.10.xip.io/tasks
42+
curl -u 'redhat:redhat1!' -H "Accept: application/json" -X GET http://tasks-dev.10.1.2.10.xip.io/ws/tasks
4343
```
4444

4545
* Delete a task by id
4646

4747
```
48-
curl -i -u 'redhat:redhat1!' -X DELETE http://tasks-dev.10.1.2.10.xip.io/tasks/1
48+
curl -i -u 'redhat:redhat1!' -X DELETE http://tasks-dev.10.1.2.10.xip.io/ws/tasks/1
4949
```
5050

5151
* Generate CPU load. Last parameter is duration of load in seconds

app-template.yaml

+71-102
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,113 @@
11
apiVersion: v1
22
kind: Template
3+
labels:
4+
template: openshift-tasks
35
metadata:
46
name: openshift-tasks
57
objects:
68
- apiVersion: v1
79
kind: ImageStream
810
metadata:
11+
labels:
12+
application: ${APPLICATION_NAME}
13+
name: ${APPLICATION_NAME}
14+
- apiVersion: v1
15+
kind: Service
16+
metadata:
17+
annotations:
18+
description: The web server's http port.
19+
labels:
20+
application: ${APPLICATION_NAME}
21+
name: ${APPLICATION_NAME}
22+
spec:
23+
ports:
24+
- port: 8080
25+
targetPort: 8080
26+
selector:
27+
deploymentConfig: ${APPLICATION_NAME}
28+
- apiVersion: v1
29+
id: ${APPLICATION_NAME}-http
30+
kind: Route
31+
metadata:
32+
annotations:
33+
description: Route for application's http service.
34+
labels:
35+
application: ${APPLICATION_NAME}
936
name: ${APPLICATION_NAME}
37+
spec:
38+
to:
39+
name: ${APPLICATION_NAME}
1040
- apiVersion: v1
1141
kind: BuildConfig
1242
metadata:
1343
labels:
14-
app: ${APPLICATION_NAME}
44+
application: ${APPLICATION_NAME}
1545
name: ${APPLICATION_NAME}
1646
spec:
1747
output:
1848
to:
1949
kind: ImageStreamTag
2050
name: ${APPLICATION_NAME}:latest
21-
postCommit: {}
22-
resources: {}
2351
source:
2452
git:
25-
ref: ${SOURCE_REFERENCE}
53+
ref: ${SOURCE_REF}
2654
uri: ${SOURCE_URL}
27-
secrets: null
2855
type: Git
2956
strategy:
3057
sourceStrategy:
58+
forcePull: true
3159
from:
3260
kind: ImageStreamTag
3361
name: jboss-eap64-openshift:1.3
3462
namespace: openshift
35-
incremental: false
3663
type: Source
3764
triggers:
38-
- generic:
39-
secret: ${GENERIC_WEBHOOK_SECRET}
40-
type: Generic
4165
- github:
42-
secret: ${GITHUB_WEBHOOK_SECRET}
66+
secret: kJZLvfQr3hZg
4367
type: GitHub
68+
- generic:
69+
secret: kJZLvfQr3hZg
70+
type: Generic
4471
- imageChange: {}
4572
type: ImageChange
4673
- type: ConfigChange
47-
status:
48-
lastVersion: 0
4974
- apiVersion: v1
5075
kind: DeploymentConfig
5176
metadata:
5277
labels:
53-
app: ${APPLICATION_NAME}
78+
application: ${APPLICATION_NAME}
5479
name: ${APPLICATION_NAME}
5580
spec:
5681
replicas: 1
5782
selector:
58-
deploymentconfig: tasks
83+
deploymentConfig: ${APPLICATION_NAME}
5984
strategy:
60-
resources: {}
61-
rollingParams:
62-
intervalSeconds: 1
63-
maxSurge: 25%
64-
maxUnavailable: 25%
65-
timeoutSeconds: 600
66-
updatePeriodSeconds: 1
67-
type: Rolling
85+
type: Recreate
6886
template:
6987
metadata:
7088
labels:
71-
app: ${APPLICATION_NAME}
72-
deploymentconfig: ${APPLICATION_NAME}
89+
application: ${APPLICATION_NAME}
90+
deploymentConfig: ${APPLICATION_NAME}
91+
name: ${APPLICATION_NAME}
7392
spec:
7493
containers:
75-
- name: ${APPLICATION_NAME}
76-
env:
94+
- env:
7795
- name: MY_POD_IP
7896
valueFrom:
7997
fieldRef:
8098
apiVersion: v1
8199
fieldPath: status.podIP
82-
image: " "
100+
- name: OPENSHIFT_KUBE_PING_LABELS
101+
value: application=${APPLICATION_NAME}
102+
- name: OPENSHIFT_KUBE_PING_NAMESPACE
103+
valueFrom:
104+
fieldRef:
105+
fieldPath: metadata.namespace
106+
- name: HORNETQ_CLUSTER_PASSWORD
107+
value: kJZLvfQr3hZg
108+
- name: JGROUPS_CLUSTER_PASSWORD
109+
value: kJZLvfQr3hZg
110+
image: ${APPLICATION_NAME}
83111
imagePullPolicy: Always
84112
livenessProbe:
85113
failureThreshold: 3
@@ -91,102 +119,43 @@ objects:
91119
periodSeconds: 45
92120
successThreshold: 1
93121
timeoutSeconds: 1
94-
name: tasks
122+
name: ${APPLICATION_NAME}
95123
ports:
96-
- containerPort: 8080
124+
- containerPort: 8778
125+
name: jolokia
97126
protocol: TCP
98-
- containerPort: 8443
127+
- containerPort: 8080
128+
name: http
99129
protocol: TCP
100-
- containerPort: 8778
130+
- containerPort: 8888
131+
name: ping
101132
protocol: TCP
102133
readinessProbe:
103134
failureThreshold: 3
104135
httpGet:
105136
path: /ws/demo/healthcheck
106137
port: 8080
107138
scheme: HTTP
108-
initialDelaySeconds: 20
109-
periodSeconds: 5
110-
successThreshold: 1
111-
timeoutSeconds: 1
112-
resources: {}
113-
terminationMessagePath: /dev/termination-log
114-
dnsPolicy: ClusterFirst
115-
restartPolicy: Always
116-
securityContext: {}
117-
terminationGracePeriodSeconds: 30
118-
test: false
139+
terminationGracePeriodSeconds: 60
119140
triggers:
120141
- imageChangeParams:
121142
automatic: true
122143
containerNames:
123144
- ${APPLICATION_NAME}
124145
from:
125-
kind: ImageStreamTag
126-
name: ${APPLICATION_NAME}:latest
146+
kind: ImageStream
147+
name: ${APPLICATION_NAME}
127148
type: ImageChange
128149
- type: ConfigChange
129-
status: {}
130-
- apiVersion: v1
131-
kind: Service
132-
metadata:
133-
labels:
134-
app: ${APPLICATION_NAME}
135-
name: ${APPLICATION_NAME}
136-
spec:
137-
ports:
138-
- name: 8080-tcp
139-
port: 8080
140-
protocol: TCP
141-
targetPort: 8080
142-
- name: 8443-tcp
143-
port: 8443
144-
protocol: TCP
145-
targetPort: 8443
146-
- name: 8778-tcp
147-
port: 8778
148-
protocol: TCP
149-
targetPort: 8778
150-
selector:
151-
deploymentconfig: ${APPLICATION_NAME}
152-
sessionAffinity: None
153-
type: ClusterIP
154-
status:
155-
loadBalancer: {}
156-
- apiVersion: v1
157-
kind: Route
158-
metadata:
159-
labels:
160-
app: ${APPLICATION_NAME}
161-
name: ${APPLICATION_NAME}
162-
spec:
163-
host: ""
164-
port:
165-
targetPort: 8080-tcp
166-
to:
167-
kind: Service
168-
name: ${APPLICATION_NAME}
169150
parameters:
170-
- description: The name of the application and the prefix for its artifacts
171-
displayName: Application Name
151+
- description: The name for the application.
172152
name: APPLICATION_NAME
153+
required: true
173154
value: tasks
174-
- description: The URL of the source code repository
175-
displayName: Source URL
155+
- description: Git source URI for application
176156
name: SOURCE_URL
157+
required: true
177158
value: https://github.com/openshiftdemos/openshift-tasks
178-
- description: The branch or tag of the source code to use
179-
displayName: Source Reference
180-
name: SOURCE_REFERENCE
159+
- description: Git branch/tag reference
160+
name: SOURCE_REF
181161
value: master
182-
- description: A secret string used to configure the GitHub webhook.
183-
displayName: GitHub Webhook Secret
184-
from: '[a-zA-Z0-9]{40}'
185-
generate: expression
186-
name: GITHUB_WEBHOOK_SECRET
187-
- description: A secret string used to configure the generic webhook.
188-
displayName: Generic Webhook Secret
189-
from: '[a-zA-Z0-9]{40}'
190-
generate: expression
191-
name: GENERIC_WEBHOOK_SECRET
192-

src/main/webapp/WEB-INF/tasks-rs-ds.xml

+5-5
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,17 @@
1515
See the License for the specific language governing permissions and
1616
limitations under the License.
1717
-->
18-
<!-- This is an unmanaged datasource. It should be used for proofs of concept
19-
or testing only. It uses H2, a lightweight, in-memory, example database that
20-
ships with JBoss EAP. It is not robust or scalable, is not supported,
21-
and should NOT be used in a production environment! -->
18+
<!-- This is an unmanaged datasource. It should be used for proofs of concept
19+
or testing only. It uses H2, a lightweight, in-memory, example database that
20+
ships with JBoss EAP. It is not robust or scalable, is not supported,
21+
and should NOT be used in a production environment! -->
2222
<datasources xmlns="http://www.jboss.org/ironjacamar/schema"
2323
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2424
xsi:schemaLocation="http://www.jboss.org/ironjacamar/schema http://docs.jboss.org/ironjacamar/schema/datasources_1_0.xsd">
2525
<!-- The datasource is bound into JNDI at this location. We reference
2626
this in META-INF/persistence.xml -->
2727
<datasource jndi-name="java:jboss/datasources/TasksRsQuickstartDS"
28-
pool-name="tasks-rs-xml-quickstart" enabled="true"
28+
pool-name="TasksRsQuickstartDS" enabled="true"
2929
use-java-context="true">
3030
<connection-url>jdbc:h2:mem:tasks-rs-xml-quickstart;DB_CLOSE_ON_EXIT=FALSE;DB_CLOSE_DELAY=-1</connection-url>
3131
<driver>h2</driver>

src/main/webapp/WEB-INF/web.xml

+2
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,6 @@
5353
<security-role>
5454
<role-name>guest</role-name>
5555
</security-role>
56+
57+
<distributable/>
5658
</web-app>

src/main/webapp/index.jsp

+10-6
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@
131131
<div class="card-pf">
132132
<div class="card-pf-heading">
133133
<h2 class="card-pf-title">
134-
Pod Info
134+
Info
135135
</h2>
136136
</div>
137137
<div class="card-pf-body">
@@ -145,10 +145,14 @@
145145
<td>Pod IP</td>
146146
<td><%= System.getenv("MY_POD_IP") %></td>
147147
</tr>
148-
<tr role="row" class="even">
148+
<tr role="row" class="odd">
149149
<td>Used Memory</td>
150150
<% int mb = 1024*1024; %>
151-
<td><%= (Runtime.getRuntime().totalMemory()) / mb %></td>
151+
<td><%= (Runtime.getRuntime().totalMemory()) / mb %> MB</td>
152+
</tr>
153+
<tr role="row" class="even">
154+
<td>Session ID</td>
155+
<td><%= session.getId() %></td>
152156
</tr>
153157
</table>
154158
</div>
@@ -185,7 +189,7 @@
185189
});
186190
setTimeout(doPoll,5000);
187191
}
188-
192+
189193
$(function() {
190194
// matchHeight the contents of each .card-pf and then the .card-pf itself
191195
$(".row-cards-pf > [class*='col'] > .card-pf .card-pf-title").matchHeight();
@@ -199,7 +203,7 @@
199203
$(document).ready(function() {
200204
// start polling
201205
doPoll();
202-
206+
203207
// info button
204208
$("#loginfo").click(function(e) {
205209
e.preventDefault();
@@ -261,7 +265,7 @@
261265
console.log(arguments);
262266
$("#messages .message-container p").html("Clicking the button did not work.");
263267
});
264-
});
268+
});
265269
// kill button
266270
$("#kill").click(function(e) {
267271
e.preventDefault();

0 commit comments

Comments
 (0)