Skip to content

Commit c22ff47

Browse files
authored
Revert "UNOMI-877: Replace Karaf Cellar and Hazelcast with PersistenceService…" (#724)
This reverts commit 3f995e4.
1 parent 3f995e4 commit c22ff47

File tree

8 files changed

+236
-575
lines changed

8 files changed

+236
-575
lines changed

api/src/main/java/org/apache/unomi/api/ClusterNode.java

Lines changed: 1 addition & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -22,31 +22,22 @@
2222
/**
2323
* Information about a cluster node.
2424
*/
25-
public class ClusterNode extends Item {
25+
public class ClusterNode implements Serializable {
2626

2727
private static final long serialVersionUID = 1281422346318230514L;
2828

29-
public static final String ITEM_TYPE = "clusterNode";
30-
3129
private double cpuLoad;
3230
private double[] loadAverage;
3331
private String publicHostAddress;
3432
private String internalHostAddress;
3533
private long uptime;
3634
private boolean master;
3735
private boolean data;
38-
private long startTime;
39-
private long lastHeartbeat;
40-
41-
// Server information
42-
private ServerInfo serverInfo;
4336

4437
/**
4538
* Instantiates a new Cluster node.
4639
*/
4740
public ClusterNode() {
48-
super();
49-
setItemType(ITEM_TYPE);
5041
}
5142

5243
/**
@@ -174,58 +165,4 @@ public boolean isData() {
174165
public void setData(boolean data) {
175166
this.data = data;
176167
}
177-
178-
/**
179-
* Retrieves the node start time in milliseconds.
180-
*
181-
* @return the start time
182-
*/
183-
public long getStartTime() {
184-
return startTime;
185-
}
186-
187-
/**
188-
* Sets the node start time in milliseconds.
189-
*
190-
* @param startTime the start time
191-
*/
192-
public void setStartTime(long startTime) {
193-
this.startTime = startTime;
194-
}
195-
196-
/**
197-
* Retrieves the last heartbeat time in milliseconds.
198-
*
199-
* @return the last heartbeat time
200-
*/
201-
public long getLastHeartbeat() {
202-
return lastHeartbeat;
203-
}
204-
205-
/**
206-
* Sets the last heartbeat time in milliseconds.
207-
*
208-
* @param lastHeartbeat the last heartbeat time
209-
*/
210-
public void setLastHeartbeat(long lastHeartbeat) {
211-
this.lastHeartbeat = lastHeartbeat;
212-
}
213-
214-
/**
215-
* Gets the server information.
216-
*
217-
* @return the server information
218-
*/
219-
public ServerInfo getServerInfo() {
220-
return serverInfo;
221-
}
222-
223-
/**
224-
* Sets the server information.
225-
*
226-
* @param serverInfo the server information
227-
*/
228-
public void setServerInfo(ServerInfo serverInfo) {
229-
this.serverInfo = serverInfo;
230-
}
231168
}

api/src/main/java/org/apache/unomi/api/services/ClusterService.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,11 @@ public interface ClusterService {
5151
*/
5252
void purge(final String scope);
5353

54+
/**
55+
* This function will send an event to the nodes of the cluster
56+
* The function takes a Serializable to avoid dependency on any clustering framework
57+
*
58+
* @param event this object will be cast to a org.apache.karaf.cellar.core.event.Event object
59+
*/
60+
void sendEvent(Serializable event);
5461
}

extensions/router/router-core/src/main/java/org/apache/unomi/router/core/context/RouterCamelContext.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import org.apache.unomi.router.api.RouterConstants;
3232
import org.apache.unomi.router.api.services.ImportExportConfigurationService;
3333
import org.apache.unomi.router.api.services.ProfileExportService;
34+
import org.apache.unomi.router.core.event.UpdateCamelRouteEvent;
3435
import org.apache.unomi.router.core.processor.ExportRouteCompletionProcessor;
3536
import org.apache.unomi.router.core.processor.ImportConfigByFileNameProcessor;
3637
import org.apache.unomi.router.core.processor.ImportRouteCompletionProcessor;
@@ -239,6 +240,12 @@ public void killExistingRoute(String routeId, boolean fireEvent) throws Exceptio
239240
camelContext.removeRouteDefinition(routeDefinition);
240241
}
241242
}
243+
244+
if (fireEvent) {
245+
UpdateCamelRouteEvent event = new UpdateCamelRouteEvent(EVENT_ID_REMOVE);
246+
event.setRouteId(routeId);
247+
clusterService.sendEvent(event);
248+
}
242249
}
243250

