48-微服务技术栈(高级):分布式协调服务zookeeper源码篇(Watcher机制-3[Zookeeper])

本文涉及的产品
云原生网关 MSE Higress,422元/月
MSE Nacos/ZooKeeper 企业版试用,1600元额度,限量50份
服务治理 MSE Sentinel/OpenSergo,Agent数量 不受限
简介:   前面已经分析了Watcher机制中的大多数类,本篇对于ZKWatchManager的外部类Zookeeper进行分析。

一、前言

  前面已经分析了Watcher机制中的大多数类,本篇对于ZKWatchManager的外部类Zookeeper进行分析。

二、ZooKeeper源码分析

2.1 类的内部类

  ZooKeeper的内部类框架图如下图所示

  

  

说明:

  • ZKWatchManager,Zookeeper的Watcher管理者,其源码在之前已经分析过,不再累赘。
  • WatchRegistration,抽象类,用作watch注册。
  • ExistsWatchRegistration,存在性watch注册。
  • DataWatchRegistration,数据watch注册。
  • ChildWatchRegistration,子节点注册。
  • States,枚举类型,表示服务器的状态。

1. WatchRegistration

  接口类型,表示对路径注册监听。  

abstract class WatchRegistration {

   // Watcher

   private Watcher watcher;

   // 客户端路径

   private String clientPath;


   // 构造函数

   public WatchRegistration(Watcher watcher, String clientPath)

   {

       this.watcher = watcher;

       this.clientPath = clientPath;

   }

   // 获取路径到Watchers集合的键值对,由子类实现

   abstract protected Map> getWatches(int rc);

   /**

        * Register the watcher with the set of watches on path.

        * @param rc the result code of the operation that             attempted to

        * add the watch on the path.

        */

   // 注册

   public void register(int rc) {

       if (shouldAddWatch(rc)) { // 应该添加监听

           // 获取路径到Watchers集合的键值对,工厂模式

           Map> watches = getWatches(rc);

           synchronized(watches) { // 同步块

               // 通过路径获取watcher集合

               Set watchers = watches.get(clientPath);

               if (watchers == null) { // watcher集合为空

                   // 新生成集合

                   watchers = new HashSet();

                   // 将路径和watchers集合存入

                   watches.put(clientPath, watchers);

               }

               // 添加至watchers集合

               watchers.add(watcher);

           }

       }

   }

   /**

        * Determine whether the watch should be added based on return code.

        * @param rc the result code of the operation that attempted to add the

        * watch on the node

        * @return true if the watch should be added, otw false

        */

   // 判断是否需要添加,判断rc是否为0

   protected boolean shouldAddWatch(int rc) {

       return rc == 0;

   }

}

说明:可以看到WatchRegistration包含了Watcher和clientPath字段,表示监听和对应的路径,值得注意的是getWatches方式抽象方法,需要子类实现,而在register方法中会调用getWatches方法,实际上调用的是子类的getWatches方法,这是典型的工厂模式。register方法首先会判定是否需要添加监听,然后再进行相应的操作,在WatchRegistration类的默认实现中shouldAddWatch是判定返回码是否为0。

2. ExistsWatchRegistration 

class ExistsWatchRegistration extends WatchRegistration {

   // 构造函数

   public ExistsWatchRegistration(Watcher watcher, String clientPath) {

       // 调用父类构造函数

       super(watcher, clientPath);

   }


   @Override

   protected Map> getWatches(int rc) {

       // 根据rc是否为0确定返回dataWatches或existsWatches

       return rc == 0 ?  watchManager.dataWatches : watchManager.existWatches;

   }

   @Override

   protected boolean shouldAddWatch(int rc) {

       // 判断rc是否为0或者rc是否等于NONODE的值

       return rc == 0 || rc == KeeperException.Code.NONODE.intValue();

   }

}

说明:ExistsWatchRegistration 表示对存在性监听的注册,其实现了getWatches方法,并且重写了shouldAddWatch方法,getWatches方法是根据返回码的值确定返回dataWatches或者是existWatches。

