Merge pull request #967 from metamx/more-logs

Add more logs for CIM
This commit is contained in:
Fangjin Yang 2014-12-15 14:20:27 -07:00
commit eed679a1ba
2 changed files with 17 additions and 11 deletions

View File

@ -46,10 +46,10 @@ import java.util.concurrent.atomic.AtomicReference;
/** /**
* An InventoryManager watches updates to inventory on Zookeeper (or some other discovery-like service publishing * An InventoryManager watches updates to inventory on Zookeeper (or some other discovery-like service publishing
* system). It is built up on two object types: containers and inventory objects. * system). It is built up on two object types: containers and inventory objects.
* * <p/>
* The logic of the InventoryManager just maintains a local cache of the containers and inventory it sees on ZK. It * The logic of the InventoryManager just maintains a local cache of the containers and inventory it sees on ZK. It
* provides methods for getting at the container objects, which house the actual individual pieces of inventory. * provides methods for getting at the container objects, which house the actual individual pieces of inventory.
* * <p/>
* A Strategy is provided to the constructor of an Inventory manager, this strategy provides all of the * A Strategy is provided to the constructor of an Inventory manager, this strategy provides all of the
* object-specific logic to serialize, deserialize, compose and alter the container and inventory objects. * object-specific logic to serialize, deserialize, compose and alter the container and inventory objects.
*/ */
@ -104,7 +104,8 @@ public class CuratorInventoryManager<ContainerClass, InventoryClass>
} }
catch (Exception e) { catch (Exception e) {
synchronized (lock) { synchronized (lock) {
try { stop(); try {
stop();
} }
catch (IOException e1) { catch (IOException e1) {
log.error(e1, "Exception when stopping InventoryManager that couldn't start."); log.error(e1, "Exception when stopping InventoryManager that couldn't start.");
@ -262,12 +263,13 @@ public class CuratorInventoryManager<ContainerClass, InventoryClass>
final ContainerClass container = strategy.deserializeContainer(child.getData()); final ContainerClass container = strategy.deserializeContainer(child.getData());
ContainerHolder oldContainer = containers.get(containerKey); log.info("Container[%s] updated.", child.getPath());
if (oldContainer == null) { ContainerHolder holder = containers.get(containerKey);
if (holder == null) {
log.warn("Container update[%s], but the old container didn't exist!? Ignoring.", child.getPath()); log.warn("Container update[%s], but the old container didn't exist!? Ignoring.", child.getPath());
} else { } else {
synchronized (oldContainer) { synchronized (holder) {
oldContainer.setContainer(strategy.updateContainer(oldContainer.getContainer(), container)); holder.setContainer(strategy.updateContainer(holder.getContainer(), container));
} }
} }
@ -276,9 +278,9 @@ public class CuratorInventoryManager<ContainerClass, InventoryClass>
case INITIALIZED: case INITIALIZED:
synchronized (lock) { synchronized (lock) {
// must await initialized of all containerholders // must await initialized of all containerholders
for(ContainerHolder holder : containers.values()) { for (ContainerHolder holder : containers.values()) {
synchronized (holder) { synchronized (holder) {
if(!holder.initialized) { if (!holder.initialized) {
uninitializedInventory.add(holder); uninitializedInventory.add(holder);
} }
} }
@ -300,12 +302,12 @@ public class CuratorInventoryManager<ContainerClass, InventoryClass>
private void maybeDoneInitializing() private void maybeDoneInitializing()
{ {
if(doneInitializing) { if (doneInitializing) {
return; return;
} }
// only fire if we are done initializing the parent PathChildrenCache // only fire if we are done initializing the parent PathChildrenCache
if(containersInitialized && uninitializedInventory.isEmpty()) { if (containersInitialized && uninitializedInventory.isEmpty()) {
doneInitializing = true; doneInitializing = true;
strategy.inventoryInitialized(); strategy.inventoryInitialized();
} }
@ -336,6 +338,7 @@ public class CuratorInventoryManager<ContainerClass, InventoryClass>
case CHILD_ADDED: { case CHILD_ADDED: {
final ChildData child = event.getData(); final ChildData child = event.getData();
final String inventoryKey = ZKPaths.getNodeFromPath(child.getPath()); final String inventoryKey = ZKPaths.getNodeFromPath(child.getPath());
log.info("CHILD_ADDED[%s] with version[%s]", child.getPath(), event.getData().getStat().getVersion());
final InventoryClass addedInventory = strategy.deserializeInventory(child.getData()); final InventoryClass addedInventory = strategy.deserializeInventory(child.getData());
@ -348,6 +351,7 @@ public class CuratorInventoryManager<ContainerClass, InventoryClass>
case CHILD_UPDATED: { case CHILD_UPDATED: {
final ChildData child = event.getData(); final ChildData child = event.getData();
final String inventoryKey = ZKPaths.getNodeFromPath(child.getPath()); final String inventoryKey = ZKPaths.getNodeFromPath(child.getPath());
log.info("CHILD_UPDATED[%s] with version[%s]", child.getPath(), event.getData().getStat().getVersion());
final InventoryClass updatedInventory = strategy.deserializeInventory(child.getData()); final InventoryClass updatedInventory = strategy.deserializeInventory(child.getData());
@ -361,6 +365,7 @@ public class CuratorInventoryManager<ContainerClass, InventoryClass>
case CHILD_REMOVED: { case CHILD_REMOVED: {
final ChildData child = event.getData(); final ChildData child = event.getData();
final String inventoryKey = ZKPaths.getNodeFromPath(child.getPath()); final String inventoryKey = ZKPaths.getNodeFromPath(child.getPath());
log.info("CHILD_REMOVED[%s] with version[%s]", child.getPath(), event.getData().getStat().getVersion());
synchronized (holder) { synchronized (holder) {
holder.setContainer(strategy.removeInventory(holder.getContainer(), inventoryKey)); holder.setContainer(strategy.removeInventory(holder.getContainer(), inventoryKey));

View File

@ -121,6 +121,7 @@ public class BatchDataSegmentAnnouncer extends AbstractDataSegmentAnnouncer
{ {
final SegmentZNode segmentZNode = segmentLookup.remove(segment); final SegmentZNode segmentZNode = segmentLookup.remove(segment);
if (segmentZNode == null) { if (segmentZNode == null) {
log.warn("No path to unannounce segment[%s]", segment.getIdentifier());
return; return;
} }