1
0
mirror of https://github.com/Rogiel/l2jserver2 synced 2025-12-06 07:32:46 +00:00

Added more debug messages

This commit is contained in:
rogiel
2011-05-07 01:17:04 -03:00
parent 51aea46020
commit d8bb472d57
3 changed files with 18 additions and 22 deletions

View File

@@ -1,16 +0,0 @@
<?xml version='1.0' encoding='UTF-8' ?>
<!-- ~ This file is part of aion-emu. ~ ~ aion-emu is free software: you
can redistribute it and/or modify ~ it under the terms of the GNU General
Public License as published by ~ the Free Software Foundation, either version
3 of the License, or ~ (at your option) any later version. ~ ~ aion-emu is
distributed in the hope that it will be useful, ~ but WITHOUT ANY WARRANTY;
without even the implied warranty of ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the ~ GNU General Public License for more details. ~ ~ You should
have received a copy of the GNU General Public License ~ along with aion-emu.
If not, see <http://www.gnu.org/licenses/>. -->
<scriptlist xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../contexts.xsd">
<scriptinfo root="./data/scripts/system/database" />
</scriptlist>

View File

@@ -5,9 +5,15 @@ import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock; import java.util.concurrent.locks.ReentrantLock;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.l2jserver.util.PrimeFinder; import com.l2jserver.util.PrimeFinder;
public class BitSetIDAllocator implements IDAllocator { public class BitSetIDAllocator implements IDAllocator {
private static final Logger log = LoggerFactory
.getLogger(BitSetIDAllocator.class);
/** /**
* Lock to guarantee synchronization * Lock to guarantee synchronization
*/ */
@@ -32,12 +38,15 @@ public class BitSetIDAllocator implements IDAllocator {
freeIdCount = new AtomicInteger(ALLOCABLE_IDS); freeIdCount = new AtomicInteger(ALLOCABLE_IDS);
nextId = new AtomicInteger(ids.nextClearBit(0)); nextId = new AtomicInteger(ids.nextClearBit(0));
log.info("BitSet IDAllocator initialized. Next available ID is {}",
nextId.get());
} }
@Override @Override
public void allocate(int id) { public void allocate(int id) {
if (ids.get(id - FIRST_ID)) if (ids.get(id - FIRST_ID))
throw new IDAllocatorException("ID not allocated"); throw new IDAllocatorException("ID not allocated");
log.debug("Allocating ID {}", id);
lock.lock(); lock.lock();
try { try {
if (id < FIRST_ID) if (id < FIRST_ID)
@@ -57,6 +66,9 @@ public class BitSetIDAllocator implements IDAllocator {
ids.set(newID); ids.set(newID);
freeIdCount.decrementAndGet(); freeIdCount.decrementAndGet();
if (log.isDebugEnabled())
log.debug("Allocated a new ID {}", newID + FIRST_ID);
int nextFree = ids.nextClearBit(newID); int nextFree = ids.nextClearBit(newID);
if (nextFree < 0) { if (nextFree < 0) {
@@ -66,12 +78,12 @@ public class BitSetIDAllocator implements IDAllocator {
if (ids.size() < ALLOCABLE_IDS) { if (ids.size() < ALLOCABLE_IDS) {
increaseBitSetCapacity(); increaseBitSetCapacity();
} else { } else {
log.error("ID exhaustion");
throw new IDAllocatorException("ID exhaustion"); throw new IDAllocatorException("ID exhaustion");
} }
} }
nextId.set(nextFree); nextId.set(nextFree);
return newID + FIRST_ID; return newID + FIRST_ID;
} finally { } finally {
lock.unlock(); lock.unlock();
@@ -86,6 +98,7 @@ public class BitSetIDAllocator implements IDAllocator {
if (!ids.get(id - FIRST_ID)) if (!ids.get(id - FIRST_ID))
throw new IDAllocatorException("ID not allocated"); throw new IDAllocatorException("ID not allocated");
log.debug("Releasing allocated ID {}", id);
lock.lock(); lock.lock();
try { try {
ids.clear(id - FIRST_ID); ids.clear(id - FIRST_ID);
@@ -96,6 +109,7 @@ public class BitSetIDAllocator implements IDAllocator {
} }
private void increaseBitSetCapacity() { private void increaseBitSetCapacity() {
log.debug("Increasing BitSet capacity from {}", ids.size());
BitSet newBitSet = new BitSet( BitSet newBitSet = new BitSet(
PrimeFinder.nextPrime((getAllocatedIDs() * 11) / 10)); PrimeFinder.nextPrime((getAllocatedIDs() * 11) / 10));
newBitSet.or(ids); newBitSet.or(ids);

View File

@@ -2,6 +2,8 @@ package com.l2jserver.model.world.player;
import com.l2jserver.model.world.actor.ActorEvent; import com.l2jserver.model.world.actor.ActorEvent;
import com.l2jserver.model.world.actor.ActorListener; import com.l2jserver.model.world.actor.ActorListener;
import com.l2jserver.model.world.event.WorldEvent;
import com.l2jserver.model.world.event.WorldListener;
public abstract class PlayerListener implements ActorListener { public abstract class PlayerListener implements ActorListener {
@Override @Override
@@ -12,11 +14,7 @@ public abstract class PlayerListener implements ActorListener {
} }
/** /**
* Once the event call is dispatched, the listener <b>WILL NOT</b> be * @see WorldListener#dispatch(WorldEvent)
* removed. You must manually remove it from the <tt>event</tt> object.
*
* @param e
* the event
*/ */
protected abstract boolean dispatch(PlayerEvent e); protected abstract boolean dispatch(PlayerEvent e);
} }