3. DataWatchRegistration

class DataWatchRegistration extends WatchRegistration {

   // 构造函数

   public DataWatchRegistration(Watcher watcher, String clientPath) {

       // 调用父类构造函数

       super(watcher, clientPath);

   }

   @Override

   protected Map> getWatches(int rc) {

       // 直接返回dataWatches

       return watchManager.dataWatches;

   }

}

说明:DataWatchRegistration表示对数据监听的注册,其实现了getWatches方法,返回dataWatches。

4. ChildWatchRegistration

class ChildWatchRegistration extends WatchRegistration {

   // 构造函数

   public ChildWatchRegistration(Watcher watcher, String clientPath) {

       // 调用父类构造函数

       super(watcher, clientPath);

   }

   @Override

   protected Map> getWatches(int rc) {

       // 直接返回childWatches

       return watchManager.childWatches;

   }

}

说明:ChildWatchRegistration表示对子节点监听的注册,其实现了getWatches方法,返回childWatches。

5. States

public enum States {

   // 代表服务器的状态

   CONNECTING, ASSOCIATING, CONNECTED, CONNECTEDREADONLY,

   CLOSED, AUTH_FAILED, NOT_CONNECTED;

   // 是否存活

   public boolean isAlive() {

       // 不为关闭状态并且未认证失败

       return this != CLOSED && this != AUTH_FAILED;

   }

   /**

        * Returns whether we are connected to a server (which

        * could possibly be read-only, if this client is allowed

        * to go to read-only mode)

        * */

   // 是否连接

   public boolean isConnected() {

       // 已连接或者只读连接

       return this == CONNECTED || this == CONNECTEDREADONLY;

   }

}

说明:States为枚举类,表示服务器的状态,其有两个方法,判断服务器是否存活和判断客户端是否连接至服务端。

2.2 类的属性  

public class ZooKeeper {

   // 客户端Socket

   public static final String ZOOKEEPER_CLIENT_CNXN_SOCKET = "zookeeper.clientCnxnSocket";

   

   // 客户端,用来管理客户端与服务端的连接

   protected final ClientCnxn cnxn;

   

   // Logger日志

   private static final Logger LOG;

   static {

       //Keep these two lines together to keep the initialization order explicit

       // 初始化

       LOG = LoggerFactory.getLogger(ZooKeeper.class);

       Environment.logEnv("Client environment:", LOG);

   }

 private final ZKWatchManager watchManager = new ZKWatchManager();

}

  说明:ZooKeeper类存维护一个ClientCnxn类,用来管理客户端与服务端的连接。  

2.3 类的构造函数

1. ZooKeeper(String connectString, int sessionTimeout, Watcher watcher, boolean canBeReadOnly)型构造函数    

public ZooKeeper(String connectString, int sessionTimeout, Watcher watcher,

           boolean canBeReadOnly) throws IOException

   {

       LOG.info("Initiating client connection, connectString=" + connectString

               + " sessionTimeout=" + sessionTimeout + " watcher=" + watcher);

       // 初始化默认Watcher

       watchManager.defaultWatcher = watcher;

       // 对传入的connectString进行解析

       // connectString 类似于127.0.0.1:3000,127.0.0.1:3001,127.0.0.1:3002未指定根空间的字符串

       // 或者是127.0.0.1:3000,127.0.0.1:3001,127.0.0.1:3002/app/a指定根空间的字符串,根为/app/a

       ConnectStringParser connectStringParser = new ConnectStringParser(

               connectString);


       // 根据服务器地址列表生成HostProvider

       HostProvider hostProvider = new StaticHostProvider(

               connectStringParser.getServerAddresses());

       // 生成客户端管理

       cnxn = new ClientCnxn(connectStringParser.getChrootPath(),

               hostProvider, sessionTimeout, this, watchManager,

               getClientCnxnSocket(), canBeReadOnly);

       // 启动

       cnxn.start();

   }

  说明:该构造函数会初始化WatchManager的defaultWatcher,同时会解析服务端地址和端口号,之后根据服务端的地址生成HostProvider(其会打乱服务器的地址),之后生成客户端管理并启动,注意此时会调用getClientCnxnSocket函数,其源码如下  

