ZooKeeper在Dubbo应用

dubbo目录下所有服务
[zk: localhost:2181(CONNECTED) 2] ls /dubbo
[uyun.bird.tenant.api.UserAuditService, uyun.spider.event.api.service.EventService, uyun.pacific.resource.api.service.ResKeyIdentifierService, uyun.spider.resource.api.HostStatusService, uyun.eagle.web.api.service.DataRestService, uyun.pacific.model.api.service.ResUniqueKeyService, uyun.eagle.web.api.service.AlertRestService, uyun.spider.topo.api.LabelService, uyun.spider.topo.rest.TopoStatusService, uyun.spider.agent.mgr.api.TaskManagerService, uyun.indian.model.api.ResourceService, uyun.spider.topo.api.NodeDisplayService, uyun.crab.repo.api.CIChangeStatisticService, uyun.crab.circle.api.ViewService, uyun.eagle.web.api.service.ApplyRuleRestService, uyun.spider.resource.api.ProtocolService, uyun.crab.model.api.service.ResClassIconService, uyun.bird.tenant.api.HealthCheckService, uyun.crab.model.api.service.CategoryService, uyun.crab.circle.api.SubscribeService, uyun.innerdatademo.rest.service.RestService, uyun.eagle.web.api.service.TreeMapRestService, uyun.bering.api.service.TagService, uyun.pacific.model.api.service.ResRelationMetaService, uyun.bird.tenant.service.UserImagesService, uyun.spider.agent.mgr.api.AgentManagerService, uyun.eagle.datacenter.api.service.RuleService, uyun.arctic.checkpoint.api.WriterService, uyun.eagle.datacenter.api.service.ApplicationService, uyun.spider.resource.api.HostGroupService, uyun.eagle.gateway.api.service.WebHookApi, uyun.eagle.gateway.api.service.HealthCheckFrontService, uyun.eagle.web.api.service.CommonRestService, uyun.indian.reader.api.ReaderService, uyun.eagle.datacenter.api.service.IncidentListService, uyun.crab.model.api.service.AuthorityService, uyun.pacific.resource.api.service.InlineObjectService, uyun.spider.resource.api.ProducerService, uyun.eagle.datacenter.api.service.AlertService, uyun.spider.topo.api.TopoGroupService, uyun.eagle.datacenter.api.service.TagService, uyun.spider.topo.api.DictDataService, uyun.crab.circle.api.CommentService, uyun.eagle.web.api.service.VisualAnalyzeRestService, uyun.bird.tenant.service.RedisService, uyun.pacific.resource.api.service.ResourceHealthCheckService, uyun.spider.agent.mgr.api.TaskRelationService, uyun.crab.circle.api.ConsumpService, uyun.bird.tenant.service.InnerMqSendService, uyun.eagle.web.api.service.ApplicationTypeRestService, uyun.bird.tenant.api.TenantService, uyun.bird.notify.api.NotifyService, uyun.pacific.resource.api.service.ResObjectService, uyun.bird.tenant.service.OnlineUserService, uyun.eagle.datacenter.api.service.TreeMapService, uyun.eagle.web.api.service.ActionRestService, uyun.bird.tenant.api.UserService, uyun.bird.tenant.api.UserExcessService, uyun.bird.tenant.service.CasHtmlService, uyun.bird.tenant.api.TagService, uyun.hornet.service.api.service.TicketStatisticService, uyun.indian.writer.api.WriterService, uyun.bird.notify.api.HealthCheckService, uyun.bird.tenant.service.LockUserService, uyun.bird.tenant.service.CodeService, uyun.eagle.datacenter.api.service.ApplyRuleService, uyun.spider.datastore.api.service.ResourceService, uyun.bird.tenant.api.CompanySizeService, uyun.pacific.model.api.service.ModelService, uyun.spider.resource.rest.ResourceStatusService, uyun.bird.tenant.service.Base64CodeService, uyun.eagle.datacenter.api.service.ActionConfigService, uyun.pacific.model.api.service.ModelHealthCheckService, uyun.eagle.web.api.service.IncidentRestService, uyun.bird.tenant.service.IComptrollerLogService, uyun.bird.tenant.service.LincenseService, uyun.crab.model.api.service.CIFormService, uyun.bird.tenant.api.SmsValidateService, uyun.spider.resource.api.TagService, uyun.spider.resource.api.StoreService, uyun.crab.circle.api.CircleService, uyun.eagle.datacenter.api.rest.service.HealthCheckFrontService, uyun.crab.repo.api.SandboxService, uyun.eagle.datacenter.api.service.ResObjectStateService, uyun.eagle.gateway.api.service.RuleRestService, uyun.bird.tenant.service.DepartUserService, uyun.spider.resource.api.HostModelService, uyun.spider.agent.mgr.service.AgentService, uyun.spider.resource.api.LinkService, uyun.spider.topo.api.CollectPointService, uyun.bird.tenant.service.TenantSecurityPolicyService, uyun.eagle.gateway.api.service.TagServiceApiService, uyun.crab.circle.api.AutoClaimPolicyService, uyun.innerdatastore.rest.service.RestService, uyun.bird.tenant.service.ConfigurationService, uyun.indian.model.api.MetricService, uyun.eagle.web.api.service.ApplicationRestService, uyun.bird.tenant.service.ExcelService, uyun.bird.tenant.service.BatchUserService, uyun.eagle.web.api.service.RuleRestService, uyun.eagle.datacenter.api.service.ApplicationTypeService, uyun.bird.tenant.api.TimezoneLangService, uyun.eagle.gateway.api.service.IncidentOpenApiService, uyun.bird.tenant.api.ProductService, uyun.bird.tenant.api.IDepartService, uyun.crab.circle.api.ChartService, uyun.eagle.datacenter.api.service.IncidentLogService, uyun.spider.monitor.api.service.MonitorService, uyun.eagle.gateway.api.service.IncidentServiceApiService, uyun.ant.manager.agent.logic.AgentOperator, uyun.innerdatazabbix.rest.service.RestService, uyun.spider.event.rest.EventStatusService, uyun.spider.topo.api.TopoService, uyun.arctic.model.api.StateService, uyun.bird.tenant.service.DepartService, uyun.pacific.model.api.service.ResAttributeService, uyun.pacific.resource.api.service.ResHistoryService, uyun.pacific.model.api.service.ResClassService, uyun.eagle.datacenter.api.service.IncidentService, uyun.pacific.model.api.service.ResInterfaceService, uyun.spider.resource.api.HostService, uyun.bird.tenant.api.ComptrollerLogService, uyun.crab.repo.api.SearchService, uyun.spider.topo.api.NodeService, uyun.bird.tenant.api.IndustryService, uyun.crab.repo.api.CIStatisticService, uyun.crab.repo.api.BaselineService, uyun.crab.repo.api.CICircleStatisticService, uyun.spider.agent.mgr.event.AgentManager, uyun.pacific.model.api.service.InlineClassService, uyun.spider.datastore.api.service.MetricService, uyun.spider.resource.api.InterfaceService, uyun.pacific.model.api.service.ResRelationTypeService, uyun.pacific.resource.api.service.ResTagService, uyun.pacific.resource.api.service.AuditService, uyun.spider.agent.mgr.api.UnsupportedHostService, uyun.spider.monitor.rest.MonitorStatusService, uyun.eagle.datacenter.api.service.ActionService, uyun.bird.notify.api.imsg.IMessageService, uyun.arctic.checkpoint.api.ReaderService, uyun.bee.lm.api.LM, uyun.spider.agent.mgr.service.TaskService, uyun.eagle.web.api.service.HealthCheckFrontService, uyun.pacific.resource.api.service.NetworkZoneService, uyun.bird.tenant.api.LogService, uyun.pacific.resource.api.service.ResRelationService, uyun.crab.circle.api.GroupService, uyun.eagle.datacenter.api.service.CommonService, uyun.spider.topo.api.TopoCategoryService, uyun.spider.agent.mgr.event.TaskManager, uyun.spider.agent.mgr.rest.AgentStatusService, uyun.eagle.gateway.api.service.FlumeService, uyun.spider.resource.api.MetricService, uyun.crab.repo.api.CIRecordService]
服务节点
[zk: localhost:2181(CONNECTED) 6] ls /dubbo/uyun.spider.resource.api.LinkService
[consumers, configurators, routers, providers]
服务提供者
  • 在服务提供者初始化时,dubbo首先会在ZooKeeper的/dubbo/uyun.spider.resource.api.LinkService/providers节点下创建一个子节点,并写入自己的URL地址,代表了LinkService服务的一个提供者
