Skip to content

Commit e7be881

Browse files
authored
UNOMI-877: Remove all reference to cellar and hazelcast. (#725)
* UNOMI-877: Remove all reference to cellar and hazelcast. UNOMI-877: Not sending event to cluster anymore. UNOMI-877: Replace Karaf Cellar and Hazelcast with PersistenceService for cluster synchronization (code isolated from branch unomi-3-dev made by Serge Huber) * Remove unused imports from ClusterNode, RouterCamelContext, and ClusterService. * Remove unused `clusterService` property from blueprint.xml. * Add `bundleWatcher` reference and properties to blueprint.xml. * Add clusterNode mapping definition for Elasticsearch. * Reorder `shutdownNow` to ensure proper node removal from PersistenceService during shutdown. * Clarify comment on node removal timing in `destroy` method. * Refactor configuration handling and remove unused OSGi ServiceTracker references. * Cache cluster nodes to optimize retrieval and reduce reliance on PersistenceService.
1 parent c22ff47 commit e7be881

File tree

31 files changed

+837
-1008
lines changed

31 files changed

+837
-1008
lines changed

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

Lines changed: 64 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,27 +17,34 @@
1717

1818
package org.apache.unomi.api;
1919

20-
import java.io.Serializable;
21-
2220
/**
2321
* Information about a cluster node.
2422
*/
25-
public class ClusterNode implements Serializable {
23+
public class ClusterNode extends Item {
2624

2725
private static final long serialVersionUID = 1281422346318230514L;
2826

27+
public static final String ITEM_TYPE = "clusterNode";
28+
2929
private double cpuLoad;
3030
private double[] loadAverage;
3131
private String publicHostAddress;
3232
private String internalHostAddress;
3333
private long uptime;
3434
private boolean master;
3535
private boolean data;
36+
private long startTime;
37+
private long lastHeartbeat;
38+
39+
// Server information
40+
private ServerInfo serverInfo;
3641

3742
/**
3843
* Instantiates a new Cluster node.
3944
*/
4045
public ClusterNode() {
46+
super();
47+
setItemType(ITEM_TYPE);
4148
}
4249

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

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

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
import org.apache.unomi.api.ClusterNode;
2121

22-
import java.io.Serializable;
2322
import java.util.Date;
2423
import java.util.List;
2524

@@ -51,11 +50,4 @@ public interface ClusterService {
5150
*/
5251
void purge(final String scope);
5352

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);
6153
}

extensions/router/router-core/pom.xml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -133,16 +133,6 @@
133133
<version>${kafka.client.version}</version>
134134
<scope>provided</scope>
135135
</dependency>
136-
<dependency>
137-
<groupId>org.apache.karaf.cellar</groupId>
138-
<artifactId>org.apache.karaf.cellar.core</artifactId>
139-
<scope>provided</scope>
140-
</dependency>
141-
<dependency>
142-
<groupId>org.apache.karaf.cellar</groupId>
143-
<artifactId>org.apache.karaf.cellar.config</artifactId>
144-
<scope>provided</scope>
145-
</dependency>
146136
</dependencies>
147137

148138
<build>

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

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import org.apache.camel.component.jackson.JacksonDataFormat;
2222
import org.apache.camel.core.osgi.OsgiDefaultCamelContext;
2323
import org.apache.camel.model.RouteDefinition;
24-
import org.apache.unomi.api.services.ClusterService;
2524
import org.apache.unomi.api.services.ConfigSharingService;
2625
import org.apache.unomi.api.services.ProfileService;
2726
import org.apache.unomi.persistence.spi.PersistenceService;
@@ -31,7 +30,6 @@
3130
import org.apache.unomi.router.api.RouterConstants;
3231
import org.apache.unomi.router.api.services.ImportExportConfigurationService;
3332
import org.apache.unomi.router.api.services.ProfileExportService;
34-
import org.apache.unomi.router.core.event.UpdateCamelRouteEvent;
3533
import org.apache.unomi.router.core.processor.ExportRouteCompletionProcessor;
3634
import org.apache.unomi.router.core.processor.ImportConfigByFileNameProcessor;
3735
import org.apache.unomi.router.core.processor.ImportRouteCompletionProcessor;
@@ -75,7 +73,6 @@ public class RouterCamelContext implements IRouterCamelContext {
7573
private String allowedEndpoints;
7674
private BundleContext bundleContext;
7775
private ConfigSharingService configSharingService;
78-
private ClusterService clusterService;
7976

8077
// TODO UNOMI-572: when fixing UNOMI-572 please remove the usage of the custom ScheduledExecutorService and re-introduce the Unomi Scheduler Service
8178
private ScheduledExecutorService scheduler;
@@ -102,10 +99,6 @@ public void setConfigSharingService(ConfigSharingService configSharingService) {
10299
this.configSharingService = configSharingService;
103100
}
104101

105-
public void setClusterService(ClusterService clusterService) {
106-
this.clusterService = clusterService;
107-
}
108-
109102
public void setTracing(boolean tracing) {
110103
camelContext.setTracing(true);
111104
}
@@ -240,12 +233,6 @@ public void killExistingRoute(String routeId, boolean fireEvent) throws Exceptio
240233
camelContext.removeRouteDefinition(routeDefinition);
241234
}
242235
}
243-
244-
if (fireEvent) {
245-
UpdateCamelRouteEvent event = new UpdateCamelRouteEvent(EVENT_ID_REMOVE);
246-
event.setRouteId(routeId);
247-
clusterService.sendEvent(event);
248-
}
249236
}
250237