private static ClientCnxnSocket getClientCnxnSocket() throws IOException {

   // 查看是否在系统属性中进行了设置

   String clientCnxnSocketName = System

       .getProperty(ZOOKEEPER_CLIENT_CNXN_SOCKET);

   if (clientCnxnSocketName == null) { // 若未进行设置,取得ClientCnxnSocketNIO的类名

       clientCnxnSocketName = ClientCnxnSocketNIO.class.getName();

   }

   try {

       // 使用反射新生成实例然后返回

       return (ClientCnxnSocket) Class.forName(clientCnxnSocketName)

           .newInstance();

   } catch (Exception e) {

       IOException ioe = new IOException("Couldn't instantiate "

                                         + clientCnxnSocketName);

       ioe.initCause(e);

       throw ioe;

   }

}

说明:该函数会利用反射创建ClientCnxnSocketNIO实例

2. public ZooKeeper(String connectString, int sessionTimeout, Watcher watcher, long sessionId, byte[] sessionPasswd, boolean canBeReadOnly) throws IOException型构造函数  

public ZooKeeper(String connectString, int sessionTimeout, Watcher watcher,

           long sessionId, byte[] sessionPasswd, boolean canBeReadOnly)

       throws IOException

   {

       LOG.info("Initiating client connection, connectString=" + connectString

               + " sessionTimeout=" + sessionTimeout

               + " watcher=" + watcher

               + " sessionId=" + Long.toHexString(sessionId)

               + " sessionPasswd="

               + (sessionPasswd == null ? "" : ""));

       // 初始化默认Watcher

       watchManager.defaultWatcher = watcher;

       // 对传入的connectString进行解析

       // connectString 类似于127.0.0.1:3000,127.0.0.1:3001,127.0.0.1:3002未指定根空间的字符串

       // 或者是127.0.0.1:3000,127.0.0.1:3001,127.0.0.1:3002/app/a指定根空间的字符串,根为/app/a

       ConnectStringParser connectStringParser = new ConnectStringParser(

               connectString);


       // 根据服务器地址列表生成HostProvider

       HostProvider hostProvider = new StaticHostProvider(

               connectStringParser.getServerAddresses());

       // 生成客户端时使用了session密码

       cnxn = new ClientCnxn(connectStringParser.getChrootPath(),

               hostProvider, sessionTimeout, this, watchManager,

               getClientCnxnSocket(), sessionId, sessionPasswd, canBeReadOnly);


       // 设置客户端的seenRwServerBefore字段为true(因为用户提供了sessionId,表示肯定已经连接过)

       cnxn.seenRwServerBefore = true; // since user has provided sessionId

       // 启动

       cnxn.start();

   }

  说明:此型构造函数和之前构造函数的区别在于本构造函数提供了sessionId和sessionPwd,这表明用户已经之前已经连接过服务端,所以能够获取到sessionId,其流程与之前的构造函数类似,不再累赘。

2.4 核心函数分析

1. create函数  

函数签名:

public String create(final String path, byte data[], List acl, CreateMode createMode)

throws KeeperException, InterruptedException

