Geode 发布应用JARS到Geode members

部署JAR文件

可以动态的部署应用jar文件到指定的members或所有的members。Geode自动追踪jar文件的版本,自动加载部署的jar文件到classpath,并自动加载jar文件中的functions。 
可以同时部署一个或多个jar文件到一个分组或多个分组当中,可指定一个jar文件也可以指定一个目录,但不能两个同时用。

部署functions.jar到所有的members

  gfsh> deploy —jar=functions.jar
  

部署functions.jar到group1组的所有members

  gfsh> deploy —jar=functions.jar —group=group1
  

部署/somepath/libs 目录下所有的jars文件到所有的members

  gfsh> deploy —dir=/somepath/libs 

卸载functions.jar

  gfsh> undeploy —jar=functions.jar  

卸载group1分组下的所有jars

  gfsh> undeploy —group=group1
  

查看所有部署的jar

  gfsh> list deployed  
  gfsh> list deployed —group=group1

JAR文件的部署位置

JAR 文件部署后存放的位置是通过deploy-working-dir配置的。例:

  #gemfire.properties
  deploy-working-dir=/usr/local/gemfire/deploy

这个部署位置可以是本地的也可以是为了节约磁盘空间而在多个成员中共享的网络资源(例如一个挂载的位置)。如果你使用一个共享的目录,你仍然需要在每个成员上部署你想要在应用中访问的JAR文件,因为部署会更新类路径并自动注册函数。(This deployment location can be local or a shared network resource (such as a mount location) used by multiple members in order to reduce disk space usage. If you use a shared directory, you still need to deploy the JAR file on every member that you want to have access to the application, because deployment updates the CLASSPATH and auto-registers functions. )???

JAR文件和群集配置服务

集群配置服务会分发部署的JAR文件到集群中的所有locators。当用命令行启动一个新server的时候,locator会将配置文件及JAR文件分给server并写入该server的目录。

JAR文件的版本控制

当部署JAR文件的时候文件的名称将会被修改,文件名会以vf.gf#做前缀,并包含一个版本号信息做后缀。例如:部署了5次 myclass.jar → vf.gf#myclass.jar#5 

当部署一个新的JAR文件会先检查该文件是否已经存在于当前Member或其它Member已经部署到共享的部署工作目录。如果有其它Member已经部署,当前Member不会写入新上传的JAR文件到磁盘,而是会更新ClassPathLoader去使用已经存在的JAR文件。如果有更新的版本已经在用了,则部署工作将被取消。 

当成员开始使用JAR文件时,成员将获取文件上的共享锁。如果成员通过部署接收到较新的版本,则会释放共享锁,并尝试删除现有的JAR文件以支持较新版本。如果没有其他成员在现有JAR上具有共享锁,则现有的旧版本JAR将被删除 

自动加载Class

当缓存启动时,新缓存请求将当前工作目录中每个JAR文件的最新版本添加到ClassPathLoader中。如果JAR文件已经存在于ClassPathLoader,则ClassPathLoader会选择最新版本; 如果没有其他成员对旧版本JAR有共享锁,则会删除较旧版本的JAR文件。 

卸载JAR文件不会自动卸载在部署期间加载的类。需要重新启动members才能卸载这些类。 

当Cache被关闭,会请求从ClassPathLoader中删除所有当前部署的JAR文件。 

如果使用共享的部署工作目录,共享该目录的所有成员应属于同一成员组。重新启动后,共享该工作目录的所有成员将自动加载CLASSPATH和当前共享工作目录中的所有JAR文件。 

自动加载Fuction

当部署的JAR包含函数(implements the Function interface), 该函数将会通过FunctionService.registerFunction方法自动注册。如果另一个JAR文件存在该相同的函数名,新的函数就会重写覆盖旧的函数。如果卸载JAR,该JAR中注册的函数也将被注销。如果一个函数ID在多个不同的JAR中存在,该函数会伴随着其任意一个JAR语言的的注册或注销而同时被注册或注销。

During cache.xml load, the parameters for any declarables are saved. If functions found in a JAR file are also declarable, and have the same class name as the declarables whose parameters were saved after loading cache.xml, then function instances are created using those Parameters and are also registered. Therefore, if the same function is declared multiple times in the cache.xml with different sets of parameters, when the JAR is deployed a function is instantiated for each set of parameters. If any functions are registered using parameters from a cache.xml load, the default, no-argument function is not registered.

猜你喜欢

转载自blog.csdn.net/huanghuitan/article/details/70141883