Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
making it possible to enable/disable instance from lb via jmx (#869)
* making it possible to enable/disable instance from lb via jmx * Moved the load balancer state to a class * Updated jmx interface to be similar to what we have in db-web-ui so as to reduce duplication in deployment script
- Loading branch information
Showing
4 changed files
with
87 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
whois-commons/src/main/java/net/ripe/db/whois/common/ReadinessUpdater.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package net.ripe.db.whois.common; | ||
|
||
import net.ripe.db.whois.common.jmx.JmxBase; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.jmx.export.annotation.ManagedAttribute; | ||
import org.springframework.jmx.export.annotation.ManagedOperation; | ||
import org.springframework.jmx.export.annotation.ManagedResource; | ||
import org.springframework.stereotype.Component; | ||
|
||
/** | ||
* in jmxterm, run with: | ||
* bean net.ripe.db.whois:name=ReadinessUpdater | ||
* run up - ready to receive traffic | ||
* run down - not ready to receive traffic | ||
* | ||
*/ | ||
@Component | ||
@ManagedResource(objectName = JmxBase.OBJECT_NAME_BASE + "ReadinessUpdater", description = "Loadbalancer switch") | ||
public class ReadinessUpdater extends JmxBase { | ||
private static final Logger LOGGER = LoggerFactory.getLogger(ReadinessUpdater.class); | ||
|
||
private boolean loadBalancerEnabled; | ||
|
||
public ReadinessUpdater() { | ||
super(LOGGER); | ||
} | ||
|
||
@ManagedOperation | ||
public void up(){ | ||
this.loadBalancerEnabled = true; | ||
LOGGER.info("Marked service as ready to receive traffic"); | ||
} | ||
|
||
@ManagedOperation | ||
public void down() { | ||
this.loadBalancerEnabled = false; | ||
LOGGER.info("Marked service as not ready to receive traffic"); | ||
} | ||
|
||
public boolean isLoadBalancerEnabled() { | ||
return loadBalancerEnabled; | ||
} | ||
|
||
} |