Skip to content

Commit

Permalink
DOSGi Cellar example
Browse files Browse the repository at this point in the history
  • Loading branch information
geichelberger committed Jan 30, 2024
1 parent cdbebed commit ad85558
Show file tree
Hide file tree
Showing 9 changed files with 581 additions and 2 deletions.
5 changes: 4 additions & 1 deletion assemblies/karaf-features/src/main/feature/feature.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<features name="opencast-${project.version}" xmlns="http://karaf.apache.org/xmlns/features/v1.3.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.3.0">

<repository>mvn:org.apache.karaf.cellar/apache-karaf-cellar/${karaf.cellar.version}/xml/features</repository>

<feature name="query-dsl" version="${project.version}">
<bundle>mvn:com.google.guava/guava/${guava.version}</bundle>
<bundle>mvn:com.google.guava/failureaccess/${failureaccess.version}</bundle>
Expand All @@ -19,6 +21,8 @@
<feature>scr</feature>
<feature>cxf-jaxrs</feature>
<feature>cxf-http-jetty</feature>
<feature>cellar</feature>
<feature>cellar-dosgi</feature>

<!-- httpclient needs to start before common so that it can get org.apache.commons.logging -->
<bundle start-level="55">mvn:org.apache.httpcomponents/httpclient-osgi/${httpcomponents-httpclient.version}</bundle>
Expand Down Expand Up @@ -147,7 +151,6 @@
<feature>opencast-core</feature>
<feature>opencast-services-processing-heavy-load</feature>
<feature>opencast-services-processing-light-load</feature>

<bundle start-level="82">mvn:org.opencastproject/opencast-admin-ui/${project.version}</bundle>
<bundle start-level="82">mvn:org.opencastproject/opencast-admin-ui-frontend/${project.version}</bundle>
<bundle start-level="82">mvn:org.opencastproject/opencast-admin-ui-interface/${project.version}</bundle>
Expand Down
216 changes: 216 additions & 0 deletions etc/hazelcast.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,216 @@
<?xml version="1.0" encoding="UTF-8"?>
<hazelcast xmlns="http://www.hazelcast.com/schema/config"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.hazelcast.com/schema/config http://www.hazelcast.com/schema/config/hazelcast-config-3.12.xsd">
<group>
<name>cellar</name>
<password>pass</password>
</group>
<management-center enabled="false">http://localhost:8080/mancenter</management-center>
<network>
<port auto-increment="true" port-count="100">5701</port>
<outbound-ports>
<!--
Allowed port range when connecting to other nodes.
0 or * means use system provided port.
-->
<ports>0</ports>
</outbound-ports>
<join>
<multicast enabled="true">
<multicast-group>224.2.2.3</multicast-group>
<multicast-port>54327</multicast-port>
</multicast>
<tcp-ip enabled="false">
<interface>127.0.0.1</interface>
</tcp-ip>
<aws enabled="false">
<access-key>my-access-key</access-key>
<secret-key>my-secret-key</secret-key>
<!--optional, default is us-east-1 -->
<region>us-west-1</region>
<!--optional, default is ec2.amazonaws.com. If set, region shouldn't be set as it will override this property -->
<host-header>ec2.amazonaws.com</host-header>
<!-- optional, only instances belonging to this group will be discovered, default will try all running instances -->
<security-group-name>hazelcast-sg</security-group-name>
<tag-key>type</tag-key>
<tag-value>hz-nodes</tag-value>
</aws>
</join>
<interfaces enabled="false">
<interface>10.10.1.*</interface>
</interfaces>
<ssl enabled="false"/>
<socket-interceptor enabled="false"/>
<symmetric-encryption enabled="false">
<!--
encryption algorithm such as
DES/ECB/PKCS5Padding,
PBEWithMD5AndDES,
AES/CBC/PKCS5Padding,
Blowfish,
DESede
-->
<algorithm>PBEWithMD5AndDES</algorithm>
<!-- salt value to use when generating the secret key -->
<salt>thesalt</salt>
<!-- pass phrase to use when generating the secret key -->
<password>thepass</password>
<!-- iteration count to use when generating the secret key -->
<iteration-count>19</iteration-count>
</symmetric-encryption>
</network>
<partition-group enabled="false"/>
<executor-service>
<pool-size>16</pool-size>
<!-- Queue capacity. 0 means Integer.MAX_VALUE -->
<queue-capacity>0</queue-capacity>
</executor-service>
<queue name="default">
<!--
Maximum size of the queue. When a JVM's local queue size reaches the maximum,
all put/offer operations will get blocked until the queue size
of the JVM goes down below the maximum.
Any integer between 0 and Integer.MAX_VALUE. 0 means
Integer.MAX_VALUE. Default is 0.
-->
<max-size>0</max-size>
<!--
Number of backups. If 1 is set as the backup-count for example,
then all entries of the map will be copied to another JVM for
fail-safety. 0 means no backup.
-->
<backup-count>1</backup-count>
<!--
Number of async backups. 0 means no backup.
-->
<async-backup-count>0</async-backup-count>
<empty-queue-ttl>-1</empty-queue-ttl>
</queue>