public String create(final String path, byte data[], List acl,

           CreateMode createMode)

       throws KeeperException, InterruptedException

   {

       final String clientPath = path;


       // 验证路径是否合法

       PathUtils.validatePath(clientPath, createMode.isSequential());

       // 添加根空间

       final String serverPath = prependChroot(clientPath);

       // 新生请求头

       RequestHeader h = new RequestHeader();

       // 设置请求头类型

       h.setType(ZooDefs.OpCode.create);

       // 新生创建节点请求

       CreateRequest request = new CreateRequest();

       // 新生创建节点响应

       CreateResponse response = new CreateResponse();

       // 设置请求的数据

       request.setData(data);

       // 设置请求对应的Flag

       request.setFlags(createMode.toFlag());

       // 设置服务器路径

       request.setPath(serverPath);

       if (acl != null && acl.size() == 0) { // ACL不为空但是大小为0,抛出异常

           throw new KeeperException.InvalidACLException();

       }

       // 设置请求的ACL列表

       request.setAcl(acl);

       // 提交请求

       ReplyHeader r = cnxn.submitRequest(h, request, response, null);

       if (r.getErr() != 0) { // 请求的响应的错误码不为0,则抛出异常

           throw KeeperException.create(KeeperException.Code.get(r.getErr()),

                   clientPath);

       }

       if (cnxn.chrootPath == null) { // 根空间为空

           // 则返回响应中的路径

           return response.getPath();

       } else {

           // 除去根空间后返回

           return response.getPath().substring(cnxn.chrootPath.length());

       }

   }

说明:该create函数是同步的,主要用作创建节点,其大致步骤如下

  ① 验证路径是否合法,若不合法,抛出异常,否则进入②

  ② 添加根空间,生成请求头、请求、响应等,并设置相应字段,进入③

  ③ 通过客户端提交请求,判断返回码是否为0,若不是,则抛出异常,否则,进入④

  ④ 除去根空间后,返回响应的路径

  其中会调用submitRequest方法,其源码如下  

public ReplyHeader submitRequest(RequestHeader h, Record request,

           Record response, WatchRegistration watchRegistration)

   throws InterruptedException {

   // 新生响应头

   ReplyHeader r = new ReplyHeader();

   // 新生Packet包

   Packet packet = queuePacket(h, r, request, response, null, null, null,

                               null, watchRegistration);

   synchronized (packet) { // 同步

       while (!packet.finished) { // 如果没有结束

           // 则等待

           packet.wait();

       }

   }

   // 返回响应头

   return r;

}

说明:submitRequest会将请求封装成Packet包,然后一直等待packet包响应结束,然后返回;若没结束,则等待。可以看到其是一个同步方法。

2. create函数

函数签名:

public void create(final String path, byte data[], List acl, CreateMode createMode, StringCallback cb, Object ctx)  

public void create(final String path, byte data[], List acl,

           CreateMode createMode,  StringCallback cb, Object ctx)

{

   final String clientPath = path;


   // 验证路径是否合法

   PathUtils.validatePath(clientPath, createMode.isSequential());

   // 添加根空间

   final String serverPath = prependChroot(clientPath);

   // 新生请求头

   RequestHeader h = new RequestHeader();

   // 设置请求头类型

   h.setType(ZooDefs.OpCode.create);

   // 新生创建节点请求

   CreateRequest request = new CreateRequest();

   // 新生创建节点响应

   CreateResponse response = new CreateResponse();

   // 新生响应头

   ReplyHeader r = new ReplyHeader();

   // 设置请求的数据

   request.setData(data);

   // 设置请求对应的Flag

   request.setFlags(createMode.toFlag());

   // 设置服务

   request.setPath(serverPath);

   // 设置ACL列表

   request.setAcl(acl);

   // 封装成packet放入队列,等待提交

   cnxn.queuePacket(h, r, request, response, cb, clientPath,

                    serverPath, ctx, null);

}

说明:该create函数是异步的,其大致步骤与同步版的create函数相同,只是最后其会将请求打包成packet,然后放入队列等待提交。

3. delete函数  

函数签名:public void delete(final String path, int version) throws InterruptedException, KeeperException