[zk: localhost:2181(CONNECTED) 7] ls /dubbo/uyun.spider.resource.api.LinkService/providers
[dubbo%3A%2F%2F10.1.50.64%3A7900%2Fuyun.spider.resource.api.LinkService%3Fanyhost%3Dtrue%26application%3Dspider-server-resource%26default.retries%3D0%26default.service.filter%3Di18nProviderFilter%26default.timeout%3D30000%26dubbo%3D2.8.4.170831%26generic%3Dfalse%26interface%3Duyun.spider.resource.api.LinkService%26methods%3DdeleteByHostId%2Cget%2Cquery%2Cupdate%2Ccreate%2CgetInterfacePeer%2Cdelete%2CfindAll%2CdeleteByIfId%26pid%3D31375%26revision%3Dapi%26serialization%3Dkryo%26service.filter%3Di18nProviderFilter%2Cerror-logger%26side%3Dprovider%26timestamp%3D1511255592038]
服务消费者
  • 服务消费者启动时,读取并且订阅ZooKeeper上/dubbo/uyun.spider.resource.api.LinkService/providers下面的所有子节点,同时,服务消费者还会在ZooKeeper的uyun.spider.resource.api.LinkService/consumers节点下创建一个临时节点,并写入自己的URL地址
[zk: localhost:2181(CONNECTED) 10] ls /dubbo/uyun.spider.resource.api.LinkService/consumers    
[consumer%3A%2F%2F10.1.50.64%2Fuyun.spider.resource.api.LinkService%3Fapplication%3Dspider-gateway%26category%3Dconsumers%26check%3Dfalse%26default.reference.filter%3Di18nConsumerFilter%26default.retries%3D0%26default.timeout%3D6000%26dubbo%3D2.8.4.170831%26interface%3Duyun.spider.resource.api.LinkService%26methods%3DdeleteByHostId%2Cget%2Cquery%2Cupdate%2Ccreate%2CgetInterfacePeer%2Cdelete%2CfindAll%2CdeleteByIfId%26pid%3D31955%26retries%3D0%26revision%3Dapi%26side%3Dconsumer%26timestamp%3D1511255599128, consumer%3A%2F%2F10.1.50.64%2Fuyun.spider.resource.api.LinkService%3Fapplication%3Dspider-server-topo%26category%3Dconsumers%26check%3Dfalse%26default.reference.filter%3Di18nConsumerFilter%26default.retries%3D0%26default.timeout%3D10000%26dubbo%3D2.8.4.170831%26interface%3Duyun.spider.resource.api.LinkService%26methods%3DdeleteByHostId%2Cget%2Cquery%2Cupdate%2Ccreate%2CgetInterfacePeer%2CfindAll%2Cdelete%2CdeleteByIfId%26pid%3D31466%26retries%3D0%26revision%3Dapi%26side%3Dconsumer%26timeout%3D10000%26timestamp%3D1511255577683]
dubbo的监控中心是dubbo服务治理体系的重要一部分,它会通过ZooKeeper的相关service节点来获取所有消费者生产者的URL地址,并且注册Watcher来监听其子节点的变化。

推荐阅读更多精彩内容