<map name="default">
<!--
Data type that will be used for storing recordMap.
Possible values:
BINARY (default): keys and values will be stored as binary data
OBJECT : values will be stored in their object forms
OFFHEAP : values will be stored in non-heap region of JVM
-->
<in-memory-format>BINARY</in-memory-format>
<!--
Number of backups. If 1 is set as the backup-count for example,
then all entries of the map will be copied to another JVM for
fail-safety. 0 means no backup.
-->
<backup-count>1</backup-count>
<!--
Number of async backups. 0 means no backup.
-->
<async-backup-count>0</async-backup-count>
<!--
Maximum number of seconds for each entry to stay in the map. Entries that are
older than <time-to-live-seconds> and not updated for <time-to-live-seconds>
will get automatically evicted from the map.
Any integer between 0 and Integer.MAX_VALUE. 0 means infinite. Default is 0.
-->
<time-to-live-seconds>0</time-to-live-seconds>
<!--
Maximum number of seconds for each entry to stay idle in the map. Entries that are
idle(not touched) for more than <max-idle-seconds> will get
automatically evicted from the map. Entry is touched if get, put or containsKey is called.
Any integer between 0 and Integer.MAX_VALUE. 0 means infinite. Default is 0.
-->
<max-idle-seconds>0</max-idle-seconds>
<!--
Valid values are:
NONE (no eviction),
LRU (Least Recently Used),
LFU (Least Frequently Used).
NONE is the default.
-->
<eviction-policy>NONE</eviction-policy>
<!--
Maximum size of the map. When max size is reached,
map is evicted based on the policy defined.
Any integer between 0 and Integer.MAX_VALUE. 0 means
Integer.MAX_VALUE. Default is 0.
-->
<max-size policy="PER_NODE">0</max-size>
<!--
When max. size is reached, specified percentage of
the map will be evicted. Any integer between 0 and 100.
If 25 is set for example, 25% of the entries will
get evicted.
-->
<eviction-percentage>25</eviction-percentage>
<!--
While recovering from split-brain (network partitioning),
map entries in the small cluster will merge into the bigger cluster
based on the policy set here. When an entry merge into the
cluster, there might an existing entry with the same key already.
Values of these entries might be different for that same key.
Which value should be set for the key? Conflict is resolved by
the policy set here. Default policy is PutIfAbsentMapMergePolicy
There are built-in merge policies such as
com.hazelcast.map.merge.PassThroughMergePolicy; entry will be added if there is no existing entry for the key.
com.hazelcast.map.merge.PutIfAbsentMapMergePolicy ; entry will be added if the merging entry doesn't exist in the cluster.
com.hazelcast.map.merge.HigherHitsMapMergePolicy ; entry with the higher hits wins.
com.hazelcast.map.merge.LatestUpdateMapMergePolicy ; entry with the latest update wins.
-->
<merge-policy>com.hazelcast.map.merge.PassThroughMergePolicy</merge-policy>
</map>
<map name="org.apache.karaf.cellar.log">
<time-to-live-seconds>0</time-to-live-seconds>
<max-idle-seconds>0</max-idle-seconds>
<eviction-policy>LRU</eviction-policy>
<max-size policy="PER_PARTITION">5000</max-size>
<eviction-percentage>25</eviction-percentage>
<backup-count>0</backup-count>
</map>

<multimap name="default">
<backup-count>1</backup-count>
<value-collection-type>SET</value-collection-type>
</multimap>

<multimap name="default">
<backup-count>1</backup-count>
<value-collection-type>SET</value-collection-type>
</multimap>

<list name="default">
<backup-count>1</backup-count>
</list>

<set name="default">
<backup-count>1</backup-count>
</set>

<jobtracker name="default">
<max-thread-size>0</max-thread-size>
<!-- Queue size 0 means number of partitions * 2 -->
<queue-size>0</queue-size>
<retry-count>0</retry-count>
<chunk-size>1000</chunk-size>
<communicate-stats>true</communicate-stats>
<topology-changed-strategy>CANCEL_RUNNING_OPERATION</topology-changed-strategy>
</jobtracker>