244251
public void updateProfileImportReaderRoute(String configId, boolean fireEvent) throws Exception {
@@ -259,6 +266,11 @@ public void updateProfileImportReaderRoute(String configId, boolean fireEvent) t
259266
builder.setJacksonDataFormat(jacksonDataFormat);
260267
builder.setContext(camelContext);
261268
camelContext.addRoutes(builder);
269+
270+
if (fireEvent) {
271+
UpdateCamelRouteEvent event = new UpdateCamelRouteEvent(EVENT_ID_IMPORT);
272+
clusterService.sendEvent(event);
273+
}
262274
}
263275
}
264276

@@ -279,6 +291,11 @@ public void updateProfileExportReaderRoute(String configId, boolean fireEvent) t
279291
profileExportCollectRouteBuilder.setJacksonDataFormat(jacksonDataFormat);
280292
profileExportCollectRouteBuilder.setContext(camelContext);
281293
camelContext.addRoutes(profileExportCollectRouteBuilder);
294+
295+
if (fireEvent) {
296+
UpdateCamelRouteEvent event = new UpdateCamelRouteEvent(EVENT_ID_EXPORT);
297+
clusterService.sendEvent(event);
298+
}
282299
}
283300
}
284301

package/src/main/resources/etc/custom.system.properties

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,11 @@ org.apache.unomi.admin.servlet.context=${env:UNOMI_ADMIN_CONTEXT:-/cxs}
8181
#######################################################################################################################
8282
## Cluster Settings ##
8383
#######################################################################################################################
84+
org.apache.unomi.cluster.group=${env:UNOMI_CLUSTER_GROUP:-default}
8485
# To simplify testing we set the public address to use HTTP, but for production environments it is highly recommended
8586
# to switch to using HTTPS with a proper SSL certificate installed.
8687
org.apache.unomi.cluster.public.address=${env:UNOMI_CLUSTER_PUBLIC_ADDRESS:-http://localhost:8181}
8788
org.apache.unomi.cluster.internal.address=${env:UNOMI_CLUSTER_INTERNAL_ADDRESS:-https://localhost:9443}
88-
# The nodeId is a required setting that uniquely identifies this node in the cluster.
89-
# It must be set to a unique value for each node in the cluster.
90-
# Example: nodeId=node1
91-
org.apache.unomi.cluster.nodeId=${env:UNOMI_CLUSTER_NODEID:-unomi-node-1}
9289
# The nodeStatisticsUpdateFrequency controls the frequency of the update of system statistics such as CPU load,
9390
# system load average and uptime. This value is set in milliseconds and is set to 10 seconds by default. Each node
9491
# will retrieve the local values and broadcast them through a cluster event to all the other nodes to update

services/pom.xml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,6 @@
5656
<version>${project.version}</version>
5757
<scope>provided</scope>
5858
</dependency>
59-
<dependency>
60-
<groupId>org.apache.unomi</groupId>
61-
<artifactId>unomi-lifecycle-watcher</artifactId>
62-
<version>${project.version}</version>
63-
<scope>provided</scope>
64-
</dependency>
6559

6660
<dependency>
6761
<groupId>javax.servlet</groupId>
@@ -181,7 +175,6 @@
181175
<Embed-Dependency>*;scope=compile|runtime</Embed-Dependency>
182176
<Import-Package>
183177
sun.misc;resolution:=optional,
184-
com.sun.management;resolution:=optional,
185178
*
186179
</Import-Package>
187180
</instructions>

0 commit comments

Comments
 (0)