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

Implements packed data directory for faster loading times

This commit is contained in:
2011-12-27 17:28:48 -02:00
parent 92c72ff155
commit 92962241c3
13 changed files with 183 additions and 73 deletions

View File

@@ -0,0 +1,92 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="configuration configuration.xsd"
xsi:noNamespaceSchemaLocation="configuration">
<!-- TODO -->
<general>
<!-- TODO -->
<rates>
<!-- TODO -->
<experience>1.0</experience>
<!-- TODO -->
<sp>1.0</sp>
</rates>
</general>
<!-- Services configuration section -->
<services>
<!-- Parameters in this section are used by DatabaseService. If you are
not sure on the usage of any parameter, read the "Configuration" section
in wiki article about DatabaseService. -->
<database>
<!-- Whether or not the service should try to update and create missing
tables at startup. This should be disabled after the first server start as
it could cause data corruption. -->
<automaticSchemaUpdate>true</automaticSchemaUpdate>
<!-- Configures OrientDB engine - plug-and-play -->
<orientdb>
<!-- The OrientDB storage location -->
<url>local:data/database</url>
<!-- The OrientDB username (local storage must use "admin") -->
<username>admin</username>
<!-- The OrientDB password (local storage must use "admin") -->
<password>admin</password>
</orientdb>
<!-- Configures JDBC engine - requires database server configuration -->
<jdbc>
<!-- Defines the connection URL used by JDBC to connect to the database. -->
<url>jdbc:mysql://localhost/l2jserver2</url>
<!-- The engine used to connect to the database. -->
<engine>com.l2jserver.service.database.sql.MySQLDatabaseEngine
</engine>
<!-- The username used to login into the database. NOTE: Try not use
"root" in production servers for security reasons. -->
<username>l2j</username>
<!-- The password used to login into the database. -->
<password>changeme</password>
</jdbc>
<connections>
<!-- The maximum number of active connections -->
<active-maximum>20</active-maximum>
<!-- The maximum number of idle connections -->
<idle-maximum>20</idle-maximum>
<!-- The minimum number of idle connections -->
<idle-minimum>5</idle-minimum>
</connections>
</database>
<!-- Parameters in this section are used by NetworkService. If you are
not sure on the usage of any parameter, read the "Configuration" section
in wiki article about NetworkService. -->
<network>
<!-- The address and port in which the server will listen to -->
<listen>0.0.0.0:7777</listen>
</network>
<!-- Parameters in this section are used by VFSService. If you are not
sure on the usage of any parameter, read the "Configuration" section in wiki
article about VFSService. -->
<vfs>
<!-- The root of the filesystem -->
<root></root>
<!-- The data folder. Relative to the root. Can be a ZIP file. -->
<data>data/</data>
</vfs>
<!-- Parameters in this section are used by VFSService. If you are not
sure on the usage of any parameter, read the "Configuration" section in wiki
article about VFSService. -->
<template>
<!-- The directory in which templates are stored. Relative to "vfs.data" -->
<directory>template/</directory>
</template>
</services>
<!-- /Services configuration section -->
</configuration>

View File

@@ -77,15 +77,15 @@
<root></root> <root></root>
<!-- The data folder. Relative to the root. Can be a ZIP file. --> <!-- The data folder. Relative to the root. Can be a ZIP file. -->
<data>./data</data> <data>data/</data>
</vfs> </vfs>
<!-- Parameters in this section are used by VFSService. If you are not <!-- Parameters in this section are used by VFSService. If you are not
sure on the usage of any parameter, read the "Configuration" section in wiki sure on the usage of any parameter, read the "Configuration" section in wiki
article about VFSService. --> article about VFSService. -->
<template> <template>
<!-- The directory in which templates are stored --> <!-- The directory in which templates are stored. Relative to "vfs.data" -->
<directory>data/template</directory> <directory>template/</directory>
</template> </template>
</services> </services>
<!-- /Services configuration section --> <!-- /Services configuration section -->

View File

