Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
8716d70
Created.
alexlomov Oct 15, 2013
3cbaec7
Persistent repository name handling updated to achieve robustness and…
alexlomov Oct 16, 2013
76207ee
Lots of trace logging.
alexlomov Oct 20, 2013
0e807ce
Tons of javadoc.
alexlomov Oct 21, 2013
63f3523
DefaultExchageHolders introduced.
alexlomov Oct 28, 2013
359d454
HazelcastAggregationRepository Constructor Tests were implemented.
alexlomov Oct 28, 2013
be172ed
Removed unused imports and variables.
alexlomov Oct 28, 2013
9d39230
useRecovery always default to true.
alexlomov Oct 28, 2013
0984043
Initial commit (test created).
alexlomov Oct 28, 2013
86a7bfe
useRecovery always default to true.
alexlomov Dec 13, 2013
242633b
Typo fix.
alexlomov Jan 3, 2014
586fe23
Superclass was extracted
alexlomov Jan 3, 2014
f68fc41
More working tests.
alexlomov Jan 4, 2014
d13ee37
Moved SumOfIntsAggregationStrategy class from inner level.
alexlomov Jan 4, 2014
22d44ea
Created a test case for recoverable HazelcastAggregationRepository.
alexlomov Jan 4, 2014
0f35396
CAMEL-6458: Add renameUsingCopy option to File Component
gzurowski Mar 29, 2014
daed640
CAMEL-6458: Add tests for renameUsingCopy option
gzurowski Mar 29, 2014
15565d9
Merge branch 'CAMEL-6458' of https://github.com/gzurowski/camel
davsclaus Apr 3, 2014
b73edad
CAMEL-7033 take clustering into consideration when stop the consumer …
WillemJiang Apr 3, 2014
5f6477c
CAMEL-7341 Fixed the issue that cxfrs:InInterceptor defined in Spring…
WillemJiang Apr 4, 2014
5646830
Merge branch 'CAMEL-6694' of https://github.com/grgrzybek/camel
davsclaus Apr 4, 2014
fc91c58
CAMEL-6694: Fixed CS
davsclaus Apr 4, 2014
dba21eb
[CAMEL-6694] Allow log EIP to use provided or registry logger
grgrzybek Apr 4, 2014
2ab36a3
CAMEL-6694 Fixed CS error and Polish the code
WillemJiang Apr 4, 2014
8f24ca3
Fixed some Eclipse warning of aggregater
WillemJiang Apr 4, 2014
44f881e
CAMEL-6694 Fixed some other warning in eclipse
WillemJiang Apr 4, 2014
134c433
Upgraded rx
davsclaus Apr 4, 2014
4eca6ca
Upgraded rx
davsclaus Apr 5, 2014
db4a557
Upgrade to AMQ 5.9.1
davsclaus Apr 5, 2014
56d1139
Upgraded AHC
davsclaus Apr 5, 2014
1fce4a3
Polished
davsclaus Apr 5, 2014
1f2b83a
CAMEL-5539 Circuit Breaker EIP
bibryam Apr 5, 2014
9ed7d85
CAMEL-5539 Circuit Breaker EIP
bibryam Apr 5, 2014
82ef800
CAMEL-5539 Circuit Breaker EIP
bibryam Apr 6, 2014
29dee17
CAMEL-7346: Remove redundant groupId definition
gzurowski Apr 6, 2014
bdf3021
CAMEL-7346: Remove redundant version specification
gzurowski Apr 6, 2014
a59414d
CAMEL-7347: camel-netty-http should return 404 instead 503 if resourc…
davsclaus Apr 7, 2014
9122881
CAMEL-7344: Some endpoints configured using beans may result in NPE u…
elakito Apr 7, 2014
1949235
CAMEL-5539: Fix compilation problems
gzurowski Apr 7, 2014
cd8da7d
[CAMEL-6694] Adding INFO log about Loggers discovered in Registry
grgrzybek Apr 8, 2014
faeeb92
Created.
alexlomov Oct 15, 2013
e8c3b7c
Persistent repository name handling updated to achieve robustness and…
alexlomov Oct 16, 2013
a48f3fc
Lots of trace logging.
alexlomov Oct 20, 2013
f254e06
Tons of javadoc.
alexlomov Oct 21, 2013
6b81f29
DefaultExchageHolders introduced.
alexlomov Oct 28, 2013
e22a96d
HazelcastAggregationRepository Constructor Tests were implemented.
alexlomov Oct 28, 2013
a729ce4
Removed unused imports and variables.
alexlomov Oct 28, 2013
8612ad3
useRecovery always default to true.
alexlomov Oct 28, 2013
0f34fb9
Initial commit (test created).
alexlomov Oct 28, 2013
629d60e
useRecovery always default to true.
alexlomov Dec 13, 2013
bcdcb64
Typo fix.
alexlomov Jan 3, 2014
77180f5
Superclass was extracted
alexlomov Jan 3, 2014
1649c23
More working tests.
alexlomov Jan 4, 2014
a9b897c
Moved SumOfIntsAggregationStrategy class from inner level.
alexlomov Jan 4, 2014
0fbe03e
Created a test case for recoverable HazelcastAggregationRepository.
alexlomov Jan 4, 2014
36a4510
Merge branch 'hazelcast-aggregation-repository' of https://github.com…
alexlomov Apr 8, 2014
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion camel-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit-version}</version>
<scope>test</scope>
</dependency>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ public class FileEndpoint extends GenericFileEndpoint<File> {
@UriParam
private boolean copyAndDeleteOnRenameFail = true;
@UriParam
private boolean renameUsingCopy;
@UriParam
private boolean forceWrites = true;

public FileEndpoint() {
Expand Down Expand Up @@ -174,6 +176,14 @@ public void setCopyAndDeleteOnRenameFail(boolean copyAndDeleteOnRenameFail) {
this.copyAndDeleteOnRenameFail = copyAndDeleteOnRenameFail;
}

public boolean isRenameUsingCopy() {
return renameUsingCopy;
}

public void setRenameUsingCopy(boolean renameUsingCopy) {
this.renameUsingCopy = renameUsingCopy;
}

public boolean isForceWrites() {
return forceWrites;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,20 @@ public boolean deleteFile(String name) throws GenericFileOperationFailedExceptio
}

public boolean renameFile(String from, String to) throws GenericFileOperationFailedException {
boolean renamed = false;
File file = new File(from);
File target = new File(to);
try {
return FileUtil.renameFile(file, target, endpoint.isCopyAndDeleteOnRenameFail());
if (endpoint.isRenameUsingCopy()) {
renamed = FileUtil.renameFileUsingCopy(file, target);
} else {
renamed = FileUtil.renameFile(file, target, endpoint.isCopyAndDeleteOnRenameFail());
}
} catch (IOException e) {
throw new GenericFileOperationFailedException("Error renaming file from " + from + " to " + to, e);
}

return renamed;
}

public boolean existsFile(String name) throws GenericFileOperationFailedException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,11 @@
import org.apache.camel.Endpoint;
import org.apache.camel.LoggingLevel;
import org.apache.camel.Processor;
import org.apache.camel.ResolveEndpointFailedException;
import org.apache.camel.impl.UriEndpointComponent;
import org.apache.camel.processor.CamelLogProcessor;
import org.apache.camel.processor.DefaultExchangeFormatter;
import org.apache.camel.processor.ThroughputLogger;
import org.apache.camel.spi.ExchangeFormatter;
import org.apache.camel.util.CamelContextHelper;
import org.apache.camel.util.CamelLogger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -57,6 +55,7 @@ protected Endpoint createEndpoint(String uri, String remaining, Map<String, Obje
Map<String, Logger> availableLoggers = getCamelContext().getRegistry().findByTypeWithName(Logger.class);
if (availableLoggers.size() == 1) {
providedLogger = availableLoggers.values().iterator().next();
LOG.info("Using custom Logger: {}", providedLogger);
} else if (availableLoggers.size() > 1) {
LOG.info("More than one {} instance found in the registry. Falling back to creating logger from URI {}.", Logger.class.getName(), uri);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,13 @@ public boolean equals(Object object) {

@Override
public String toString() {
return String.format("Endpoint[%s]", URISupport.sanitizeUri(getEndpointUri()));
String value = null;
try {
value = getEndpointUri();
} catch (RuntimeException e) {
// ignore any exception and use null for building the string value
}
return String.format("Endpoint[%s]", URISupport.sanitizeUri(value));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,15 @@

import org.apache.camel.Expression;
import org.apache.camel.Processor;
import org.apache.camel.model.loadbalancer.CircuitBreakerLoadBalancerDefinition;
import org.apache.camel.model.loadbalancer.CustomLoadBalancerDefinition;
import org.apache.camel.model.loadbalancer.FailoverLoadBalancerDefinition;
import org.apache.camel.model.loadbalancer.RandomLoadBalancerDefinition;
import org.apache.camel.model.loadbalancer.RoundRobinLoadBalancerDefinition;
import org.apache.camel.model.loadbalancer.StickyLoadBalancerDefinition;
import org.apache.camel.model.loadbalancer.TopicLoadBalancerDefinition;
import org.apache.camel.model.loadbalancer.WeightedLoadBalancerDefinition;
import org.apache.camel.processor.loadbalancer.CircuitBreakerLoadBalancer;
import org.apache.camel.processor.loadbalancer.FailOverLoadBalancer;
import org.apache.camel.processor.loadbalancer.LoadBalancer;
import org.apache.camel.processor.loadbalancer.RandomLoadBalancer;
Expand Down Expand Up @@ -66,7 +68,8 @@ public class LoadBalanceDefinition extends ProcessorDefinition<LoadBalanceDefini
@XmlElement(required = false, name = "roundRobin", type = RoundRobinLoadBalancerDefinition.class),
@XmlElement(required = false, name = "sticky", type = StickyLoadBalancerDefinition.class),
@XmlElement(required = false, name = "topic", type = TopicLoadBalancerDefinition.class),
@XmlElement(required = false, name = "weighted", type = WeightedLoadBalancerDefinition.class)}
@XmlElement(required = false, name = "weighted", type = WeightedLoadBalancerDefinition.class),
@XmlElement(required = false, name = "circuitBreaker", type = CircuitBreakerLoadBalancerDefinition.class)}
)
private LoadBalancerDefinition loadBalancerType;
@XmlElementRef
Expand Down Expand Up @@ -213,6 +216,23 @@ public LoadBalanceDefinition failover(int maximumFailoverAttempts, boolean inher
public LoadBalanceDefinition weighted(boolean roundRobin, String distributionRatio) {
return weighted(roundRobin, distributionRatio, ",");
}

/**
* Uses circuitBreaker load balancer
*
* @param threshold number of errors before failure.
* @param halfOpenAfter time interval in milliseconds for half open state.
* @param exceptions exception classes which we want to break if one of them was thrown
* @return the builder
*/
public LoadBalanceDefinition circuitBreaker(int threshold, long halfOpenAfter, Class<?>... exceptions) {
CircuitBreakerLoadBalancer breakerLoadBalancer = new CircuitBreakerLoadBalancer(Arrays.asList(exceptions));
breakerLoadBalancer.setThreshold(threshold);
breakerLoadBalancer.setHalfOpenAfter(halfOpenAfter);

setLoadBalancerType(new LoadBalancerDefinition(breakerLoadBalancer));
return this;
}

/**
* Uses weighted load balancer
Expand Down
63 changes: 58 additions & 5 deletions camel-core/src/main/java/org/apache/camel/model/LogDefinition.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,24 @@
*/
package org.apache.camel.model;

import java.util.Map;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

import org.apache.camel.Expression;
import org.apache.camel.LoggingLevel;
import org.apache.camel.Processor;
import org.apache.camel.processor.LogProcessor;
import org.apache.camel.spi.RouteContext;
import org.apache.camel.util.CamelContextHelper;
import org.apache.camel.util.CamelLogger;
import org.apache.camel.util.ObjectHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Represents an XML &lt;log/&gt; element
Expand All @@ -37,6 +43,8 @@
@XmlRootElement(name = "log")
@XmlAccessorType(XmlAccessType.FIELD)
public class LogDefinition extends NoOutputDefinition<LogDefinition> {
@XmlTransient
private static final Logger LOG = LoggerFactory.getLogger(LogDefinition.class);
@XmlAttribute(required = true)
private String message;
@XmlAttribute
Expand All @@ -45,6 +53,10 @@ public class LogDefinition extends NoOutputDefinition<LogDefinition> {
private String logName;
@XmlAttribute
private String marker;
@XmlAttribute
private String loggerRef;
@XmlTransient
private Logger logger;

public LogDefinition() {
}
Expand Down Expand Up @@ -75,15 +87,40 @@ public Processor createProcessor(RouteContext routeContext) throws Exception {
// use simple language for the message string to give it more power
Expression exp = routeContext.getCamelContext().resolveLanguage("simple").createExpression(message);

String name = getLogName();
if (name == null) {
name = routeContext.getRoute().getId();
// get logger explicitely set in the definition
Logger logger = this.getLogger();

// get logger which may be set in XML definition
if (logger == null && ObjectHelper.isNotEmpty(loggerRef)) {
logger = CamelContextHelper.mandatoryLookup(routeContext.getCamelContext(), loggerRef, Logger.class);
}

if (logger == null) {
// first - try to lookup single instance in the registry, just like LogComponent
Map<String, Logger> availableLoggers = routeContext.lookupByType(Logger.class);
if (availableLoggers.size() == 1) {
logger = availableLoggers.values().iterator().next();
LOG.info("Using custom Logger: {}", logger);
} else if (availableLoggers.size() > 1) {
// we should log about this somewhere...
LOG.info("More than one {} instance found in the registry. Falling back to create logger by name.", Logger.class.getName());
}
}

if (logger == null) {
String name = getLogName();
if (name == null) {
name = routeContext.getRoute().getId();
LOG.info("The LogName is null. Falling back to create logger by using the route id {}.", name);
}
logger = LoggerFactory.getLogger(name);
}

// should be INFO by default
LoggingLevel level = getLoggingLevel() != null ? getLoggingLevel() : LoggingLevel.INFO;
CamelLogger logger = new CamelLogger(name, level, getMarker());
CamelLogger camelLogger = new CamelLogger(logger, level, getMarker());

return new LogProcessor(exp, logger);
return new LogProcessor(exp, camelLogger);
}

@Override
Expand Down Expand Up @@ -123,4 +160,20 @@ public String getMarker() {
public void setMarker(String marker) {
this.marker = marker;
}

public String getLoggerRef() {
return loggerRef;
}

public void setLoggerRef(String loggerRef) {
this.loggerRef = loggerRef;
}

public Logger getLogger() {
return logger;
}

public void setLogger(Logger logger) {
this.logger = logger;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1539,6 +1539,23 @@ public Type log(LoggingLevel loggingLevel, String logName, String message) {
return (Type) this;
}

/**
* Creates a log message to be logged at the given level using provided logger.
*
* @param loggingLevel the logging level to use
* @param logger the logger to use
* @param message the log message, (you can use {@link org.apache.camel.language.simple.SimpleLanguage} syntax)
* @return the builder
*/
@SuppressWarnings("unchecked")
public Type log(LoggingLevel loggingLevel, Logger logger, String message) {
LogDefinition answer = new LogDefinition(message);
answer.setLoggingLevel(loggingLevel);
answer.setLogger(logger);
addOutput(answer);
return (Type) this;
}

/**
* Creates a log message to be logged at the given level and name.
*
Expand All @@ -1559,6 +1576,26 @@ public Type log(LoggingLevel loggingLevel, String logName, String marker, String
return (Type) this;
}

/**
* Creates a log message to be logged at the given level using provided logger.
*
*
* @param loggingLevel the logging level to use
* @param logger the logger to use
* @param marker log marker name
* @param message the log message, (you can use {@link org.apache.camel.language.simple.SimpleLanguage} syntax)
* @return the builder
*/
@SuppressWarnings("unchecked")
public Type log(LoggingLevel loggingLevel, Logger logger, String marker, String message) {
LogDefinition answer = new LogDefinition(message);
answer.setLoggingLevel(loggingLevel);
answer.setLogger(logger);
answer.setMarker(marker);
addOutput(answer);
return (Type) this;
}

/**
* <a href="http://camel.apache.org/content-based-router.html">Content Based Router EIP:</a>
* Creates a choice of one or more predicates with an otherwise clause
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ public String getRef() {
public void setRef(String ref) {
this.ref = ref;
}

@SuppressWarnings({"unchecked", "rawtypes"})

public List<RouteDefinition> lookupRoutes(CamelContext camelContext) {
return RouteContextRefDefinitionHelper.lookupRoutes(camelContext, ref);
}
Expand Down
Loading