Game updates improvements

* Added a set of tables which define game updates and their targets.
These definitions replace the old enumerate type. Added a set of
triggers which automatically create specific update tables, insert
missing entries, etc... when game update types are being manipulated.

* Removed manual insertion of game updates from empire creation
function and universe generator.

* Added registration of core update targets (i.e. planets and empires),
updated all existing game update processing functions and added type
registrations

* Created Maven project for game updates control components, moved
existing components from the -simple project, rewritten most of what
they contained, added new components for server-side update batch
processing
This commit is contained in:
Emmanuel BENOîT 2012-02-03 16:25:03 +01:00
parent ba6a1e2b41
commit 56eddcc4f0
93 changed files with 4004 additions and 578 deletions
legacyworlds-server-interfaces/src/main/java/com/deepclone/lw/interfaces/game

View file

@ -1,7 +0,0 @@
package com.deepclone.lw.interfaces.game;
public interface UpdatesDAO
{
public boolean processUpdates( long tickId );
}

View file

@ -0,0 +1,75 @@
package com.deepclone.lw.interfaces.game.updates;
/**
* Game update processor
*
* <p>
* The game update processor allows game update cycles to be executed. It also provides the ability
* to terminated an existing update cycle.
*
* <p>
* The game update processor includes a locking mechanism which can be used to prevent two
* components (for example the game update ticker task and the administration interface) from
* executing game updates simultaneously.
*
* @author <a href="mailto:tseeker@legacyworlds.com">E. Benoît</a>
*/
public interface GameUpdateProcessor
{
/**
* Try locking the game update processor
*
* <p>
* Test and set the processor's lock. This lock is not re-entrant and should only be called once
* per locking thread.
*
* @return <code>true</code> if the lock was acquired, <code>false</code> it some other
* component had already locked the processor.
*/
public boolean tryLock( );
/**
* Unlock the game update processor
*
* <p>
* Reset the processor's lock. This method should be called from the thread which actually
* locked the processor in the first place, although that will not be checked.
*
* @throws IllegalStateException
* if the processor is not locked.
*/
public void unlock( )
throws IllegalStateException;
/**
* End the previous update cycle
*
* <p>
* Check if an update cycle had already started. If such is the case, execute all remaining
* update batches.
*
* @return <code>true</code> if an update cycle was processed or if the system is under
* maintenance, <code>false</code> otherwise.
*/
public boolean endPreviousCycle( );
/**
* Execute a full update cycle
*
* <p>
* Check for an update cycle that was already started. If one exists, finish it. Otherwise,
* start a new cycle and execute all batches in separate transactions.
*
* <p>
* Update cycles will not be processed if the system is under maintenance. In addition, if the
* system enters maintenance mode while updates are being processed, the processing will stop
* after the current batch.
*/
public void executeUpdateCycle( );
}

View file

@ -0,0 +1,42 @@
package com.deepclone.lw.interfaces.game.updates;
/**
* Update batch processor interface
*
* <p>
* This interface must be implemented by all components which provide support for server-side game
* updates processing. The components will be gathered automatically when the server initialises.
*
* @author <a href="mailto:tseeker@legacyworlds.com">E. Benoît</a>
*
*/
public interface UpdateBatchProcessor
{
/**
* Obtain the component's supported update type
*
* <p>
* This method must be implemented to return a string which corresponds to the name of the
* update type in the database's <code>sys.update_types</code> registry table.
*
* @return the update type supported by the component
*/
public String getUpdateType( );
/**
* Process a batch of updates
*
* <p>
* This method is called by the main update processor in the transaction during which items from
* the batch will have been marked for processing. It should process the update, but it must not
* modify the update rows in the <code>sys.updates</code> table.
*
* @param tickId
* the identifier of the current game update cycle
*/
public void processBatch( long tickId );
}

View file

@ -0,0 +1,34 @@
package com.deepclone.lw.interfaces.game.updates;
import com.deepclone.lw.sqld.sys.GameUpdateResult;
/**
* Game updates data access
*
* <p>
* This interface allows access to the data and stored procedure which constitute the game update
* sub-system.
*
* @author <a href="mailto:tseeker@legacyworlds.com">E. Benoît</a>
*/
public interface UpdatesDAO
{
/**
* Run a batch of game updates
*
* <p>
* Execute a batch of game updates for the current game update cycle. The value returned by this
* method determines whether the caller should call the method again, and if so whether it needs
* to do some in-server processing.
*
* @param tickId
* the identifier of the current game update cycle
*
* @return the results of the game update processor
*/
public GameUpdateResult processUpdates( long tickId );
}