@@ -73,15 +73,19 @@
sure on the usage of any parameter, read the "Configuration" section in wiki sure on the usage of any parameter, read the "Configuration" section in wiki
article about VFSService. --> article about VFSService. -->
<vfs> <vfs>
<!-- The root of the filesystem -->
<root></root> <root></root>
<!-- The data folder. Relative to the root. Can be a ZIP file. -->
<data>data.zip</data>
</vfs> </vfs>
<!-- Parameters in this section are used by VFSService. If you are not <!-- Parameters in this section are used by VFSService. If you are not
sure on the usage of any parameter, read the "Configuration" section in wiki sure on the usage of any parameter, read the "Configuration" section in wiki
article about VFSService. --> article about VFSService. -->
<template> <template>
<!-- The directory in which templates are stored --> <!-- The directory in which templates are stored. Relative to "vfs.data" -->
<directory>data/template</directory> <directory>template/</directory>
</template> </template>
</services> </services>
<!-- /Services configuration section --> <!-- /Services configuration section -->

View File

@@ -20,6 +20,7 @@
<artifactId>maven-assembly-plugin</artifactId> <artifactId>maven-assembly-plugin</artifactId>
<configuration> <configuration>
<descriptors> <descriptors>
<descriptor>src/main/assembly/distribution-data.xml</descriptor>
<descriptor>src/main/assembly/distribution-mysql5-bin.xml</descriptor> <descriptor>src/main/assembly/distribution-mysql5-bin.xml</descriptor>
<descriptor>src/main/assembly/distribution-orientdb-bin.xml</descriptor> <descriptor>src/main/assembly/distribution-orientdb-bin.xml</descriptor>
<descriptor>src/main/assembly/distribution-h2-bin.xml</descriptor> <descriptor>src/main/assembly/distribution-h2-bin.xml</descriptor>
@@ -28,6 +29,30 @@
</descriptors> </descriptors>
</configuration> </configuration>
</plugin> </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<files>${project.artifactId}</files>
<classifiers>mysql5-bin</classifiers>
<types>zip</types>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>libs/</classpathPrefix>
<mainClass>com.l2jserver.L2JGameServerMain</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins> </plugins>
</build> </build>

View File

