Ice introduction online collection

Source: Internet
Author: User
Tags format definition
ArticleDirectory
    • Advantages of ice
    • Comparison with WebService
    • Basic concepts and models
    • Ice call mode
    • Ice Version Control (FACET)
    • Feeze)
    • Icebox)
    • File distribution (icepatch2)
    • Icestorm)
    • Network Topology Load Solution (icegrid) -- routing weapon
    • I. Syntax Specification
    • Ii. Basic Types
    • Iii. interfaces and exceptions

There are a lot of online materials about ice, but there are not many comments from the application perspective, in today's technological innovation, we may focus more on the application field rather than the research field. Therefore, based on my personal experience, I would like to summarize and introduce the ice technology.

What is ice (Internet communications engine)? It is an open-source Middleware system developed by zeroc, similar to DCOM, CORBA, and Web servicedcom, RPC (Remote Procedure Call) protocol is supported, but the efficiency is higher than the preceding technical solutions. It is an object-oriented middleware platform suitable for various environments: customers and servers can use differentProgramming LanguageCan run on different operating systems and system architectures, and can use a variety of network technologies for communication (such as TCP, UDP, SSL, etc ), this brings great convenience to our applications and deployment.

Advantages of ice

1. cross-platform support for multiple languages

2. Object-Oriented Programming

3. provides a complete set of powerful features and functions for distributed applications (such as load balancing, software distribution, and data synchronization ).

4. Efficient implementation has been built into the network bandwidth, memory usage, and CPU overhead.

5. built-in security features can be used across insecure networks (wide area networks.

6. It reduces complexity and is easy to learn and use.

 

Comparison with WebService

When talking about remote calls, we are most familiar With WebService, so let's make a simple comparison between them. The number of stars in them remains to be discussed, and they only express what they mean, but from my perspective, they are no longer comparable, because you are comparing a machine with a group of machines.

In my opinion, the power of ice lies in its introduction of icegrid, which will be highlighted in subsequent articles.

 

Basic concepts and models

First, let's take a look at ICE's Basic Call model (as shown in the figure below). It is worth mentioning that there are no steps 4, 5, or 6 in individual calls and datagram services, the several concepts and keywords here are particularly important and are also the basis for our study.

 

Client (customer): it is estimated that everyone knows this very well. Generally speaking, it is a request initiator.

Proxy: the proxy is actually a representative of the remote service resident. when creating the proxy, it will first perform operations such as shaking hands and status confirmation with the remote service, all client operations are handled through the proxy. The proxy can be divided into direct proxy (you already know the location of the server and its messages) and indirect proxy (you do not know where the server is, and the registry will tell it the address and other information ).

Adapter: A manager configured as a service unit (Servant). It manages the service unit to which each request is allocated.

Servant (Service Unit): it is the smallest unit of a service. It is generally specific to the implementation of an interface.

We mentioned the implementation of The interface just now, but who defined this interface, we will inevitably mention slice (specification language for ice), that is, the "language" used by ice ", it is with this "Intermediate Language" that we can support a variety of programming languages, because the language you use only needs to deal with slice, I may elaborate on slice later.

Ice call mode

Ice uses three network protocols: TCP, UDP, and SSL. Unlike WebService, ice has several options in call mode, in addition, each solution selects the characteristics of different network protocols.

Oneway (single-call): the client only needs to register the call to the local transport buffers and return immediately. It is not responsible for the call result.

Twoway (dual-direction call): The most common mode, synchronous method call mode, can only use TCP or SSL protocol.

Datax (datagram): similar to one-way calls, the difference is that datax calls can only use UDP protocol and can only call methods without return values or output parameters.

Batchoneway (batch one-way call): First save the call in the call buffer, and then automatically send all requests in batch after reaching a certain limit (you can also manually delete the buffer ).

Batchdatasync (batch datagram): similar to the above.

Different call modes actually correspond to non-moving services. For most methods that return values or require real-time response, we may use twoway to call them, for businesses that do not require a return value or do not rely on the return value, we can use the oneway or batchoneway method, such as Message notification; the rest of the datax and batchdatax methods are generally used for businesses that do not return values and do not perform reliability checks, such as logs.

Ice Version Control (FACET)

Ice is integrated with a very good version control function (FACET). In fact, each service unit (Servant) has a facet that coexist with it. If you do not think it is specified, the default facet value is null (string. empty ). In the actual application process of our business, we often encounter service upgrades. However, upgrading services means increasing the stability of original service calls and increasing risk, this facet solves this problem. Every time we upgrade it, we add services instead of changing the original business. New Businesses call new services, the original service calls the original service version. When detecting some "old" services and confirming that no one is calling them, we can turn them off.

The implementation of facet is actually very simple. The server (adapter) has developed the corresponding version number when mounting the server (Servant. To call this method, the client must provide the correct version number (instead of the default version number ).

Feeze)

A management and persistence tool for the servant service. The adapter can register multiple servant in the memory. When the adapter receives a new request) then, go to the management list to check whether an existing servant exists. If yes, this servant is returned. If not, a new servant instance is instantiated. The continuous implementation of the new servant will inevitably result in a memory surge and a waste of CPU resources, and some rarely called servant will remain in the service. For this reason, we set the Service's servant ceiling. When this limit is reached, the "minimum called" servant status is automatically saved in the database (or persistent devices such as files), and then these servant are disabled, once a new request is sent to this servant, the original status is obtained again to activate the servant ......

