mirror of
https://github.com/ProjectSWGCore/NGECore2.git
synced 2026-10-13 03:13:26 -04:00
Fixed database access problems in terrainservice
Killed multi-threaded planet buildout loading because it caused some objects not being loaded due to concurrency problems in the database ORM binder. Sleepycat runs better when accessed with a single thread. Fixed stream buffer overload error resulting in illegalstateexception in playerservice check method.
This commit is contained in:
@@ -28,6 +28,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.Vector;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.Executors;
|
||||
@@ -38,10 +39,12 @@ import java.util.function.Predicate;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
|
||||
|
||||
import org.apache.mina.core.buffer.IoBuffer;
|
||||
import org.apache.mina.core.session.IoSession;
|
||||
|
||||
|
||||
|
||||
import protocol.swg.CharacterSheetResponseMessage;
|
||||
import protocol.swg.ClientIdMsg;
|
||||
import protocol.swg.ClientMfdStatusUpdateMessage;
|
||||
@@ -279,7 +282,16 @@ public class PlayerService implements INetworkDispatch {
|
||||
return;
|
||||
}
|
||||
|
||||
long[] ids = creature.getAwareObjects().stream().mapToLong(SWGObject::getObjectID).toArray();
|
||||
//long[] ids = creature.getAwareObjects().stream().mapToLong(SWGObject::getObjectID).toArray();
|
||||
// causes java.lang.IllegalStateException: Accept exceeded fixed size of 1336
|
||||
|
||||
Set<SWGObject> awareObjects = creature.getAwareObjects();
|
||||
List<Long> idList = new ArrayList<Long>();
|
||||
for (SWGObject ob : awareObjects) {
|
||||
idList.add(ob.getObjectID());
|
||||
}
|
||||
|
||||
Long[] ids = idList.toArray(new Long[idList.size()]);
|
||||
for(int i = 0; i < ids.length; i++) {
|
||||
for(int j = 0; j < ids.length; j++) {
|
||||
if(ids[i] == ids[j] && i != j)
|
||||
|
||||
@@ -198,11 +198,72 @@ public class TerrainService {
|
||||
loadClientRegions(planet);
|
||||
}
|
||||
|
||||
|
||||
public void loadSnapShotObjects() {
|
||||
|
||||
Map<Planet, Thread> threadMap = new HashMap<Planet, Thread>();
|
||||
|
||||
for(final Planet planet : planets) {
|
||||
|
||||
if(planet.getSnapshotVisitor() != null) {
|
||||
|
||||
Config options = core.getOptions();
|
||||
|
||||
if (options != null && options.getInt("LOAD.SNAPSHOT_OBJECTS") > 0) {
|
||||
if (!core.getExcludedDevelopers().contains(System.getProperty("user.name"))){
|
||||
try {
|
||||
core.objectService.loadSnapshotObjects(planet);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (options != null && options.getInt("LOAD.BUILDOUT_OBJECTS") > 0) {
|
||||
if (!core.getExcludedDevelopers().contains(System.getProperty("user.name"))){
|
||||
if (! options.keyExists("LOAD.BUILDOUT_ONLY_FOR")){
|
||||
try {
|
||||
System.out.println("Loading buildout objects for: " + planet.getName());
|
||||
core.objectService.loadBuildoutObjects(planet);
|
||||
System.out.println("Finished loading buildout objects for: " + planet.getName());
|
||||
} catch (InstantiationException | IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
if (planet.getName().trim().equals(options.getString("LOAD.BUILDOUT_ONLY_FOR").trim())){
|
||||
try {
|
||||
System.out.println("Loading buildout objects for: " + planet.getName());
|
||||
core.objectService.loadBuildoutObjects(planet);
|
||||
System.out.println("Finished loading buildout objects for " + planet.getName());
|
||||
} catch (InstantiationException | IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// // wait for threads to finish loading
|
||||
// for(Planet planet : planets) {
|
||||
// try {
|
||||
// if(threadMap.get(planet) != null)
|
||||
// threadMap.get(planet).join();
|
||||
// } catch (InterruptedException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void loadSnapShotObjectsOLD() {
|
||||
// Unwise to allow concurrent access to a single Sleepycat odb for 11 threads!
|
||||
// Several objects didn't get loaded due to access restrictions
|
||||
Map<Planet, Thread> threadMap = new HashMap<Planet, Thread>();
|
||||
|
||||
for(final Planet planet : planets) {
|
||||
|
||||
if(planet.getSnapshotVisitor() != null) {
|
||||
|
||||
@@ -1753,9 +1753,9 @@ public class ObjectService implements INetworkDispatch {
|
||||
}
|
||||
} else {/*System.out.println("Cellist null");*/}
|
||||
|
||||
|
||||
it.remove();
|
||||
}
|
||||
it.remove();
|
||||
|
||||
}
|
||||
|
||||
private void finalizeBuildings(){
|
||||
|
||||
Reference in New Issue
Block a user