forked from ctripcorp/x-pipe
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
104 changed files
with
2,502 additions
and
668 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
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
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
52 changes: 52 additions & 0 deletions
52
...in/java/com/ctrip/xpipe/redis/console/controller/consoleportal/HealthCheckController.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,52 @@ | ||
package com.ctrip.xpipe.redis.console.controller.consoleportal; | ||
|
||
import java.util.Map; | ||
|
||
import org.apache.logging.log4j.util.Strings; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestMethod; | ||
import org.springframework.web.bind.annotation.RestController; | ||
import com.ctrip.xpipe.metric.HostPort; | ||
import com.ctrip.xpipe.redis.console.config.ConsoleConfig; | ||
import com.ctrip.xpipe.redis.console.controller.AbstractConsoleController; | ||
import com.ctrip.xpipe.redis.console.health.delay.DelayService; | ||
import com.ctrip.xpipe.redis.console.health.ping.PingService; | ||
import com.google.common.collect.ImmutableMap; | ||
|
||
/** | ||
* @author shyin | ||
* | ||
* Jan 5, 2017 | ||
*/ | ||
@RestController | ||
@RequestMapping("console") | ||
public class HealthCheckController extends AbstractConsoleController{ | ||
|
||
@Autowired | ||
private PingService pingService; | ||
@Autowired | ||
private DelayService delayService; | ||
@Autowired | ||
private ConsoleConfig config; | ||
|
||
@RequestMapping(value = "/redis/health/{redisIp}/{redisPort}", method = RequestMethod.GET) | ||
public Map<String, Boolean> isRedisHealth(@PathVariable String redisIp, @PathVariable int redisPort) { | ||
return ImmutableMap.of("isHealth", pingService.isRedisAlive(new HostPort(redisIp, redisPort))); | ||
} | ||
|
||
@RequestMapping(value = "/redis/delay/{redisIp}/{redisPort}", method = RequestMethod.GET) | ||
public Map<String, Long> getReplDelayMillis(@PathVariable String redisIp, @PathVariable int redisPort) { | ||
return ImmutableMap.of("delay", delayService.getDelay(new HostPort(redisIp, redisPort))); | ||
} | ||
|
||
@RequestMapping(value = "/redis/health/hickwall/{cluster}/{shard}/{redisIp}/{redisPort}", method = RequestMethod.GET) | ||
public Map<String, String> getHickwallAddress(@PathVariable String cluster, @PathVariable String shard, @PathVariable String redisIp, @PathVariable int redisPort) { | ||
String addr = config.getHickwallAddress(); | ||
if(Strings.isEmpty(addr)) { | ||
return ImmutableMap.of("addr", ""); | ||
} | ||
return ImmutableMap.of("addr", String.format("%s.%s.%s.%s.%s", addr, cluster, shard, redisIp, redisPort)); | ||
} | ||
} |
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
41 changes: 41 additions & 0 deletions
41
.../main/java/com/ctrip/xpipe/redis/console/controller/consoleportal/SentinelController.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,41 @@ | ||
package com.ctrip.xpipe.redis.console.controller.consoleportal; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestMethod; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import com.ctrip.xpipe.redis.console.controller.AbstractConsoleController; | ||
import com.ctrip.xpipe.redis.console.model.SetinelTbl; | ||
import com.ctrip.xpipe.redis.console.service.SentinelService; | ||
|
||
/** | ||
* @author shyin | ||
* | ||
* Jan 4, 2017 | ||
*/ | ||
@RestController | ||
@RequestMapping("/console") | ||
public class SentinelController extends AbstractConsoleController{ | ||
@Autowired | ||
private SentinelService sentinelService; | ||
|
||
@RequestMapping(value="/{dcName}/sentinels", method = RequestMethod.GET) | ||
public List<SetinelTbl> getSentinelsByDcName(@PathVariable String dcName) { | ||
return sentinelService.findAllByDcName(dcName); | ||
} | ||
|
||
@RequestMapping(value="/sentinels/{sentinelId}", method = RequestMethod.GET) | ||
public SetinelTbl findSentinel(@PathVariable long sentinelId){ | ||
return sentinelService.find(sentinelId); | ||
} | ||
|
||
@RequestMapping(value="/sentinels/shard/{shardId}", method = RequestMethod.GET) | ||
public Map<Long,SetinelTbl> findSentinelByShard(@PathVariable long shardId) { | ||
return sentinelService.findByShard(shardId); | ||
} | ||
} |
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
Oops, something went wrong.