2020
2121import org .apache .hadoop .classification .InterfaceAudience .Public ;
2222import org .apache .hadoop .classification .InterfaceStability .Stable ;
23+ import org .apache .hadoop .classification .InterfaceStability .Unstable ;
2324import org .apache .hadoop .yarn .api .ContainerManagementProtocol ;
25+ import org .apache .hadoop .yarn .api .records .ContainerId ;
2426import org .apache .hadoop .yarn .api .records .ContainerLaunchContext ;
2527import org .apache .hadoop .yarn .api .records .NMToken ;
28+ import org .apache .hadoop .yarn .api .records .NodeId ;
2629import org .apache .hadoop .yarn .api .records .Token ;
2730import org .apache .hadoop .yarn .util .Records ;
2831
3639 * necessary binaries/jar/shared-objects etc. via the
3740 * {@link ContainerLaunchContext}.</p>
3841 *
42+ * <p>The <em>isMove</em> flag tells whether this request corresponds to a container
43+ * relocation. If true, then no container launch context is needed as it will be
44+ * transferred directly from the origin node manager to the target node manager.
45+ * The container to be relocated is identified by the <em>originNodeId</em> and
46+ * <em>originContainerId</em>.
47+ * The originNMToken is sent along so that the origin container can be shut down
48+ * by the target node manager.
49+ * </p>
50+ *
3951 * @see ContainerManagementProtocol#startContainers(StartContainersRequest)
4052 */
4153@ Public
@@ -49,6 +61,21 @@ public static StartContainerRequest newInstance(
4961 Records .newRecord (StartContainerRequest .class );
5062 request .setContainerLaunchContext (context );
5163 request .setContainerToken (container );
64+ request .setIsMove (false );
65+ return request ;
66+ }
67+
68+ @ Public
69+ @ Stable
70+ public static StartContainerRequest newInstance (
71+ Token container , ContainerId originContainerId , NodeId originNodeId , Token originNMToken ) {
72+ StartContainerRequest request =
73+ Records .newRecord (StartContainerRequest .class );
74+ request .setContainerToken (container );
75+ request .setIsMove (true );
76+ request .setOriginContainerId (originContainerId );
77+ request .setOriginNodeId (originNodeId );
78+ request .setOriginNMToken (originNMToken );
5279 return request ;
5380 }
5481
@@ -91,4 +118,91 @@ public static StartContainerRequest newInstance(
91118 @ Public
92119 @ Stable
93120 public abstract void setContainerToken (Token container );
121+
122+ /**
123+ * Gets whether this start container request corresponds to a container relocation.
124+ * @return whether this start container request corresponds to a container relocation
125+ */
126+ @ Public
127+ @ Unstable
128+ public abstract boolean getIsMove ();
129+
130+ /**
131+ * Sets whether this start container request corresponds to a container relocation.
132+ * @param isMove whether this start container request corresponds to a container
133+ * relocation
134+ */
135+ @ Public
136+ @ Unstable
137+ public abstract void setIsMove (boolean isMove );
138+
139+ /**
140+ * Gets the origin container id for this start container request.
141+ * The origin container id is set if and only if this start container request
142+ * corresponds to a container relocation. It identifies the container that should
143+ * be relocated.
144+ *
145+ * @return the origin container id for this start container request
146+ */
147+ @ Public
148+ @ Unstable
149+ public abstract ContainerId getOriginContainerId ();
150+
151+ /**
152+ * Sets the origin container id for this start container request.
153+ * The origin container id should be set if and only if this start container request
154+ * corresponds to a container relocation. It identifies the container that should
155+ * be relocated.
156+ *
157+ * @param originContainerId the origin container id for this start container request
158+ */
159+ @ Public
160+ @ Unstable
161+ public abstract void setOriginContainerId (ContainerId originContainerId );
162+
163+ /**
164+ * Gets the origin node id for this start container request.
165+ * The origin node id is set if and only if this resource start container corresponds
166+ * to a container relocation. It identifies the node of the container that should
167+ * be relocated.
168+ *
169+ * @return the origin node id for this start container request
170+ */
171+ @ Public
172+ @ Unstable
173+ public abstract NodeId getOriginNodeId ();
174+
175+ /**
176+ * Sets the origin node id for this start container request.
177+ * The origin node id should be set if and only if this start container request
178+ * corresponds to a container relocation. It identifies the node of the container
179+ * that should be relocated.
180+ *
181+ * @param originNodeId the origin node id for this start container request
182+ */
183+ @ Public
184+ @ Unstable
185+ public abstract void setOriginNodeId (NodeId originNodeId );
186+
187+ /**
188+ * Gets the security token for the origin node.
189+ * The origin NM token is set if and only if this start container request corresponds
190+ * to a container relocation. It is used for shutting down the origin container.
191+ *
192+ * @return the security token for the origin node
193+ */
194+ @ Public
195+ @ Unstable
196+ public abstract Token getOriginNMToken ();
197+
198+ /**
199+ * Sets the security token for the origin node.
200+ * The origin NM token should be set if and only if this start container request corresponds
201+ * to a container relocation. It is used for shutting down the origin container.
202+ *
203+ * @param originNMToken the security token for the origin node
204+ */
205+ @ Public
206+ @ Unstable
207+ public abstract void setOriginNMToken (Token originNMToken );
94208}
0 commit comments