251238
public void updateProfileImportReaderRoute(String configId, boolean fireEvent) throws Exception {
@@ -266,11 +253,6 @@ public void updateProfileImportReaderRoute(String configId, boolean fireEvent) t
266253
builder.setJacksonDataFormat(jacksonDataFormat);
267254
builder.setContext(camelContext);
268255
camelContext.addRoutes(builder);
269-
270-
if (fireEvent) {
271-
UpdateCamelRouteEvent event = new UpdateCamelRouteEvent(EVENT_ID_IMPORT);
272-
clusterService.sendEvent(event);
273-
}
274256
}
275257
}
276258

@@ -291,11 +273,6 @@ public void updateProfileExportReaderRoute(String configId, boolean fireEvent) t
291273
profileExportCollectRouteBuilder.setJacksonDataFormat(jacksonDataFormat);
292274
profileExportCollectRouteBuilder.setContext(camelContext);
293275
camelContext.addRoutes(profileExportCollectRouteBuilder);
294-
295-
if (fireEvent) {
296-
UpdateCamelRouteEvent event = new UpdateCamelRouteEvent(EVENT_ID_EXPORT);
297-
clusterService.sendEvent(event);
298-
}
299276
}
300277
}
301278

extensions/router/router-core/src/main/java/org/apache/unomi/router/core/event/UpdateCamelRouteEvent.java

Lines changed: 0 additions & 38 deletions
This file was deleted.

extensions/router/router-core/src/main/java/org/apache/unomi/router/core/event/UpdateCamelRouteEventHandler.java

Lines changed: 0 additions & 76 deletions
This file was deleted.

extensions/router/router-core/src/main/resources/OSGI-INF/blueprint/blueprint.xml

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -112,26 +112,13 @@
112112
<property name="persistenceService" ref="persistenceService"/>
113113
<property name="profileExportService" ref="profileExportService"/>
114114
<property name="profileService" ref="profileService"/>
115-
<property name="clusterService" ref="clusterService" />
116115
</bean>
117116
<service id="camelContextOSGI" ref="camelContext" interface="org.apache.unomi.router.api.IRouterCamelContext"/>
118117

119118
<bean id="collectProfileBean" class="org.apache.unomi.router.core.bean.CollectProfileBean">
120119
<property name="persistenceService" ref="persistenceService"/>
121120
</bean>
122121

123-
<bean id="updateCamelRouteEventHandler" class="org.apache.unomi.router.core.event.UpdateCamelRouteEventHandler">
124-
<property name="configurationAdmin" ref="osgiConfigurationAdmin"/>
125-
<property name="clusterManager" ref="karafCellarClusterManager"/>
126-
<property name="groupManager" ref="karafCellarGroupManager"/>
127-
<property name="routerCamelContext" ref="camelContext"/>
128-
</bean>
129-
<service ref="updateCamelRouteEventHandler" interface="org.apache.karaf.cellar.core.event.EventHandler">
130-
<service-properties>
131-
<entry key="managed" value="true"/>
132-
</service-properties>
133-
</service>
134-
135122
<reference id="configSharingService" interface="org.apache.unomi.api.services.ConfigSharingService" />
136123
<reference id="profileImportService" interface="org.apache.unomi.router.api.services.ProfileImportService"/>
137124
<reference id="profileExportService" interface="org.apache.unomi.router.api.services.ProfileExportService"/>
@@ -141,8 +128,6 @@
141128
<reference id="importConfigurationService" interface="org.apache.unomi.router.api.services.ImportExportConfigurationService" filter="(configDiscriminator=IMPORT)"/>
142129
<reference id="exportConfigurationService" interface="org.apache.unomi.router.api.services.ImportExportConfigurationService" filter="(configDiscriminator=EXPORT)"/>
143130
<reference id="clusterService" interface="org.apache.unomi.api.services.ClusterService" />
144-
<reference id="karafCellarGroupManager" interface="org.apache.karaf.cellar.core.GroupManager" />
145131
<reference id="osgiConfigurationAdmin" interface="org.osgi.service.cm.ConfigurationAdmin"/>
146-
<reference id="karafCellarClusterManager" interface="org.apache.karaf.cellar.core.ClusterManager" />
147132

148-
</blueprint>
133+
</blueprint>

0 commit comments

Comments
 (0)