Icebox)

It can be seen from the name that it is a boxed hosting solution. Similar to IIS, it can host multiple application services, and each Service supports plug-in management without affecting each other, an interface is designed for ice applications. Each Service only implements ice. services interface is enough, so that we can focus more on our business rather than the running platform. It provides us with a unified hosting platform, which is a good tool.

File distribution (icepatch2)

The most important function of ice is to deploy multiple nodes to achieve load balancing or disaster tolerance. In most cases, each node (generally a server) is configured for the application.ProgramThey are all the same. When there are updates or new applications, You need to manually synchronize the files on each node. This manual operation is very complicated and relies entirely on the actions of the operator. Icepatch2 solves this problem. As long as an icepatch2 service is running, files on other nodes can be synchronized through distribution, that is to say, O & M personnel only need to maintain the Application Files of one machine.

Icestorm)

Not complete To be continued ......

Network Topology Load Solution (icegrid) -- routing weapon

Icegrid is actually a combination of a series of components, forming a set of powerful file distribution, load balancing, Fast deployment and other solutions. This is also the most powerful set of ice functions. As for details, it will be coming soon.

 

To learn about ice, we must start with ICE's "language", or slice (simple language of ice ). Slice has its own independent syntax system and structure. We must be familiar with and abide by these syntax systems to achieve what we want.

Based on the official instructions and our own use, we can explain the following:

    1. Syntax Specification
    2. Basic Type
    3. User-Defined type
    4. Interface and its exceptions
    5. GenerateCodeAnalysis
    6. Docized
I. Syntax Specification

Like other languages, slice also has its own syntax specifications, including naming, format, keywords, and sensitive prefix and suffix. We can also learn from other language learning methods. In the getting-started stage, we don't need to master every keyword and naming rule. Just grasp several common keywords, as shown below:

Module: defines the namespace or package path.

Interface: Interface

Struct: structure (compiled into C # And then class)

Class: Class

Exception: exception

Throws: throws an exception.

Sequence: Sequence

Dictionary: Dictionary

Idempotent: idempotent method (that is, multiple calls do not affect the final result)

These keywords are basically the backbone of the ice syntax. In addition, an important function is attribute.Attribute.

Attribute can do many things for us. It can be roughly divided into two categories. One is the inherent characteristics of ice, such as AMI, AMD, and deprected. The table name has a specific function of ice. The other type is all the features used by a specific language (such as Java and net), such as CLR: Generic: List, CLR: Generic: queue, etc (.. Net). When these attributes are marked, the corresponding type is generated when the corresponding CS file is generated. For specific functions, see Appendix B (3.4.0) of the Manual)

