Class Etcd3RoutePolicy
java.lang.Object
org.apache.camel.support.service.BaseService
org.apache.camel.support.service.ServiceSupport
org.apache.camel.support.RoutePolicySupport
org.apache.camel.component.etcd3.policy.Etcd3RoutePolicy
- All Implemented Interfaces:
AutoCloseable
,org.apache.camel.CamelContextAware
,org.apache.camel.Service
,org.apache.camel.ShutdownableService
,org.apache.camel.spi.RoutePolicy
,org.apache.camel.StatefulService
,org.apache.camel.SuspendableService
@ManagedResource(description="Route policy using Etcd as clustered lock")
public class Etcd3RoutePolicy
extends org.apache.camel.support.RoutePolicySupport
implements org.apache.camel.CamelContextAware
An implementation of a route policy based on etcd.
-
Field Summary
Fields inherited from class org.apache.camel.support.service.BaseService
BUILT, FAILED, INITIALIZED, INITIALIZING, lock, NEW, SHUTDOWN, SHUTTING_DOWN, STARTED, STARTING, status, STOPPED, STOPPING, SUSPENDED, SUSPENDING
-
Constructor Summary
ConstructorDescriptionEtcd3RoutePolicy
(io.etcd.jetcd.Client client) Etcd3RoutePolicy
(String... endpoints) Etcd3RoutePolicy
(Etcd3Configuration configuration) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
doStart()
protected void
doStop()
org.apache.camel.CamelContext
io.etcd.jetcd.Client
int
int
getTtl()
boolean
isLeader()
boolean
void
onInit
(org.apache.camel.Route route) void
onStart
(org.apache.camel.Route route) void
onStop
(org.apache.camel.Route route) void
onSuspend
(org.apache.camel.Route route) void
setCamelContext
(org.apache.camel.CamelContext camelContext) void
setEndpoints
(String endpoints) void
setEndpoints
(String[] endpoints) protected void
setLeader
(boolean isLeader) Sets the latest leadership state of the current node and potentially triggers actions if the state has changed.void
setServiceName
(String serviceName) void
setServicePath
(String servicePath) void
setShouldStopConsumer
(boolean shouldStopConsumer) void
setTimeout
(int timeout) void
setTtl
(int ttl) Methods inherited from class org.apache.camel.support.RoutePolicySupport
controller, getExceptionHandler, handleException, onExchangeBegin, onExchangeDone, onRemove, onResume, resumeOrStartConsumer, resumeRoute, setExceptionHandler, startConsumer, startRoute, stopConsumer, stopRoute, stopRoute, stopRouteAsync, suspendOrStopConsumer, suspendRoute, suspendRoute
Methods inherited from class org.apache.camel.support.service.BaseService
build, doBuild, doFail, doInit, doLifecycleChange, doResume, doShutdown, doSuspend, fail, getStatus, init, isBuild, isInit, isNew, isRunAllowed, isShutdown, isStarted, isStarting, isStartingOrStarted, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, isSuspendingOrSuspended, resume, shutdown, start, stop, suspend
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.camel.Service
build, close, init, start, stop
Methods inherited from interface org.apache.camel.ShutdownableService
shutdown
Methods inherited from interface org.apache.camel.StatefulService
getStatus, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isSuspending
Methods inherited from interface org.apache.camel.SuspendableService
isSuspended, resume, suspend
-
Constructor Details
-
Etcd3RoutePolicy
public Etcd3RoutePolicy() -
Etcd3RoutePolicy
-
Etcd3RoutePolicy
public Etcd3RoutePolicy(io.etcd.jetcd.Client client) -
Etcd3RoutePolicy
-
-
Method Details
-
onInit
public void onInit(org.apache.camel.Route route) - Specified by:
onInit
in interfaceorg.apache.camel.spi.RoutePolicy
- Overrides:
onInit
in classorg.apache.camel.support.RoutePolicySupport
-
onStart
public void onStart(org.apache.camel.Route route) - Specified by:
onStart
in interfaceorg.apache.camel.spi.RoutePolicy
- Overrides:
onStart
in classorg.apache.camel.support.RoutePolicySupport
-
onStop
public void onStop(org.apache.camel.Route route) - Specified by:
onStop
in interfaceorg.apache.camel.spi.RoutePolicy
- Overrides:
onStop
in classorg.apache.camel.support.RoutePolicySupport
-
onSuspend
public void onSuspend(org.apache.camel.Route route) - Specified by:
onSuspend
in interfaceorg.apache.camel.spi.RoutePolicy
- Overrides:
onSuspend
in classorg.apache.camel.support.RoutePolicySupport
-
doStart
- Overrides:
doStart
in classorg.apache.camel.support.RoutePolicySupport
- Throws:
Exception
-
doStop
- Overrides:
doStop
in classorg.apache.camel.support.RoutePolicySupport
- Throws:
Exception
-
getCamelContext
public org.apache.camel.CamelContext getCamelContext()- Specified by:
getCamelContext
in interfaceorg.apache.camel.CamelContextAware
-
setCamelContext
public void setCamelContext(org.apache.camel.CamelContext camelContext) - Specified by:
setCamelContext
in interfaceorg.apache.camel.CamelContextAware
-
setLeader
protected void setLeader(boolean isLeader) Sets the latest leadership state of the current node and potentially triggers actions if the state has changed.- Parameters:
isLeader
-true
if the current node is the leader,false
otherwise.
-
getClient
public io.etcd.jetcd.Client getClient() -
getRouteId
-
getEndpointUrl
-
getServiceName
-
setServiceName
@ManagedAttribute(description="The etcd service name") public void setServiceName(String serviceName) -
getServicePath
-
setServicePath
-
getTtl
@ManagedAttribute(description="The time to live (seconds)") public int getTtl() -
setTtl
public void setTtl(int ttl) -
getTimeout
@ManagedAttribute(description="The request timeout (seconds)") public int getTimeout() -
setTimeout
public void setTimeout(int timeout) -
isShouldStopConsumer
@ManagedAttribute(description="Whether to stop consumer when starting up and failed to become master") public boolean isShouldStopConsumer() -
setShouldStopConsumer
public void setShouldStopConsumer(boolean shouldStopConsumer) -
isLeader
@ManagedAttribute(description="Is this route the master or a slave") public boolean isLeader() -
getEndpoints
-
setEndpoints
-
setEndpoints
-