public void delete(final String path, int version)

       throws InterruptedException, KeeperException

   {

       final String clientPath = path;

       // 验证路径的合法性

       PathUtils.validatePath(clientPath);

       final String serverPath;

       // maintain semantics even in chroot case

       // specifically - root cannot be deleted

       // I think this makes sense even in chroot case.

       if (clientPath.equals("/")) { // 判断是否是"/",即zookeeper的根目录,根目录无法删除

           // a bit of a hack, but delete(/) will never succeed and ensures

           // that the same semantics are maintained

           //

           serverPath = clientPath;

       } else { // 添加根空间

           serverPath = prependChroot(clientPath);

       }


       // 新生请求头

       RequestHeader h = new RequestHeader();

       // 设置请求头类型

       h.setType(ZooDefs.OpCode.delete);

       // 新生删除请求

       DeleteRequest request = new DeleteRequest();

       // 设置路径

       request.setPath(serverPath);

       // 设置版本号

       request.setVersion(version);

       // 新生响应头

       ReplyHeader r = cnxn.submitRequest(h, request, null, null);

       if (r.getErr() != 0) { // 判断返回码

           throw KeeperException.create(KeeperException.Code.get(r.getErr()),

                   clientPath);

       }

   }

说明:该函数是同步的,其流程与create流程相似,不再累赘。

4. delete函数

函数签名:public void delete(final String path, int version, VoidCallback cb, Object ctx)

public void delete(final String path, int version, VoidCallback cb,

           Object ctx)

   {

       final String clientPath = path;

       

       // 验证路径是否合法

       PathUtils.validatePath(clientPath);

       final String serverPath;

       // maintain semantics even in chroot case

       // specifically - root cannot be deleted

       // I think this makes sense even in chroot case.

       if (clientPath.equals("/")) { // 判断是否是"/",即zookeeper的根目录,根目录无法删除

           // a bit of a hack, but delete(/) will never succeed and ensures

           // that the same semantics are maintained

           serverPath = clientPath;

       } else {

           serverPath = prependChroot(clientPath);

       }

       

       // 新生请求头

       RequestHeader h = new RequestHeader();

       // 设置请求头类型

       h.setType(ZooDefs.OpCode.delete);

       // 新生删除请求

       DeleteRequest request = new DeleteRequest();

       // 设置路径

       request.setPath(serverPath);

       // 设置版本号

       request.setVersion(version);

       // 封装成packet放入队列,等待提交

       cnxn.queuePacket(h, new ReplyHeader(), request, null, cb, clientPath,

               serverPath, ctx, null);

   }

  说明:该函数是异步的,其流程也相对简单,不再累赘。

5. multi函数  

public List multi(Iterable ops) throws InterruptedException, KeeperException {

   for (Op op : ops) { // 验证每个操作是否合法

       op.validate();

   }

   // reconstructing transaction with the chroot prefix

   // 新生事务列表

   List transaction = new ArrayList();

   for (Op op : ops) { // 将每个操作添加根空间后添加到事务列表中

       transaction.add(withRootPrefix(op));

   }

   // 调用multiInternal后返回

   return multiInternal(new MultiTransactionRecord(transaction));

}

说明:该函数用于执行多个操作或者不执行,其首先会验证每个操作的合法性,然后将每个操作添加根空间后加入到事务列表中,之后会调用multiInternal函数,其源码如下  

protected List multiInternal(MultiTransactionRecord request)

   throws InterruptedException, KeeperException {

   // 新生请求头

   RequestHeader h = new RequestHeader();

   // 设置请求头类型

   h.setType(ZooDefs.OpCode.multi);

   // 新生多重响应

   MultiResponse response = new MultiResponse();

   // 新生响应头

   ReplyHeader r = cnxn.submitRequest(h, request, response, null);

   if (r.getErr() != 0) { // 判断返回码是否为0

       throw KeeperException.create(KeeperException.Code.get(r.getErr()));

   }

   // 获取响应的结果集

   List results = response.getResultList();


   ErrorResult fatalError = null;

   for (OpResult result : results) { // 遍历结果集

       if (result instanceof ErrorResult && ((ErrorResult)result).getErr() != KeeperException.Code.OK.intValue()) { //判断结果集中是否出现了异常

           fatalError = (ErrorResult) result;

           break;

       }

   }

   if (fatalError != null) { // 出现了异常

       // 新生异常后抛出

       KeeperException ex = KeeperException.create(KeeperException.Code.get(fatalError.getErr()));

       ex.setMultiResults(results);

       throw ex;

   }

   // 返回结果集

   return results;

}

