Search in sources :

Example 16 with Service

use of com.alibaba.nacos.naming.core.v2.pojo.Service in project nacos by alibaba.

the class InstanceMetadataProcessor method updateInstanceMetadata.

private void updateInstanceMetadata(MetadataOperation<InstanceMetadata> op) {
    Service service = Service.newService(op.getNamespace(), op.getGroup(), op.getServiceName());
    namingMetadataManager.updateInstanceMetadata(service, op.getTag(), op.getMetadata());
    NotifyCenter.publishEvent(new ServiceEvent.ServiceChangedEvent(service, true));
}
Also used : ServiceEvent(com.alibaba.nacos.naming.core.v2.event.service.ServiceEvent) Service(com.alibaba.nacos.naming.core.v2.pojo.Service)

Example 17 with Service

use of com.alibaba.nacos.naming.core.v2.pojo.Service in project nacos by alibaba.

the class InstanceMetadataProcessor method deleteInstanceMetadata.

private void deleteInstanceMetadata(MetadataOperation<InstanceMetadata> op) {
    Service service = Service.newService(op.getNamespace(), op.getGroup(), op.getServiceName());
    namingMetadataManager.removeInstanceMetadata(service, op.getTag());
}
Also used : Service(com.alibaba.nacos.naming.core.v2.pojo.Service)

Example 18 with Service

use of com.alibaba.nacos.naming.core.v2.pojo.Service in project nacos by alibaba.

the class NamingMetadataManager method handleInstanceMetadataEvent.

private void handleInstanceMetadataEvent(MetadataEvent.InstanceMetadataEvent event) {
    Service service = event.getService();
    String metadataId = event.getMetadataId();
    if (containInstanceMetadata(service, metadataId)) {
        updateExpiredInfo(event.isExpired(), ExpiredMetadataInfo.newExpiredInstanceMetadata(event.getService(), event.getMetadataId()));
    }
}
Also used : Service(com.alibaba.nacos.naming.core.v2.pojo.Service)

Example 19 with Service

use of com.alibaba.nacos.naming.core.v2.pojo.Service in project nacos by alibaba.

the class NamingMetadataManager method loadServiceMetadataSnapshot.

/**
 * Load service metadata snapshot.
 *
 * <p>Service metadata need load back the service.
 *
 * @param snapshot snapshot
 */
public void loadServiceMetadataSnapshot(ConcurrentMap<Service, ServiceMetadata> snapshot) {
    for (Service each : snapshot.keySet()) {
        ServiceManager.getInstance().getSingleton(each);
    }
    ConcurrentMap<Service, ServiceMetadata> oldSnapshot = serviceMetadataMap;
    serviceMetadataMap = snapshot;
    oldSnapshot.clear();
}
Also used : Service(com.alibaba.nacos.naming.core.v2.pojo.Service)

Example 20 with Service

use of com.alibaba.nacos.naming.core.v2.pojo.Service in project nacos by alibaba.

the class ServiceMetadataProcessor method updateServiceMetadata.

private void updateServiceMetadata(MetadataOperation<ServiceMetadata> op) {
    Service service = Service.newService(op.getNamespace(), op.getGroup(), op.getServiceName(), op.getMetadata().isEphemeral());
    Optional<ServiceMetadata> currentMetadata = namingMetadataManager.getServiceMetadata(service);
    if (currentMetadata.isPresent()) {
        ServiceMetadata newMetadata = mergeMetadata(currentMetadata.get(), op.getMetadata());
        Service singleton = ServiceManager.getInstance().getSingleton(service);
        namingMetadataManager.updateServiceMetadata(singleton, newMetadata);
    } else {
        Service singleton = ServiceManager.getInstance().getSingleton(service);
        namingMetadataManager.updateServiceMetadata(singleton, op.getMetadata());
    }
    doubleWriteMetadata(service, false);
}
Also used : Service(com.alibaba.nacos.naming.core.v2.pojo.Service)

Aggregations

Service (com.alibaba.nacos.naming.core.v2.pojo.Service)75 ServiceMetadata (com.alibaba.nacos.naming.core.v2.metadata.ServiceMetadata)20 NamingMetadataOperateService (com.alibaba.nacos.naming.core.v2.metadata.NamingMetadataOperateService)19 ClientOperationService (com.alibaba.nacos.naming.core.v2.service.ClientOperationService)17 Test (org.junit.Test)16 Instance (com.alibaba.nacos.api.naming.pojo.Instance)13 InstancePublishInfo (com.alibaba.nacos.naming.core.v2.pojo.InstancePublishInfo)13 UdpPushService (com.alibaba.nacos.naming.push.UdpPushService)13 NacosException (com.alibaba.nacos.api.exception.NacosException)11 ServiceInfo (com.alibaba.nacos.api.naming.pojo.ServiceInfo)11 HealthCheckInstancePublishInfo (com.alibaba.nacos.naming.core.v2.pojo.HealthCheckInstancePublishInfo)11 HashSet (java.util.HashSet)11 Secured (com.alibaba.nacos.auth.annotation.Secured)10 Before (org.junit.Before)10 Client (com.alibaba.nacos.naming.core.v2.client.Client)9 ClientOperationEvent (com.alibaba.nacos.naming.core.v2.event.client.ClientOperationEvent)8 ClusterMetadata (com.alibaba.nacos.naming.core.v2.metadata.ClusterMetadata)8 InstanceMetadata (com.alibaba.nacos.naming.core.v2.metadata.InstanceMetadata)8 IpPortBasedClient (com.alibaba.nacos.naming.core.v2.client.impl.IpPortBasedClient)7 Set (java.util.Set)7