use of com.alibaba.nacos.naming.core.v2.metadata.ServiceMetadata 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.metadata.ServiceMetadata in project nacos by alibaba.
the class ServiceEnableBeatCheckInterceptor method intercept.
@Override
public boolean intercept(InstanceBeatCheckTask object) {
NamingMetadataManager metadataManager = ApplicationUtils.getBean(NamingMetadataManager.class);
Optional<ServiceMetadata> metadata = metadataManager.getServiceMetadata(object.getService());
if (metadata.isPresent() && metadata.get().getExtendData().containsKey(UtilsAndCommons.ENABLE_CLIENT_BEAT)) {
return Boolean.parseBoolean(metadata.get().getExtendData().get(UtilsAndCommons.ENABLE_CLIENT_BEAT));
}
return false;
}
use of com.alibaba.nacos.naming.core.v2.metadata.ServiceMetadata in project nacos by alibaba.
the class PushExecutorDelegateTest method setUp.
@Before
public void setUp() throws Exception {
serviceMetadata = new ServiceMetadata();
pushdata = new PushDataWrapper(serviceMetadata, new ServiceInfo("G@@S"));
delegate = new PushExecutorDelegate(pushExecutorRpc, pushExecutorUdp);
}
use of com.alibaba.nacos.naming.core.v2.metadata.ServiceMetadata 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.metadata.ServiceMetadata 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