接口 Client
-
- 所有已知实现类:
AbstractClient,ConnectionBasedClient,IpPortBasedClient
public interface ClientNacos naming client.The abstract concept of the client stored by on the server of Nacos naming module. It is used to store which services the client has published and subscribed.
- 作者:
- xiweng.yy
-
-
方法概要
所有方法 实例方法 抽象方法 修饰符和类型 方法 说明 booleanaddServiceInstance(Service service, InstancePublishInfo instancePublishInfo)Add a new instance for service for current client.booleanaddServiceSubscriber(Service service, Subscriber subscriber)Add a new subscriber for target service.ClientSyncDatagenerateSyncData()Generate sync data.java.util.Collection<Service>getAllPublishedService()Get all published service of current client.java.util.Collection<Service>getAllSubscribeService()Get all subscribe service of current client.java.lang.StringgetClientId()Get the unique id of current client.InstancePublishInfogetInstancePublishInfo(Service service)Get instance info of service from client.longgetLastUpdatedTime()Get the last time for updating current client.longgetRevision()Get client revision.SubscribergetSubscriber(Service service)Get subscriber of service from client.booleanisEphemeral()Whether is ephemeral of current client.booleanisExpire(long currentTime)Whether current client is expired.longrecalculateRevision()Recalculate client revision and get its value.voidrelease()Release current client and release resources if neccessary.InstancePublishInforemoveServiceInstance(Service service)Remove service instance from client.booleanremoveServiceSubscriber(Service service)Remove subscriber for service.voidsetLastUpdatedTime()Set the last time for updating current client as current time.voidsetRevision(long revision)Set client revision.
-
-
-
方法详细资料
-
getClientId
java.lang.String getClientId()
Get the unique id of current client.- 返回:
- id of client
-
isEphemeral
boolean isEphemeral()
Whether is ephemeral of current client.- 返回:
- true if client is ephemeral, otherwise false
-
setLastUpdatedTime
void setLastUpdatedTime()
Set the last time for updating current client as current time.
-
getLastUpdatedTime
long getLastUpdatedTime()
Get the last time for updating current client.- 返回:
- last time for updating
-
addServiceInstance
boolean addServiceInstance(Service service, InstancePublishInfo instancePublishInfo)
Add a new instance for service for current client.- 参数:
service- publish serviceinstancePublishInfo- instance- 返回:
- true if add successfully, otherwise false
-
removeServiceInstance
InstancePublishInfo removeServiceInstance(Service service)
Remove service instance from client.- 参数:
service- service of instance- 返回:
- instance info if exist, otherwise
null
-
getInstancePublishInfo
InstancePublishInfo getInstancePublishInfo(Service service)
Get instance info of service from client.- 参数:
service- service of instance- 返回:
- instance info
-
getAllPublishedService
java.util.Collection<Service> getAllPublishedService()
Get all published service of current client.- 返回:
- published services
-
addServiceSubscriber
boolean addServiceSubscriber(Service service, Subscriber subscriber)
Add a new subscriber for target service.- 参数:
service- subscribe servicesubscriber- subscriber- 返回:
- true if add successfully, otherwise false
-
removeServiceSubscriber
boolean removeServiceSubscriber(Service service)
Remove subscriber for service.- 参数:
service- service of subscriber- 返回:
- true if remove successfully, otherwise false
-
getSubscriber
Subscriber getSubscriber(Service service)
Get subscriber of service from client.- 参数:
service- service of subscriber- 返回:
- subscriber
-
getAllSubscribeService
java.util.Collection<Service> getAllSubscribeService()
Get all subscribe service of current client.- 返回:
- subscribe services
-
generateSyncData
ClientSyncData generateSyncData()
Generate sync data.- 返回:
- sync data
-
isExpire
boolean isExpire(long currentTime)
Whether current client is expired.- 参数:
currentTime- unified current timestamp- 返回:
- true if client has expired, otherwise false
-
release
void release()
Release current client and release resources if neccessary.
-
recalculateRevision
long recalculateRevision()
Recalculate client revision and get its value.- 返回:
- recalculated revision value
-
getRevision
long getRevision()
Get client revision.- 返回:
- current revision without recalculation
-
setRevision
void setRevision(long revision)
Set client revision.- 参数:
revision- revision of this client to update
-
-