/** * Pull a slot out of a preexisting shared memory segment. * * Must be called with the manager lock held. * * @param blockId The blockId to put inside the Slot object. * * @return null if none of our shared memory segments contain a * free slot; the slot object otherwise. */ private Slot allocSlotFromExistingShm(ExtendedBlockId blockId) { if (notFull.isEmpty()) { return null; } Entry<ShmId, DfsClientShm> entry = notFull.firstEntry(); DfsClientShm shm = entry.getValue(); ShmId shmId = shm.getShmId(); Slot slot = shm.allocAndRegisterSlot(blockId); if (shm.isFull()) { LOG.trace("{}: pulled the last slot {} out of {}", this, slot.getSlotIdx(), shm); DfsClientShm removedShm = notFull.remove(shmId); Preconditions.checkState(removedShm == shm); full.put(shmId, shm); } else { LOG.trace("{}: pulled slot {} out of {}", this, slot.getSlotIdx(), shm); } return slot; }
if (shm.isFull()) { if (LOG.isTraceEnabled()) { LOG.trace(this + ": pulled the last slot " + slot.getSlotIdx() + " out of " + shm); } else { if (LOG.isTraceEnabled()) { LOG.trace(this + ": pulled slot " + slot.getSlotIdx() + " out of " + shm);
shm.unregisterSlot(slot.getSlotIdx()); if (shm.isDisconnected()) {
shm.unregisterSlot(slot.getSlotIdx()); if (shm.isDisconnected()) {
Assert.assertEquals(slotIdx++, slot.getSlotIdx()); shm.unregisterSlot(slot.getSlotIdx()); slot.makeInvalid();
shm.unregisterSlot(slot.getSlotIdx()); if (shm.isDisconnected()) {
Assert.assertEquals(slotIdx++, slot.getSlotIdx()); shm.unregisterSlot(slot.getSlotIdx()); slot.makeInvalid();
if (shm.isFull()) { if (LOG.isTraceEnabled()) { LOG.trace(this + ": pulled the last slot " + slot.getSlotIdx() + " out of " + shm); } else { if (LOG.isTraceEnabled()) { LOG.trace(this + ": pulled slot " + slot.getSlotIdx() + " out of " + shm);
@Override public String toString() { return "Slot(slotIdx=" + getSlotIdx() + ", shm=" + getShm() + ")"; } }
/** * Get the SlotId of this slot, containing both shmId and slotIdx. * * @return The SlotId of this slot. */ public SlotId getSlotId() { return new SlotId(getShmId(), getSlotIdx()); }
/** * Get the SlotId of this slot, containing both shmId and slotIdx. * * @return The SlotId of this slot. */ public SlotId getSlotId() { return new SlotId(getShmId(), getSlotIdx()); }
/** * Get the SlotId of this slot, containing both shmId and slotIdx. * * @return The SlotId of this slot. */ public SlotId getSlotId() { return new SlotId(getShmId(), getSlotIdx()); }
@Override public String toString() { return "Slot(slotIdx=" + getSlotIdx() + ", shm=" + getShm() + ")"; } }
@Override public String toString() { return "Slot(slotIdx=" + getSlotIdx() + ", shm=" + getShm() + ")"; } }