use of org.corfudb.runtime.clients.ManagementClient in project CorfuDB by CorfuDB.
the class ManagementServer method analyzePollReportAndTriggerHandler.
/**
* Analyzes the poll report and triggers the failure handler if status change
* of node detected.
* <p>
* @param pollReport Poll report obtained from failure detection policy.
*/
private void analyzePollReportAndTriggerHandler(PollReport pollReport) {
// Check if handler has been initiated.
if (!startFailureHandler) {
log.debug("Failure Handler not yet initiated: {}", pollReport.toString());
return;
}
final ManagementClient localManagementClient = corfuRuntime.getRouter(getLocalEndpoint()).getClient(ManagementClient.class);
try {
if (!pollReport.getIsFailurePresent()) {
// un-mark them as they respond to polling now.
if (!latestLayout.getUnresponsiveServers().isEmpty()) {
log.info("Received response from unresponsive server");
localManagementClient.handleFailure(pollReport.getFailingNodes()).get();
return;
}
log.debug("No failures present.");
} else if (!pollReport.getFailingNodes().isEmpty() && !latestLayout.getUnresponsiveServers().isEmpty()) {
// CASE 2:
// Failures detected - unresponsive servers.
// We check if these servers are the same set of servers which are marked as
// unresponsive in the layout. If yes take no action. Else trigger handler.
log.info("Failures detected. Failed nodes : {}", pollReport.toString());
//TODO: Does not handle the un-marking case where markedSet is a superset of pollFailures.
for (String failedServer : pollReport.getFailingNodes()) {
if (!latestLayout.getUnresponsiveServers().contains(failedServer)) {
localManagementClient.handleFailure(pollReport.getFailingNodes()).get();
return;
}
}
log.debug("Failure already taken care of.");
} else {
// CASE 3:
// Failures detected but not marked in the layout or
// some servers have been partially sealed to new epoch or stuck on
// the previous epoch.
localManagementClient.handleFailure(pollReport.getFailingNodes()).get();
// TODO: Only re-sealing needed if server stuck on a previous epoch.
}
} catch (Exception e) {
log.error("Exception invoking failure handler : {}", e);
}
}
use of org.corfudb.runtime.clients.ManagementClient in project CorfuDB by CorfuDB.
the class AbstractViewTest method getRouterFunction.
/** Function for obtaining a router, given a runtime and an endpoint.
*
* @param runtime The CorfuRuntime to obtain a router for.
* @param endpoint An endpoint string for the router.
* @return
*/
private IClientRouter getRouterFunction(CorfuRuntime runtime, String endpoint) {
runtimeRouterMap.putIfAbsent(runtime, new ConcurrentHashMap<>());
if (!endpoint.startsWith("test:")) {
throw new RuntimeException("Unsupported endpoint in test: " + endpoint);
}
return runtimeRouterMap.get(runtime).computeIfAbsent(endpoint, x -> {
TestClientRouter tcn = new TestClientRouter(testServerMap.get(endpoint).getServerRouter());
tcn.addClient(new BaseClient()).addClient(new SequencerClient()).addClient(new LayoutClient()).addClient(new LogUnitClient()).addClient(new ManagementClient());
return tcn;
});
}
Aggregations