use of com.alibaba.nacos.core.cluster.Member in project nacos by alibaba.
the class RaftListener method removeOldRaftMetadata.
void removeOldRaftMetadata() {
Loggers.RAFT.warn("start to move old raft protocol metadata");
Member self = memberManager.getSelf();
self.delExtendVal(Constants.OLD_NAMING_RAFT_GROUP);
memberManager.update(self);
}
use of com.alibaba.nacos.core.cluster.Member in project nacos by alibaba.
the class ClusterRpcClientProxyTest method setUp.
@Before
public void setUp() {
EnvUtil.setEnvironment(new MockEnvironment());
Member member = new Member();
member.setIp("1.1.1.1");
ServerAbilities serverAbilities = new ServerAbilities();
ServerRemoteAbility remoteAbility = new ServerRemoteAbility();
remoteAbility.setSupportRemoteConnection(true);
serverAbilities.setRemoteAbility(remoteAbility);
member.setAbilities(serverAbilities);
Mockito.when(serverMemberManager.allMembersWithoutSelf()).thenReturn(Collections.singletonList(member));
clusterRpcClientProxy.init();
}
use of com.alibaba.nacos.core.cluster.Member in project nacos by alibaba.
the class ClusterRpcClientProxyTest method testSendRequest.
@Test
public void testSendRequest() {
Member member = new Member();
member.setIp("1.1.1.1");
try {
Response response = clusterRpcClientProxy.sendRequest(member, new HealthCheckRequest());
} catch (NacosException e) {
Assert.assertEquals(-401, e.getErrCode());
} catch (Exception e) {
e.printStackTrace();
Assert.fail(e.getMessage());
}
}
use of com.alibaba.nacos.core.cluster.Member in project nacos by alibaba.
the class ClusterRpcClientProxyTest method testAsyncRequest.
@Test
public void testAsyncRequest() {
RequestCallBack requestCallBack = new RequestCallBack() {
@Override
public Executor getExecutor() {
return null;
}
@Override
public long getTimeout() {
return 0;
}
@Override
public void onResponse(Response response) {
}
@Override
public void onException(Throwable e) {
Assert.assertTrue(e instanceof NacosException);
}
};
Member member = new Member();
member.setIp("1.1.1.1");
try {
clusterRpcClientProxy.asyncRequest(member, new HealthCheckRequest(), requestCallBack);
} catch (NacosException e) {
Assert.assertEquals(500, e.getErrCode());
}
}
use of com.alibaba.nacos.core.cluster.Member in project nacos by alibaba.
the class ServerLoaderControllerTest method testSmartReload.
@Test
public void testSmartReload() throws NacosException {
EnvUtil.setEnvironment(new MockEnvironment());
Member member = new Member();
member.setIp("1.1.1.1");
member.setPort(8848);
ServerAbilities serverAbilities = new ServerAbilities();
ServerRemoteAbility serverRemoteAbility = new ServerRemoteAbility();
serverRemoteAbility.setSupportRemoteConnection(true);
serverAbilities.setRemoteAbility(serverRemoteAbility);
member.setAbilities(serverAbilities);
Mockito.when(serverMemberManager.allMembersWithoutSelf()).thenReturn(Collections.singletonList(member));
Map<String, String> metrics = new HashMap<>();
metrics.put("conCount", "1");
metrics.put("sdkConCount", "1");
ServerLoaderInfoResponse serverLoaderInfoResponse = new ServerLoaderInfoResponse();
serverLoaderInfoResponse.setLoaderMetrics(metrics);
Mockito.when(serverLoaderInfoRequestHandler.handle(Mockito.any(), Mockito.any())).thenReturn(serverLoaderInfoResponse);
Mockito.when(serverMemberManager.getSelf()).thenReturn(member);
MockHttpServletRequest httpServletRequest = new MockHttpServletRequest();
ResponseEntity<String> result = serverLoaderController.smartReload(httpServletRequest, "1", null);
Assert.assertEquals("Ok", result.getBody());
}
Aggregations