ESPlatform cluster platform (01) -- migrate to cluster platform ESFramework development manual (00) -- Overview

Source: Internet
Author: User
Document directory
  • 1. Construction and initialization
  • 2. Platform User Manager
  • 3. After replacement
  • 1. Manage online application servers and users
  • 2. Forward messages

In the ESFramework development manual (00) -- Overview, we mentioned one of the advantages of ESFramework: by modifying several lines of code or configuration, You can smoothly migrate an ESFramework-based application to the ESPlatform platform. Now is the time to fulfill this promise. To migrate a single AS ESFramework application to the ESPlatform cluster platform, generally, only two steps are required:

(1) Deploy and start the application Cluster Management Server ACMS.

(2) The server uses ESPlatform. Rapid. RapidServerEngine to replace ESPlus. Rapid. RapidServerEngine. The client does not need to make any changes.

I. ESPlatform. Rapid. RapidServerEngine

In a single AS ESFramework application, our server engine uses ESPlus. Rapid. RapidServerEngine. during migration, we need to use ESPlatform. Rapid. RapidServerEngine in the ESPlatform. dll assembly. ESPlatform. Rapid. RapidServerEngine also implements the ESPlus. Rapid. IRapidServerEngine interface.

1. Construction and initialization

For developers, only the constructors used to construct the ESPlatform. Rapid. RapidServerEngine object are different:

public RapidServerEngine(int currentServerID, AgileIPE acmsIPE)

The first parameter of the constructor is the ID of the current startup server, and the second parameter specifies the address information of the ACMS server.

(1) In the ESPlatform cluster, each running server instance has a unique ID called ServerID. In a single AS system, ServerID can be ignored. In a cluster system, ServerID is the ID of the server instance.

(2) If the acmsIPE parameter points to a location that does not run the ACMS server, the execution of the constructor will not report an error. However, an exception will be thrown when calling the Initialize method of RapidServerEngine.

(3) When the ESPlatform. Rapid. RapidServerEngine Initialize method is executed, AS registers with ACMS. After Initialization is complete, AS also periodically reports its status to ACMS.

2. Platform User Manager

Do you still remember the UserManager attribute of ESPlus. Rapid. IRapidServerEngine? When programming on the server side, we can use this attribute to access information of all online users on the current AS server. ESPlus. Rapid. IRapidServerEngine also has a PlatformUserManager attribute. In a single AS application, this attribute is equivalent to the UserManager attribute. However, even in a single AS application, the PlatformUserManager attribute has its own value. Its role is: when we develop a single AS application, based on predictions that may be migrated to the ESPlatform cluster platform in the future, use PlatformUserManager instead of UserManager to access any online user, paving the way for fast migration to the cluster platform in the future.

The PlatformUserManager attribute exposed by ESPlatform. Rapid. RapidServerEngine is the real platform User Manager. Through it, AS can access information of any online user in the cluster system.

3. After replacement

After ESPlus. Rapid. RapidServerEngine is replaced with ESPlatform. Rapid. RapidServerEngine, the four weapons and two optional functions provided by ESFramework/ESPlus will work as expected. For example, if a client sends a message to another AS client through ICustomizeOutter, the target client can receive the message. For example, when we send a broadcast message through IGroupOutter, even if members of the same group log on to different AS instances in the cluster system, each member can still receive the broadcast message.

Functions such as synchronous call, asynchronous reply call, file transfer, creation of P2P channels, and so on all work normally without being affected.

2. Application Cluster Management Server ACMS

Esplatformform allows you to directly deploy and run the Application Group Management Server esplatform.acmserver.exe. When deploying the ESPlatform cluster system, you only need to modify the configuration and start it.

As mentioned in ESPlatform cluster platform (00)-concepts and models, ACMS plays an important role in the cluster system. It can be said that it is the core of the whole ESPlatform cluster platform. ACMS's core responsibilities include managing all online AS, managing all online users, forwarding messages between AS, and providing service interfaces to other systems outside the cluster.

ACMS exposes these functions and services through Remoting. ACMS provides three Remoting service interfaces: IApplicationService, IClusterControlService, and IPlatformCustomizeService.

IApplicationService is used by the AS in the ESPlatform cluster system. AS reports its status to ACMS in real time through this interface. IClusterControlService and IPlatformCustomizeService are used to provide external systems (such as BL) to access information in the cluster or control servers in the cluster. In this article, we will first discuss IApplicationService, and the other two interfaces will be reserved for the next article.

ACMS provides the Remoting interface IApplicationService for the following purposes: managing online servers, managing online users, and forwarding messages between.