说明:multiInternal函数会提交多个操作并且等待响应结果集,然后判断结果集中是否有异常,若有异常则抛出异常,否则返回响应结果集。

6. exists函数  

函数签名:public Stat exists(final String path, Watcher watcher) throws KeeperException, InterruptedException

public Stat exists(final String path, Watcher watcher)

       throws KeeperException, InterruptedException

   {

       final String clientPath = path;


       // 验证路径是否合法

       PathUtils.validatePath(clientPath);

       // the watch contains the un-chroot path

       WatchRegistration wcb = null;

       if (watcher != null) { // 生成存在性注册

           wcb = new ExistsWatchRegistration(watcher, clientPath);

       }

       // 添加根空间

       final String serverPath = prependChroot(clientPath);

       // 新生请求头

       RequestHeader h = new RequestHeader();

       // 设置请求头类型

       h.setType(ZooDefs.OpCode.exists);

       // 新生节点存在请求

       ExistsRequest request = new ExistsRequest();

       // 设置路径

       request.setPath(serverPath);

       // 设置Watcher

       request.setWatch(watcher != null);

       // 新生设置数据响应

       SetDataResponse response = new SetDataResponse();

       // 提交请求

       ReplyHeader r = cnxn.submitRequest(h, request, response, wcb);

       if (r.getErr() != 0) { // 判断返回码

           if (r.getErr() == KeeperException.Code.NONODE.intValue()) {

               return null;

           }

           throw KeeperException.create(KeeperException.Code.get(r.getErr()),

                   clientPath);

       }


       // 返回结果的状态

       return response.getStat().getCzxid() == -1 ? null : response.getStat();

   }

说明:该函数是同步的,用于判断指定路径的节点是否存在,值得注意的是,其会对指定路径的结点进行注册监听。

7. exists

函数签名:public void exists(final String path, Watcher watcher, StatCallback cb, Object ctx) 

public void exists(final String path, Watcher watcher,

           StatCallback cb, Object ctx)

{

   final String clientPath = path;

   // 验证路径是否合法

   PathUtils.validatePath(clientPath);

   // the watch contains the un-chroot path

   WatchRegistration wcb = null;

   if (watcher != null) { // 生成存在性注册

       wcb = new ExistsWatchRegistration(watcher, clientPath);

   }

   // 添加根空间

   final String serverPath = prependChroot(clientPath);

   // 新生请求头

   RequestHeader h = new RequestHeader();

   // 设置请求头类型

   h.setType(ZooDefs.OpCode.exists);

   // 新生节点存在请求

   ExistsRequest request = new ExistsRequest();

   // 设置路径

   request.setPath(serverPath);

   // 设置Watcher

   request.setWatch(watcher != null);

   // 新生设置数据响应

   SetDataResponse response = new SetDataResponse();

   // 将请求封装成packet,放入队列,等待执行

   cnxn.queuePacket(h, new ReplyHeader(), request, response, cb,

                    clientPath, serverPath, ctx, wcb);

}

说明:该函数是异步的,与同步的流程相似,不再累赘。

之后的getData、setData、getACL、setACL、getChildren函数均类似,只是生成的响应类别和监听类别不相同,大同小异,不再累赘。

三、总结

  本篇博文分析了Watcher机制的ZooKeeper类,该类包括了对服务器的很多事务性操作,并且包含了同步和异步两个版本,但是相对来说,较为简单。