After mastering these "syntaxes", we can basically organize the content. However, from a practical perspective, there are some points worth noting:

    1. The definition of each statement must end with a semicolon (;), including the definition of the namespace.
    2. Except for comments, it cannot contain any characters other than ASCII codes (such as Chinese ).
    3. All methods, interfaces, and classes in ice are objects, and there must be no repeated names between objects. Therefore, we cannot repeat the definitions (case-insensitive in this respect, for example, the name is the same as the name ).
    4. Ice files can be reused. Similar to the C syntax, add # include in the file header.
    5. If you really want to use some keywords for naming, you can use the Escape Character "\" for identification, such as "\ Dictionary ".

After understanding the above points, let's make an example (the following code does not include any function definitions ):

 
Module joyaspx {
Module com {
/* Code here */
};
};

Ii. Basic Types

After understanding the above basic syntax, we still need to master some basic types. What is the basic type? The basic type can be parsed into all languages (C ++, Java ,. net, etc.) can be recognized, these basic types can be summarized as two types: numeric type and digital type. For details, see the following table (from the manual ):

 

After reading the above table, careful friends will immediately find a problem. The common decimal and datetime types are not listed in the List. It has been officially verified that these two common types do not exist, which is inconvenient for friends who are familiar with specific languages (such as. net. Since it has become a fact, we will discuss how to solve this problem.

For a general enterprise of the decimal type, the double type can be used in most cases, and the relationship is not very large. However, the datetime type is not so interesting, fortunately, datetime has a ticks attribute whose type is long, that is, it can still be converted to the long type, as shown below:

 
Long ticks = datetime. Now. ticks;
Datetime now = new datetime (ticks );

For Java developers, the method is similar, but there is a little difference. NET and Java ticks are a little different in 7. Of course, there is another simplest and most cumbersome method, that is, the conversion between types and strings, which must be implemented by reflection and other mechanisms. Well, with these basic types in hand, we can start a small experiment. The definition of ice is as follows:
 
Module joyaspx {
Module com {
Class person {
String name;
Int age;
Bool gender;
};
};
};

Then use the slice2cs tool to generate the corresponding CS code. Let's take a look at what is generated.

Statement generated: slice2cs *. Ice (this will be introduced later in the slice2cs tool)

For classes, the generated code can be divided into three parts: constructor, ice. Object base class method, and metadata support method.
    1. Constructor. The constructor has two overloads: one is a constructor without parameters, and the other is a constructor with parameters, which are assigned values for each field (attribute.
    2. Ice. Object base class method implementation.

      There are a total of seven methods, including ice_isa, ice_ids, ice_id, and ice_staticid. The other three methods are overloaded with the current context. The four methods can be roughly seen from the name: ice_isa is used to determine whether the current object is consistent with the specified class, ice_ids is used to obtain the class attributes of the current object (including parent class inheritance, ice_id is used to obtain the type identifier (typeid) of the current object. ice_staticid has the same function as ice_id, but is a static method. For details, see section 4.14 of the manual.

    3. Metadata support
I believe that everyone should be familiar with the term metadata. It not only contains the data itself, but also the description of the data, including the data type, format, and length. Therefore, the format definition of metadata is also very important, and it is related to the accuracy and reliability of the Upper-layer data acquisition. However, ice has already done a very good job of this kind of work. We just need to call the upper layer. There are four methods in total, but we can summarize the two actions as write and read, it corresponds to the write before the client call and the read when the server receives the message, so that the message can be completely accepted. The definition of the format is not detailed here. If you are interested, we recommend that you study the operation principles of ice. Iii. interfaces and exceptions

This chapter may be the one we are most concerned about. The preceding syntax and basic classes ultimately serve to implement an interface, the interface refers to the channel for communication with the outside world. With the basis above, it is much easier to define an interface.

To be continued ......

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.