标签:
slice: ice提供了自己的接口定义语言。用来定义rpc的接口和对象。
ice.object: rpc调用的接口必须继承自ice.Object
servant:ice.Object的实例化对象叫做servant,rpc调用的就是servant对象,因此servant需要线程安全
endpoints:客户端rpc调用servant的地址
icebox:servant的容器
icenode:icebox的容器
registry:注册中心,负责管理icenode的注册,负责和发布。
步骤:
启动registry
启动node,注册到registry
将代码部署到node服务器上
将应用描述文件应用到registry上,node上将自动启动application
registry配置文件一个:registry.cfg
node配置文件n个:node1.cfg, node2.cfg
应用描述文件app.xml
配置文件详情:
registry.cfg
# grid实例名 IceGrid.InstanceName=SzcIceGrid #客户端连接到注册中心的地址 IceGrid.Registry.Client.Endpoints=tcp -p 4061 IceGrid.Registry.Server.Endpoints=tcp IceGrid.Registry.Internal.Endpoints=tcp IceGrid.Registry.PermissionsVerifier=SzcIceGrid/NullPermissionsVerifier IceGrid.Registry.AdminPermissionsVerifier=SzcIceGrid/NullPermissionsVerifier #注册中心数据保存路径,需要手动创建文件夹 IceGrid.Registry.Data=/data/shizc/Desktop/ice/registry IceGrid.Registry.DynamicRegistration=1 Ice.Admin.InstanceName=AdminInstance Ice.Admin.ServerId=Admin
node1.cfg
# 注册中心地址 Ice.Default.Locator=SzcIceGrid/Locator:tcp -h 192.168.7.7 -p 4061 #node名 IceGrid.Node.Name=node1 IceGrid.Node.Endpoints=tcp #node存储路径 IceGrid.Node.Data=/data/shizc/Desktop/ice/nodes/node1 IceGrid.Node.Output=/data/shizc/Desktop/ice/nodes/node1 IceGrid.Node.CollocateRegistry=0 #IceGrid.Node.Trace.Replica=2 #IceGrid.Node.Trace.Activator=3 #IceGrid.Node.Trace.Adapter=3 #IceGrid.Node.Trace.Server=3
node2.cfg
# 注册中心地址 Ice.Default.Locator=SzcIceGrid/Locator:tcp -h 192.168.7.7 -p 4061 IceGrid.Node.Name=node2 IceGrid.Node.Endpoints=tcp IceGrid.Node.Data=/data/shizc/Desktop/ice/nodes/node2 IceGrid.Node.Output=/data/shizc/Desktop/ice/nodes/node2 IceGrid.Node.CollocateRegistry=0 #IceGrid.Node.Trace.Replica=2 #IceGrid.Node.Trace.Activator=3 #IceGrid.Node.Trace.Adapter=3 #IceGrid.Node.Trace.Server=3
app.xml
<icegrid> <application name="FileSystemApp"> <properties id="MultiThreaded" > <property name="Ice.PrintStackTraces" value="1" ></property> <property name="IceSSL.Trace.Security" value="2" ></property> <property name="Ice.ThreadPool.Client.Size" value="2" ></property> <property name="Ice.ThreadPool.Client.SizeMax" value="50" ></property> <property name="Ice.ThreadPool.Server.Size" value="10" ></property> <property name="Ice.ThreadPool.Server.SizeMax" value="100" ></property> <property name="IceBox.InheritProperties" value="1" ></property> <property name="Ice.Override.ConnectTimeout" value="5000" ></property> <property name="Ice.Override.Timeout" value="10000" ></property> <property name="IceBox.Trace.ServiceObserver" value="1" ></property> <property name="Ice.Default.LocatorCacheTimeout" value="300" ></property> <property name="Ice.BackgroundLocatorCacheUpdates" value="1" ></property> </properties> <!-- 配置模板 --> <server-template id="FileSystemServerIceBoxTemplate"> <parameter name="index" default="0"></parameter> <!-- exe指定java启动 --> <icebox id="FileSystemServerIceBox${index}" exe="java" activation="on-demand" > <properties> <properties refid="MultiThreaded" /> </properties> <option>-Xmx512M</option> <!-- icebox启动main方法 --> <option>IceBox.Server</option> <!-- 开发的代码路径 --> <env>CLASSPATH=.:/usr/share/java/*:/data/shizc/Desktop/ice/bin</env> <!-- entry指定icebox启动的service, replica-group指定endpoints组 --> <service name="FilesystemService" entry="service.FilesystemService"> <adapter name="FilesystemService" id="FilesystemService${index}" endpoints="default" replica-group="FilesystemServiceRep" ></adapter> </service> </icebox> </server-template> <replica-group id="FilesystemServiceRep"> <load-balancing type="round-robin" n-replicas="0" /> <!-- 指定servant的名字 --> <object identity="RootDir" type="::filesystem::Directory"></object> <object identity="iamfile" type="::filesystem::File"></object> </replica-group> <!-- 每个node定义2个icebox --> <node name="node1"> <server-instance template="FileSystemServerIceBoxTemplate" index="11"></server-instance> <server-instance template="FileSystemServerIceBoxTemplate" index="12"></server-instance> </node> <node name="node2"> <server-instance template="FileSystemServerIceBoxTemplate" index="21"></server-instance> <server-instance template="FileSystemServerIceBoxTemplate" index="22"></server-instance> </node> </application> </icegrid>
icegridregistry --Ice.Config=registry.cfg
icegridnode --Ice.Config=node1.cfg
icegridnode --Ice.Config=node2.cfg
icegridadmin --Ice.Config=node1.cfg
登陆后
application add app.xml
明天加上。。。
标签:
原文地址:http://my.oschina.net/purely/blog/476358