use of com.alibaba.nacos.naming.core.v2.pojo.Service in project nacos by alibaba.
the class ServiceMetadataProcessor method deleteServiceMetadata.
private void deleteServiceMetadata(MetadataOperation<ServiceMetadata> op) {
Service service = Service.newService(op.getNamespace(), op.getGroup(), op.getServiceName());
namingMetadataManager.removeServiceMetadata(service);
Service removed = ServiceManager.getInstance().removeSingleton(service);
if (removed != null) {
service = removed;
}
serviceStorage.removeData(service);
doubleWriteMetadata(service, true);
}
use of com.alibaba.nacos.naming.core.v2.pojo.Service in project nacos by alibaba.
the class NamingSubscriberServiceV1ImplTest method testGetSubscribersWithServiceParam.
@Test
public void testGetSubscribersWithServiceParam() {
Service service = Service.newService("1", "G1", "S1");
Collection<Subscriber> actual = namingSubscriberService.getSubscribers(service);
assertEquals(1, actual.size());
assertSubscriber("1", "G1@@S1", actual.iterator().next());
}
use of com.alibaba.nacos.naming.core.v2.pojo.Service in project nacos by alibaba.
the class NamingSubscriberServiceV1ImplTest method testGetFuzzySubscribersWithServiceParam.
@Test
public void testGetFuzzySubscribersWithServiceParam() {
Service service = Service.newService("1", "G", "S");
Collection<Subscriber> actual = namingSubscriberService.getFuzzySubscribers(service);
assertEquals(2, actual.size());
assertSubscriber("1", "DEFAULT_GROUP@@S2", actual.iterator().next());
}
use of com.alibaba.nacos.naming.core.v2.pojo.Service in project nacos by alibaba.
the class ServiceController method create.
/**
* Create a new service. This API will create a persistence service.
*
* @param namespaceId namespace id
* @param serviceName service name
* @param protectThreshold protect threshold
* @param metadata service metadata
* @param selector selector
* @return 'ok' if success
* @throws Exception exception
*/
@PostMapping
@Secured(action = ActionTypes.WRITE)
public String create(@RequestParam(defaultValue = Constants.DEFAULT_NAMESPACE_ID) String namespaceId, @RequestParam String serviceName, @RequestParam(required = false, defaultValue = "0.0F") float protectThreshold, @RequestParam(defaultValue = StringUtils.EMPTY) String metadata, @RequestParam(defaultValue = StringUtils.EMPTY) String selector) throws Exception {
ServiceMetadata serviceMetadata = new ServiceMetadata();
serviceMetadata.setProtectThreshold(protectThreshold);
serviceMetadata.setSelector(parseSelector(selector));
serviceMetadata.setExtendData(UtilsAndCommons.parseMetadata(metadata));
serviceMetadata.setEphemeral(false);
getServiceOperator().create(namespaceId, serviceName, serviceMetadata);
return "ok";
}
use of com.alibaba.nacos.naming.core.v2.pojo.Service in project nacos by alibaba.
the class ServiceControllerV2 method update.
/**
* Update service.
*
* @param namespaceId namespace id
* @param serviceName service name
* @param protectThreshold protect threshold
* @param metadata service metadata
* @param selector selector
* @return 'ok' if success
* @throws Exception exception
*/
@PutMapping(value = "/{serviceName}")
@Secured(action = ActionTypes.WRITE)
public RestResult<String> update(@RequestParam(defaultValue = Constants.DEFAULT_NAMESPACE_ID) String namespaceId, @PathVariable String serviceName, @RequestParam(defaultValue = Constants.DEFAULT_GROUP) String groupName, @RequestParam(required = false, defaultValue = "0.0F") float protectThreshold, @RequestParam(defaultValue = StringUtils.EMPTY) String metadata, @RequestParam(defaultValue = StringUtils.EMPTY) String selector) throws Exception {
ServiceMetadata serviceMetadata = new ServiceMetadata();
serviceMetadata.setProtectThreshold(protectThreshold);
serviceMetadata.setExtendData(UtilsAndCommons.parseMetadata(metadata));
serviceMetadata.setSelector(parseSelector(selector));
Service service = Service.newService(namespaceId, groupName, serviceName);
serviceOperatorV2.update(service, serviceMetadata);
return RestResultUtils.success("ok");
}
Aggregations