use of com.alibaba.nacos.consistency.DataOperation in project nacos by alibaba.
the class PersistentClientOperationServiceImpl method onApply.
@Override
public Response onApply(WriteRequest request) {
final InstanceStoreRequest instanceRequest = serializer.deserialize(request.getData().toByteArray());
final DataOperation operation = DataOperation.valueOf(request.getOperation());
final Lock lock = readLock;
lock.lock();
try {
switch(operation) {
case ADD:
onInstanceRegister(instanceRequest.service, instanceRequest.instance, instanceRequest.getClientId());
break;
case DELETE:
onInstanceDeregister(instanceRequest.service, instanceRequest.getClientId());
break;
default:
return Response.newBuilder().setSuccess(false).setErrMsg("unsupport operation : " + operation).build();
}
return Response.newBuilder().setSuccess(true).build();
} finally {
lock.unlock();
}
}
use of com.alibaba.nacos.consistency.DataOperation 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());
}
Aggregations