相关文章
|
3月前
|
存储 安全 Java
管理 Spring 微服务中的分布式会话
在微服务架构中,管理分布式会话是确保用户体验一致性和系统可扩展性的关键挑战。本文探讨了在 Spring 框架下实现分布式会话管理的多种方法,包括集中式会话存储和客户端会话存储(如 Cookie),并分析了它们的优缺点。同时,文章还涵盖了与分布式会话相关的安全考虑,如数据加密、令牌验证、安全 Cookie 政策以及服务间身份验证。此外,文中强调了分布式会话在提升系统可扩展性、增强可用性、实现数据一致性及优化资源利用方面的显著优势。通过合理选择会话管理策略,结合 Spring 提供的强大工具,开发人员可以在保证系统鲁棒性的同时,提供无缝的用户体验。
|
4月前
|
监控 Java API
Spring Boot 3.2 结合 Spring Cloud 微服务架构实操指南 现代分布式应用系统构建实战教程
Spring Boot 3.2 + Spring Cloud 2023.0 微服务架构实践摘要 本文基于Spring Boot 3.2.5和Spring Cloud 2023.0.1最新稳定版本,演示现代微服务架构的构建过程。主要内容包括: 技术栈选择:采用Spring Cloud Netflix Eureka 4.1.0作为服务注册中心,Resilience4j 2.1.0替代Hystrix实现熔断机制,配合OpenFeign和Gateway等组件。 核心实操步骤: 搭建Eureka注册中心服务 构建商品
763 3
|
2月前
|
消息中间件 分布式计算 资源调度
《聊聊分布式》ZooKeeper与ZAB协议:分布式协调的核心引擎
ZooKeeper是一个开源的分布式协调服务,基于ZAB协议实现数据一致性,提供分布式锁、配置管理、领导者选举等核心功能,具有高可用、强一致和简单易用的特点,广泛应用于Kafka、Hadoop等大型分布式系统中。
|
2月前
|
负载均衡 Java API
《深入理解Spring》Spring Cloud 构建分布式系统的微服务全家桶
Spring Cloud为微服务架构提供一站式解决方案,涵盖服务注册、配置管理、负载均衡、熔断限流等核心功能,助力开发者构建高可用、易扩展的分布式系统,并持续向云原生演进。
|
8月前
|
人工智能 安全 Java
智慧工地源码,Java语言开发,微服务架构,支持分布式和集群部署,多端覆盖
智慧工地是“互联网+建筑工地”的创新模式,基于物联网、移动互联网、BIM、大数据、人工智能等技术,实现对施工现场人员、设备、材料、安全等环节的智能化管理。其解决方案涵盖数据大屏、移动APP和PC管理端,采用高性能Java微服务架构,支持分布式与集群部署,结合Redis、消息队列等技术确保系统稳定高效。通过大数据驱动决策、物联网实时监测预警及AI智能视频监控,消除数据孤岛,提升项目可控性与安全性。智慧工地提供专家级远程管理服务,助力施工质量和安全管理升级,同时依托可扩展平台、多端应用和丰富设备接口,满足多样化需求,推动建筑行业数字化转型。
290 5
|
3月前
|
数据采集 消息中间件 NoSQL
分布式爬虫的全局请求间隔协调与IP轮换策略
分布式爬虫的全局请求间隔协调与IP轮换策略
|
11月前
|
Java 关系型数据库 数据库
微服务SpringCloud分布式事务之Seata
SpringCloud+SpringCloudAlibaba的Seata实现分布式事务,步骤超详细,附带视频教程
854 1
|
存储 运维 数据可视化
如何为微服务实现分布式日志记录
如何为微服务实现分布式日志记录
720 1
|
消息中间件 监控 Ubuntu
大数据-54 Kafka 安装配置 环境变量配置 启动服务 Ubuntu配置 ZooKeeper
大数据-54 Kafka 安装配置 环境变量配置 启动服务 Ubuntu配置 ZooKeeper
399 3
大数据-54 Kafka 安装配置 环境变量配置 启动服务 Ubuntu配置 ZooKeeper
|
消息中间件 存储 负载均衡
微服务与分布式系统设计看这篇就够了!
【10月更文挑战第12天】 在现代软件架构中,微服务和分布式系统设计已经成为构建可扩展、灵活和可靠应用程序的主流方法。本文将深入探讨微服务架构的核心概念、设计原则和挑战,并提供一些关于如何在分布式系统中实现微服务的实用指导。
506 2

相关产品

  • 微服务引擎