|
17 | 17 |
|
18 | 18 | package org.apache.ignite.internal.processors.cache.version; |
19 | 19 |
|
20 | | -import java.io.Externalizable; |
21 | | -import java.io.IOException; |
22 | | -import java.io.ObjectInput; |
23 | | -import java.io.ObjectOutput; |
24 | | -import java.nio.ByteBuffer; |
25 | | -import org.apache.ignite.IgniteCheckedException; |
26 | | -import org.apache.ignite.internal.GridDirectTransient; |
27 | | -import org.apache.ignite.internal.IgniteCodeGeneratingFail; |
| 20 | +import org.apache.ignite.internal.Order; |
28 | 21 | import org.apache.ignite.internal.processors.cache.CacheObject; |
29 | | -import org.apache.ignite.internal.processors.cache.CacheObjectContext; |
30 | 22 | import org.apache.ignite.internal.processors.cache.CacheObjectValueContext; |
31 | 23 | import org.apache.ignite.internal.processors.cache.KeyCacheObject; |
32 | 24 | import org.apache.ignite.internal.processors.datastreamer.DataStreamerEntry; |
33 | 25 | import org.apache.ignite.internal.util.typedef.internal.S; |
34 | | -import org.apache.ignite.internal.util.typedef.internal.U; |
35 | | -import org.apache.ignite.marshaller.Marshaller; |
36 | | -import org.apache.ignite.plugin.extensions.communication.MessageReader; |
37 | | -import org.apache.ignite.plugin.extensions.communication.MessageWriter; |
38 | 26 | import org.jetbrains.annotations.Nullable; |
39 | 27 |
|
40 | 28 | /** |
41 | 29 | * Raw versioned entry. |
42 | 30 | */ |
43 | | -@IgniteCodeGeneratingFail |
44 | 31 | public class GridCacheRawVersionedEntry<K, V> extends DataStreamerEntry implements |
45 | | - GridCacheVersionedEntry<K, V>, GridCacheVersionable, Externalizable { |
46 | | - /** */ |
47 | | - private static final long serialVersionUID = 0L; |
48 | | - |
49 | | - /** Key bytes. */ |
50 | | - @GridDirectTransient |
51 | | - private byte[] keyBytes; |
52 | | - |
53 | | - /** Value bytes. */ |
54 | | - private byte[] valBytes; |
55 | | - |
| 32 | + GridCacheVersionedEntry<K, V>, GridCacheVersionable { |
56 | 33 | /** TTL. */ |
57 | | - private long ttl; |
| 34 | + @Order(0) |
| 35 | + long ttl; |
58 | 36 |
|
59 | 37 | /** Expire time. */ |
60 | | - private long expireTime; |
| 38 | + @Order(1) |
| 39 | + long expireTime; |
61 | 40 |
|
62 | 41 | /** Version. */ |
63 | | - private GridCacheVersion ver; |
| 42 | + @Order(2) |
| 43 | + GridCacheVersion ver; |
64 | 44 |
|
65 | 45 | /** |
66 | 46 | * {@code Externalizable} support. |
@@ -92,28 +72,6 @@ public GridCacheRawVersionedEntry(KeyCacheObject key, |
92 | 72 | this.ver = ver; |
93 | 73 | } |
94 | 74 |
|
95 | | - /** |
96 | | - * Constructor used in receiver hub where marshalled key and value are available and we do not want to |
97 | | - * unmarshal value. |
98 | | - * |
99 | | - * @param keyBytes Key. |
100 | | - * @param valBytes Value bytes. |
101 | | - * @param expireTime Expire time. |
102 | | - * @param ttl TTL. |
103 | | - * @param ver Version. |
104 | | - */ |
105 | | - public GridCacheRawVersionedEntry(byte[] keyBytes, |
106 | | - byte[] valBytes, |
107 | | - long ttl, |
108 | | - long expireTime, |
109 | | - GridCacheVersion ver) { |
110 | | - this.keyBytes = keyBytes; |
111 | | - this.valBytes = valBytes; |
112 | | - this.ttl = ttl; |
113 | | - this.expireTime = expireTime; |
114 | | - this.ver = ver; |
115 | | - } |
116 | | - |
117 | 75 | /** {@inheritDoc} */ |
118 | 76 | @Override public K key() { |
119 | 77 | assert key != null : "Entry is being improperly processed."; |
@@ -156,162 +114,13 @@ public GridCacheRawVersionedEntry(byte[] keyBytes, |
156 | 114 | return ver; |
157 | 115 | } |
158 | 116 |
|
159 | | - /** |
160 | | - * Perform internal unmarshal of this entry. It must be performed after entry is deserialized and before |
161 | | - * its restored key/value are needed. |
162 | | - * |
163 | | - * @param ctx Context. |
164 | | - * @param marsh Marshaller. |
165 | | - * @throws IgniteCheckedException If failed. |
166 | | - */ |
167 | | - public void unmarshal(CacheObjectContext ctx, Marshaller marsh) throws IgniteCheckedException { |
168 | | - unmarshalKey(ctx, marsh); |
169 | | - |
170 | | - if (val == null && valBytes != null) { |
171 | | - val = U.unmarshal(marsh, valBytes, U.resolveClassLoader(null, ctx.classLoader())); |
172 | | - |
173 | | - val.finishUnmarshal(ctx, null); |
174 | | - } |
175 | | - } |
176 | | - |
177 | | - /** |
178 | | - * Perform internal key unmarshal of this entry. It must be performed after entry is deserialized and before |
179 | | - * its restored key/value are needed. |
180 | | - * |
181 | | - * @param ctx Context. |
182 | | - * @param marsh Marshaller. |
183 | | - * @throws IgniteCheckedException If failed. |
184 | | - */ |
185 | | - public void unmarshalKey(CacheObjectContext ctx, Marshaller marsh) throws IgniteCheckedException { |
186 | | - if (key == null) { |
187 | | - assert keyBytes != null; |
188 | | - |
189 | | - key = U.unmarshal(marsh, keyBytes, U.resolveClassLoader(null, ctx.classLoader())); |
190 | | - |
191 | | - key.finishUnmarshal(ctx, null); |
192 | | - } |
193 | | - } |
194 | | - |
195 | | - /** |
196 | | - * @param ctx Context. |
197 | | - * @throws IgniteCheckedException If failed. |
198 | | - */ |
199 | | - public void prepareDirectMarshal(CacheObjectContext ctx) throws IgniteCheckedException { |
200 | | - key.prepareMarshal(ctx); |
201 | | - |
202 | | - if (val != null) |
203 | | - val.prepareMarshal(ctx); |
204 | | - } |
205 | | - |
206 | 117 | /** {@inheritDoc} */ |
207 | 118 | @Override public short directType() { |
208 | 119 | return 103; |
209 | 120 | } |
210 | 121 |
|
211 | | - /** {@inheritDoc} */ |
212 | | - @Override public boolean readFrom(ByteBuffer buf, MessageReader reader) { |
213 | | - reader.setBuffer(buf); |
214 | | - |
215 | | - if (!super.readFrom(buf, reader)) |
216 | | - return false; |
217 | | - |
218 | | - switch (reader.state()) { |
219 | | - case 2: |
220 | | - expireTime = reader.readLong(); |
221 | | - |
222 | | - if (!reader.isLastRead()) |
223 | | - return false; |
224 | | - |
225 | | - reader.incrementState(); |
226 | | - |
227 | | - case 3: |
228 | | - ttl = reader.readLong(); |
229 | | - |
230 | | - if (!reader.isLastRead()) |
231 | | - return false; |
232 | | - |
233 | | - reader.incrementState(); |
234 | | - |
235 | | - case 4: |
236 | | - valBytes = reader.readByteArray(); |
237 | | - |
238 | | - if (!reader.isLastRead()) |
239 | | - return false; |
240 | | - |
241 | | - reader.incrementState(); |
242 | | - |
243 | | - case 5: |
244 | | - ver = reader.readMessage(); |
245 | | - |
246 | | - if (!reader.isLastRead()) |
247 | | - return false; |
248 | | - |
249 | | - reader.incrementState(); |
250 | | - |
251 | | - } |
252 | | - |
253 | | - return true; |
254 | | - } |
255 | | - |
256 | | - /** {@inheritDoc} */ |
257 | | - @Override public boolean writeTo(ByteBuffer buf, MessageWriter writer) { |
258 | | - writer.setBuffer(buf); |
259 | | - |
260 | | - if (!super.writeTo(buf, writer)) |
261 | | - return false; |
262 | | - |
263 | | - if (!writer.isHeaderWritten()) { |
264 | | - if (!writer.writeHeader(directType())) |
265 | | - return false; |
266 | | - |
267 | | - writer.onHeaderWritten(); |
268 | | - } |
269 | | - |
270 | | - switch (writer.state()) { |
271 | | - case 2: |
272 | | - if (!writer.writeLong(expireTime)) |
273 | | - return false; |
274 | | - |
275 | | - writer.incrementState(); |
276 | | - |
277 | | - case 3: |
278 | | - if (!writer.writeLong(ttl)) |
279 | | - return false; |
280 | | - |
281 | | - writer.incrementState(); |
282 | | - |
283 | | - case 4: |
284 | | - if (!writer.writeByteArray(valBytes)) |
285 | | - return false; |
286 | | - |
287 | | - writer.incrementState(); |
288 | | - |
289 | | - case 5: |
290 | | - if (!writer.writeMessage(ver)) |
291 | | - return false; |
292 | | - |
293 | | - writer.incrementState(); |
294 | | - |
295 | | - } |
296 | | - |
297 | | - return true; |
298 | | - } |
299 | | - |
300 | | - /** {@inheritDoc} */ |
301 | | - @Override public void writeExternal(ObjectOutput out) throws IOException { |
302 | | - assert false; |
303 | | - } |
304 | | - |
305 | | - /** {@inheritDoc} */ |
306 | | - @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { |
307 | | - assert false; |
308 | | - } |
309 | | - |
310 | 122 | /** {@inheritDoc} */ |
311 | 123 | @Override public String toString() { |
312 | | - return S.toString(GridCacheRawVersionedEntry.class, this, |
313 | | - "keyBytesLen", keyBytes != null ? keyBytes.length : "n/a", |
314 | | - "valBytesLen", valBytes != null ? valBytes.length : "n/a", |
315 | | - "super", super.toString()); |
| 124 | + return S.toString(GridCacheRawVersionedEntry.class, this, "super", super.toString()); |
316 | 125 | } |
317 | 126 | } |
0 commit comments