<semaphore name="default">
<initial-permits>0</initial-permits>
<backup-count>1</backup-count>
<async-backup-count>0</async-backup-count>
</semaphore>

<serialization>
<portable-version>0</portable-version>
</serialization>

<services enable-defaults="true" />

<properties>
<property name="hazelcast.max.no.heartbeat.seconds">60</property>
<property name="hazelcast.max.no.master.confirmation.seconds">120</property>
</properties>
</hazelcast>
62 changes: 62 additions & 0 deletions etc/org.apache.karaf.cellar.groups.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#
# This property stores the cluster groups for which the local node is member
#
groups = default

#
# Filtering of the bundles in the default cluster group
#
default.bundle.whitelist.inbound=*
default.bundle.whitelist.outbound=*
default.bundle.blacklist.inbound=*.xml
default.bundle.blacklist.outbound=*.xml

#
# Filtering of the configurations in the default cluster group
#
default.config.whitelist.inbound=*
default.config.whitelist.outbound=*
default.config.blacklist.inbound=org.apache.felix.fileinstall*, \
org.apache.karaf.management, \
org.apache.karaf.shell, \
org.ops4j.pax.web, \
org.apache.aries.transaction, \
org.ops4j.pax.logging, \
org.apache.karaf.cellar.node, \
org.apache.karaf.cellar.groups
default.config.blacklist.outbound=org.apache.felix.fileinstall*, \
org.apache.karaf.management, \
org.apache.karaf.shell, \
org.ops4j.pax.web, \
org.apache.aries.transaction, \
org.ops4j.pax.logging, \
org.apache.karaf.cellar.node, \
org.apache.karaf.cellar.groups

#
# Filtering of the features in the default cluster group
#
default.feature.whitelist.inbound=*
default.feature.whitelist.outbound=*
default.feature.blacklist.inbound=none
default.feature.blacklist.outbound=none

#
# The following properties define the behavior to use when the node joins the cluster (the usage of the bootstrap
# synchronizer), per cluster group and per resource.
# The following values are accepted:
# disabled: means that the synchronizer doesn't sync cluster group and node states
# cluster: the synchronizer retrieves the state from the cluster group first (pull first), and push the node the state
# to the cluster group after (push after)
# node: the synchronizer push the node state to the cluster group (push first), and pull the state from the cluster group
# after (pull after)
# clusterOnly: the cluster is the "master", the node only retrieves and applies the cluster group state, nothing is
# pushed to the cluster group
# nodeOnly: the node is the "master", the node pushes his state to the cluster group, nothing is pulled from the
# cluster group
#
default.bundle.sync=disabled
default.config.sync=disabled
default.feature.sync=disabled
default.obr.urls.sync=disabled
default.balanced.servlet.sync=disabled
47 changes: 47 additions & 0 deletions etc/org.apache.karaf.cellar.node.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#
# This node is member of the following cluster groups
#
groups = default

#
# The following properties define if the local event listeners (per resource)
# A local listener listens for local events (like bundle install, etc) and broadcast this state change to the cluster
#
bundle.listener = false
config.listener = false
feature.listener = false

#
# Cluster event producer
#
producer = true

#
# Cluster event consumer
#
consumer = true

#
# Cluster event handlers
#
# bundle event handler
handler.org.apache.karaf.cellar.bundle.BundleEventHandler = true
# config event handler
handler.org.apache.karaf.cellar.config.ConfigurationEventHandler = true
# feature event handler
handler.org.apache.karaf.cellar.features.FeaturesEventHandler = true
# DOSGi event handler
handler.org.apache.karaf.cellar.dosgi.RemoteServiceCallHandler = true
# OSGi event handler
handler.org.apache.karaf.cellar.event.ClusterEventHandler = true
# OBR event handler
handler.org.apache.karaf.cellar.obr.ObrBundleEventHandler = true
handler.org.apache.karaf.cellar.obr.ObrUrlEventHandler = true
# HTTP balancer event handler
handler.org.apache.karaf.cellar.http.balancer.BalancerEventHandler = true

#
# Excluded config properties from the sync
# Some config properties can be considered as local to a node, and should not be sync on the cluster.
#
config.excluded.properties = felix.fileinstall.filename, felix.fileinstall.dir, felix.fileinstall.tmpdir, org.ops4j.pax.url.mvn.defaultRepositories
Loading

0 comments on commit ad85558

Please sign in to comment.