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.CamelContextAwareAn implementation of a route policy based on etcd.
-
-
Constructor Summary
Constructors Constructor Description Etcd3RoutePolicy()Etcd3RoutePolicy(io.etcd.jetcd.Client client)Etcd3RoutePolicy(String... endpoints)Etcd3RoutePolicy(Etcd3Configuration configuration)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voiddoStart()protected voiddoStop()org.apache.camel.CamelContextgetCamelContext()io.etcd.jetcd.ClientgetClient()StringgetEndpoints()StringgetEndpointUrl()StringgetRouteId()StringgetServiceName()StringgetServicePath()intgetTimeout()intgetTtl()booleanisLeader()booleanisShouldStopConsumer()voidonInit(org.apache.camel.Route route)voidonStart(org.apache.camel.Route route)voidonStop(org.apache.camel.Route route)voidonSuspend(org.apache.camel.Route route)voidsetCamelContext(org.apache.camel.CamelContext camelContext)voidsetEndpoints(String endpoints)voidsetEndpoints(String[] endpoints)protected voidsetLeader(boolean isLeader)Sets the latest leadership state of the current node and potentially triggers actions if the state has changed.voidsetServiceName(String serviceName)voidsetServicePath(String servicePath)voidsetShouldStopConsumer(boolean shouldStopConsumer)voidsetTimeout(int timeout)voidsetTtl(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
-
-
-
-
Constructor Detail
-
Etcd3RoutePolicy
public Etcd3RoutePolicy()
-
Etcd3RoutePolicy
public Etcd3RoutePolicy(Etcd3Configuration configuration)
-
Etcd3RoutePolicy
public Etcd3RoutePolicy(io.etcd.jetcd.Client client)
-
Etcd3RoutePolicy
public Etcd3RoutePolicy(String... endpoints)
-
-
Method Detail
-
onInit
public void onInit(org.apache.camel.Route route)
- Specified by:
onInitin interfaceorg.apache.camel.spi.RoutePolicy- Overrides:
onInitin classorg.apache.camel.support.RoutePolicySupport
-
onStart
public void onStart(org.apache.camel.Route route)
- Specified by:
onStartin interfaceorg.apache.camel.spi.RoutePolicy- Overrides:
onStartin classorg.apache.camel.support.RoutePolicySupport
-
onStop
public void onStop(org.apache.camel.Route route)
- Specified by:
onStopin interfaceorg.apache.camel.spi.RoutePolicy- Overrides:
onStopin classorg.apache.camel.support.RoutePolicySupport
-
onSuspend
public void onSuspend(org.apache.camel.Route route)
- Specified by:
onSuspendin interfaceorg.apache.camel.spi.RoutePolicy- Overrides:
onSuspendin classorg.apache.camel.support.RoutePolicySupport
-
doStart
protected void doStart() throws Exception- Overrides:
doStartin classorg.apache.camel.support.RoutePolicySupport- Throws:
Exception
-
doStop
protected void doStop() throws Exception- Overrides:
doStopin classorg.apache.camel.support.RoutePolicySupport- Throws:
Exception
-
getCamelContext
public org.apache.camel.CamelContext getCamelContext()
- Specified by:
getCamelContextin interfaceorg.apache.camel.CamelContextAware
-
setCamelContext
public void setCamelContext(org.apache.camel.CamelContext camelContext)
- Specified by:
setCamelContextin 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-trueif the current node is the leader,falseotherwise.
-
getClient
public io.etcd.jetcd.Client getClient()
-
getRouteId
@ManagedAttribute(description="The route id") public String getRouteId()
-
getEndpointUrl
@ManagedAttribute(description="The consumer endpoint", mask=true) public String getEndpointUrl()
-
getServiceName
public String getServiceName()
-
setServiceName
@ManagedAttribute(description="The etcd service name") public void setServiceName(String serviceName)
-
getServicePath
@ManagedAttribute(description="The etcd service path") public String getServicePath()
-
setServicePath
public void setServicePath(String servicePath)
-
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
@ManagedAttribute(description="Etcd endpoints") public String getEndpoints()
-
setEndpoints
public void setEndpoints(String[] endpoints)
-
setEndpoints
public void setEndpoints(String endpoints)
-
-