Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 1 addition & 64 deletions api/src/main/java/org/apache/unomi/api/ClusterNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,31 +22,22 @@
/**
* Information about a cluster node.
*/
public class ClusterNode extends Item {
public class ClusterNode implements Serializable {

private static final long serialVersionUID = 1281422346318230514L;

public static final String ITEM_TYPE = "clusterNode";

private double cpuLoad;
private double[] loadAverage;
private String publicHostAddress;
private String internalHostAddress;
private long uptime;
private boolean master;
private boolean data;
private long startTime;
private long lastHeartbeat;

// Server information
private ServerInfo serverInfo;

/**
* Instantiates a new Cluster node.
*/
public ClusterNode() {
super();
setItemType(ITEM_TYPE);
}

/**
Expand Down Expand Up @@ -174,58 +165,4 @@ public boolean isData() {
public void setData(boolean data) {
this.data = data;
}

/**
* Retrieves the node start time in milliseconds.
*
* @return the start time
*/
public long getStartTime() {
return startTime;
}

/**
* Sets the node start time in milliseconds.
*
* @param startTime the start time
*/
public void setStartTime(long startTime) {
this.startTime = startTime;
}

/**
* Retrieves the last heartbeat time in milliseconds.
*
* @return the last heartbeat time
*/
public long getLastHeartbeat() {
return lastHeartbeat;
}

/**
* Sets the last heartbeat time in milliseconds.
*
* @param lastHeartbeat the last heartbeat time
*/
public void setLastHeartbeat(long lastHeartbeat) {
this.lastHeartbeat = lastHeartbeat;
}

/**
* Gets the server information.
*
* @return the server information
*/
public ServerInfo getServerInfo() {
return serverInfo;
}

/**
* Sets the server information.
*
* @param serverInfo the server information
*/
public void setServerInfo(ServerInfo serverInfo) {
this.serverInfo = serverInfo;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,11 @@ public interface ClusterService {
*/
void purge(final String scope);

/**
* This function will send an event to the nodes of the cluster
* The function takes a Serializable to avoid dependency on any clustering framework
*
* @param event this object will be cast to a org.apache.karaf.cellar.core.event.Event object
*/
void sendEvent(Serializable event);
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.apache.unomi.router.api.RouterConstants;
import org.apache.unomi.router.api.services.ImportExportConfigurationService;
import org.apache.unomi.router.api.services.ProfileExportService;
import org.apache.unomi.router.core.event.UpdateCamelRouteEvent;
import org.apache.unomi.router.core.processor.ExportRouteCompletionProcessor;
import org.apache.unomi.router.core.processor.ImportConfigByFileNameProcessor;
import org.apache.unomi.router.core.processor.ImportRouteCompletionProcessor;
Expand Down Expand Up @@ -239,6 +240,12 @@ public void killExistingRoute(String routeId, boolean fireEvent) throws Exceptio
camelContext.removeRouteDefinition(routeDefinition);
}
}

if (fireEvent) {
UpdateCamelRouteEvent event = new UpdateCamelRouteEvent(EVENT_ID_REMOVE);
event.setRouteId(routeId);
clusterService.sendEvent(event);
}
}

public void updateProfileImportReaderRoute(String configId, boolean fireEvent) throws Exception {
Expand All @@ -259,6 +266,11 @@ public void updateProfileImportReaderRoute(String configId, boolean fireEvent) t
builder.setJacksonDataFormat(jacksonDataFormat);
builder.setContext(camelContext);
camelContext.addRoutes(builder);

if (fireEvent) {
UpdateCamelRouteEvent event = new UpdateCamelRouteEvent(EVENT_ID_IMPORT);
clusterService.sendEvent(event);
}
}
}

Expand All @@ -279,6 +291,11 @@ public void updateProfileExportReaderRoute(String configId, boolean fireEvent) t
profileExportCollectRouteBuilder.setJacksonDataFormat(jacksonDataFormat);
profileExportCollectRouteBuilder.setContext(camelContext);
camelContext.addRoutes(profileExportCollectRouteBuilder);

if (fireEvent) {
UpdateCamelRouteEvent event = new UpdateCamelRouteEvent(EVENT_ID_EXPORT);
clusterService.sendEvent(event);
}
}
}

Expand Down
5 changes: 1 addition & 4 deletions package/src/main/resources/etc/custom.system.properties
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,11 @@ org.apache.unomi.admin.servlet.context=${env:UNOMI_ADMIN_CONTEXT:-/cxs}
#######################################################################################################################
## Cluster Settings ##
#######################################################################################################################
org.apache.unomi.cluster.group=${env:UNOMI_CLUSTER_GROUP:-default}
# To simplify testing we set the public address to use HTTP, but for production environments it is highly recommended
# to switch to using HTTPS with a proper SSL certificate installed.
org.apache.unomi.cluster.public.address=${env:UNOMI_CLUSTER_PUBLIC_ADDRESS:-http://localhost:8181}
org.apache.unomi.cluster.internal.address=${env:UNOMI_CLUSTER_INTERNAL_ADDRESS:-https://localhost:9443}
# The nodeId is a required setting that uniquely identifies this node in the cluster.
# It must be set to a unique value for each node in the cluster.
# Example: nodeId=node1
org.apache.unomi.cluster.nodeId=${env:UNOMI_CLUSTER_NODEID:-unomi-node-1}
# The nodeStatisticsUpdateFrequency controls the frequency of the update of system statistics such as CPU load,
# system load average and uptime. This value is set in milliseconds and is set to 10 seconds by default. Each node
# will retrieve the local values and broadcast them through a cluster event to all the other nodes to update
Expand Down
7 changes: 0 additions & 7 deletions services/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,6 @@
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.unomi</groupId>
<artifactId>unomi-lifecycle-watcher</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>javax.servlet</groupId>
Expand Down Expand Up @@ -181,7 +175,6 @@
<Embed-Dependency>*;scope=compile|runtime</Embed-Dependency>
<Import-Package>
sun.misc;resolution:=optional,
com.sun.management;resolution:=optional,
*
</Import-Package>
</instructions>
Expand Down
Loading