1 5 package com.tc.objectserver.handler; 6 7 import com.tc.async.api.AbstractEventHandler; 8 import com.tc.async.api.ConfigurationContext; 9 import com.tc.async.api.EventContext; 10 import com.tc.logging.TCLogger; 11 import com.tc.logging.TCLogging; 12 import com.tc.object.ObjectID; 13 import com.tc.objectserver.api.ObjectManager; 14 import com.tc.objectserver.context.ManagedObjectFaultingContext; 15 import com.tc.objectserver.core.api.ManagedObject; 16 import com.tc.objectserver.core.api.ServerConfigurationContext; 17 import com.tc.objectserver.persistence.api.ManagedObjectStore; 18 import com.tc.properties.TCPropertiesImpl; 19 20 public class ManagedObjectFaultHandler extends AbstractEventHandler { 21 22 private static final TCLogger logger = TCLogging.getLogger(ManagedObjectFaultHandler.class); 23 private static final boolean LOG_OBJECT_FAULT = TCPropertiesImpl.getProperties() 24 .getBoolean("l2.objectmanager.fault.logging.enabled"); 25 26 private ObjectManager objectManager; 27 private ManagedObjectStore objectStore; 28 29 public void handleEvent(EventContext context) { 30 if (LOG_OBJECT_FAULT) incrementAndLog(); 31 ManagedObjectFaultingContext mfc = (ManagedObjectFaultingContext) context; 32 ObjectID oid = mfc.getId(); 33 ManagedObject mo = objectStore.getObjectByID(oid); 34 objectManager.addFaultedObject(oid, mo, mfc.isRemoveOnRelease()); 35 } 36 37 int count = 0; 38 39 private synchronized void incrementAndLog() { 40 count++; 41 if (count % 100 == 0) { 42 logger.info("Fault count = " + count); 43 } 44 } 45 46 public void initialize(ConfigurationContext context) { 47 super.initialize(context); 48 ServerConfigurationContext oscc = (ServerConfigurationContext) context; 49 objectManager = oscc.getObjectManager(); 50 objectStore = oscc.getObjectStore(); 51 } 52 53 } 54 | Popular Tags |