use of com.alibaba.nacos.naming.core.v2.pojo.HealthCheckInstancePublishInfo in project nacos by alibaba.
the class TcpHealthCheckProcessor method process.
@Override
public void process(HealthCheckTaskV2 task, Service service, ClusterMetadata metadata) {
HealthCheckInstancePublishInfo instance = (HealthCheckInstancePublishInfo) task.getClient().getInstancePublishInfo(service);
if (null == instance) {
return;
}
// TODO handle marked(white list) logic like v1.x.
if (!instance.tryStartCheck()) {
SRV_LOG.warn("[HEALTH-CHECK-V2] tcp check started before last one finished, service: {} : {} : {}:{}", service.getGroupedServiceName(), instance.getCluster(), instance.getIp(), instance.getPort());
healthCheckCommon.reEvaluateCheckRT(task.getCheckRtNormalized() * 2, task, switchDomain.getTcpHealthParams());
return;
}
taskQueue.add(new Beat(task, service, metadata, instance));
MetricsMonitor.getTcpHealthCheckMonitor().incrementAndGet();
}
use of com.alibaba.nacos.naming.core.v2.pojo.HealthCheckInstancePublishInfo in project nacos by alibaba.
the class HealthCheckTaskInterceptWrapperTest method injectInstance.
private HealthCheckInstancePublishInfo injectInstance(boolean healthy, long heartbeatTime) {
Service service = Service.newService(NAMESPACE, GROUP_NAME, SERVICE_NAME);
HealthCheckInstancePublishInfo instance = new HealthCheckInstancePublishInfo(IP, PORT);
instance.setHealthy(healthy);
instance.setLastHeartBeatTime(heartbeatTime);
client.addServiceInstance(service, instance);
return instance;
}
use of com.alibaba.nacos.naming.core.v2.pojo.HealthCheckInstancePublishInfo in project nacos by alibaba.
the class MysqlHealthCheckProcessor method process.
@Override
public void process(HealthCheckTaskV2 task, Service service, ClusterMetadata metadata) {
HealthCheckInstancePublishInfo instance = (HealthCheckInstancePublishInfo) task.getClient().getInstancePublishInfo(service);
if (null == instance) {
return;
}
SRV_LOG.debug("mysql check, ip:" + instance);
try {
// TODO handle marked(white list) logic like v1.x.
if (!instance.tryStartCheck()) {
SRV_LOG.warn("mysql check started before last one finished, service: {} : {} : {}:{}", service.getGroupedServiceName(), instance.getCluster(), instance.getIp(), instance.getPort());
healthCheckCommon.reEvaluateCheckRT(task.getCheckRtNormalized() * 2, task, switchDomain.getMysqlHealthParams());
return;
}
GlobalExecutor.executeMysqlCheckTask(new MysqlCheckTask(task, service, instance, metadata));
MetricsMonitor.getMysqlHealthCheckMonitor().incrementAndGet();
} catch (Exception e) {
instance.setCheckRt(switchDomain.getMysqlHealthParams().getMax());
healthCheckCommon.checkFail(task, service, "mysql:error:" + e.getMessage());
healthCheckCommon.reEvaluateCheckRT(switchDomain.getMysqlHealthParams().getMax(), task, switchDomain.getMysqlHealthParams());
}
}
use of com.alibaba.nacos.naming.core.v2.pojo.HealthCheckInstancePublishInfo in project nacos by alibaba.
the class ClientBeatUpdateTask method run.
@Override
public void run() {
long currentTime = System.currentTimeMillis();
for (InstancePublishInfo each : client.getAllInstancePublishInfo()) {
((HealthCheckInstancePublishInfo) each).setLastHeartBeatTime(currentTime);
}
client.setLastUpdatedTime();
}
use of com.alibaba.nacos.naming.core.v2.pojo.HealthCheckInstancePublishInfo in project nacos by alibaba.
the class HealthCheckCommonV2 method checkFailNow.
/**
* Health check fail, set instance unhealthy directly.
*
* @param task health check task
* @param service service
* @param msg message
*/
public void checkFailNow(HealthCheckTaskV2 task, Service service, String msg) {
try {
HealthCheckInstancePublishInfo instance = (HealthCheckInstancePublishInfo) task.getClient().getInstancePublishInfo(service);
if (null == instance) {
return;
}
try {
if (instance.isHealthy()) {
String serviceName = service.getGroupedServiceName();
String clusterName = instance.getCluster();
if (switchDomain.isHealthCheckEnabled(serviceName) && !task.isCancelled() && distroMapper.responsible(task.getClient().getResponsibleId())) {
healthStatusSynchronizer.instanceHealthStatusChange(false, task.getClient(), service, instance);
Loggers.EVT_LOG.info("serviceName: {} {POS} {IP-DISABLED} invalid: {}:{}@{}, region: {}, msg: {}", serviceName, instance.getIp(), instance.getPort(), clusterName, UtilsAndCommons.LOCALHOST_SITE, msg);
}
}
} finally {
instance.resetOkCount();
instance.finishCheck();
}
} catch (Throwable t) {
Loggers.SRV_LOG.error("[CHECK-FAIL] error when close check task.", t);
}
}
Aggregations