1 4 package com.tc.admin.dso; 5 6 import java.util.Date ; 7 8 import javax.swing.Icon ; 9 10 import com.tc.admin.ConnectionContext; 11 import com.tc.admin.common.XTreeNode; 12 13 import com.tc.objectserver.lockmanager.api.LockMBean; 14 import com.tc.objectserver.lockmanager.api.LockHolder; 15 import com.tc.objectserver.lockmanager.api.ServerLockRequest; 16 import com.tc.objectserver.lockmanager.api.Waiter; 17 18 public class LockTreeNode extends XTreeNode { 19 private XTreeNode m_holders; 20 private XTreeNode m_pendingRequests; 21 private XTreeNode m_pendingUpgrades; 22 private XTreeNode m_waiters; 23 24 public LockTreeNode(ConnectionContext cc, LockMBean lock) { 25 super(lock); 26 27 LockHolder[] holders = lock.getHolders(); 28 if(holders != null && holders.length > 0) { 29 add(m_holders = new XTreeNode("Holders")); 30 addHolders(holders); 31 } 32 33 ServerLockRequest[] pendingRequests = lock.getPendingRequests(); 34 if(pendingRequests != null && pendingRequests.length > 0) { 35 add(m_pendingRequests = new XTreeNode("Pending Requests")); 36 addPendingRequests(pendingRequests); 37 } 38 39 ServerLockRequest[] pendingUpgrades = lock.getPendingUpgrades(); 40 if(pendingUpgrades != null && pendingUpgrades.length > 0) { 41 add(m_pendingUpgrades = new XTreeNode("Pending Upgrades")); 42 addPendingUpgrades(pendingUpgrades); 43 } 44 45 Waiter[] waiters = lock.getWaiters(); 46 if(waiters != null && waiters.length > 0) { 47 add(m_waiters = new XTreeNode("Waiters")); 48 addWaiters(waiters); 49 } 50 } 51 52 public LockMBean getLock() { 53 return (LockMBean)getUserObject(); 54 } 55 56 public Icon getIcon() { 57 return LocksHelper.getHelper().getLockIcon(); 58 } 59 60 public String toString() { 61 return getLock().getLockName(); 62 } 63 64 public void addHolders(LockHolder[] holders) { 65 for(int i = 0; i < holders.length; i++) { 66 m_holders.add(new HolderNode(holders[i])); 67 } 68 } 69 70 class HolderNode extends XTreeNode { 71 private Date acquiredDate; 72 73 HolderNode(LockHolder holder) { 74 super(holder); 75 acquiredDate = new Date (holder.getTimeAcquired()); 76 } 77 78 public LockHolder getHolder() { 79 return (LockHolder)getUserObject(); 80 } 81 82 public String toString() { 83 LockHolder holder = getHolder(); 84 return holder.getChannelID() + "," + holder.getThreadID() + 85 ",level=" + holder.getLockLevel() + ",acquired=" + acquiredDate; 86 } 87 } 88 89 public void addPendingRequests(ServerLockRequest[] requests) { 90 for(int i = 0; i < requests.length; i++) { 91 m_pendingRequests.add(new RequestNode(requests[i])); 92 } 93 } 94 95 public void addPendingUpgrades(ServerLockRequest[] upgrades) { 96 for(int i = 0; i < upgrades.length; i++) { 97 m_pendingUpgrades.add(new RequestNode(upgrades[i])); 98 } 99 } 100 101 class RequestNode extends XTreeNode { 102 private Date requestDate; 103 104 RequestNode(ServerLockRequest request) { 105 super(request); 106 requestDate = new Date (request.getRequestTime()); 107 } 108 109 public ServerLockRequest getRequest() { 110 return (ServerLockRequest)getUserObject(); 111 } 112 113 public String toString() { 114 ServerLockRequest request = getRequest(); 115 return request.getChannelID() + "," + request.getThreadID() + 116 ",level=" + request.getLockLevel() + ",requested=" + requestDate; 117 } 118 } 119 120 public void addWaiters(Waiter[] waiters) { 121 for(int i = 0; i < waiters.length; i++) { 122 m_waiters.add(new WaiterNode(waiters[i])); 123 } 124 } 125 126 class WaiterNode extends XTreeNode { 127 private Date startDate; 128 129 WaiterNode(Waiter waiter) { 130 super(waiter); 131 startDate = new Date (waiter.getStartTime()); 132 } 133 134 public Waiter getWaiter() { 135 return (Waiter)getUserObject(); 136 } 137 138 public String toString() { 139 Waiter waiter = getWaiter(); 140 return waiter.getChannelID() + "," + waiter.getThreadID() + 141 ",invocation=" + waiter.getWaitInvocation() + ",startTime=" + startDate; 142 } 143 } 144 } 145 | Popular Tags |