01: /*
02: * All content copyright (c) 2003-2007 Terracotta, Inc., except as may otherwise be noted in a separate copyright
03: * notice. All rights reserved.
04: */
05: package com.tc.object.msg;
06:
07: import com.tc.async.api.EventContext;
08: import com.tc.bytes.TCByteBuffer;
09: import com.tc.io.TCByteBufferOutput;
10: import com.tc.net.protocol.tcm.MessageChannel;
11: import com.tc.net.protocol.tcm.MessageMonitor;
12: import com.tc.net.protocol.tcm.TCMessageHeader;
13: import com.tc.net.protocol.tcm.TCMessageType;
14: import com.tc.object.ObjectID;
15: import com.tc.object.session.SessionID;
16:
17: import java.io.IOException;
18: import java.util.HashSet;
19: import java.util.Iterator;
20: import java.util.Set;
21:
22: public class ObjectsNotFoundMessage extends DSOMessageBase implements
23: EventContext {
24:
25: private final static byte BATCH_ID = 0;
26: private final static byte MISSING_OID = 1;
27:
28: private Set missingOids;
29: private long batchID;
30:
31: public ObjectsNotFoundMessage(SessionID sessionID,
32: MessageMonitor monitor, TCByteBufferOutput out,
33: MessageChannel channel, TCMessageType type) {
34: super (sessionID, monitor, out, channel, type);
35: }
36:
37: public ObjectsNotFoundMessage(SessionID sessionID,
38: MessageMonitor monitor, MessageChannel channel,
39: TCMessageHeader header, TCByteBuffer[] data) {
40: super (sessionID, monitor, channel, header, data);
41: }
42:
43: public void initialize(Set missingObjectIDs, long batchId) {
44: this .missingOids = missingObjectIDs;
45: this .batchID = batchId;
46: }
47:
48: protected void dehydrateValues() {
49: putNVPair(BATCH_ID, batchID);
50: for (Iterator i = missingOids.iterator(); i.hasNext();) {
51: ObjectID oid = (ObjectID) i.next();
52: putNVPair(MISSING_OID, oid.toLong());
53: }
54: }
55:
56: protected boolean hydrateValue(byte name) throws IOException {
57: switch (name) {
58: case BATCH_ID:
59: this .batchID = getLongValue();
60: return true;
61: case MISSING_OID:
62: if (missingOids == null) {
63: missingOids = new HashSet();
64: }
65: this .missingOids.add(new ObjectID(getLongValue()));
66: return true;
67: default:
68: return false;
69: }
70: }
71:
72: public long getBatchID() {
73: return batchID;
74: }
75:
76: public Set getMissingObjectIDs() {
77: return missingOids;
78: }
79:
80: }
|