Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

the translation of packaging section #95

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 19 additions & 39 deletions docs/dev/packaging.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,54 +24,34 @@ under the License.
-->


As described earlier, Flink programs can be executed on
clusters by using a `remote environment`. Alternatively, programs can be packaged into JAR Files
(Java Archives) for execution. Packaging the program is a prerequisite to executing them through the
[command line interface]({{ site.baseurl }}/setup/cli.html).
����֮ǰ������������,Flink�ij��������`Զ�̻�����remote environment��`�ķ�ʽִ���ڼ�Ⱥ�ϡ�
ͬʱ������Ҳ����ѡ���ô��JAR����Java Archives���ķ�ʽ��ִ�С����������ʹ��[������command line interface]({{ site.baseurl }}/setup/cli.html)���������ǵ�ǰ��������

### Packaging Programs
### �������Packaging Programs��

To support execution from a packaged JAR file via the command line or web interface, a program must
use the environment obtained by `StreamExecutionEnvironment.getExecutionEnvironment()`. This environment
will act as the cluster's environment when the JAR is submitted to the command line or web
interface. If the Flink program is invoked differently than through these interfaces, the
environment will act like a local environment.
Ϊ��֧��JAR��ͨ�������л�������ӿڵķ�ʽִ�У������ڲ�����ʹ�ð���`StreamExecutionEnvironment.getExecutionEnvironment()`��
��������JAR��ͨ�������л�������ӿ��ύʱ�������������Ϊ��Ⱥִ�еĻ��������Flink����û��ͨ����Щ�ӿڵ��ã�
��ô����������Ϊһ�����ػ�����ִ�С�

To package the program, simply export all involved classes as a JAR file. The JAR file's manifest
must point to the class that contains the program's *entry point* (the class with the public
`main` method). The simplest way to do this is by putting the *main-class* entry into the
manifest (such as `main-class: org.apache.flinkexample.MyProgram`). The *main-class* attribute is
the same one that is used by the Java Virtual Machine to find the main method when executing a JAR
files through the command `java -jar pathToTheJarFile`. Most IDEs offer to include that attribute
automatically when exporting JAR files.
Ϊ�˴�����������Լ򵥵Ľ����е��ർ����һ��JAR����JAR����manifestһ��Ҫָ������г���
*��ڵ㣨entry point��*���й���`main`���������ࡣ��򵥵�һ�ַ�ʽ���ǽ�*main-class*����manifest����������:`main-class: org.apache.flinkexample.MyProgram`�������*main-class* ������ָ������������Java�������ͨ��������`java -jar pathToTheJarFile`
ִ��JAR��ʱ�ҵ�����������һ��������������� IDE���ṩ���ڵ���JAR��ʱ�Զ���������԰���������Ĺ��ܡ�

### ͨ���ƻ����������Packaging Programs through Plans��

### Packaging Programs through Plans
���⣬���ǻ�֧�ֽ���������*�ƻ���Plans)*�� �ƻ���������һ�����������������������*����ƻ���Program Plan��*��
���������������ж���һ���������ڻ����е���`execute()`ִ�к�����Ϊ��������һ���أ��������Ҫʵ��`org.apache.flink.api.common.Program`
�ӿڣ�����`getPlan(String...)`��������������е��ַ���������һ�������в������ڴ������ƻ��Ĺ����У�JAR����manifest����ָ��ʵ�ֵ�`org.apache.flinkapi.common.Program`�ӿڣ����������������ࡣ

Additionally, we support packaging programs as *Plans*. Instead of defining a progam in the main
method and calling
`execute()` on the environment, plan packaging returns the *Program Plan*, which is a description of
the program's data flow. To do that, the program must implement the
`org.apache.flink.api.common.Program` interface, defining the `getPlan(String...)` method. The
strings passed to that method are the command line arguments. The program's plan can be created from
the environment via the `ExecutionEnvironment#createProgramPlan()` method. When packaging the
program's plan, the JAR manifest must point to the class implementing the
`org.apache.flinkapi.common.Program` interface, instead of the class with the main method.
### �ܽᣨSummary��

�ܵ���˵������һ������ij���������¼������裺

### Summary
1. JAR����manifestѰ��*main-class* ���� *program-class*���ԡ�����������Զ��ҵ��ˣ���*program-class* Ҫ������*main-class* ���ԡ�
��JAR��manifest�ļ��������κ�һ������ʱ�������л�������ӿڶ�֧�ֽ�������ڵ��������ֶ�����ķ�ʽ��

The overall procedure to invoke a packaged program is as follows:
2. ��������ʵ����`org.apache.flinkapi.common.Program`�ӿڣ���ôϵͳ������`getPlan(String...)`������ִ�в���ó���ƻ���

1. The JAR's manifest is searched for a *main-class* or *program-class* attribute. If both
attributes are found, the *program-class* attribute takes precedence over the *main-class*
attribute. Both the command line and the web interface support a parameter to pass the entry point
class name manually for cases where the JAR manifest contains neither attribute.

2. If the entry point class implements the `org.apache.flinkapi.common.Program`, then the system
calls the `getPlan(String...)` method to obtain the program plan to execute.

3. If the entry point class does not implement the `org.apache.flinkapi.common.Program` interface,
the system will invoke the main method of the class.
3. ��������û��ʵ��`org.apache.flinkapi.common.Program`�ӿڣ���ôϵͳ���������е���������

{% top %}