Search in sources :

Example 16 with DistroData

use of com.alibaba.nacos.core.distributed.distro.entity.DistroData in project nacos by alibaba.

the class DistroControllerTest method testGetAllDatums.

@Test
public void testGetAllDatums() {
    Mockito.when(distroProtocol.onSnapshot(Mockito.any())).thenReturn(new DistroData(null, "content".getBytes()));
    ResponseEntity<byte[]> responseEntity = distroController.getAllDatums();
    Assert.assertArrayEquals("content".getBytes(), responseEntity.getBody());
}
Also used : DistroData(com.alibaba.nacos.core.distributed.distro.entity.DistroData) Test(org.junit.Test)

Example 17 with DistroData

use of com.alibaba.nacos.core.distributed.distro.entity.DistroData in project nacos by alibaba.

the class DistroDataRequestHandler method handleSnapshot.

private DistroDataResponse handleSnapshot() {
    DistroDataResponse result = new DistroDataResponse();
    DistroData distroData = distroProtocol.onSnapshot(DistroClientDataProcessor.TYPE);
    result.setDistroData(distroData);
    return result;
}
Also used : DistroDataResponse(com.alibaba.nacos.naming.cluster.remote.response.DistroDataResponse) DistroData(com.alibaba.nacos.core.distributed.distro.entity.DistroData)

Example 18 with DistroData

use of com.alibaba.nacos.core.distributed.distro.entity.DistroData in project nacos by alibaba.

the class DistroDataRequestHandler method handleQueryData.

private DistroDataResponse handleQueryData(DistroData distroData) {
    DistroDataResponse result = new DistroDataResponse();
    DistroKey distroKey = distroData.getDistroKey();
    DistroData queryData = distroProtocol.onQuery(distroKey);
    result.setDistroData(queryData);
    return result;
}
Also used : DistroKey(com.alibaba.nacos.core.distributed.distro.entity.DistroKey) DistroDataResponse(com.alibaba.nacos.naming.cluster.remote.response.DistroDataResponse) DistroData(com.alibaba.nacos.core.distributed.distro.entity.DistroData)

Example 19 with DistroData

use of com.alibaba.nacos.core.distributed.distro.entity.DistroData in project nacos by alibaba.

the class DistroDataRequestTest method testGetterAndSetter.

@Test
public void testGetterAndSetter() {
    DistroData distroData = mock(DistroData.class);
    DataOperation dataOperation = mock(DataOperation.class);
    DistroDataRequest req = new DistroDataRequest();
    req.setDistroData(distroData);
    req.setDataOperation(dataOperation);
    assertEquals(distroData, req.getDistroData());
    assertEquals(dataOperation, req.getDataOperation());
}
Also used : DataOperation(com.alibaba.nacos.consistency.DataOperation) DistroData(com.alibaba.nacos.core.distributed.distro.entity.DistroData) Test(org.junit.Test)

Example 20 with DistroData

use of com.alibaba.nacos.core.distributed.distro.entity.DistroData in project nacos by alibaba.

the class DistroSyncChangeTask method doExecuteWithCallback.

@Override
protected void doExecuteWithCallback(DistroCallback callback) {
    String type = getDistroKey().getResourceType();
    DistroData distroData = getDistroData(type);
    if (null == distroData) {
        Loggers.DISTRO.warn("[DISTRO] {} with null data to sync, skip", toString());
        return;
    }
    getDistroComponentHolder().findTransportAgent(type).syncData(distroData, getDistroKey().getTargetServer(), callback);
}
Also used : DistroData(com.alibaba.nacos.core.distributed.distro.entity.DistroData)

Aggregations

DistroData (com.alibaba.nacos.core.distributed.distro.entity.DistroData)24 DistroKey (com.alibaba.nacos.core.distributed.distro.entity.DistroKey)5 Test (org.junit.Test)5 DistroDataResponse (com.alibaba.nacos.naming.cluster.remote.response.DistroDataResponse)4 Serializer (com.alibaba.nacos.naming.cluster.transport.Serializer)4 DistroHttpCombinedKey (com.alibaba.nacos.naming.consistency.ephemeral.distro.combined.DistroHttpCombinedKey)4 NacosException (com.alibaba.nacos.api.exception.NacosException)3 Member (com.alibaba.nacos.core.cluster.Member)3 Datum (com.alibaba.nacos.naming.consistency.Datum)3 Client (com.alibaba.nacos.naming.core.v2.client.Client)3 DistroDataStorage (com.alibaba.nacos.core.distributed.distro.component.DistroDataStorage)2 DistroTransportAgent (com.alibaba.nacos.core.distributed.distro.component.DistroTransportAgent)2 DistroException (com.alibaba.nacos.core.distributed.distro.exception.DistroException)2 DistroDataRequest (com.alibaba.nacos.naming.cluster.remote.request.DistroDataRequest)2 HashMap (java.util.HashMap)2 LinkedList (java.util.LinkedList)2 RequestMeta (com.alibaba.nacos.api.remote.request.RequestMeta)1 Response (com.alibaba.nacos.api.remote.response.Response)1 DataOperation (com.alibaba.nacos.consistency.DataOperation)1 DistroDataProcessor (com.alibaba.nacos.core.distributed.distro.component.DistroDataProcessor)1