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

Commit 50c4dfe

Browse files
author
suba
committed
initial commit
1 parent 482c873 commit 50c4dfe

File tree

12 files changed

+387
-6
lines changed

12 files changed

+387
-6
lines changed

Rakefile

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,10 @@ define "ode" do
8383
desc "ODE Axis Integration Layer"
8484
define "axis2" do
8585
compile.with projects("bpel-api", "bpel-connector", "bpel-dao", "bpel-epr", "bpel-runtime",
86-
"scheduler-simple", "bpel-schemas", "bpel-store", "utils", "agents"),
86+
"scheduler-simple", "bpel-schemas", "bpel-store", "utils", "agents", "clustering"),
8787
AXIOM, AXIS2_ALL, COMMONS.lang, COMMONS.collections, COMMONS.httpclient, COMMONS.lang,
8888
DERBY, GERONIMO.kernel, GERONIMO.transaction, JAVAX.activation, JAVAX.servlet, JAVAX.stream,
89-
JAVAX.transaction, JENCKS, WSDL4J, WS_COMMONS, XMLBEANS, AXIS2_MODULES.libs, SLF4J, LOG4J
89+
JAVAX.transaction, JENCKS, WSDL4J, WS_COMMONS, XMLBEANS, AXIS2_MODULES.libs, SLF4J, LOG4J, HAZELCAST
9090

9191
test.exclude 'org.apache.ode.axis2.management.*'
9292
test.with project("tools"), AXIOM, JAVAX.javamail, COMMONS.codec, COMMONS.httpclient, XERCES, WOODSTOX
@@ -99,12 +99,12 @@ define "ode" do
9999
libs = projects("axis2", "bpel-api", "bpel-compiler", "bpel-connector", "bpel-dao",
100100
"bpel-epr", "bpel-obj", "bpel-ql", "bpel-runtime", "scheduler-simple",
101101
"bpel-schemas", "bpel-store", "dao-hibernate", "jca-ra", "jca-server",
102-
"utils", "dao-jpa", "agents"),
102+
"utils", "dao-jpa", "agents", "clustering"),
103103
AXIS2_ALL, ANNONGEN, BACKPORT, COMMONS.codec, COMMONS.collections, COMMONS.fileupload, COMMONS.io, COMMONS.httpclient, COMMONS.beanutils,
104104
COMMONS.lang, COMMONS.pool, DERBY, DERBY_TOOLS, JACOB, JAXEN, JAVAX.activation, JAVAX.ejb, JAVAX.javamail,
105105
JAVAX.connector, JAVAX.jms, JAVAX.persistence, JAVAX.transaction, JAVAX.stream, JIBX,
106106
GERONIMO.connector, GERONIMO.kernel, GERONIMO.transaction, LOG4J, OPENJPA, SAXON, TRANQL,
107-
WOODSTOX, WSDL4J, WS_COMMONS, XALAN, XERCES, XMLBEANS, SPRING, AXIS2_MODULES.libs, SLF4J, LOG4J
107+
WOODSTOX, WSDL4J, WS_COMMONS, XALAN, XERCES, XMLBEANS, SPRING, AXIS2_MODULES.libs, SLF4J, LOG4J, HAZELCAST
108108

109109
package(:war).with(:libs=>libs).path("WEB-INF").tap do |web_inf|
110110
web_inf.merge project("dao-jpa-ojpa-derby").package(:zip)
@@ -166,7 +166,7 @@ define "ode" do
166166

167167
desc "ODE APIs"
168168
define "bpel-api" do
169-
compile.with projects("utils", "bpel-obj", "bpel-schemas"), WSDL4J, XERCES, SLF4J, LOG4J
169+
compile.with projects("utils", "bpel-obj", "bpel-schemas"), WSDL4J, XERCES, SLF4J, LOG4J, HAZELCAST
170170
package :jar
171171
end
172172

@@ -206,6 +206,12 @@ define "ode" do
206206
package :jar
207207
end
208208

