diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components.properties b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components.properties index 0bedb28dab1db..bd2c8b1365d25 100644 --- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components.properties +++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components.properties @@ -150,6 +150,7 @@ hazelcast-instance hazelcast-list hazelcast-map hazelcast-multimap +hazelcast-pncounter hazelcast-queue hazelcast-replicatedmap hazelcast-ringbuffer diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/hazelcast-atomicvalue.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/hazelcast-atomicvalue.json index 9989ea1526fff..86a9f41c33e03 100644 --- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/hazelcast-atomicvalue.json +++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/hazelcast-atomicvalue.json @@ -4,7 +4,7 @@ "name": "hazelcast-atomicvalue", "title": "Hazelcast Atomic Number", "description": "Increment, decrement, set, etc. Hazelcast atomic number (a grid wide number).", - "deprecated": false, + "deprecated": true, "firstVersion": "2.7.0", "label": "cache,clustering", "javaType": "org.apache.camel.component.hazelcast.atomicnumber.HazelcastAtomicnumberComponent", diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/hazelcast-pncounter.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/hazelcast-pncounter.json new file mode 100644 index 0000000000000..b525c1d57882f --- /dev/null +++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/hazelcast-pncounter.json @@ -0,0 +1,40 @@ +{ + "component": { + "kind": "component", + "name": "hazelcast-pncounter", + "title": "Hazelcast PN Counter", + "description": "Increment, decrement, get, etc. operations on a Hazelcast PN Counter (CRDT counter).", + "deprecated": false, + "firstVersion": "4.19.0", + "label": "cache,clustering", + "javaType": "org.apache.camel.component.hazelcast.pncounter.HazelcastPNCounterComponent", + "supportLevel": "Preview", + "groupId": "org.apache.camel", + "artifactId": "camel-hazelcast", + "version": "4.19.0-SNAPSHOT", + "scheme": "hazelcast-pncounter", + "extendsScheme": "", + "syntax": "hazelcast-pncounter:cacheName", + "async": false, + "api": false, + "consumerOnly": false, + "producerOnly": true, + "lenientProperties": false, + "browsable": false, + "remote": true + }, + "componentProperties": { + "lazyStartProducer": { "index": 0, "kind": "property", "displayName": "Lazy Start Producer", "group": "producer", "label": "producer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel's routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing." }, + "autowiredEnabled": { "index": 1, "kind": "property", "displayName": "Autowired Enabled", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching type, which then gets configured on the component. This can be used for automatic configuring JDBC data sources, JMS connection factories, AWS Clients, etc." }, + "hazelcastInstance": { "index": 2, "kind": "property", "displayName": "Hazelcast Instance", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "com.hazelcast.core.HazelcastInstance", "deprecated": false, "autowired": false, "secret": false, "description": "The hazelcast instance reference which can be used for hazelcast endpoint. If you don't specify the instance reference, camel use the default hazelcast instance from the camel-hazelcast instance." }, + "hazelcastMode": { "index": 3, "kind": "property", "displayName": "Hazelcast Mode", "group": "advanced", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "node", "description": "The hazelcast mode reference which kind of instance should be used. If you don't specify the mode, then the node mode will be the default." } + }, + "properties": { + "cacheName": { "index": 0, "kind": "path", "displayName": "Cache Name", "group": "producer", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The name of the cache" }, + "defaultOperation": { "index": 1, "kind": "parameter", "displayName": "Default Operation", "group": "producer", "label": "", "required": false, "type": "enum", "javaType": "org.apache.camel.component.hazelcast.HazelcastOperation", "enum": [ "put", "delete", "get", "update", "query", "getAll", "clear", "putIfAbsent", "addAll", "removeAll", "retainAll", "evict", "evictAll", "valueCount", "containsKey", "containsValue", "getKeys", "removeValue", "increment", "decrement", "setValue", "destroy", "compareAndSet", "getAndAdd", "add", "offer", "peek", "poll", "remainingCapacity", "drainTo", "removeIf", "take", "publish", "readOnceHead", "readOnceTail", "capacity" ], "deprecated": false, "autowired": false, "secret": false, "description": "To specify a default operation to use, if no operation header has been provided." }, + "hazelcastConfigUri": { "index": 2, "kind": "parameter", "displayName": "Hazelcast Config Uri", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "supportFileReference": true, "description": "Hazelcast configuration file." }, + "hazelcastInstance": { "index": 3, "kind": "parameter", "displayName": "Hazelcast Instance", "group": "producer", "label": "", "required": false, "type": "object", "javaType": "com.hazelcast.core.HazelcastInstance", "deprecated": false, "autowired": false, "secret": false, "description": "The hazelcast instance reference which can be used for hazelcast endpoint." }, + "hazelcastInstanceName": { "index": 4, "kind": "parameter", "displayName": "Hazelcast Instance Name", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The hazelcast instance reference name which can be used for hazelcast endpoint. If you don't specify the instance reference, camel use the default hazelcast instance from the camel-hazelcast instance." }, + "lazyStartProducer": { "index": 5, "kind": "parameter", "displayName": "Lazy Start Producer", "group": "producer (advanced)", "label": "producer,advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel's routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing." } + } +} diff --git a/components/camel-hazelcast/src/generated/java/org/apache/camel/component/hazelcast/pncounter/HazelcastPNCounterComponentConfigurer.java b/components/camel-hazelcast/src/generated/java/org/apache/camel/component/hazelcast/pncounter/HazelcastPNCounterComponentConfigurer.java new file mode 100644 index 0000000000000..b5eb5ea13e06b --- /dev/null +++ b/components/camel-hazelcast/src/generated/java/org/apache/camel/component/hazelcast/pncounter/HazelcastPNCounterComponentConfigurer.java @@ -0,0 +1,69 @@ +/* Generated by camel build tools - do NOT edit this file! */ +package org.apache.camel.component.hazelcast.pncounter; + +import javax.annotation.processing.Generated; +import java.util.Map; + +import org.apache.camel.CamelContext; +import org.apache.camel.spi.ExtendedPropertyConfigurerGetter; +import org.apache.camel.spi.PropertyConfigurerGetter; +import org.apache.camel.spi.ConfigurerStrategy; +import org.apache.camel.spi.GeneratedPropertyConfigurer; +import org.apache.camel.util.CaseInsensitiveMap; +import org.apache.camel.support.component.PropertyConfigurerSupport; + +/** + * Generated by camel build tools - do NOT edit this file! + */ +@Generated("org.apache.camel.maven.packaging.EndpointSchemaGeneratorMojo") +@SuppressWarnings("unchecked") +public class HazelcastPNCounterComponentConfigurer extends PropertyConfigurerSupport implements GeneratedPropertyConfigurer, PropertyConfigurerGetter { + + @Override + public boolean configure(CamelContext camelContext, Object obj, String name, Object value, boolean ignoreCase) { + HazelcastPNCounterComponent target = (HazelcastPNCounterComponent) obj; + switch (ignoreCase ? name.toLowerCase() : name) { + case "autowiredenabled": + case "autowiredEnabled": target.setAutowiredEnabled(property(camelContext, boolean.class, value)); return true; + case "hazelcastinstance": + case "hazelcastInstance": target.setHazelcastInstance(property(camelContext, com.hazelcast.core.HazelcastInstance.class, value)); return true; + case "hazelcastmode": + case "hazelcastMode": target.setHazelcastMode(property(camelContext, java.lang.String.class, value)); return true; + case "lazystartproducer": + case "lazyStartProducer": target.setLazyStartProducer(property(camelContext, boolean.class, value)); return true; + default: return false; + } + } + + @Override + public Class getOptionType(String name, boolean ignoreCase) { + switch (ignoreCase ? name.toLowerCase() : name) { + case "autowiredenabled": + case "autowiredEnabled": return boolean.class; + case "hazelcastinstance": + case "hazelcastInstance": return com.hazelcast.core.HazelcastInstance.class; + case "hazelcastmode": + case "hazelcastMode": return java.lang.String.class; + case "lazystartproducer": + case "lazyStartProducer": return boolean.class; + default: return null; + } + } + + @Override + public Object getOptionValue(Object obj, String name, boolean ignoreCase) { + HazelcastPNCounterComponent target = (HazelcastPNCounterComponent) obj; + switch (ignoreCase ? name.toLowerCase() : name) { + case "autowiredenabled": + case "autowiredEnabled": return target.isAutowiredEnabled(); + case "hazelcastinstance": + case "hazelcastInstance": return target.getHazelcastInstance(); + case "hazelcastmode": + case "hazelcastMode": return target.getHazelcastMode(); + case "lazystartproducer": + case "lazyStartProducer": return target.isLazyStartProducer(); + default: return null; + } + } +} + diff --git a/components/camel-hazelcast/src/generated/java/org/apache/camel/component/hazelcast/pncounter/HazelcastPNCounterEndpointConfigurer.java b/components/camel-hazelcast/src/generated/java/org/apache/camel/component/hazelcast/pncounter/HazelcastPNCounterEndpointConfigurer.java new file mode 100644 index 0000000000000..9821d418e8442 --- /dev/null +++ b/components/camel-hazelcast/src/generated/java/org/apache/camel/component/hazelcast/pncounter/HazelcastPNCounterEndpointConfigurer.java @@ -0,0 +1,75 @@ +/* Generated by camel build tools - do NOT edit this file! */ +package org.apache.camel.component.hazelcast.pncounter; + +import javax.annotation.processing.Generated; +import java.util.Map; + +import org.apache.camel.CamelContext; +import org.apache.camel.spi.ExtendedPropertyConfigurerGetter; +import org.apache.camel.spi.PropertyConfigurerGetter; +import org.apache.camel.spi.ConfigurerStrategy; +import org.apache.camel.spi.GeneratedPropertyConfigurer; +import org.apache.camel.util.CaseInsensitiveMap; +import org.apache.camel.support.component.PropertyConfigurerSupport; + +/** + * Generated by camel build tools - do NOT edit this file! + */ +@Generated("org.apache.camel.maven.packaging.EndpointSchemaGeneratorMojo") +@SuppressWarnings("unchecked") +public class HazelcastPNCounterEndpointConfigurer extends PropertyConfigurerSupport implements GeneratedPropertyConfigurer, PropertyConfigurerGetter { + + @Override + public boolean configure(CamelContext camelContext, Object obj, String name, Object value, boolean ignoreCase) { + HazelcastPNCounterEndpoint target = (HazelcastPNCounterEndpoint) obj; + switch (ignoreCase ? name.toLowerCase() : name) { + case "defaultoperation": + case "defaultOperation": target.setDefaultOperation(property(camelContext, org.apache.camel.component.hazelcast.HazelcastOperation.class, value)); return true; + case "hazelcastconfiguri": + case "hazelcastConfigUri": target.setHazelcastConfigUri(property(camelContext, java.lang.String.class, value)); return true; + case "hazelcastinstance": + case "hazelcastInstance": target.setHazelcastInstance(property(camelContext, com.hazelcast.core.HazelcastInstance.class, value)); return true; + case "hazelcastinstancename": + case "hazelcastInstanceName": target.setHazelcastInstanceName(property(camelContext, java.lang.String.class, value)); return true; + case "lazystartproducer": + case "lazyStartProducer": target.setLazyStartProducer(property(camelContext, boolean.class, value)); return true; + default: return false; + } + } + + @Override + public Class getOptionType(String name, boolean ignoreCase) { + switch (ignoreCase ? name.toLowerCase() : name) { + case "defaultoperation": + case "defaultOperation": return org.apache.camel.component.hazelcast.HazelcastOperation.class; + case "hazelcastconfiguri": + case "hazelcastConfigUri": return java.lang.String.class; + case "hazelcastinstance": + case "hazelcastInstance": return com.hazelcast.core.HazelcastInstance.class; + case "hazelcastinstancename": + case "hazelcastInstanceName": return java.lang.String.class; + case "lazystartproducer": + case "lazyStartProducer": return boolean.class; + default: return null; + } + } + + @Override + public Object getOptionValue(Object obj, String name, boolean ignoreCase) { + HazelcastPNCounterEndpoint target = (HazelcastPNCounterEndpoint) obj; + switch (ignoreCase ? name.toLowerCase() : name) { + case "defaultoperation": + case "defaultOperation": return target.getDefaultOperation(); + case "hazelcastconfiguri": + case "hazelcastConfigUri": return target.getHazelcastConfigUri(); + case "hazelcastinstance": + case "hazelcastInstance": return target.getHazelcastInstance(); + case "hazelcastinstancename": + case "hazelcastInstanceName": return target.getHazelcastInstanceName(); + case "lazystartproducer": + case "lazyStartProducer": return target.isLazyStartProducer(); + default: return null; + } + } +} + diff --git a/components/camel-hazelcast/src/generated/java/org/apache/camel/component/hazelcast/pncounter/HazelcastPNCounterEndpointUriFactory.java b/components/camel-hazelcast/src/generated/java/org/apache/camel/component/hazelcast/pncounter/HazelcastPNCounterEndpointUriFactory.java new file mode 100644 index 0000000000000..2b6b14e72ea41 --- /dev/null +++ b/components/camel-hazelcast/src/generated/java/org/apache/camel/component/hazelcast/pncounter/HazelcastPNCounterEndpointUriFactory.java @@ -0,0 +1,75 @@ +/* Generated by camel build tools - do NOT edit this file! */ +package org.apache.camel.component.hazelcast.pncounter; + +import javax.annotation.processing.Generated; +import java.net.URISyntaxException; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import org.apache.camel.spi.EndpointUriFactory; + +/** + * Generated by camel build tools - do NOT edit this file! + */ +@Generated("org.apache.camel.maven.packaging.GenerateEndpointUriFactoryMojo") +public class HazelcastPNCounterEndpointUriFactory extends org.apache.camel.support.component.EndpointUriFactorySupport implements EndpointUriFactory { + + private static final String BASE = ":cacheName"; + + private static final Set PROPERTY_NAMES; + private static final Set SECRET_PROPERTY_NAMES; + private static final Map MULTI_VALUE_PREFIXES; + static { + Set props = new HashSet<>(6); + props.add("cacheName"); + props.add("defaultOperation"); + props.add("hazelcastConfigUri"); + props.add("hazelcastInstance"); + props.add("hazelcastInstanceName"); + props.add("lazyStartProducer"); + PROPERTY_NAMES = Collections.unmodifiableSet(props); + SECRET_PROPERTY_NAMES = Collections.emptySet(); + MULTI_VALUE_PREFIXES = Collections.emptyMap(); + } + + @Override + public boolean isEnabled(String scheme) { + return "hazelcast-pncounter".equals(scheme); + } + + @Override + public String buildUri(String scheme, Map properties, boolean encode) throws URISyntaxException { + String syntax = scheme + BASE; + String uri = syntax; + + Map copy = new HashMap<>(properties); + + uri = buildPathParameter(syntax, uri, "cacheName", null, true, copy); + uri = buildQueryParameters(uri, copy, encode); + return uri; + } + + @Override + public Set propertyNames() { + return PROPERTY_NAMES; + } + + @Override + public Set secretPropertyNames() { + return SECRET_PROPERTY_NAMES; + } + + @Override + public Map multiValuePrefixes() { + return MULTI_VALUE_PREFIXES; + } + + @Override + public boolean isLenientProperties() { + return false; + } +} + diff --git a/components/camel-hazelcast/src/generated/resources/META-INF/org/apache/camel/component/hazelcast/atomicnumber/hazelcast-atomicvalue.json b/components/camel-hazelcast/src/generated/resources/META-INF/org/apache/camel/component/hazelcast/atomicnumber/hazelcast-atomicvalue.json index 9989ea1526fff..86a9f41c33e03 100644 --- a/components/camel-hazelcast/src/generated/resources/META-INF/org/apache/camel/component/hazelcast/atomicnumber/hazelcast-atomicvalue.json +++ b/components/camel-hazelcast/src/generated/resources/META-INF/org/apache/camel/component/hazelcast/atomicnumber/hazelcast-atomicvalue.json @@ -4,7 +4,7 @@ "name": "hazelcast-atomicvalue", "title": "Hazelcast Atomic Number", "description": "Increment, decrement, set, etc. Hazelcast atomic number (a grid wide number).", - "deprecated": false, + "deprecated": true, "firstVersion": "2.7.0", "label": "cache,clustering", "javaType": "org.apache.camel.component.hazelcast.atomicnumber.HazelcastAtomicnumberComponent", diff --git a/components/camel-hazelcast/src/generated/resources/META-INF/org/apache/camel/component/hazelcast/pncounter/hazelcast-pncounter.json b/components/camel-hazelcast/src/generated/resources/META-INF/org/apache/camel/component/hazelcast/pncounter/hazelcast-pncounter.json new file mode 100644 index 0000000000000..b525c1d57882f --- /dev/null +++ b/components/camel-hazelcast/src/generated/resources/META-INF/org/apache/camel/component/hazelcast/pncounter/hazelcast-pncounter.json @@ -0,0 +1,40 @@ +{ + "component": { + "kind": "component", + "name": "hazelcast-pncounter", + "title": "Hazelcast PN Counter", + "description": "Increment, decrement, get, etc. operations on a Hazelcast PN Counter (CRDT counter).", + "deprecated": false, + "firstVersion": "4.19.0", + "label": "cache,clustering", + "javaType": "org.apache.camel.component.hazelcast.pncounter.HazelcastPNCounterComponent", + "supportLevel": "Preview", + "groupId": "org.apache.camel", + "artifactId": "camel-hazelcast", + "version": "4.19.0-SNAPSHOT", + "scheme": "hazelcast-pncounter", + "extendsScheme": "", + "syntax": "hazelcast-pncounter:cacheName", + "async": false, + "api": false, + "consumerOnly": false, + "producerOnly": true, + "lenientProperties": false, + "browsable": false, + "remote": true + }, + "componentProperties": { + "lazyStartProducer": { "index": 0, "kind": "property", "displayName": "Lazy Start Producer", "group": "producer", "label": "producer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel's routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing." }, + "autowiredEnabled": { "index": 1, "kind": "property", "displayName": "Autowired Enabled", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching type, which then gets configured on the component. This can be used for automatic configuring JDBC data sources, JMS connection factories, AWS Clients, etc." }, + "hazelcastInstance": { "index": 2, "kind": "property", "displayName": "Hazelcast Instance", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "com.hazelcast.core.HazelcastInstance", "deprecated": false, "autowired": false, "secret": false, "description": "The hazelcast instance reference which can be used for hazelcast endpoint. If you don't specify the instance reference, camel use the default hazelcast instance from the camel-hazelcast instance." }, + "hazelcastMode": { "index": 3, "kind": "property", "displayName": "Hazelcast Mode", "group": "advanced", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "node", "description": "The hazelcast mode reference which kind of instance should be used. If you don't specify the mode, then the node mode will be the default." } + }, + "properties": { + "cacheName": { "index": 0, "kind": "path", "displayName": "Cache Name", "group": "producer", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The name of the cache" }, + "defaultOperation": { "index": 1, "kind": "parameter", "displayName": "Default Operation", "group": "producer", "label": "", "required": false, "type": "enum", "javaType": "org.apache.camel.component.hazelcast.HazelcastOperation", "enum": [ "put", "delete", "get", "update", "query", "getAll", "clear", "putIfAbsent", "addAll", "removeAll", "retainAll", "evict", "evictAll", "valueCount", "containsKey", "containsValue", "getKeys", "removeValue", "increment", "decrement", "setValue", "destroy", "compareAndSet", "getAndAdd", "add", "offer", "peek", "poll", "remainingCapacity", "drainTo", "removeIf", "take", "publish", "readOnceHead", "readOnceTail", "capacity" ], "deprecated": false, "autowired": false, "secret": false, "description": "To specify a default operation to use, if no operation header has been provided." }, + "hazelcastConfigUri": { "index": 2, "kind": "parameter", "displayName": "Hazelcast Config Uri", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "supportFileReference": true, "description": "Hazelcast configuration file." }, + "hazelcastInstance": { "index": 3, "kind": "parameter", "displayName": "Hazelcast Instance", "group": "producer", "label": "", "required": false, "type": "object", "javaType": "com.hazelcast.core.HazelcastInstance", "deprecated": false, "autowired": false, "secret": false, "description": "The hazelcast instance reference which can be used for hazelcast endpoint." }, + "hazelcastInstanceName": { "index": 4, "kind": "parameter", "displayName": "Hazelcast Instance Name", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The hazelcast instance reference name which can be used for hazelcast endpoint. If you don't specify the instance reference, camel use the default hazelcast instance from the camel-hazelcast instance." }, + "lazyStartProducer": { "index": 5, "kind": "parameter", "displayName": "Lazy Start Producer", "group": "producer (advanced)", "label": "producer,advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel's routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing." } + } +} diff --git a/components/camel-hazelcast/src/generated/resources/META-INF/services/org/apache/camel/component.properties b/components/camel-hazelcast/src/generated/resources/META-INF/services/org/apache/camel/component.properties index 91c3cdcd33cbc..8051f6c13e8a9 100644 --- a/components/camel-hazelcast/src/generated/resources/META-INF/services/org/apache/camel/component.properties +++ b/components/camel-hazelcast/src/generated/resources/META-INF/services/org/apache/camel/component.properties @@ -1,5 +1,5 @@ # Generated by camel build tools - do NOT edit this file! -components=hazelcast-atomicvalue hazelcast-instance hazelcast-list hazelcast-map hazelcast-multimap hazelcast-queue hazelcast-replicatedmap hazelcast-ringbuffer hazelcast-seda hazelcast-set hazelcast-topic +components=hazelcast-atomicvalue hazelcast-instance hazelcast-list hazelcast-map hazelcast-multimap hazelcast-pncounter hazelcast-queue hazelcast-replicatedmap hazelcast-ringbuffer hazelcast-seda hazelcast-set hazelcast-topic groupId=org.apache.camel artifactId=camel-hazelcast version=4.19.0-SNAPSHOT diff --git a/components/camel-hazelcast/src/generated/resources/META-INF/services/org/apache/camel/component/hazelcast-pncounter b/components/camel-hazelcast/src/generated/resources/META-INF/services/org/apache/camel/component/hazelcast-pncounter new file mode 100644 index 0000000000000..81eaf0d56555b --- /dev/null +++ b/components/camel-hazelcast/src/generated/resources/META-INF/services/org/apache/camel/component/hazelcast-pncounter @@ -0,0 +1,2 @@ +# Generated by camel build tools - do NOT edit this file! +class=org.apache.camel.component.hazelcast.pncounter.HazelcastPNCounterComponent diff --git a/components/camel-hazelcast/src/generated/resources/META-INF/services/org/apache/camel/configurer/hazelcast-pncounter-component b/components/camel-hazelcast/src/generated/resources/META-INF/services/org/apache/camel/configurer/hazelcast-pncounter-component new file mode 100644 index 0000000000000..4914da7ccb52c --- /dev/null +++ b/components/camel-hazelcast/src/generated/resources/META-INF/services/org/apache/camel/configurer/hazelcast-pncounter-component @@ -0,0 +1,2 @@ +# Generated by camel build tools - do NOT edit this file! +class=org.apache.camel.component.hazelcast.pncounter.HazelcastPNCounterComponentConfigurer diff --git a/components/camel-hazelcast/src/generated/resources/META-INF/services/org/apache/camel/configurer/hazelcast-pncounter-endpoint b/components/camel-hazelcast/src/generated/resources/META-INF/services/org/apache/camel/configurer/hazelcast-pncounter-endpoint new file mode 100644 index 0000000000000..9eb6c28589f1e --- /dev/null +++ b/components/camel-hazelcast/src/generated/resources/META-INF/services/org/apache/camel/configurer/hazelcast-pncounter-endpoint @@ -0,0 +1,2 @@ +# Generated by camel build tools - do NOT edit this file! +class=org.apache.camel.component.hazelcast.pncounter.HazelcastPNCounterEndpointConfigurer diff --git a/components/camel-hazelcast/src/generated/resources/META-INF/services/org/apache/camel/urifactory/hazelcast-pncounter-endpoint b/components/camel-hazelcast/src/generated/resources/META-INF/services/org/apache/camel/urifactory/hazelcast-pncounter-endpoint new file mode 100644 index 0000000000000..8eb9683b96ace --- /dev/null +++ b/components/camel-hazelcast/src/generated/resources/META-INF/services/org/apache/camel/urifactory/hazelcast-pncounter-endpoint @@ -0,0 +1,2 @@ +# Generated by camel build tools - do NOT edit this file! +class=org.apache.camel.component.hazelcast.pncounter.HazelcastPNCounterEndpointUriFactory diff --git a/components/camel-hazelcast/src/main/docs/hazelcast-atomicvalue-component.adoc b/components/camel-hazelcast/src/main/docs/hazelcast-atomicvalue-component.adoc index 30a3d55413cce..d5d45c1faa030 100644 --- a/components/camel-hazelcast/src/main/docs/hazelcast-atomicvalue-component.adoc +++ b/components/camel-hazelcast/src/main/docs/hazelcast-atomicvalue-component.adoc @@ -1,10 +1,11 @@ -= Hazelcast Atomic Number Component += Hazelcast Atomic Number Component (deprecated) :doctitle: Hazelcast Atomic Number :shortname: hazelcast-atomicvalue :artifactid: camel-hazelcast :description: Increment, decrement, set, etc. Hazelcast atomic number (a grid wide number). :since: 2.7 -:supportlevel: Stable +:supportlevel: Stable-deprecated +:deprecated: *deprecated* :tabs-sync-option: :component-header: Only producer is supported //Manually maintained attributes @@ -15,6 +16,14 @@ *{component-header}* +[WARNING] +==== +*Deprecated*: This component is deprecated as of Camel 4.19.0 and will be removed in a future release. + +Since Hazelcast 5.5, IAtomicLong requires the CP Subsystem which is only available in Hazelcast Enterprise Edition. +This component will throw `UnsupportedOperationException` at runtime when used with Hazelcast Community Edition 5.5+. +==== + The http://www.hazelcast.com/[Hazelcast] atomic number component is one of Camel Hazelcast Components which allows you to access Hazelcast atomic number. An atomic number is an object that simply provides a grid wide number (long). diff --git a/components/camel-hazelcast/src/main/docs/hazelcast-pncounter-component.adoc b/components/camel-hazelcast/src/main/docs/hazelcast-pncounter-component.adoc new file mode 100644 index 0000000000000..47e9401f0d938 --- /dev/null +++ b/components/camel-hazelcast/src/main/docs/hazelcast-pncounter-component.adoc @@ -0,0 +1,203 @@ += Hazelcast PN Counter Component +:doctitle: Hazelcast PN Counter +:shortname: hazelcast-pncounter +:artifactid: camel-hazelcast +:description: Increment, decrement, get, etc. operations on a Hazelcast PN Counter (CRDT counter). +:since: 4.19 +:supportlevel: Preview +:tabs-sync-option: +:component-header: Only producer is supported +//Manually maintained attributes +:group: Hazelcast +:camel-spring-boot-name: hazelcast + +*Since Camel {since}* + +*{component-header}* + +The http://www.hazelcast.com/[Hazelcast] PN Counter component is one of Camel Hazelcast Components which allows you to access a Hazelcast PN Counter (CRDT counter). +A PN Counter is a Conflict-free Replicated Data Type (CRDT) that provides a distributed counter with eventual consistency guarantees. + +This component is not a direct replacement for the hazelcast-atomicvalue component that is availble in Camel 2.7 -> 4.19, but it does replicates most of the functionality (get / increment / decrement / getAndAdd / destroy) apart from the compare method. + + +// component options: START +include::partial$component-configure-options.adoc[] +include::partial$component-endpoint-options.adoc[] +include::partial$component-endpoint-headers.adoc[] +// component options: END + + +== PN Counter producer - to("hazelcast-pncounter:foo") + +The operations for this producer are: + +* get +* increment (+1) +* decrement (-1) +* getAndAdd +* destroy + +NOTE: PNCounter is a CRDT (Conflict-free Replicated Data Type) that provides eventual consistency. Operations are local and fast but do not support strong consistency operations like `compareAndSet` or `set`. + +=== Example for *increment*: + +[tabs] +==== + +Java DSL:: ++ +[source,java] +------------------------------------------------------------------------------------------ +from("direct:increment") +.setHeader(HazelcastConstants.OPERATION, constant(HazelcastOperation.INCREMENT)) +.toF("hazelcast-%sfoo", HazelcastConstants.PNCOUNTER_PREFIX); +------------------------------------------------------------------------------------------ + +Spring XML:: ++ +[source,xml] +----------------------------------------------------------------------------------------------- + + + + increment + + + +----------------------------------------------------------------------------------------------- + +==== + +The actual value (after increment) will be provided inside the message body. + +=== Example for *decrement*: + +[tabs] +==== + +Java DSL:: ++ +[source,java] +------------------------------------------------------------------------------------------ +from("direct:decrement") +.setHeader(HazelcastConstants.OPERATION, constant(HazelcastOperation.DECREMENT)) +.toF("hazelcast-%sfoo", HazelcastConstants.PNCOUNTER_PREFIX); +------------------------------------------------------------------------------------------ + +Spring XML:: ++ +[source,xml] +----------------------------------------------------------------------------------------------- + + + + decrement + + + +----------------------------------------------------------------------------------------------- + +==== + +The actual value (after decrement) will be provided inside the message body. + +=== Example for *get*: + +[tabs] +==== + +Java DSL:: ++ +[source,java] +------------------------------------------------------------------------------------ +from("direct:get") +.setHeader(HazelcastConstants.OPERATION, constant(HazelcastOperation.GET)) +.toF("hazelcast-%sfoo", HazelcastConstants.PNCOUNTER_PREFIX); +------------------------------------------------------------------------------------ + +Spring XML:: ++ +[source,xml] +----------------------------------------------------------------------------------------------- + + + + get + + + +----------------------------------------------------------------------------------------------- + +==== + +You can get the counter value with +`long body = template.requestBody("direct:get", null, Long.class);`. + +=== Example for *getAndAdd*: + +[tabs] +==== + +Java DSL:: ++ +[source,java] +------------------------------------------------------------------------------------ +from("direct:getAndAdd") +.setHeader(HazelcastConstants.OPERATION, constant(HazelcastOperation.GET_AND_ADD)) +.toF("hazelcast-%sfoo", HazelcastConstants.PNCOUNTER_PREFIX); +------------------------------------------------------------------------------------ + +Spring XML:: ++ +[source,xml] +----------------------------------------------------------------------------------------------- + + + + getAndAdd + + + +----------------------------------------------------------------------------------------------- + +==== + +Provide the delta value in the message body (e.g., 5 to add 5 to the counter): +`long previousValue = template.requestBody("direct:getAndAdd", 5L, Long.class);` + +The previous value (before the add) will be returned in the message body. + +=== Example for *destroy*: + +[tabs] +==== + +Java DSL:: ++ +[source,java] +------------------------------------------------------------------------------------ +from("direct:destroy") +.setHeader(HazelcastConstants.OPERATION, constant(HazelcastOperation.DESTROY)) +.toF("hazelcast-%sfoo", HazelcastConstants.PNCOUNTER_PREFIX); +------------------------------------------------------------------------------------ + +Spring XML:: ++ +[source,xml] +----------------------------------------------------------------------------------------------- + + + + destroy + + + +----------------------------------------------------------------------------------------------- + +==== + +Destroys the PN Counter instance: +`template.sendBody("direct:destroy", null);` + +include::spring-boot:partial$starter.adoc[] diff --git a/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/HazelcastCommand.java b/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/HazelcastCommand.java index 4a57e8e680adf..a7ffe344edc4d 100644 --- a/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/HazelcastCommand.java +++ b/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/HazelcastCommand.java @@ -28,6 +28,7 @@ public enum HazelcastCommand { instance, list, replicatedmap, - ringbuffer + ringbuffer, + pncounter } diff --git a/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/HazelcastConstants.java b/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/HazelcastConstants.java index 0217c4778c8fc..3ed1c2a2e14f0 100644 --- a/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/HazelcastConstants.java +++ b/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/HazelcastConstants.java @@ -28,6 +28,7 @@ public final class HazelcastConstants { public static final String SCHEME_LIST = "hazelcast-list"; public static final String SCHEME_MAP = "hazelcast-map"; public static final String SCHEME_MULTIMAP = "hazelcast-multimap"; + public static final String SCHEME_PNCOUNTER = "hazelcast-pncounter"; public static final String SCHEME_QUEUE = "hazelcast-queue"; public static final String SCHEME_REPLICATED_MAP = "hazelcast-replicatedmap"; public static final String SCHEME_RING_BUFFER = "hazelcast-ringbuffer"; @@ -43,6 +44,7 @@ public final class HazelcastConstants { public static final String REPLICATEDMAP_PREFIX = "replicatedmap:"; public static final String ATOMICNUMBER_PREFIX = "atomicvalue:"; public static final String INSTANCE_PREFIX = "instance:"; + public static final String PNCOUNTER_PREFIX = "pncounter:"; public static final String QUEUE_PREFIX = "queue:"; public static final String TOPIC_PREFIX = "topic:"; public static final String SEDA_PREFIX = "seda:"; diff --git a/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/atomicnumber/HazelcastAtomicnumberComponent.java b/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/atomicnumber/HazelcastAtomicnumberComponent.java index 8691ef7df60cf..e66e3726b15d2 100644 --- a/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/atomicnumber/HazelcastAtomicnumberComponent.java +++ b/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/atomicnumber/HazelcastAtomicnumberComponent.java @@ -24,6 +24,12 @@ import org.apache.camel.component.hazelcast.HazelcastDefaultEndpoint; import org.apache.camel.spi.annotations.Component; +/** + * @deprecated Since Hazelcast 5.5, IAtomicLong requires the CP Subsystem which is only available in Hazelcast + * Enterprise Edition. This component will throw UnsupportedOperationException at runtime when used with + * Hazelcast Community Edition 5.5+. + */ +@Deprecated(since = "4.19.0", forRemoval = true) @Component("hazelcast-atomicvalue") public class HazelcastAtomicnumberComponent extends HazelcastDefaultComponent { diff --git a/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/atomicnumber/HazelcastAtomicnumberEndpoint.java b/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/atomicnumber/HazelcastAtomicnumberEndpoint.java index 65594e142e8ae..9567d519a4254 100644 --- a/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/atomicnumber/HazelcastAtomicnumberEndpoint.java +++ b/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/atomicnumber/HazelcastAtomicnumberEndpoint.java @@ -31,7 +31,12 @@ /** * Increment, decrement, set, etc. Hazelcast atomic number (a grid wide number). + * + * @deprecated Since Hazelcast 5.5, IAtomicLong requires the CP Subsystem which is only available in Hazelcast + * Enterprise Edition. This component will throw UnsupportedOperationException at runtime when used with + * Hazelcast Community Edition 5.5+. */ +@Deprecated(since = "4.19.0", forRemoval = true) @UriEndpoint(firstVersion = "2.7.0", scheme = SCHEME_ATOMIC_VALUE, title = "Hazelcast Atomic Number", syntax = "hazelcast-atomicvalue:cacheName", producerOnly = true, category = { Category.CACHE, Category.CLUSTERING }, diff --git a/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/atomicnumber/HazelcastAtomicnumberProducer.java b/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/atomicnumber/HazelcastAtomicnumberProducer.java index 5761f39b6bd2b..ed58627200786 100644 --- a/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/atomicnumber/HazelcastAtomicnumberProducer.java +++ b/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/atomicnumber/HazelcastAtomicnumberProducer.java @@ -28,6 +28,12 @@ import org.apache.camel.component.hazelcast.HazelcastOperation; import org.apache.camel.util.ObjectHelper; +/** + * @deprecated Since Hazelcast 5.5, IAtomicLong requires the CP Subsystem which is only available in Hazelcast + * Enterprise Edition. This component will throw UnsupportedOperationException at runtime when used with + * Hazelcast Community Edition 5.5+. + */ +@Deprecated(since = "4.19.0", forRemoval = true) public class HazelcastAtomicnumberProducer extends HazelcastDefaultProducer { private final IAtomicLong atomicnumber; diff --git a/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/pncounter/HazelcastPNCounterComponent.java b/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/pncounter/HazelcastPNCounterComponent.java new file mode 100644 index 0000000000000..31152ad70e39a --- /dev/null +++ b/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/pncounter/HazelcastPNCounterComponent.java @@ -0,0 +1,44 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.component.hazelcast.pncounter; + +import java.util.Map; + +import com.hazelcast.core.HazelcastInstance; +import org.apache.camel.CamelContext; +import org.apache.camel.component.hazelcast.HazelcastDefaultComponent; +import org.apache.camel.component.hazelcast.HazelcastDefaultEndpoint; +import org.apache.camel.spi.annotations.Component; + +@Component("hazelcast-pncounter") +public class HazelcastPNCounterComponent extends HazelcastDefaultComponent { + + public HazelcastPNCounterComponent() { + } + + public HazelcastPNCounterComponent(final CamelContext context) { + super(context); + } + + @Override + protected HazelcastDefaultEndpoint doCreateEndpoint( + String uri, String remaining, Map parameters, HazelcastInstance hzInstance) + throws Exception { + return new HazelcastPNCounterEndpoint(hzInstance, uri, this, remaining); + } + +} diff --git a/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/pncounter/HazelcastPNCounterEndpoint.java b/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/pncounter/HazelcastPNCounterEndpoint.java new file mode 100644 index 0000000000000..8d6f8fec75def --- /dev/null +++ b/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/pncounter/HazelcastPNCounterEndpoint.java @@ -0,0 +1,57 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.component.hazelcast.pncounter; + +import com.hazelcast.core.HazelcastInstance; +import org.apache.camel.Category; +import org.apache.camel.Component; +import org.apache.camel.Consumer; +import org.apache.camel.Processor; +import org.apache.camel.Producer; +import org.apache.camel.component.hazelcast.HazelcastCommand; +import org.apache.camel.component.hazelcast.HazelcastConstants; +import org.apache.camel.component.hazelcast.HazelcastDefaultEndpoint; +import org.apache.camel.spi.UriEndpoint; + +import static org.apache.camel.component.hazelcast.HazelcastConstants.SCHEME_PNCOUNTER; + +/** + * Increment, decrement, get, etc. operations on a Hazelcast PN Counter (CRDT counter). + */ +@UriEndpoint(firstVersion = "4.19.0", scheme = SCHEME_PNCOUNTER, title = "Hazelcast PN Counter", + syntax = "hazelcast-pncounter:cacheName", producerOnly = true, + category = { Category.CACHE, Category.CLUSTERING }, + headersClass = HazelcastConstants.class) +public class HazelcastPNCounterEndpoint extends HazelcastDefaultEndpoint { + + public HazelcastPNCounterEndpoint(HazelcastInstance hazelcastInstance, String uri, Component component, + final String cacheName) { + super(hazelcastInstance, uri, component, cacheName); + setCommand(HazelcastCommand.pncounter); + } + + @Override + public Consumer createConsumer(Processor processor) throws Exception { + throw new UnsupportedOperationException("You cannot send messages to this endpoint: " + getEndpointUri()); + } + + @Override + public Producer createProducer() throws Exception { + return new HazelcastPNCounterProducer(hazelcastInstance, this, cacheName); + } + +} diff --git a/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/pncounter/HazelcastPNCounterProducer.java b/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/pncounter/HazelcastPNCounterProducer.java new file mode 100644 index 0000000000000..9840218f054d5 --- /dev/null +++ b/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/pncounter/HazelcastPNCounterProducer.java @@ -0,0 +1,96 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.component.hazelcast.pncounter; + +import com.hazelcast.core.HazelcastInstance; +import com.hazelcast.crdt.pncounter.PNCounter; +import org.apache.camel.Exchange; +import org.apache.camel.component.hazelcast.HazelcastComponentHelper; +import org.apache.camel.component.hazelcast.HazelcastConstants; +import org.apache.camel.component.hazelcast.HazelcastDefaultEndpoint; +import org.apache.camel.component.hazelcast.HazelcastDefaultProducer; +import org.apache.camel.component.hazelcast.HazelcastOperation; + +public class HazelcastPNCounterProducer extends HazelcastDefaultProducer { + + private final PNCounter pnCounter; + + public HazelcastPNCounterProducer(HazelcastInstance hazelcastInstance, HazelcastDefaultEndpoint endpoint, + String cacheName) { + super(endpoint); + this.pnCounter = hazelcastInstance.getPNCounter(cacheName); + } + + @Override + public void process(Exchange exchange) throws Exception { + + HazelcastOperation operation = lookupOperation(exchange); + + switch (operation) { + + case INCREMENT: + this.increment(exchange); + break; + + case DECREMENT: + this.decrement(exchange); + break; + + case GET_AND_ADD: + this.getAndAdd(exchange); + break; + + case GET: + this.get(exchange); + break; + + case DESTROY: + this.destroy(exchange); + break; + + default: + throw new IllegalArgumentException( + String.format("The value '%s' is not allowed for parameter '%s' on the PNCOUNTER.", operation, + HazelcastConstants.OPERATION)); + } + + // finally copy headers + HazelcastComponentHelper.copyHeaders(exchange); + } + + private void get(Exchange exchange) { + exchange.getMessage().setBody(this.pnCounter.get()); + } + + private void increment(Exchange exchange) { + exchange.getMessage().setBody(this.pnCounter.incrementAndGet()); + } + + private void decrement(Exchange exchange) { + exchange.getMessage().setBody(this.pnCounter.decrementAndGet()); + } + + private void getAndAdd(Exchange exchange) { + long delta = exchange.getIn().getBody(Long.class); + exchange.getMessage().setBody(this.pnCounter.getAndAdd(delta)); + } + + private void destroy(Exchange exchange) { + this.pnCounter.destroy(); + } + +} diff --git a/components/camel-hazelcast/src/main/java/org/apache/camel/processor/aggregate/hazelcast/HazelcastAggregationRepository.java b/components/camel-hazelcast/src/main/java/org/apache/camel/processor/aggregate/hazelcast/HazelcastAggregationRepository.java index 544b01a9bdcaf..f76d68f843f33 100644 --- a/components/camel-hazelcast/src/main/java/org/apache/camel/processor/aggregate/hazelcast/HazelcastAggregationRepository.java +++ b/components/camel-hazelcast/src/main/java/org/apache/camel/processor/aggregate/hazelcast/HazelcastAggregationRepository.java @@ -19,7 +19,6 @@ import java.util.Collections; import java.util.Set; import java.util.concurrent.TimeUnit; -import java.util.concurrent.locks.Lock; import com.hazelcast.config.Config; import com.hazelcast.config.XmlConfigBuilder; @@ -233,15 +232,15 @@ public Exchange add(CamelContext camelContext, String key, Exchange exchange) { throw new UnsupportedOperationException(); } LOG.trace("Adding an Exchange with ID {} for key {} in a thread-safe manner.", exchange.getExchangeId(), key); - Lock l = hazelcastInstance.getCPSubsystem().getLock(mapName); + // Use IMap-based locking (community edition compatible) + cache.lock(key); try { - l.lock(); DefaultExchangeHolder newHolder = DefaultExchangeHolder.marshal(exchange, true, allowSerializedHeaders); DefaultExchangeHolder oldHolder = cache.put(key, newHolder); return unmarshallExchange(camelContext, oldHolder); } finally { LOG.trace("Added an Exchange with ID {} for key {} in a thread-safe manner.", exchange.getExchangeId(), key); - l.unlock(); + cache.unlock(key); } } diff --git a/components/camel-hazelcast/src/main/java/org/apache/camel/processor/aggregate/hazelcast/ReplicatedHazelcastAggregationRepository.java b/components/camel-hazelcast/src/main/java/org/apache/camel/processor/aggregate/hazelcast/ReplicatedHazelcastAggregationRepository.java index fc83d30c9c9b7..bd2de42595c05 100644 --- a/components/camel-hazelcast/src/main/java/org/apache/camel/processor/aggregate/hazelcast/ReplicatedHazelcastAggregationRepository.java +++ b/components/camel-hazelcast/src/main/java/org/apache/camel/processor/aggregate/hazelcast/ReplicatedHazelcastAggregationRepository.java @@ -19,7 +19,6 @@ import java.util.Collections; import java.util.Map; import java.util.Set; -import java.util.concurrent.locks.Lock; import com.hazelcast.config.Config; import com.hazelcast.config.XmlConfigBuilder; @@ -55,6 +54,8 @@ public class ReplicatedHazelcastAggregationRepository extends HazelcastAggregati private static final Logger LOG = LoggerFactory.getLogger(ReplicatedHazelcastAggregationRepository.class.getName()); protected Map replicatedCache; protected Map replicatedPersistedCache; + // IMap for distributed locking since ReplicatedMap doesn't support lock operations + protected IMap lockMap; public ReplicatedHazelcastAggregationRepository() { } @@ -192,15 +193,16 @@ public Exchange add(CamelContext camelContext, String key, Exchange exchange) { throw new UnsupportedOperationException(); } LOG.trace("Adding an Exchange with ID {} for key {} in a thread-safe manner.", exchange.getExchangeId(), key); - Lock l = hazelcastInstance.getCPSubsystem().getLock(mapName); + // Use IMap-based distributed locking (community edition compatible) + // ReplicatedMap doesn't support lock operations, so we use a separate IMap for locking + lockMap.lock(key); try { - l.lock(); DefaultExchangeHolder newHolder = DefaultExchangeHolder.marshal(exchange, true, allowSerializedHeaders); DefaultExchangeHolder oldHolder = replicatedCache.put(key, newHolder); return unmarshallExchange(camelContext, oldHolder); } finally { LOG.trace("Added an Exchange with ID {} for key {} in a thread-safe manner.", exchange.getExchangeId(), key); - l.unlock(); + lockMap.unlock(key); } } @@ -345,6 +347,8 @@ protected void doStart() throws Exception { ObjectHelper.notNull(hazelcastInstance, "hazelcastInstance"); } replicatedCache = hazelcastInstance.getReplicatedMap(mapName); + // Create IMap for distributed locking (ReplicatedMap doesn't support lock operations) + lockMap = hazelcastInstance.getMap(mapName + "-locks"); if (useRecovery) { replicatedPersistedCache = hazelcastInstance.getReplicatedMap(persistenceMapName); } diff --git a/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastCamelTestHelper.java b/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastCamelTestHelper.java index f13b51a09f4d8..1e721b51549de 100644 --- a/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastCamelTestHelper.java +++ b/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastCamelTestHelper.java @@ -23,6 +23,7 @@ import org.apache.camel.component.hazelcast.list.HazelcastListComponent; import org.apache.camel.component.hazelcast.map.HazelcastMapComponent; import org.apache.camel.component.hazelcast.multimap.HazelcastMultimapComponent; +import org.apache.camel.component.hazelcast.pncounter.HazelcastPNCounterComponent; import org.apache.camel.component.hazelcast.queue.HazelcastQueueComponent; import org.apache.camel.component.hazelcast.replicatedmap.HazelcastReplicatedmapComponent; import org.apache.camel.component.hazelcast.ringbuffer.HazelcastRingbufferComponent; @@ -51,6 +52,9 @@ public static void registerHazelcastComponents(CamelContext context, HazelcastIn HazelcastMultimapComponent multimap = new HazelcastMultimapComponent(context); multimap.setHazelcastInstance(hazelcastInstance); context.addComponent("hazelcast-multimap", multimap); + HazelcastPNCounterComponent pncounter = new HazelcastPNCounterComponent(context); + pncounter.setHazelcastInstance(hazelcastInstance); + context.addComponent("hazelcast-pncounter", pncounter); HazelcastQueueComponent queue = new HazelcastQueueComponent(context); queue.setHazelcastInstance(hazelcastInstance); context.addComponent("hazelcast-queue", queue); diff --git a/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastErrorMessagesTest.java b/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastErrorMessagesTest.java index 0eaa19609fdd5..0b39792782f9a 100644 --- a/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastErrorMessagesTest.java +++ b/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastErrorMessagesTest.java @@ -39,6 +39,21 @@ public void configure() throws Exception { .contains("You cannot send messages to this endpoint: hazelcast-atomicvalue://foo")); } + @Test + public void testPNCounterConsumer() { + RouteBuilder builder = new RouteBuilder() { + public void configure() throws Exception { + from("hazelcast-pncounter:foo").to("seda:out"); + } + }; + Exception e = assertThrows(Exception.class, () -> { + context.addRoutes(builder); + context.start(); + }); + assertTrue(e.getCause().getMessage() + .contains("You cannot send messages to this endpoint: hazelcast-pncounter://foo")); + } + @Test public void testInstanceProducer() { RouteBuilder builder = new RouteBuilder() { diff --git a/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastPNCounterProducerForSpringTest.java b/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastPNCounterProducerForSpringTest.java new file mode 100644 index 0000000000000..b0ab152237634 --- /dev/null +++ b/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastPNCounterProducerForSpringTest.java @@ -0,0 +1,94 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.component.hazelcast; + +import com.hazelcast.core.HazelcastInstance; +import com.hazelcast.crdt.pncounter.PNCounter; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; +import org.mockito.Mock; +import org.springframework.context.support.AbstractApplicationContext; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.verifyNoMoreInteractions; +import static org.mockito.Mockito.when; + +public class HazelcastPNCounterProducerForSpringTest extends HazelcastCamelSpringTestSupport { + + @Mock + private PNCounter pnCounter; + + @Override + protected void trainHazelcastInstance(HazelcastInstance hazelcastInstance) { + when(hazelcastInstance.getPNCounter("foo")).thenReturn(pnCounter); + } + + @Override + protected void verifyHazelcastInstance(HazelcastInstance hazelcastInstance) { + verify(hazelcastInstance, times(5)).getPNCounter("foo"); + } + + @AfterEach + public void verifyPNCounterMock() { + verifyNoMoreInteractions(pnCounter); + } + + @Override + protected AbstractApplicationContext createApplicationContext() { + return newAppContext("/META-INF/spring/test-camel-context-pncounter.xml"); + } + + @Test + public void testGet() { + when(pnCounter.get()).thenReturn(1234L); + long body = template.requestBody("direct:get", null, Long.class); + verify(pnCounter).get(); + assertEquals(1234, body); + } + + @Test + public void testIncrement() { + when(pnCounter.incrementAndGet()).thenReturn(11L); + long body = template.requestBody("direct:increment", null, Long.class); + verify(pnCounter).incrementAndGet(); + assertEquals(11, body); + } + + @Test + public void testDecrement() { + when(pnCounter.decrementAndGet()).thenReturn(9L); + long body = template.requestBody("direct:decrement", null, Long.class); + verify(pnCounter).decrementAndGet(); + assertEquals(9, body); + } + + @Test + public void testGetAndAdd() { + when(pnCounter.getAndAdd(12L)).thenReturn(13L); + long result = template.requestBody("direct:getAndAdd", 12L, Long.class); + verify(pnCounter).getAndAdd(12L); + assertEquals(13L, result); + } + + @Test + public void testDestroy() throws InterruptedException { + template.sendBody("direct:destroy", null); + verify(pnCounter).destroy(); + } +} diff --git a/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastPNCounterProducerTest.java b/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastPNCounterProducerTest.java new file mode 100644 index 0000000000000..19ba9b08cda24 --- /dev/null +++ b/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastPNCounterProducerTest.java @@ -0,0 +1,126 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.component.hazelcast; + +import com.hazelcast.core.HazelcastInstance; +import com.hazelcast.crdt.pncounter.PNCounter; +import org.apache.camel.CamelExecutionException; +import org.apache.camel.builder.RouteBuilder; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; +import org.mockito.Mock; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.verifyNoMoreInteractions; +import static org.mockito.Mockito.when; + +public class HazelcastPNCounterProducerTest extends HazelcastCamelTestSupport { + + @Mock + private PNCounter pnCounter; + + @Override + protected void trainHazelcastInstance(HazelcastInstance hazelcastInstance) { + when(hazelcastInstance.getPNCounter("foo")).thenReturn(pnCounter); + } + + @Override + protected void verifyHazelcastInstance(HazelcastInstance hazelcastInstance) { + verify(hazelcastInstance, times(6)).getPNCounter("foo"); + } + + @AfterEach + public void verifyPNCounterMock() { + verifyNoMoreInteractions(pnCounter); + } + + @Test + public void testWithInvalidOperationName() { + assertThrows(CamelExecutionException.class, + () -> template.sendBody("direct:setInvalid", 4711)); + } + + @Test + public void testGet() { + when(pnCounter.get()).thenReturn(1234L); + long body = template.requestBody("direct:get", null, Long.class); + verify(pnCounter).get(); + assertEquals(1234, body); + } + + @Test + public void testIncrement() { + when(pnCounter.incrementAndGet()).thenReturn(11L); + long body = template.requestBody("direct:increment", null, Long.class); + verify(pnCounter).incrementAndGet(); + assertEquals(11, body); + } + + @Test + public void testDecrement() { + when(pnCounter.decrementAndGet()).thenReturn(9L); + long body = template.requestBody("direct:decrement", null, Long.class); + verify(pnCounter).decrementAndGet(); + assertEquals(9, body); + } + + @Test + public void testGetAndAdd() { + when(pnCounter.getAndAdd(12L)).thenReturn(13L); + long result = template.requestBody("direct:getAndAdd", 12L, Long.class); + verify(pnCounter).getAndAdd(12L); + assertEquals(13L, result); + } + + @Test + public void testDestroy() throws InterruptedException { + template.sendBody("direct:destroy", null); + verify(pnCounter).destroy(); + } + + @Override + protected RouteBuilder createRouteBuilder() throws Exception { + return new RouteBuilder() { + @Override + public void configure() throws Exception { + + from("direct:setInvalid").setHeader(HazelcastConstants.OPERATION, constant("invalid")) + .to(String.format("hazelcast-%sfoo", HazelcastConstants.PNCOUNTER_PREFIX)); + + from("direct:get").setHeader(HazelcastConstants.OPERATION, constant(HazelcastOperation.GET)) + .to(String.format("hazelcast-%sfoo", HazelcastConstants.PNCOUNTER_PREFIX)); + + from("direct:increment").setHeader(HazelcastConstants.OPERATION, constant(HazelcastOperation.INCREMENT)).to( + String.format("hazelcast-%sfoo", HazelcastConstants.PNCOUNTER_PREFIX)); + + from("direct:decrement").setHeader(HazelcastConstants.OPERATION, constant(HazelcastOperation.DECREMENT)).to( + String.format("hazelcast-%sfoo", HazelcastConstants.PNCOUNTER_PREFIX)); + + from("direct:getAndAdd").setHeader(HazelcastConstants.OPERATION, constant(HazelcastOperation.GET_AND_ADD)).to( + String.format("hazelcast-%sfoo", HazelcastConstants.PNCOUNTER_PREFIX)); + + from("direct:destroy").setHeader(HazelcastConstants.OPERATION, constant(HazelcastOperation.DESTROY)).to( + String.format("hazelcast-%sfoo", HazelcastConstants.PNCOUNTER_PREFIX)); + + } + }; + } + +} diff --git a/components/camel-hazelcast/src/test/resources/META-INF/spring/test-camel-context-pncounter.xml b/components/camel-hazelcast/src/test/resources/META-INF/spring/test-camel-context-pncounter.xml new file mode 100644 index 0000000000000..af656128477d2 --- /dev/null +++ b/components/camel-hazelcast/src/test/resources/META-INF/spring/test-camel-context-pncounter.xml @@ -0,0 +1,70 @@ + + + + + + + + + + get + + + + + + + + increment + + + + + + + + decrement + + + + + + + + getAndAdd + + + + + + + + destroy + + + + + + + diff --git a/core/camel-main/src/generated/resources/org/apache/camel/main/components.properties b/core/camel-main/src/generated/resources/org/apache/camel/main/components.properties index 0bedb28dab1db..bd2c8b1365d25 100644 --- a/core/camel-main/src/generated/resources/org/apache/camel/main/components.properties +++ b/core/camel-main/src/generated/resources/org/apache/camel/main/components.properties @@ -150,6 +150,7 @@ hazelcast-instance hazelcast-list hazelcast-map hazelcast-multimap +hazelcast-pncounter hazelcast-queue hazelcast-replicatedmap hazelcast-ringbuffer diff --git a/docs/components/modules/ROOT/examples/json/hazelcast-pncounter.json b/docs/components/modules/ROOT/examples/json/hazelcast-pncounter.json new file mode 120000 index 0000000000000..b9f8a2c5a7fa8 --- /dev/null +++ b/docs/components/modules/ROOT/examples/json/hazelcast-pncounter.json @@ -0,0 +1 @@ +../../../../../../components/camel-hazelcast/src/generated/resources/META-INF/org/apache/camel/component/hazelcast/pncounter/hazelcast-pncounter.json \ No newline at end of file diff --git a/docs/components/modules/ROOT/nav.adoc b/docs/components/modules/ROOT/nav.adoc index 5b7887b650c4b..746f29a60f1a7 100644 --- a/docs/components/modules/ROOT/nav.adoc +++ b/docs/components/modules/ROOT/nav.adoc @@ -177,6 +177,7 @@ *** xref:hazelcast-list-component.adoc[Hazelcast List] *** xref:hazelcast-map-component.adoc[Hazelcast Map] *** xref:hazelcast-multimap-component.adoc[Hazelcast Multimap] +*** xref:hazelcast-pncounter-component.adoc[Hazelcast PN Counter] *** xref:hazelcast-queue-component.adoc[Hazelcast Queue] *** xref:hazelcast-replicatedmap-component.adoc[Hazelcast Replicated Map] *** xref:hazelcast-ringbuffer-component.adoc[Hazelcast Ringbuffer] diff --git a/docs/components/modules/ROOT/pages/hazelcast-pncounter-component.adoc b/docs/components/modules/ROOT/pages/hazelcast-pncounter-component.adoc new file mode 120000 index 0000000000000..eb92ceb483e49 --- /dev/null +++ b/docs/components/modules/ROOT/pages/hazelcast-pncounter-component.adoc @@ -0,0 +1 @@ +../../../../../components/camel-hazelcast/src/main/docs/hazelcast-pncounter-component.adoc \ No newline at end of file diff --git a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/ComponentsBuilderFactory.java b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/ComponentsBuilderFactory.java index e02ec586e7edf..26972a01d7927 100644 --- a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/ComponentsBuilderFactory.java +++ b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/ComponentsBuilderFactory.java @@ -2062,6 +2062,20 @@ static HazelcastMapComponentBuilderFactory.HazelcastMapComponentBuilder hazelcas static HazelcastMultimapComponentBuilderFactory.HazelcastMultimapComponentBuilder hazelcastMultimap() { return HazelcastMultimapComponentBuilderFactory.hazelcastMultimap(); } + /** + * Hazelcast PN Counter (camel-hazelcast) + * Increment, decrement, get, etc. operations on a Hazelcast PN Counter + * (CRDT counter). + * + * Category: cache,clustering + * Since: 4.19 + * Maven coordinates: org.apache.camel:camel-hazelcast + * + * @return the dsl builder + */ + static HazelcastPncounterComponentBuilderFactory.HazelcastPncounterComponentBuilder hazelcastPncounter() { + return HazelcastPncounterComponentBuilderFactory.hazelcastPncounter(); + } /** * Hazelcast Queue (camel-hazelcast) * Perform operations on Hazelcast distributed queue. diff --git a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/HazelcastPncounterComponentBuilderFactory.java b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/HazelcastPncounterComponentBuilderFactory.java new file mode 100644 index 0000000000000..0d7c1f5f5adc6 --- /dev/null +++ b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/HazelcastPncounterComponentBuilderFactory.java @@ -0,0 +1,161 @@ +/* Generated by camel build tools - do NOT edit this file! */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.builder.component.dsl; + +import javax.annotation.processing.Generated; +import org.apache.camel.Component; +import org.apache.camel.builder.component.AbstractComponentBuilder; +import org.apache.camel.builder.component.ComponentBuilder; +import org.apache.camel.component.hazelcast.pncounter.HazelcastPNCounterComponent; + +/** + * Increment, decrement, get, etc. operations on a Hazelcast PN Counter (CRDT + * counter). + * + * Generated by camel build tools - do NOT edit this file! + */ +@Generated("org.apache.camel.maven.packaging.ComponentDslMojo") +public interface HazelcastPncounterComponentBuilderFactory { + + /** + * Hazelcast PN Counter (camel-hazelcast) + * Increment, decrement, get, etc. operations on a Hazelcast PN Counter + * (CRDT counter). + * + * Category: cache,clustering + * Since: 4.19 + * Maven coordinates: org.apache.camel:camel-hazelcast + * + * @return the dsl builder + */ + static HazelcastPncounterComponentBuilder hazelcastPncounter() { + return new HazelcastPncounterComponentBuilderImpl(); + } + + /** + * Builder for the Hazelcast PN Counter component. + */ + interface HazelcastPncounterComponentBuilder extends ComponentBuilder { + + + /** + * Whether the producer should be started lazy (on the first message). + * By starting lazy you can use this to allow CamelContext and routes to + * startup in situations where a producer may otherwise fail during + * starting and cause the route to fail being started. By deferring this + * startup to be lazy then the startup failure can be handled during + * routing messages via Camel's routing error handlers. Beware that when + * the first message is processed then creating and starting the + * producer may take a little time and prolong the total processing time + * of the processing. + * + * The option is a: <code>boolean</code> type. + * + * Default: false + * Group: producer + * + * @param lazyStartProducer the value to set + * @return the dsl builder + */ + default HazelcastPncounterComponentBuilder lazyStartProducer(boolean lazyStartProducer) { + doSetProperty("lazyStartProducer", lazyStartProducer); + return this; + } + + + /** + * Whether autowiring is enabled. This is used for automatic autowiring + * options (the option must be marked as autowired) by looking up in the + * registry to find if there is a single instance of matching type, + * which then gets configured on the component. This can be used for + * automatic configuring JDBC data sources, JMS connection factories, + * AWS Clients, etc. + * + * The option is a: <code>boolean</code> type. + * + * Default: true + * Group: advanced + * + * @param autowiredEnabled the value to set + * @return the dsl builder + */ + default HazelcastPncounterComponentBuilder autowiredEnabled(boolean autowiredEnabled) { + doSetProperty("autowiredEnabled", autowiredEnabled); + return this; + } + + /** + * The hazelcast instance reference which can be used for hazelcast + * endpoint. If you don't specify the instance reference, camel use the + * default hazelcast instance from the camel-hazelcast instance. + * + * The option is a: + * <code>com.hazelcast.core.HazelcastInstance</code> type. + * + * Group: advanced + * + * @param hazelcastInstance the value to set + * @return the dsl builder + */ + default HazelcastPncounterComponentBuilder hazelcastInstance(com.hazelcast.core.HazelcastInstance hazelcastInstance) { + doSetProperty("hazelcastInstance", hazelcastInstance); + return this; + } + + + /** + * The hazelcast mode reference which kind of instance should be used. + * If you don't specify the mode, then the node mode will be the + * default. + * + * The option is a: <code>java.lang.String</code> type. + * + * Default: node + * Group: advanced + * + * @param hazelcastMode the value to set + * @return the dsl builder + */ + default HazelcastPncounterComponentBuilder hazelcastMode(java.lang.String hazelcastMode) { + doSetProperty("hazelcastMode", hazelcastMode); + return this; + } + } + + class HazelcastPncounterComponentBuilderImpl + extends AbstractComponentBuilder + implements HazelcastPncounterComponentBuilder { + @Override + protected HazelcastPNCounterComponent buildConcreteComponent() { + return new HazelcastPNCounterComponent(); + } + @Override + protected boolean setPropertyOnComponent( + Component component, + String name, + Object value) { + switch (name) { + case "lazyStartProducer": ((HazelcastPNCounterComponent) component).setLazyStartProducer((boolean) value); return true; + case "autowiredEnabled": ((HazelcastPNCounterComponent) component).setAutowiredEnabled((boolean) value); return true; + case "hazelcastInstance": ((HazelcastPNCounterComponent) component).setHazelcastInstance((com.hazelcast.core.HazelcastInstance) value); return true; + case "hazelcastMode": ((HazelcastPNCounterComponent) component).setHazelcastMode((java.lang.String) value); return true; + default: return false; + } + } + } +} \ No newline at end of file diff --git a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/EndpointBuilderFactory.java b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/EndpointBuilderFactory.java index 98435404e317f..17af69f485d74 100644 --- a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/EndpointBuilderFactory.java +++ b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/EndpointBuilderFactory.java @@ -160,6 +160,7 @@ public interface EndpointBuilderFactory org.apache.camel.builder.endpoint.dsl.HazelcastListEndpointBuilderFactory.HazelcastListBuilders, org.apache.camel.builder.endpoint.dsl.HazelcastMapEndpointBuilderFactory.HazelcastMapBuilders, org.apache.camel.builder.endpoint.dsl.HazelcastMultimapEndpointBuilderFactory.HazelcastMultimapBuilders, + org.apache.camel.builder.endpoint.dsl.HazelcastPNCounterEndpointBuilderFactory.HazelcastPNCounterBuilders, org.apache.camel.builder.endpoint.dsl.HazelcastQueueEndpointBuilderFactory.HazelcastQueueBuilders, org.apache.camel.builder.endpoint.dsl.HazelcastReplicatedmapEndpointBuilderFactory.HazelcastReplicatedmapBuilders, org.apache.camel.builder.endpoint.dsl.HazelcastRingbufferEndpointBuilderFactory.HazelcastRingbufferBuilders, diff --git a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/EndpointBuilders.java b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/EndpointBuilders.java index 167a8119ae814..037df29231069 100644 --- a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/EndpointBuilders.java +++ b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/EndpointBuilders.java @@ -157,6 +157,7 @@ public interface EndpointBuilders org.apache.camel.builder.endpoint.dsl.HazelcastListEndpointBuilderFactory, org.apache.camel.builder.endpoint.dsl.HazelcastMapEndpointBuilderFactory, org.apache.camel.builder.endpoint.dsl.HazelcastMultimapEndpointBuilderFactory, + org.apache.camel.builder.endpoint.dsl.HazelcastPNCounterEndpointBuilderFactory, org.apache.camel.builder.endpoint.dsl.HazelcastQueueEndpointBuilderFactory, org.apache.camel.builder.endpoint.dsl.HazelcastReplicatedmapEndpointBuilderFactory, org.apache.camel.builder.endpoint.dsl.HazelcastRingbufferEndpointBuilderFactory, diff --git a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/StaticEndpointBuilders.java b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/StaticEndpointBuilders.java index 5c160cacd5b56..ae99274f4b01e 100644 --- a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/StaticEndpointBuilders.java +++ b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/StaticEndpointBuilders.java @@ -6582,6 +6582,7 @@ public static HashicorpVaultEndpointBuilderFactory.HashicorpVaultEndpointBuilder * @param path cacheName * @return the dsl builder */ + @Deprecated public static HazelcastAtomicnumberEndpointBuilderFactory.HazelcastAtomicnumberEndpointBuilder hazelcastAtomicvalue(String path) { return hazelcastAtomicvalue("hazelcast-atomicvalue", path); } @@ -6604,6 +6605,7 @@ public static HazelcastAtomicnumberEndpointBuilderFactory.HazelcastAtomicnumberE * @param path cacheName * @return the dsl builder */ + @Deprecated public static HazelcastAtomicnumberEndpointBuilderFactory.HazelcastAtomicnumberEndpointBuilder hazelcastAtomicvalue(String componentName, String path) { return HazelcastAtomicnumberEndpointBuilderFactory.endpointBuilder(componentName, path); } @@ -6767,6 +6769,48 @@ public static HazelcastMultimapEndpointBuilderFactory.HazelcastMultimapEndpointB public static HazelcastMultimapEndpointBuilderFactory.HazelcastMultimapEndpointBuilder hazelcastMultimap(String componentName, String path) { return HazelcastMultimapEndpointBuilderFactory.endpointBuilder(componentName, path); } + /** + * Hazelcast PN Counter (camel-hazelcast) + * Increment, decrement, get, etc. operations on a Hazelcast PN Counter + * (CRDT counter). + * + * Category: cache,clustering + * Since: 4.19 + * Maven coordinates: org.apache.camel:camel-hazelcast + * + * Syntax: hazelcast-pncounter:cacheName + * + * Path parameter: cacheName (required) + * The name of the cache + * + * @param path cacheName + * @return the dsl builder + */ + public static HazelcastPNCounterEndpointBuilderFactory.HazelcastPNCounterEndpointBuilder hazelcastPncounter(String path) { + return hazelcastPncounter("hazelcast-pncounter", path); + } + /** + * Hazelcast PN Counter (camel-hazelcast) + * Increment, decrement, get, etc. operations on a Hazelcast PN Counter + * (CRDT counter). + * + * Category: cache,clustering + * Since: 4.19 + * Maven coordinates: org.apache.camel:camel-hazelcast + * + * Syntax: hazelcast-pncounter:cacheName + * + * Path parameter: cacheName (required) + * The name of the cache + * + * @param componentName to use a custom component name for the endpoint + * instead of the default name + * @param path cacheName + * @return the dsl builder + */ + public static HazelcastPNCounterEndpointBuilderFactory.HazelcastPNCounterEndpointBuilder hazelcastPncounter(String componentName, String path) { + return HazelcastPNCounterEndpointBuilderFactory.endpointBuilder(componentName, path); + } /** * Hazelcast Queue (camel-hazelcast) * Perform operations on Hazelcast distributed queue. diff --git a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/HazelcastAtomicnumberEndpointBuilderFactory.java b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/HazelcastAtomicnumberEndpointBuilderFactory.java index 817bbdc4fa2f6..faa71ad3c4ddb 100644 --- a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/HazelcastAtomicnumberEndpointBuilderFactory.java +++ b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/HazelcastAtomicnumberEndpointBuilderFactory.java @@ -215,6 +215,7 @@ public interface HazelcastAtomicnumberBuilders { * * @return the dsl builder for the headers' name. */ + @Deprecated default HazelcastAtomicnumberHeaderNameBuilder hazelcastAtomicvalue() { return HazelcastAtomicnumberHeaderNameBuilder.INSTANCE; } @@ -235,6 +236,7 @@ default HazelcastAtomicnumberHeaderNameBuilder hazelcastAtomicvalue() { * @param path cacheName * @return the dsl builder */ + @Deprecated default HazelcastAtomicnumberEndpointBuilder hazelcastAtomicvalue(String path) { return HazelcastAtomicnumberEndpointBuilderFactory.endpointBuilder("hazelcast-atomicvalue", path); } @@ -257,6 +259,7 @@ default HazelcastAtomicnumberEndpointBuilder hazelcastAtomicvalue(String path) { * @param path cacheName * @return the dsl builder */ + @Deprecated default HazelcastAtomicnumberEndpointBuilder hazelcastAtomicvalue(String componentName, String path) { return HazelcastAtomicnumberEndpointBuilderFactory.endpointBuilder(componentName, path); } diff --git a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/HazelcastPNCounterEndpointBuilderFactory.java b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/HazelcastPNCounterEndpointBuilderFactory.java new file mode 100644 index 0000000000000..36778575e38d5 --- /dev/null +++ b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/HazelcastPNCounterEndpointBuilderFactory.java @@ -0,0 +1,260 @@ +/* Generated by camel build tools - do NOT edit this file! */ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.builder.endpoint.dsl; + +import java.util.*; +import java.util.concurrent.*; +import java.util.function.*; +import java.util.stream.*; +import javax.annotation.processing.Generated; +import org.apache.camel.builder.EndpointConsumerBuilder; +import org.apache.camel.builder.EndpointProducerBuilder; +import org.apache.camel.builder.endpoint.AbstractEndpointBuilder; + +/** + * Increment, decrement, get, etc. operations on a Hazelcast PN Counter (CRDT + * counter). + * + * Generated by camel build tools - do NOT edit this file! + */ +@Generated("org.apache.camel.maven.packaging.EndpointDslMojo") +public interface HazelcastPNCounterEndpointBuilderFactory { + + /** + * Builder for endpoint for the Hazelcast PN Counter component. + */ + public interface HazelcastPNCounterEndpointBuilder + extends + EndpointProducerBuilder { + default AdvancedHazelcastPNCounterEndpointBuilder advanced() { + return (AdvancedHazelcastPNCounterEndpointBuilder) this; + } + + /** + * To specify a default operation to use, if no operation header has + * been provided. + * + * The option is a: + * org.apache.camel.component.hazelcast.HazelcastOperation + * type. + * + * Group: producer + * + * @param defaultOperation the value to set + * @return the dsl builder + */ + default HazelcastPNCounterEndpointBuilder defaultOperation(org.apache.camel.component.hazelcast.HazelcastOperation defaultOperation) { + doSetProperty("defaultOperation", defaultOperation); + return this; + } + /** + * To specify a default operation to use, if no operation header has + * been provided. + * + * The option will be converted to a + * org.apache.camel.component.hazelcast.HazelcastOperation + * type. + * + * Group: producer + * + * @param defaultOperation the value to set + * @return the dsl builder + */ + default HazelcastPNCounterEndpointBuilder defaultOperation(String defaultOperation) { + doSetProperty("defaultOperation", defaultOperation); + return this; + } + /** + * Hazelcast configuration file. + * + * This option can also be loaded from an existing file, by prefixing + * with file: or classpath: followed by the location of the file. + * + * The option is a: java.lang.String type. + * + * Group: producer + * + * @param hazelcastConfigUri the value to set + * @return the dsl builder + */ + default HazelcastPNCounterEndpointBuilder hazelcastConfigUri(String hazelcastConfigUri) { + doSetProperty("hazelcastConfigUri", hazelcastConfigUri); + return this; + } + /** + * The hazelcast instance reference which can be used for hazelcast + * endpoint. + * + * The option is a: com.hazelcast.core.HazelcastInstance + * type. + * + * Group: producer + * + * @param hazelcastInstance the value to set + * @return the dsl builder + */ + default HazelcastPNCounterEndpointBuilder hazelcastInstance(com.hazelcast.core.HazelcastInstance hazelcastInstance) { + doSetProperty("hazelcastInstance", hazelcastInstance); + return this; + } + /** + * The hazelcast instance reference which can be used for hazelcast + * endpoint. + * + * The option will be converted to a + * com.hazelcast.core.HazelcastInstance type. + * + * Group: producer + * + * @param hazelcastInstance the value to set + * @return the dsl builder + */ + default HazelcastPNCounterEndpointBuilder hazelcastInstance(String hazelcastInstance) { + doSetProperty("hazelcastInstance", hazelcastInstance); + return this; + } + /** + * The hazelcast instance reference name which can be used for hazelcast + * endpoint. If you don't specify the instance reference, camel use the + * default hazelcast instance from the camel-hazelcast instance. + * + * The option is a: java.lang.String type. + * + * Group: producer + * + * @param hazelcastInstanceName the value to set + * @return the dsl builder + */ + default HazelcastPNCounterEndpointBuilder hazelcastInstanceName(String hazelcastInstanceName) { + doSetProperty("hazelcastInstanceName", hazelcastInstanceName); + return this; + } + } + + /** + * Advanced builder for endpoint for the Hazelcast PN Counter component. + */ + public interface AdvancedHazelcastPNCounterEndpointBuilder + extends + EndpointProducerBuilder { + default HazelcastPNCounterEndpointBuilder basic() { + return (HazelcastPNCounterEndpointBuilder) this; + } + + /** + * Whether the producer should be started lazy (on the first message). + * By starting lazy you can use this to allow CamelContext and routes to + * startup in situations where a producer may otherwise fail during + * starting and cause the route to fail being started. By deferring this + * startup to be lazy then the startup failure can be handled during + * routing messages via Camel's routing error handlers. Beware that when + * the first message is processed then creating and starting the + * producer may take a little time and prolong the total processing time + * of the processing. + * + * The option is a: boolean type. + * + * Default: false + * Group: producer (advanced) + * + * @param lazyStartProducer the value to set + * @return the dsl builder + */ + default AdvancedHazelcastPNCounterEndpointBuilder lazyStartProducer(boolean lazyStartProducer) { + doSetProperty("lazyStartProducer", lazyStartProducer); + return this; + } + /** + * Whether the producer should be started lazy (on the first message). + * By starting lazy you can use this to allow CamelContext and routes to + * startup in situations where a producer may otherwise fail during + * starting and cause the route to fail being started. By deferring this + * startup to be lazy then the startup failure can be handled during + * routing messages via Camel's routing error handlers. Beware that when + * the first message is processed then creating and starting the + * producer may take a little time and prolong the total processing time + * of the processing. + * + * The option will be converted to a boolean type. + * + * Default: false + * Group: producer (advanced) + * + * @param lazyStartProducer the value to set + * @return the dsl builder + */ + default AdvancedHazelcastPNCounterEndpointBuilder lazyStartProducer(String lazyStartProducer) { + doSetProperty("lazyStartProducer", lazyStartProducer); + return this; + } + } + + public interface HazelcastPNCounterBuilders { + /** + * Hazelcast PN Counter (camel-hazelcast) + * Increment, decrement, get, etc. operations on a Hazelcast PN Counter + * (CRDT counter). + * + * Category: cache,clustering + * Since: 4.19 + * Maven coordinates: org.apache.camel:camel-hazelcast + * + * Syntax: hazelcast-pncounter:cacheName + * + * Path parameter: cacheName (required) + * The name of the cache + * + * @param path cacheName + * @return the dsl builder + */ + default HazelcastPNCounterEndpointBuilder hazelcastPncounter(String path) { + return HazelcastPNCounterEndpointBuilderFactory.endpointBuilder("hazelcast-pncounter", path); + } + /** + * Hazelcast PN Counter (camel-hazelcast) + * Increment, decrement, get, etc. operations on a Hazelcast PN Counter + * (CRDT counter). + * + * Category: cache,clustering + * Since: 4.19 + * Maven coordinates: org.apache.camel:camel-hazelcast + * + * Syntax: hazelcast-pncounter:cacheName + * + * Path parameter: cacheName (required) + * The name of the cache + * + * @param componentName to use a custom component name for the endpoint + * instead of the default name + * @param path cacheName + * @return the dsl builder + */ + default HazelcastPNCounterEndpointBuilder hazelcastPncounter(String componentName, String path) { + return HazelcastPNCounterEndpointBuilderFactory.endpointBuilder(componentName, path); + } + + } + static HazelcastPNCounterEndpointBuilder endpointBuilder(String componentName, String path) { + class HazelcastPNCounterEndpointBuilderImpl extends AbstractEndpointBuilder implements HazelcastPNCounterEndpointBuilder, AdvancedHazelcastPNCounterEndpointBuilder { + public HazelcastPNCounterEndpointBuilderImpl(String path) { + super(componentName, path); + } + } + return new HazelcastPNCounterEndpointBuilderImpl(path); + } +} \ No newline at end of file diff --git a/dsl/camel-kamelet-main/src/generated/resources/camel-component-known-dependencies.properties b/dsl/camel-kamelet-main/src/generated/resources/camel-component-known-dependencies.properties index e43336848887f..f95e9e4cd06ac 100644 --- a/dsl/camel-kamelet-main/src/generated/resources/camel-component-known-dependencies.properties +++ b/dsl/camel-kamelet-main/src/generated/resources/camel-component-known-dependencies.properties @@ -167,6 +167,7 @@ org.apache.camel.component.hazelcast.instance.HazelcastInstanceComponent=camel:h org.apache.camel.component.hazelcast.list.HazelcastListComponent=camel:hazelcast org.apache.camel.component.hazelcast.map.HazelcastMapComponent=camel:hazelcast org.apache.camel.component.hazelcast.multimap.HazelcastMultimapComponent=camel:hazelcast +org.apache.camel.component.hazelcast.pncounter.HazelcastPNCounterComponent=camel:hazelcast org.apache.camel.component.hazelcast.queue.HazelcastQueueComponent=camel:hazelcast org.apache.camel.component.hazelcast.replicatedmap.HazelcastReplicatedmapComponent=camel:hazelcast org.apache.camel.component.hazelcast.ringbuffer.HazelcastRingbufferComponent=camel:hazelcast