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

Implements better logging while loading ID cache

This commit is contained in:
2011-12-26 15:16:39 -02:00
parent c62d9c86ec
commit b562920831
2 changed files with 24 additions and 8 deletions

View File

@@ -205,5 +205,17 @@ public abstract class AbstractDAO<T extends Model<?>, I extends ID<?>>
return database; return database;
} }
/**
* Wraps the {@link Model}<?> array into an more specific array
*
* @param objects
* the arrays of objects to be "casted"
* @return the wrapped array
*/
protected abstract T[] wrap(Model<?>... objects); protected abstract T[] wrap(Model<?>... objects);
@Override
public String toString() {
return this.getClass().getSimpleName();
}
} }

View File

@@ -35,6 +35,7 @@ import com.l2jserver.service.ServiceStartException;
import com.l2jserver.service.ServiceStopException; import com.l2jserver.service.ServiceStopException;
import com.l2jserver.service.cache.Cache; import com.l2jserver.service.cache.Cache;
import com.l2jserver.service.cache.CacheService; import com.l2jserver.service.cache.CacheService;
import com.l2jserver.service.database.DataAccessObject;
import com.l2jserver.service.database.DatabaseService; import com.l2jserver.service.database.DatabaseService;
/** /**
@@ -118,9 +119,9 @@ public class CachedWorldIDService extends AbstractService implements
public void load() { public void load() {
log.debug("Loading IDs from database"); log.debug("Loading IDs from database");
load(characterDao.selectIDs()); load(characterDao);
load(itemDao.selectIDs()); load(itemDao);
load(npcDao.selectIDs()); load(npcDao);
loaded = true; loaded = true;
} }
@@ -134,12 +135,15 @@ public class CachedWorldIDService extends AbstractService implements
/** /**
* Load the pre-existing ids * Load the pre-existing ids
* *
* @param ids * @param dao
* an collection of ids * the {@link DataAccessObject} that gives access to the IDs
*/ */
private void load(Collection<? extends ObjectID<?>> ids) { private void load(DataAccessObject<?, ? extends ObjectID<?>> dao) {
Preconditions.checkNotNull(ids, "ids"); Preconditions.checkNotNull(dao, "dao");
log.info("Loading {} IDs", ids.size());
final Collection<? extends ObjectID<?>> ids = dao.selectIDs();
log.info("Loaded {} IDs from {}", ids.size(), dao);
for (final ObjectID<?> id : ids) { for (final ObjectID<?> id : ids) {
log.debug("Loading {}", id); log.debug("Loading {}", id);
allocator.allocate(id.getID()); allocator.allocate(id.getID());