@@ -8,19 +8,6 @@
</formats> </formats>
<baseDirectory></baseDirectory> <baseDirectory></baseDirectory>
<fileSets> <fileSets>
<fileSet>
<directory>${project.basedir}</directory>
<outputDirectory>/</outputDirectory>
<includes>
<include>data/**</include>
</includes>
<excludes>
<exclude>.gitignore</exclude>
<exclude>data/cache/**</exclude>
<exclude>data/pathing.db</exclude>
<exclude>data/database/**</exclude>
</excludes>
</fileSet>
<fileSet> <fileSet>
<directory>${project.basedir}/distribution/global</directory> <directory>${project.basedir}/distribution/global</directory>
<outputDirectory>/</outputDirectory> <outputDirectory>/</outputDirectory>
@@ -33,6 +20,11 @@
<destName>l2jserver2.jar</destName> <destName>l2jserver2.jar</destName>
<fileMode>0755</fileMode> <fileMode>0755</fileMode>
</file> </file>
<file>
<source>${project.build.directory}/${project.artifactId}-${project.version}-data.zip</source>
<outputDirectory>/</outputDirectory>
<destName>data.zip</destName>
</file>
</files> </files>
<dependencySets> <dependencySets>
<dependencySet> <dependencySet>

View File

@@ -8,19 +8,6 @@
</formats> </formats>
<baseDirectory></baseDirectory> <baseDirectory></baseDirectory>
<fileSets> <fileSets>
<fileSet>
<directory>${project.basedir}</directory>
<outputDirectory>/</outputDirectory>
<includes>
<include>data/**</include>
</includes>
<excludes>
<exclude>.gitignore</exclude>
<exclude>data/cache/**</exclude>
<exclude>data/pathing.db</exclude>
<exclude>data/database/**</exclude>
</excludes>
</fileSet>
<fileSet> <fileSet>
<directory>${project.basedir}/distribution/global</directory> <directory>${project.basedir}/distribution/global</directory>
<outputDirectory>/</outputDirectory> <outputDirectory>/</outputDirectory>
@@ -33,6 +20,11 @@
<destName>l2jserver2.jar</destName> <destName>l2jserver2.jar</destName>
<fileMode>0755</fileMode> <fileMode>0755</fileMode>
</file> </file>
<file>
<source>${project.build.directory}/${project.artifactId}-${project.version}-data.zip</source>
<outputDirectory>/</outputDirectory>
<destName>data.zip</destName>
</file>
</files> </files>
<dependencySets> <dependencySets>
<dependencySet> <dependencySet>

View File

@@ -8,19 +8,6 @@
</formats> </formats>
<baseDirectory></baseDirectory> <baseDirectory></baseDirectory>
<fileSets> <fileSets>
<fileSet>
<directory>${project.basedir}</directory>
<outputDirectory>/</outputDirectory>
<includes>
<include>data/**</include>
</includes>
<excludes>
<exclude>.gitignore</exclude>
<exclude>data/cache/**</exclude>
<exclude>data/pathing.db</exclude>
<exclude>data/database/**</exclude>
</excludes>
</fileSet>
<fileSet> <fileSet>
<directory>${project.basedir}/distribution/global</directory> <directory>${project.basedir}/distribution/global</directory>
<outputDirectory>/</outputDirectory> <outputDirectory>/</outputDirectory>
@@ -33,6 +20,11 @@
<destName>l2jserver2.jar</destName> <destName>l2jserver2.jar</destName>
<fileMode>0755</fileMode> <fileMode>0755</fileMode>
</file> </file>
<file>
<source>${project.build.directory}/${project.artifactId}-${project.version}-data.zip</source>
<outputDirectory>/</outputDirectory>
<destName>data.zip</destName>
</file>
</files> </files>
<dependencySets> <dependencySets>
<dependencySet> <dependencySet>

View File

@@ -8,19 +8,6 @@
</formats> </formats>
<baseDirectory></baseDirectory> <baseDirectory></baseDirectory>
<fileSets> <fileSets>
<fileSet>
<directory>${project.basedir}</directory>
<outputDirectory>/</outputDirectory>
<includes>
<include>data/**</include>
</includes>
<excludes>
<exclude>.gitignore</exclude>
<exclude>data/cache/**</exclude>
<exclude>data/pathing.db</exclude>
<exclude>data/database/**</exclude>
</excludes>
</fileSet>
<fileSet> <fileSet>
<directory>${project.basedir}/distribution/global</directory> <directory>${project.basedir}/distribution/global</directory>
<outputDirectory>/</outputDirectory> <outputDirectory>/</outputDirectory>
@@ -33,6 +20,11 @@
<destName>l2jserver2.jar</destName> <destName>l2jserver2.jar</destName>
<fileMode>0755</fileMode> <fileMode>0755</fileMode>
</file> </file>
<file>
<source>${project.build.directory}/${project.artifactId}-${project.version}-data.zip</source>
<outputDirectory>/</outputDirectory>
<destName>data.zip</destName>
</file>
</files> </files>
<dependencySets> <dependencySets>
<dependencySet> <dependencySet>

View File

@@ -0,0 +1,22 @@
<assembly
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
<id>data</id>
<formats>
<format>zip</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<fileSets>
<fileSet>
<directory>${project.basedir}/data</directory>
<outputDirectory>/</outputDirectory>
<excludes>
<exclude>.gitignore</exclude>
<exclude>cache/**</exclude>
<exclude>pathing.db</exclude>
<exclude>database/**</exclude>
</excludes>
</fileSet>
</fileSets>
</assembly>

View File

@@ -120,7 +120,7 @@ public class GameServerJDBCDatabaseService extends AbstractSQLDatabaseService
updateSchema(QLogChat.logChat); updateSchema(QLogChat.logChat);
if (updateSchema(QNPC.npc)) { if (updateSchema(QNPC.npc)) {
try { try {
importData(vfsService.resolve("data/static/npc.csv"), QNPC.npc); importData(vfsService.resolveDataFile("static/npc.csv"), QNPC.npc);
} catch (IOException e) { } catch (IOException e) {
throw new DatabaseException(e); throw new DatabaseException(e);
} }

View File

@@ -100,7 +100,7 @@ public class GameServerOrientDatabaseService extends
updateSchema(QLogChat.logChat); updateSchema(QLogChat.logChat);
if (updateSchema(QNPC.npc)) { if (updateSchema(QNPC.npc)) {
try { try {
importData(vfsService.resolve("data/static/npc.csv"), QNPC.npc); importData(vfsService.resolveDataFile("static/npc.csv"), QNPC.npc);
} catch (IOException e) { } catch (IOException e) {
throw new DatabaseException(e); throw new DatabaseException(e);
} }

View File

@@ -18,7 +18,6 @@ package com.l2jserver.service.game.template;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.net.URI;
import java.nio.file.FileVisitResult; import java.nio.file.FileVisitResult;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
@@ -143,9 +142,9 @@ public class XMLTemplateService extends AbstractService implements
/** /**
* @return the directory in which templates are stored * @return the directory in which templates are stored
*/ */
@ConfigurationPropertyGetter(defaultValue = "data/template") @ConfigurationPropertyGetter(defaultValue = "template/")
@ConfigurationXPath("/configuration/services/template/directory") @ConfigurationXPath("/configuration/services/template/directory")
URI getTemplateDirectory(); String getTemplateDirectory();
/** /**
* @param file * @param file
@@ -153,7 +152,7 @@ public class XMLTemplateService extends AbstractService implements
*/ */
@ConfigurationPropertySetter @ConfigurationPropertySetter
@ConfigurationXPath("/configuration/services/template/directory") @ConfigurationXPath("/configuration/services/template/directory")
void setTemplateDirectory(URI file); void setTemplateDirectory(String file);
} }
/** /**
@@ -215,8 +214,8 @@ public class XMLTemplateService extends AbstractService implements
unmarshaller.setAdapter(effectIdTemplateAdapter); unmarshaller.setAdapter(effectIdTemplateAdapter);
unmarshaller.setAdapter(teleportationIdTemplateAdapter); unmarshaller.setAdapter(teleportationIdTemplateAdapter);
final Path templatePath = vfsService.resolve(config final Path templatePath = vfsService.resolveDataFile(config
.getTemplateDirectory().toString()); .getTemplateDirectory());
log.info("Scanning {} for XML templates", templatePath); log.info("Scanning {} for XML templates", templatePath);

16
pom.xml
View File

@@ -25,16 +25,16 @@
<uniqueVersion>false</uniqueVersion> <uniqueVersion>false</uniqueVersion>
<id>l2jserver2-repository</id> <id>l2jserver2-repository</id>
<name>L2JServer 2 Maven Repository</name> <name>L2JServer 2 Maven Repository</name>
<url>scp://l2jserver2@l2jserver2.com/home/l2jserver2/maven.l2jserver2.com</url> <url>file://C:\Users\Rogiel\Documents\Test\repo</url>
<layout>default</layout> <layout>default</layout>
</repository> </repository>
<snapshotRepository> <!-- <snapshotRepository> -->
<uniqueVersion>true</uniqueVersion> <!-- <uniqueVersion>true</uniqueVersion> -->
<id>l2jserver2-repository-snapshot</id> <!-- <id>l2jserver2-repository-snapshot</id> -->
<name>L2JServer 2 Maven Repository</name> <!-- <name>L2JServer 2 Maven Repository</name> -->
<url>scp://l2jserver2@l2jserver2.com/home/l2jserver2/snapshot.l2jserver2.com</url> <!-- <url>scp://l2jserver2@l2jserver2.com/home/l2jserver2/snapshot.l2jserver2.com</url> -->
<layout>default</layout> <!-- <layout>default</layout> -->
</snapshotRepository> <!-- </snapshotRepository> -->
<site> <site>
<id>l2jserver2-site</id> <id>l2jserver2-site</id>
<name>l2jserver2</name> <name>l2jserver2</name>