3131import org .apache .log4j .Level ;
3232import org .apache .log4j .Logger ;
3333
34- import com .cloud .agent .api .Answer ;
35- import com .cloud .agent .api .Command ;
36- import com .cloud .agent .api .SecStorageFirewallCfgCommand .PortConfig ;
37- import com .cloud .exception .UnsupportedVersionException ;
38- import com .cloud .serializer .GsonHelper ;
39- import com .cloud .utils .NumbersUtil ;
40- import com .cloud .utils .Pair ;
41- import com .cloud .utils .exception .CloudRuntimeException ;
4234import com .google .gson .Gson ;
4335import com .google .gson .JsonArray ;
4436import com .google .gson .JsonDeserializationContext ;
5042import com .google .gson .JsonSerializer ;
5143import com .google .gson .stream .JsonReader ;
5244
45+ import com .cloud .agent .api .Answer ;
46+ import com .cloud .agent .api .Command ;
47+ import com .cloud .agent .api .SecStorageFirewallCfgCommand .PortConfig ;
48+ import com .cloud .exception .UnsupportedVersionException ;
49+ import com .cloud .serializer .GsonHelper ;
50+ import com .cloud .utils .NumbersUtil ;
51+ import com .cloud .utils .Pair ;
52+ import com .cloud .utils .exception .CloudRuntimeException ;
53+
5354/**
5455 * Request is a simple wrapper around command and answer to add sequencing,
5556 * versioning, and flags. Note that the version here represents the changes
@@ -107,7 +108,7 @@ public static Version get(final byte ver) throws UnsupportedVersionException {
107108 protected long _agentId ;
108109 protected Command [] _cmds ;
109110 protected String _content ;
110-
111+
111112 protected Request () {
112113 }
113114
@@ -158,14 +159,14 @@ protected void setInSequence(Command[] cmds) {
158159 }
159160
160161 protected Request (final Request that , final Command [] cmds ) {
161- this . _ver = that ._ver ;
162- this . _seq = that ._seq ;
162+ _ver = that ._ver ;
163+ _seq = that ._seq ;
163164 setInSequence (that .executeInSequence ());
164165 setStopOnError (that .stopOnError ());
165- this . _cmds = cmds ;
166- this . _mgmtId = that ._mgmtId ;
167- this . _via = that ._via ;
168- this . _agentId = that ._agentId ;
166+ _cmds = cmds ;
167+ _mgmtId = that ._mgmtId ;
168+ _via = that ._via ;
169+ _agentId = that ._agentId ;
169170 setFromServer (!that .isFromServer ());
170171 }
171172
@@ -287,7 +288,7 @@ public static ByteBuffer doDecompress(ByteBuffer buffer, int length) {
287288 retBuff .flip ();
288289 return retBuff ;
289290 }
290-
291+
291292 public static ByteBuffer doCompress (ByteBuffer buffer , int length ) {
292293 ByteArrayOutputStream byteOut = new ByteArrayOutputStream (length );
293294 byte [] array ;
@@ -307,11 +308,11 @@ public static ByteBuffer doCompress(ByteBuffer buffer, int length) {
307308 }
308309 return ByteBuffer .wrap (byteOut .toByteArray ());
309310 }
310-
311+
311312 public ByteBuffer [] toBytes () {
312313 final ByteBuffer [] buffers = new ByteBuffer [2 ];
313314 ByteBuffer tmp ;
314-
315+
315316 if (_content == null ) {
316317 _content = s_gson .toJson (_cmds , _cmds .getClass ());
317318 }
@@ -372,7 +373,7 @@ public void logT(String msg, boolean logD) {
372373 }
373374 }
374375 }
375-
376+
376377 @ Override
377378 public String toString () {
378379 return log ("" , true , Level .DEBUG );
@@ -447,7 +448,7 @@ public static Request parse(final byte[] bytes) throws ClassNotFoundException, U
447448 if (version .ordinal () != Version .v1 .ordinal () && version .ordinal () != Version .v3 .ordinal ()) {
448449 throw new UnsupportedVersionException ("This version is no longer supported: " + version .toString (), UnsupportedVersionException .IncompatibleVersion );
449450 }
450- final byte reserved = buff .get (); // tossed away for now.
451+ buff .get ();
451452 final short flags = buff .getShort ();
452453 final boolean isRequest = (flags & FLAG_REQUEST ) > 0 ;
453454
@@ -456,7 +457,7 @@ public static Request parse(final byte[] bytes) throws ClassNotFoundException, U
456457 final int size = buff .getInt ();
457458 final long mgmtId = buff .getLong ();
458459 final long agentId = buff .getLong ();
459-
460+
460461 long via ;
461462 if (version .ordinal () == Version .v1 .ordinal ()) {
462463 via = buff .getLong ();
@@ -467,7 +468,7 @@ public static Request parse(final byte[] bytes) throws ClassNotFoundException, U
467468 if ((flags & FLAG_COMPRESSED ) != 0 ) {
468469 buff = doDecompress (buff , size );
469470 }
470-
471+
471472 byte [] command = null ;
472473 int offset = 0 ;
473474 if (buff .hasArray ()) {
@@ -519,7 +520,7 @@ public static long getAgentId(final byte[] bytes) {
519520 public static long getViaAgentId (final byte [] bytes ) {
520521 return NumbersUtil .bytesToLong (bytes , 32 );
521522 }
522-
523+
523524 public static boolean fromServer (final byte [] bytes ) {
524525 return (bytes [3 ] & FLAG_FROM_SERVER ) > 0 ;
525526 }
0 commit comments