use of com.alibaba.nacos.naming.core.Instance in project nacos by alibaba.
the class MysqlHealthCheckProcessor method process.
@Override
public void process(HealthCheckTask task) {
List<Instance> ips = task.getCluster().allIPs(false);
SRV_LOG.debug("mysql check, ips:" + ips);
if (CollectionUtils.isEmpty(ips)) {
return;
}
for (Instance ip : ips) {
try {
if (ip.isMarked()) {
if (SRV_LOG.isDebugEnabled()) {
SRV_LOG.debug("mysql check, ip is marked as to skip health check, ip: {}", ip.getIp());
}
continue;
}
if (!ip.markChecking()) {
SRV_LOG.warn("mysql check started before last one finished, service: {}:{}:{}", task.getCluster().getService().getName(), task.getCluster().getName(), ip.getIp());
healthCheckCommon.reEvaluateCheckRT(task.getCheckRtNormalized() * 2, task, switchDomain.getMysqlHealthParams());
continue;
}
GlobalExecutor.executeMysqlCheckTask(new MysqlCheckTask(ip, task));
MetricsMonitor.getMysqlHealthCheckMonitor().incrementAndGet();
} catch (Exception e) {
ip.setCheckRt(switchDomain.getMysqlHealthParams().getMax());
healthCheckCommon.checkFail(ip, task, "mysql:error:" + e.getMessage());
healthCheckCommon.reEvaluateCheckRT(switchDomain.getMysqlHealthParams().getMax(), task, switchDomain.getMysqlHealthParams());
}
}
}
use of com.alibaba.nacos.naming.core.Instance in project nacos by alibaba.
the class DefaultInstanceUpgradeHelper method toV1.
@Override
public Instance toV1(com.alibaba.nacos.api.naming.pojo.Instance v2) {
Instance v1 = new Instance(v2.getIp(), v2.getPort(), v2.getClusterName());
BeanUtils.copyProperties(v2, v1);
return v1;
}
use of com.alibaba.nacos.naming.core.Instance in project nacos by alibaba.
the class TcpSuperSenseProcessor method process.
@Override
public void process(HealthCheckTask task) {
List<Instance> ips = task.getCluster().allIPs(false);
if (CollectionUtils.isEmpty(ips)) {
return;
}
for (Instance ip : ips) {
if (ip.isMarked()) {
if (SRV_LOG.isDebugEnabled()) {
SRV_LOG.debug("tcp check, ip is marked as to skip health check, ip:" + ip.getIp());
}
continue;
}
if (!ip.markChecking()) {
SRV_LOG.warn("tcp check started before last one finished, service: " + task.getCluster().getService().getName() + ":" + task.getCluster().getName() + ":" + ip.getIp() + ":" + ip.getPort());
healthCheckCommon.reEvaluateCheckRT(task.getCheckRtNormalized() * 2, task, switchDomain.getTcpHealthParams());
continue;
}
Beat beat = new Beat(ip, task);
taskQueue.add(beat);
MetricsMonitor.getTcpHealthCheckMonitor().incrementAndGet();
}
}
use of com.alibaba.nacos.naming.core.Instance in project nacos by alibaba.
the class RaftStoreTest method wrietDatum.
@Test
public void wrietDatum() throws Exception {
Datum<Instances> datum = new Datum<>();
String key = KeyBuilder.buildInstanceListKey(TEST_NAMESPACE, TEST_SERVICE_NAME, false);
datum.key = key;
datum.timestamp.getAndIncrement();
datum.value = new Instances();
Instance instance = new Instance("1.1.1.1", 1, TEST_CLUSTER_NAME);
datum.value.getInstanceList().add(instance);
instance = new Instance("2.2.2.2", 2, TEST_CLUSTER_NAME);
datum.value.getInstanceList().add(instance);
raftStore.write(datum);
raftCore.init();
Datum result = raftCore.getDatum(key);
Assert.assertEquals(key, result.key);
Assert.assertEquals(1, result.timestamp.intValue());
Assert.assertEquals(datum.value.toString(), result.value.toString());
}
use of com.alibaba.nacos.naming.core.Instance in project nacos by alibaba.
the class ClientBeatCheckTaskTest method testIpDeleteNotTimeOut.
@Test
public void testIpDeleteNotTimeOut() {
Instance instance = new Instance();
instance.setLastBeat(System.currentTimeMillis());
instance.setMarked(true);
instance.setHealthy(true);
Map<String, String> metadata = new HashMap<>();
metadata.put(PreservedMetadataKeys.IP_DELETE_TIMEOUT, "10000");
instance.setMetadata(metadata);
Mockito.doReturn(true).when(distroMapperSpy).responsible(null);
clientBeatCheckTask.run();
}
Aggregations