Note that ESPlatform. rapid. rapidServerEngine has automatically completed these functions with ACMS internally. When we perform secondary development based on ESFramework, ESPlus, and ESPlatform, we do not need to do any additional work for these tasks. Even so, we can take a brief look at it to help us better understand the ESPlatform operating mechanism.

1. Manage online application servers and users

When we start an application server AS, the AS will automatically register with ACMS; when an AS is disabled, it will automatically log out to ACMS. When a user logs on to or exits from an AS instance, The AS instance reports to ACMS in real time. The IApplicationService interface clearly shows these features:

Public interface IApplicationService: IMessageTransferor, IPlatformUserManager {
/// <Summary> /// register the server to the cluster /// </summary> void RegisterServer (ClusterServerInfo server ); /// <summary> /// remove the server from the cluster /// </summary> void UnregisterServer (int serverID ); /// <summary> /// is the target server running? /// </Summary> /// <param name = "serverID"> ServerID of the target server </param> /// <returns> online? </Returns> bool IsServerOnline (int serverID); // <summary> // report the latest status data to ACMS. /// </Summary> /// <param name = "serverID"> target server ID </param> /// <param name = "performance"> performance data </ param> // <param name = "onlineUserCount"> Number of online users </param> void ReportPerformance (int serverID, performance performance, int onlineUserCount); // <summary> // The ACMS notification is sent when the user logs on to the. /// </Summary> void RegisterUser (UserData user); // <summary> /// notify ACMS when the user logs out of the. /// </Summary> void UnregisterUser (string userID );}

AS also periodically calls the ReportPerformance method to report its own performance data to ACMS. The ACMS cluster allocation policy makes decisions based on these performance data.

In addition, IApplicationService inherits IPlatformUserManager, which is used to manage all online users. The PlatformUserManager exposed by ESPlatform. Rapid. RapidServerEngine is a simple encapsulation of this Remoting interface.

2. Forward messages

IApplicationService inherits IMessageTransferor. The IMessageTransferor interface is used to forward messages between.

Public interface IMessageTransferor {// <summary> // forward messages between servers of the same type in the cluster. /// </Summary> /// <param name = "sourceServerID"> ID of the message source server </param> /// <param name = "msg"> message </param> /// <param name = "destUserIDs"> set of userids of the target user who receives the message </param> void TransferMessage (int sourceServerID, IMessage msg, IEnumerable <string> destUserIDs, bool post, ActionTypeOnChannelIsBusy action); // <summary> // forward messages between servers of the same type in the cluster. /// </Summary> /// <param name = "sourceServerID"> ID of the message source server </param> /// <param name = "msg"> message </param> // <param name = "destUserID"> UserID of the target user who receives the message </param> void TransferMessage (int sourceServerID, IMessage msg, string destUserID, bool post, ActionTypeOnChannelIsBusy action );}

The two methods in this interface already involve the IMessage interface at the bottom of ESFramework. It may be the first time that a friend directly developed based on ESPlus sees this interface. We will not go into the details here, but will briefly discuss the principles of message forwarding.

We still use the first model diagram in the above text as an example:

When client 01 sends a message to client 02, the message is submitted to AS01 because there is no P2P channel between client 01 and client 02. AS01 finds that Client02 is no longer on the current server, so it submits the message to ACMS. Then, ACMS queries the platform User Manager and finds that Client02 is on AS02. Therefore, ACMS calls back AS02 and sends the message to AS02.

3. Start ACMS

Is the main interface that runs after esplatform.acmserver.exe is started:

The basic information of each online AS is displayed in the list, including: server ID, address, number of online users on the AS, frozen status, Cpu usage, memory usage, startup time, and last update time.

The main interface of ACMS also provides the function of searching online users and kicker.

Right-click the shortcut menu to freeze an AS or remove it from the cluster system.

(1) freeze AS: when we don't want a new user to connect to an AS in the cluster system, we can freeze it. If the AS is frozen, the server no longer receives new users. However, all activities of logged-on users are normal.

(2) remove AS: When an AS accidentally goes down (for example, a hardware problem occurs), we need to manually remove it from the platform. When the AS is removed, all users located on the AS are also cleared from the platform.

Of course, the main interface of ACMS provides very limited cluster control functions, but ACMS also exposes the two Remoting interfaces mentioned above: IClusterControlService and IPlatformCustomizeService. Outside the cluster system, we can use these two interfaces to more comprehensively access and control the cluster system. This will be detailed in the next article.

Read more ESFramework development manual articles.

Certificate -----------------------------------------------------------------------------------------------------------------------------------------------

For any questions about ESFramework, please contact us:

Tel: 027-87638960

Q: 372841921

Mail: esframework@oraycn.com
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.