001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.camel.model; 018 019import javax.xml.bind.annotation.XmlAccessType; 020import javax.xml.bind.annotation.XmlAccessorType; 021import javax.xml.bind.annotation.XmlAttribute; 022 023import org.apache.camel.spi.Metadata; 024 025@XmlAccessorType(XmlAccessType.FIELD) 026public class FaultToleranceConfigurationCommon extends IdentifiedType { 027 028 @XmlAttribute 029 @Metadata(label = "circuitbreaker") 030 private String circuitBreakerRef; 031 @XmlAttribute 032 @Metadata(label = "circuitbreaker", defaultValue = "5s", javaType = "java.time.Duration") 033 private String delay; 034 @XmlAttribute 035 @Metadata(label = "circuitbreaker", defaultValue = "1", javaType = "java.lang.Integer") 036 private String successThreshold; 037 @XmlAttribute 038 @Metadata(label = "circuitbreaker", defaultValue = "20", javaType = "java.lang.Integer") 039 private String requestVolumeThreshold; 040 @XmlAttribute 041 @Metadata(label = "circuitbreaker", defaultValue = "50", javaType = "java.lang.Integer") 042 private String failureRatio; 043 @XmlAttribute 044 @Metadata(label = "timeout", defaultValue = "false", javaType = "java.lang.Boolean") 045 private String timeoutEnabled; 046 @XmlAttribute 047 @Metadata(label = "timeout", defaultValue = "1s", javaType = "java.time.Duration") 048 private String timeoutDuration; 049 @XmlAttribute 050 @Metadata(label = "timeout", defaultValue = "10", javaType = "java.lang.Integer") 051 private String timeoutPoolSize; 052 @XmlAttribute 053 @Metadata(label = "timeout") 054 private String timeoutScheduledExecutorServiceRef; 055 @XmlAttribute 056 @Metadata(label = "bulkhead", defaultValue = "false", javaType = "java.lang.Boolean") 057 private String bulkheadEnabled; 058 @XmlAttribute 059 @Metadata(label = "bulkhead", defaultValue = "10", javaType = "java.lang.Integer") 060 private String bulkheadMaxConcurrentCalls; 061 @XmlAttribute 062 @Metadata(label = "bulkhead", defaultValue = "10", javaType = "java.lang.Integer") 063 private String bulkheadWaitingTaskQueue; 064 @XmlAttribute 065 @Metadata(label = "bulkhead") 066 private String bulkheadExecutorServiceRef; 067 068 // Getter/Setter 069 // ------------------------------------------------------------------------- 070 071 public String getCircuitBreakerRef() { 072 return circuitBreakerRef; 073 } 074 075 /** 076 * Refers to an existing io.smallrye.faulttolerance.core.circuit.breaker.CircuitBreaker instance 077 * to lookup and use from the registry. When using this, then any other circuit breaker options 078 * are not in use. 079 */ 080 public void setCircuitBreakerRef(String circuitBreakerRef) { 081 this.circuitBreakerRef = circuitBreakerRef; 082 } 083 084 public String getDelay() { 085 return delay; 086 } 087 088 /** 089 * Control how long the circuit breaker stays open. The value are in seconds and the default is 5 seconds. 090 */ 091 public void setDelay(String delay) { 092 this.delay = delay; 093 } 094 095 public String getSuccessThreshold() { 096 return successThreshold; 097 } 098 099 /** 100 * Controls the number of trial calls which are allowed when the circuit breaker is half-open 101 */ 102 public void setSuccessThreshold(String successThreshold) { 103 this.successThreshold = successThreshold; 104 } 105 106 public String getRequestVolumeThreshold() { 107 return requestVolumeThreshold; 108 } 109 110 /** 111 * Controls the size of the rolling window used when the circuit breaker is closed 112 */ 113 public void setRequestVolumeThreshold(String requestVolumeThreshold) { 114 this.requestVolumeThreshold = requestVolumeThreshold; 115 } 116 117 public String getFailureRatio() { 118 return failureRatio; 119 } 120 121 /** 122 * Configures the failure rate threshold in percentage. 123 * If the failure rate is equal or greater than the threshold the CircuitBreaker transitions to open and starts short-circuiting calls. 124 * <p> 125 * The threshold must be greater than 0 and not greater than 100. Default value is 50 percentage. 126 */ 127 public void setFailureRatio(String failureRatio) { 128 this.failureRatio = failureRatio; 129 } 130 131 public String getTimeoutEnabled() { 132 return timeoutEnabled; 133 } 134 135 /** 136 * Whether timeout is enabled or not on the circuit breaker. 137 * Default is false. 138 */ 139 public void setTimeoutEnabled(String timeoutEnabled) { 140 this.timeoutEnabled = timeoutEnabled; 141 } 142 143 public String getTimeoutDuration() { 144 return timeoutDuration; 145 } 146 147 /** 148 * Configures the thread execution timeout. 149 * Default value is 1 second. 150 */ 151 public void setTimeoutDuration(String timeoutDuration) { 152 this.timeoutDuration = timeoutDuration; 153 } 154 155 public String getTimeoutPoolSize() { 156 return timeoutPoolSize; 157 } 158 159 /** 160 * Configures the pool size of the thread pool when timeout is enabled. 161 * Default value is 10. 162 */ 163 public void setTimeoutPoolSize(String timeoutPoolSize) { 164 this.timeoutPoolSize = timeoutPoolSize; 165 } 166 167 public String getTimeoutScheduledExecutorServiceRef() { 168 return timeoutScheduledExecutorServiceRef; 169 } 170 171 /** 172 * References to a custom thread pool to use when timeout is enabled 173 */ 174 public void setTimeoutScheduledExecutorServiceRef(String timeoutScheduledExecutorServiceRef) { 175 this.timeoutScheduledExecutorServiceRef = timeoutScheduledExecutorServiceRef; 176 } 177 178 public String getBulkheadEnabled() { 179 return bulkheadEnabled; 180 } 181 182 /** 183 * Whether bulkhead is enabled or not on the circuit breaker. 184 * Default is false. 185 */ 186 public void setBulkheadEnabled(String bulkheadEnabled) { 187 this.bulkheadEnabled = bulkheadEnabled; 188 } 189 190 public String getBulkheadMaxConcurrentCalls() { 191 return bulkheadMaxConcurrentCalls; 192 } 193 194 /** 195 * Configures the max amount of concurrent calls the bulkhead will support. 196 */ 197 public void setBulkheadMaxConcurrentCalls(String bulkheadMaxConcurrentCalls) { 198 this.bulkheadMaxConcurrentCalls = bulkheadMaxConcurrentCalls; 199 } 200 201 public String getBulkheadWaitingTaskQueue() { 202 return bulkheadWaitingTaskQueue; 203 } 204 205 /** 206 * Configures the task queue size for holding waiting tasks to be processed by the bulkhead. 207 */ 208 public void setBulkheadWaitingTaskQueue(String bulkheadWaitingTaskQueue) { 209 this.bulkheadWaitingTaskQueue = bulkheadWaitingTaskQueue; 210 } 211 212 public String getBulkheadExecutorServiceRef() { 213 return bulkheadExecutorServiceRef; 214 } 215 216 /** 217 * References to a custom thread pool to use when bulkhead is enabled. 218 */ 219 public void setBulkheadExecutorServiceRef(String bulkheadExecutorServiceRef) { 220 this.bulkheadExecutorServiceRef = bulkheadExecutorServiceRef; 221 } 222}