209+
desc "ODE Clustering"
210+
define "clustering" do
211+
compile.with projects("bpel-api"),HAZELCAST, COMMONS.logging
212+
package :jar
213+
end
214+
209215
desc "ODE BPEL Object Model"
210216
define "bpel-obj" do
211217
compile.with project("utils"), SAXON, WSDL4J, COMMONS.collections
@@ -225,7 +231,7 @@ define "ode" do
225231
desc "ODE Runtime Engine"
226232
define "bpel-runtime" do
227233
compile.with projects("bpel-api", "bpel-compiler", "bpel-dao", "bpel-epr", "bpel-obj", "bpel-schemas",
228-
"bpel-store", "utils", "agents"),
234+
"bpel-store", "utils", "agents","clustering"),
229235
COMMONS.collections, COMMONS.httpclient, JACOB, JAVAX.persistence, JAVAX.stream, JAXEN, SAXON, WSDL4J, XMLBEANS, SPRING, SLF4J, LOG4J
230236

231237

axis2/src/main/java/org/apache/ode/axis2/ODEServer.java

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@
8282
import org.apache.ode.utils.GUID;
8383
import org.apache.ode.utils.fs.TempFileManager;
8484

85+
import org.apache.ode.clustering.hazelcast.*;
86+
import com.hazelcast.core.*;
87+
8588
/**
8689
* Server class called by our Axis hooks to handle all ODE lifecycle management.
8790
*
@@ -133,6 +136,14 @@ public class ODEServer {
133136

134137
public Runnable txMgrCreatedCallback;
135138

139+
private HazelcastInstanceConfig hazelcastInstanceConfig;
140+
141+
private HazelcastClusterImpl hazelcastClusterImpl;
142+
143+
private String clusteringState = "";
144+
145+
private boolean isClusteringEnabled;
146+
136147
public void init(ServletConfig config, ConfigurationContext configContext) throws ServletException {
137148
init(config.getServletContext().getRealPath("/WEB-INF"), configContext);
138149
}
@@ -184,6 +195,11 @@ public void init(String contextPath, ConfigurationContext configContext, ODEConf
184195
if (txMgrCreatedCallback != null) {
185196
txMgrCreatedCallback.run();
186197
}
198+
199+
clusteringState = _odeConfig.getClusteringState();
200+
if (isClusteringEnabled()) initClustering();
201+
else __log.info("Clustering has not been initialized");
202+
187203
__log.debug("Creating data source.");
188204
initDataSource();
189205
__log.debug("Starting DAO.");
@@ -455,6 +471,39 @@ private void initConnector() throws ServletException {
455471
}
456472
}
457473

474+
public boolean isClusteringEnabled() {
475+
boolean state;
476+
if (clusteringState.equals("true")) state = true;
477+
else state = false;
478+
setClustering(state);
479+
return state;
480+
}
481+
482+
public void setClustering (boolean state) {
483+
isClusteringEnabled = state;
484+
}
485+
486+
public boolean getClusteringState() {
487+
return isClusteringEnabled;
488+
}
489+
490+
/**
491+
* Initialize the clustering if it is enabled
492+
*/
493+
private void initClustering() {
494+
String hzConfig = System.getProperty("hazelcast.config");
495+
if (hzConfig != null) hazelcastInstanceConfig = new HazelcastInstanceConfig();
496+
else {
497+
File hzXml = new File(_configRoot, "hazelcast.xml");
498+
if (!hzXml.isFile())
499+
__log.error("hazelcast.xml does not exist or is not a file");
500+
else hazelcastInstanceConfig = new HazelcastInstanceConfig(hzXml);
501+
}
502+
if (hazelcastInstanceConfig != null) {
503+
hazelcastClusterImpl = new HazelcastClusterImpl(hazelcastInstanceConfig.getHazelcastInstance());
504+
}
505+
}
506+
458507
/**
459508
* Initialize the DAO.
460509
*
@@ -533,6 +582,7 @@ public Thread newThread(Runnable r) {
533582
_bpelServer.setCronScheduler(_cronScheduler);
534583

535584
_bpelServer.setDaoConnectionFactory(_daoCF);
585+
_bpelServer.setHazelcastCluster(hazelcastClusterImpl);
536586
_bpelServer.setInMemDaoConnectionFactory(new BpelDAOConnectionFactoryImpl(_scheduler, _odeConfig.getInMemMexTtl()));
537587
_bpelServer.setEndpointReferenceContext(eprContext);
538588
_bpelServer.setMessageExchangeContext(new MessageExchangeContextImpl(this));
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with 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,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.apache.ode.bpel.hzapi;
20+
21+
import com.hazelcast.core.Member;
22+
23+
import java.util.List;
24+
25+
public interface HazelcastCluster {
26+
27+
/**
28+
* Initialization of the cluster
29+
*/
30+
void init();
31+
32+
/**
33+
* Get hostName + port nu of Member
34+
* @param member
35+
* @return
36+
*/
37+
String getHazelCastNodeID(Member member);
38+
39+
/**
40+
* Check whether current node is the leader or not.
41+
*/
42+
void isLeader();
43+
44+
/**
45+
* returns Current Nodes in the cluster.
46+
* @return
47+
*/
48+
List<String> getKnownNodes();
49+
50+
/**
51+
* Return isMaster
52+
* @return
53+
*/
54+
boolean getIsMaster();
55+
56+
}

bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelServerImpl.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
import org.apache.ode.bpel.iapi.Scheduler.Synchronizer;
6060
import org.apache.ode.bpel.intercept.MessageExchangeInterceptor;
6161
import org.apache.ode.bpel.o.OProcess;
62+
import org.apache.ode.clustering.hazelcast.HazelcastClusterImpl;
6263
import org.apache.ode.utils.msg.MessageBundle;
6364
import org.apache.ode.utils.stl.CollectionsX;
6465
import org.apache.ode.utils.stl.MemberOfFunction;
@@ -534,6 +535,10 @@ public void setBindingContext(BindingContext bc) {
534535
_contexts.bindingContext = bc;
535536
}
536537

538+
public void setHazelcastCluster(HazelcastClusterImpl hzCImpl) {
539+
_contexts.hazelcastClusterImpl = hzCImpl;
540+
}
541+
537542
public DebuggerContext getDebugger(QName pid) throws BpelEngineException {
538543
return _engine._activeProcesses.get(pid)._debugger;
539544
}

bpel-runtime/src/main/java/org/apache/ode/bpel/engine/Contexts.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import org.apache.ode.bpel.intercept.MessageExchangeInterceptor;
2929
import org.apache.ode.bpel.engine.cron.CronScheduler;
3030
import org.apache.ode.bpel.evar.ExternalVariableModule;
31+
import org.apache.ode.clustering.hazelcast.HazelcastClusterImpl;
3132

3233
import java.util.HashMap;
3334
import java.util.List;
@@ -46,6 +47,8 @@ public class Contexts {
4647

4748
public CronScheduler cronScheduler;
4849

50+
public HazelcastClusterImpl hazelcastClusterImpl;
51+
4952
EndpointReferenceContext eprContext;
5053

5154
BindingContext bindingContext;

clustering/pom.xml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
~ Licensed to the Apache Software Foundation (ASF) under one
4+
~ or more contributor license agreements. See the NOTICE file
5+
~ distributed with this work for additional information
6+
~ regarding copyright ownership. The ASF licenses this file
7+
~ to you under the Apache License, Version 2.0 (the
8+
~ "License"); you may not use this file except in compliance
9+
~ with the License. You may obtain a copy of the License at
10+
~
11+
~ http://www.apache.org/licenses/LICENSE-2.0
12+
~
13+
~ Unless required by applicable law or agreed to in writing,
14+
~ software distributed under the License is distributed on an
15+
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
~ KIND, either express or implied. See the License for the
17+
~ specific language governing permissions and limitations
18+
~ under the License.
19+
-->
20+
<project>
21+
<modelVersion>4.0.0</modelVersion>
22+
<groupId>org.apache.ode</groupId>
23+
<artifactId>ode-clustering</artifactId>
24+
<name>ODE :: Clustering</name>
25+
<parent>
26+
<groupId>org.apache.ode</groupId>
27+
<artifactId>ode</artifactId>
28+
<version>1.4-SNAPSHOT</version>
29+
</parent>
30+
</project>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package org.apache.ode.clustering;
2+
3+
public class Test {
4+
}

0 commit comments

Comments
 (0)