Search in sources :

Example 11 with Member

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);
}
Also used : Member(com.alibaba.nacos.core.cluster.Member)

Example 12 with Member

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();
}
Also used : MockEnvironment(org.springframework.mock.env.MockEnvironment) ServerRemoteAbility(com.alibaba.nacos.api.remote.ability.ServerRemoteAbility) ServerAbilities(com.alibaba.nacos.api.ability.ServerAbilities) Member(com.alibaba.nacos.core.cluster.Member) Before(org.junit.Before)

Example 13 with Member

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());
    }
}
Also used : Response(com.alibaba.nacos.api.remote.response.Response) HealthCheckRequest(com.alibaba.nacos.api.remote.request.HealthCheckRequest) Member(com.alibaba.nacos.core.cluster.Member) NacosException(com.alibaba.nacos.api.exception.NacosException) NacosException(com.alibaba.nacos.api.exception.NacosException) Test(org.junit.Test)

Example 14 with Member

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());
    }
}
Also used : Response(com.alibaba.nacos.api.remote.response.Response) RequestCallBack(com.alibaba.nacos.api.remote.RequestCallBack) HealthCheckRequest(com.alibaba.nacos.api.remote.request.HealthCheckRequest) Member(com.alibaba.nacos.core.cluster.Member) NacosException(com.alibaba.nacos.api.exception.NacosException) Test(org.junit.Test)

Example 15 with Member

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());
}
Also used : HashMap(java.util.HashMap) MockEnvironment(org.springframework.mock.env.MockEnvironment) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) ServerLoaderInfoResponse(com.alibaba.nacos.api.remote.response.ServerLoaderInfoResponse) ServerRemoteAbility(com.alibaba.nacos.api.remote.ability.ServerRemoteAbility) ServerAbilities(com.alibaba.nacos.api.ability.ServerAbilities) Member(com.alibaba.nacos.core.cluster.Member) Test(org.junit.Test)

Aggregations

Member (com.alibaba.nacos.core.cluster.Member)53 Test (org.junit.Test)17 NacosException (com.alibaba.nacos.api.exception.NacosException)11 HashMap (java.util.HashMap)11 Response (com.alibaba.nacos.api.remote.response.Response)8 CountDownLatch (java.util.concurrent.CountDownLatch)7 DistroDataRequest (com.alibaba.nacos.naming.cluster.remote.request.DistroDataRequest)6 Map (java.util.Map)5 ServerLoaderInfoResponse (com.alibaba.nacos.api.remote.response.ServerLoaderInfoResponse)4 NacosAsyncRestTemplate (com.alibaba.nacos.common.http.client.NacosAsyncRestTemplate)4 DistroDataResponse (com.alibaba.nacos.naming.cluster.remote.response.DistroDataResponse)4 ArrayList (java.util.ArrayList)4 Collection (java.util.Collection)4 Before (org.junit.Before)4 GetMapping (org.springframework.web.bind.annotation.GetMapping)4 ServerAbilities (com.alibaba.nacos.api.ability.ServerAbilities)3 RequestCallBack (com.alibaba.nacos.api.remote.RequestCallBack)3 ServerRemoteAbility (com.alibaba.nacos.api.remote.ability.ServerRemoteAbility)3 RestResult (com.alibaba.nacos.common.model.RestResult)3 GenericType (com.alibaba.nacos.core.utils.GenericType)3