1717
1818package org .apache .ignite .internal .managers .deployment ;
1919
20- import java .nio .ByteBuffer ;
2120import java .util .Collection ;
2221import java .util .UUID ;
23- import org .apache .ignite .internal . GridDirectCollection ;
24- import org .apache .ignite .internal .GridDirectTransient ;
22+ import org .apache .ignite .IgniteCheckedException ;
23+ import org .apache .ignite .internal .Order ;
2524import org .apache .ignite .internal .util .tostring .GridToStringInclude ;
2625import org .apache .ignite .internal .util .typedef .internal .S ;
26+ import org .apache .ignite .internal .util .typedef .internal .U ;
2727import org .apache .ignite .lang .IgniteUuid ;
28+ import org .apache .ignite .marshaller .Marshaller ;
2829import org .apache .ignite .plugin .extensions .communication .Message ;
29- import org .apache .ignite .plugin .extensions .communication .MessageCollectionItemType ;
30- import org .apache .ignite .plugin .extensions .communication .MessageReader ;
31- import org .apache .ignite .plugin .extensions .communication .MessageWriter ;
3230
3331/**
3432 * Deployment request.
3533 */
3634public class GridDeploymentRequest implements Message {
3735 /** Response topic. Response should be sent back to this topic. */
38- @ GridDirectTransient
3936 private Object resTopic ;
4037
4138 /** Serialized topic. */
39+ @ Order (value = 0 , method = "responseTopicBytes" )
4240 private byte [] resTopicBytes ;
4341
4442 /** Requested class name. */
43+ @ Order (value = 1 , method = "resourceName" )
4544 private String rsrcName ;
4645
4746 /** Class loader ID. */
47+ @ Order (value = 2 , method = "classLoaderId" )
4848 private IgniteUuid ldrId ;
4949
5050 /** Undeploy flag. */
51+ @ Order (3 )
5152 private boolean isUndeploy ;
5253
5354 /** Nodes participating in request (chain). */
55+ @ Order (4 )
5456 @ GridToStringInclude
55- @ GridDirectCollection (UUID .class )
5657 private Collection <UUID > nodeIds ;
5758
5859 /**
@@ -90,24 +91,17 @@ Object responseTopic() {
9091 return resTopic ;
9192 }
9293
93- /**
94- * @param resTopic Response topic.
95- */
96- void responseTopic (Object resTopic ) {
97- this .resTopic = resTopic ;
98- }
99-
10094 /**
10195 * @return Serialized topic.
10296 */
103- byte [] responseTopicBytes () {
97+ public byte [] responseTopicBytes () {
10498 return resTopicBytes ;
10599 }
106100
107101 /**
108102 * @param resTopicBytes Serialized topic.
109103 */
110- void responseTopicBytes (byte [] resTopicBytes ) {
104+ public void responseTopicBytes (byte [] resTopicBytes ) {
111105 this .resTopicBytes = resTopicBytes ;
112106 }
113107
@@ -116,28 +110,49 @@ void responseTopicBytes(byte[] resTopicBytes) {
116110 *
117111 * @return Resource or class name.
118112 */
119- String resourceName () {
113+ public String resourceName () {
120114 return rsrcName ;
121115 }
122116
117+ /**
118+ * @param rsrcName Resource or class name.
119+ */
120+ public void resourceName (String rsrcName ) {
121+ this .rsrcName = rsrcName ;
122+ }
123+
123124 /**
124125 * Gets property ldrId.
125126 *
126- * @return Property ldrId .
127+ * @return Property class loader ID .
127128 */
128- IgniteUuid classLoaderId () {
129+ public IgniteUuid classLoaderId () {
129130 return ldrId ;
130131 }
131132
133+ /**
134+ * @param ldrId Property class loader ID.
135+ */
136+ public void classLoaderId (IgniteUuid ldrId ) {
137+ this .ldrId = ldrId ;
138+ }
139+
132140 /**
133141 * Gets property undeploy.
134142 *
135143 * @return Property undeploy.
136144 */
137- boolean isUndeploy () {
145+ public boolean isUndeploy () {
138146 return isUndeploy ;
139147 }
140148
149+ /**
150+ * @param isUndeploy Property undeploy.
151+ */
152+ public void isUndeploy (boolean isUndeploy ) {
153+ this .isUndeploy = isUndeploy ;
154+ }
155+
141156 /**
142157 * @return Node IDs chain which is updated as request jumps
143158 * from node to node.
@@ -154,101 +169,24 @@ public void nodeIds(Collection<UUID> nodeIds) {
154169 this .nodeIds = nodeIds ;
155170 }
156171
157- /** {@inheritDoc} */
158- @ Override public boolean writeTo (ByteBuffer buf , MessageWriter writer ) {
159- writer .setBuffer (buf );
160-
161- if (!writer .isHeaderWritten ()) {
162- if (!writer .writeHeader (directType ()))
163- return false ;
164-
165- writer .onHeaderWritten ();
166- }
167-
168- switch (writer .state ()) {
169- case 0 :
170- if (!writer .writeBoolean (isUndeploy ))
171- return false ;
172-
173- writer .incrementState ();
174-
175- case 1 :
176- if (!writer .writeIgniteUuid (ldrId ))
177- return false ;
178-
179- writer .incrementState ();
180-
181- case 2 :
182- if (!writer .writeCollection (nodeIds , MessageCollectionItemType .UUID ))
183- return false ;
184-
185- writer .incrementState ();
186-
187- case 3 :
188- if (!writer .writeByteArray (resTopicBytes ))
189- return false ;
190-
191- writer .incrementState ();
192-
193- case 4 :
194- if (!writer .writeString (rsrcName ))
195- return false ;
196-
197- writer .incrementState ();
198-
199- }
200-
201- return true ;
172+ /**
173+ * @param marsh Marshaller.
174+ */
175+ public void prepareMarshal (Marshaller marsh ) throws IgniteCheckedException {
176+ if (resTopic != null && resTopicBytes == null )
177+ resTopicBytes = U .marshal (marsh , resTopic );
202178 }
203179
204- /** {@inheritDoc} */
205- @ Override public boolean readFrom (ByteBuffer buf , MessageReader reader ) {
206- reader .setBuffer (buf );
207-
208- switch (reader .state ()) {
209- case 0 :
210- isUndeploy = reader .readBoolean ();
211-
212- if (!reader .isLastRead ())
213- return false ;
214-
215- reader .incrementState ();
216-
217- case 1 :
218- ldrId = reader .readIgniteUuid ();
219-
220- if (!reader .isLastRead ())
221- return false ;
222-
223- reader .incrementState ();
224-
225- case 2 :
226- nodeIds = reader .readCollection (MessageCollectionItemType .UUID );
227-
228- if (!reader .isLastRead ())
229- return false ;
230-
231- reader .incrementState ();
232-
233- case 3 :
234- resTopicBytes = reader .readByteArray ();
235-
236- if (!reader .isLastRead ())
237- return false ;
238-
239- reader .incrementState ();
240-
241- case 4 :
242- rsrcName = reader .readString ();
243-
244- if (!reader .isLastRead ())
245- return false ;
246-
247- reader .incrementState ();
180+ /**
181+ * @param marsh Marshaller.
182+ * @param ldr Class loader.
183+ */
184+ public void finishUnmarshal (Marshaller marsh , ClassLoader ldr ) throws IgniteCheckedException {
185+ if (resTopicBytes != null && resTopic == null ) {
186+ resTopic = U .unmarshal (marsh , resTopicBytes , ldr );
248187
188+ resTopicBytes = null ;
249189 }
250-
251- return true ;
252190 }
253191
254192 /** {@inheritDoc} */
0 commit comments