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.l2.handler;
06:
07: import com.tc.async.api.AbstractEventHandler;
08: import com.tc.async.api.ConfigurationContext;
09: import com.tc.async.api.EventContext;
10: import com.tc.async.api.Sink;
11: import com.tc.l2.context.ManagedObjectSyncContext;
12: import com.tc.l2.context.SyncObjectsRequest;
13: import com.tc.l2.objectserver.L2ObjectStateManager;
14: import com.tc.net.groups.ClientID;
15: import com.tc.net.groups.NodeID;
16: import com.tc.objectserver.api.ObjectManager;
17: import com.tc.objectserver.core.api.ServerConfigurationContext;
18:
19: public class L2ObjectSyncRequestHandler extends AbstractEventHandler {
20:
21: private final L2ObjectStateManager l2ObjectStateMgr;
22: private Sink dehydrateSink;
23: private ObjectManager objectManager;
24:
25: public L2ObjectSyncRequestHandler(
26: L2ObjectStateManager objectStateManager) {
27: l2ObjectStateMgr = objectStateManager;
28: }
29:
30: public void handleEvent(EventContext context) {
31: SyncObjectsRequest request = (SyncObjectsRequest) context;
32: doSyncObjectsRequest(request);
33: }
34:
35: // TODO:: Update stats so that admin console reflects these data
36: private void doSyncObjectsRequest(SyncObjectsRequest request) {
37: NodeID nodeID = request.getNodeID();
38: ManagedObjectSyncContext lookupContext = l2ObjectStateMgr
39: .getSomeObjectsToSyncContext(nodeID, 500, dehydrateSink);
40: if (lookupContext != null) {
41: objectManager.lookupObjectsFor(ClientID.NULL_ID,
42: lookupContext);
43: }
44: }
45:
46: public void initialize(ConfigurationContext context) {
47: super .initialize(context);
48: ServerConfigurationContext oscc = (ServerConfigurationContext) context;
49: this.objectManager = oscc.getObjectManager();
50: this.dehydrateSink = oscc
51: .getStage(
52: ServerConfigurationContext.OBJECTS_SYNC_DEHYDRATE_STAGE)
53: .getSink();
54: }
55: }
|