Importing SVN archives - Trunk
This commit is contained in:
parent
fc4c6bd340
commit
ff53af6668
507 changed files with 8866 additions and 2450 deletions
legacyworlds-server/legacyworlds-server-beans/legacyworlds-server-beans-system
pom.xml
src/main/java/com/deepclone/lw/beans/sys
|
@ -4,12 +4,12 @@
|
|||
<parent>
|
||||
<artifactId>legacyworlds-server-beans</artifactId>
|
||||
<groupId>com.deepclone.lw</groupId>
|
||||
<version>5.99.1</version>
|
||||
<version>5.99.2</version>
|
||||
</parent>
|
||||
|
||||
<groupId>com.deepclone.lw</groupId>
|
||||
<artifactId>legacyworlds-server-beans-system</artifactId>
|
||||
<version>5.99.1</version>
|
||||
<version>5.99.2</version>
|
||||
<name>Legacy Worlds system management</name>
|
||||
<description>This module regroups system management beans such as the constants manager.</description>
|
||||
</project>
|
|
@ -93,7 +93,7 @@ class ConstantsData
|
|||
this.uocConstantNoBounds.addDeclaredParameter( new SqlParameter( "cname" , Types.VARCHAR ) );
|
||||
this.uocConstantNoBounds.addDeclaredParameter( new SqlParameter( "cdesc" , Types.VARCHAR ) );
|
||||
this.uocConstantNoBounds.addDeclaredParameter( new SqlParameter( "catname" , Types.VARCHAR ) );
|
||||
this.uocConstantNoBounds.addDeclaredParameter( new SqlParameter( "value" , Types.REAL ) );
|
||||
this.uocConstantNoBounds.addDeclaredParameter( new SqlParameter( "value" , Types.DOUBLE ) );
|
||||
|
||||
this.uocConstantSingleBound = new SimpleJdbcCall( dataSource );
|
||||
this.uocConstantSingleBound.withCatalogName( "sys" ).withFunctionName( "uoc_constant" );
|
||||
|
@ -101,8 +101,8 @@ class ConstantsData
|
|||
this.uocConstantSingleBound.addDeclaredParameter( new SqlParameter( "cname" , Types.VARCHAR ) );
|
||||
this.uocConstantSingleBound.addDeclaredParameter( new SqlParameter( "cdesc" , Types.VARCHAR ) );
|
||||
this.uocConstantSingleBound.addDeclaredParameter( new SqlParameter( "catname" , Types.VARCHAR ) );
|
||||
this.uocConstantSingleBound.addDeclaredParameter( new SqlParameter( "value" , Types.REAL ) );
|
||||
this.uocConstantSingleBound.addDeclaredParameter( new SqlParameter( "boundary" , Types.REAL ) );
|
||||
this.uocConstantSingleBound.addDeclaredParameter( new SqlParameter( "value" , Types.DOUBLE ) );
|
||||
this.uocConstantSingleBound.addDeclaredParameter( new SqlParameter( "boundary" , Types.DOUBLE ) );
|
||||
this.uocConstantSingleBound.addDeclaredParameter( new SqlParameter( "is_min" , Types.BOOLEAN ) );
|
||||
|
||||
this.uocConstantTwoBounds = new SimpleJdbcCall( dataSource );
|
||||
|
@ -111,13 +111,13 @@ class ConstantsData
|
|||
this.uocConstantTwoBounds.addDeclaredParameter( new SqlParameter( "cname" , Types.VARCHAR ) );
|
||||
this.uocConstantTwoBounds.addDeclaredParameter( new SqlParameter( "cdesc" , Types.VARCHAR ) );
|
||||
this.uocConstantTwoBounds.addDeclaredParameter( new SqlParameter( "catname" , Types.VARCHAR ) );
|
||||
this.uocConstantTwoBounds.addDeclaredParameter( new SqlParameter( "value" , Types.REAL ) );
|
||||
this.uocConstantTwoBounds.addDeclaredParameter( new SqlParameter( "min" , Types.REAL ) );
|
||||
this.uocConstantTwoBounds.addDeclaredParameter( new SqlParameter( "max" , Types.REAL ) );
|
||||
this.uocConstantTwoBounds.addDeclaredParameter( new SqlParameter( "value" , Types.DOUBLE ) );
|
||||
this.uocConstantTwoBounds.addDeclaredParameter( new SqlParameter( "min" , Types.DOUBLE ) );
|
||||
this.uocConstantTwoBounds.addDeclaredParameter( new SqlParameter( "max" , Types.DOUBLE ) );
|
||||
|
||||
this.fSetConstant = new StoredProc( dataSource , "sys" , "set_constant" );
|
||||
this.fSetConstant.addParameter( "cname" , Types.VARCHAR );
|
||||
this.fSetConstant.addParameter( "value" , Types.REAL );
|
||||
this.fSetConstant.addParameter( "value" , Types.DOUBLE );
|
||||
this.fSetConstant.addParameter( "admin" , Types.INTEGER );
|
||||
|
||||
this.tTemplate = tTemplate;
|
||||
|
@ -149,8 +149,8 @@ class ConstantsData
|
|||
c.setName( rs.getString( "name" ) );
|
||||
c.setDescription( rs.getString( "description" ) );
|
||||
c.setValue( rs.getDouble( "value" ) );
|
||||
c.setMinValue( (Float) rs.getObject( "min" ) );
|
||||
c.setMaxValue( (Float) rs.getObject( "max" ) );
|
||||
c.setMinValue( (Double) rs.getObject( "min" ) );
|
||||
c.setMaxValue( (Double) rs.getObject( "max" ) );
|
||||
return c;
|
||||
}
|
||||
|
||||
|
@ -609,7 +609,7 @@ class ConstantsData
|
|||
@Override
|
||||
protected void doInTransactionWithoutResult( TransactionStatus status )
|
||||
{
|
||||
fSetConstant.execute( name , value.floatValue( ) , admin );
|
||||
fSetConstant.execute( name , value , admin );
|
||||
}
|
||||
|
||||
} );
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
package com.deepclone.lw.beans.sys;
|
||||
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
import java.util.HashSet;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
|
@ -92,9 +93,10 @@ public class ConstantsManagerBean
|
|||
|
||||
/* Documented in ConstantsManager interface */
|
||||
@Override
|
||||
public void registerUser( ConstantsUser user , Set< String > constants )
|
||||
public void registerUser( ConstantsUser user , String... constants )
|
||||
{
|
||||
this.data.registerUser( user , constants );
|
||||
HashSet< String > cSet = new HashSet< String >( Arrays.asList( constants ) );
|
||||
this.data.registerUser( user , cSet );
|
||||
}
|
||||
|
||||
|
||||
|
@ -112,4 +114,5 @@ public class ConstantsManagerBean
|
|||
{
|
||||
return new ConstantsAdministrationImpl( this.data , admin );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -89,7 +89,7 @@ public class ConstantsRegistrarBean
|
|||
// Work and income
|
||||
String[] wcNames = {
|
||||
"population" , "factory" , "strikeEffect" , "wuPerPopUnit" , "destructionRecovery" , "destructionWork" ,
|
||||
"rpPerPopUnit" , "cancelRecovery"
|
||||
"cancelRecovery"
|
||||
};
|
||||
for ( int i = 0 ; i < wcNames.length ; i++ ) {
|
||||
wcNames[ i ] = "game.work." + wcNames[ i ];
|
||||
|
@ -107,10 +107,8 @@ public class ConstantsRegistrarBean
|
|||
defs.add( new ConstantDefinition( wcNames[ 4 ] , cat , cDesc , 0.1 , 0.01 , 0.99 ) );
|
||||
cDesc = "Proportion of a building's construction work units required to destroy it";
|
||||
defs.add( new ConstantDefinition( wcNames[ 5 ] , cat , cDesc , 0.25 , 0.01 , 1.0 ) );
|
||||
cDesc = "Research points per population unit.";
|
||||
defs.add( new ConstantDefinition( wcNames[ 6 ] , cat , cDesc , 0.50 , 0.01 , true ) );
|
||||
cDesc = "Proportion of queue investments that is recovered when flushing the queue.";
|
||||
defs.add( new ConstantDefinition( wcNames[ 7 ] , cat , cDesc , 0.1 , 0.01 , 1.0 ) );
|
||||
defs.add( new ConstantDefinition( wcNames[ 6 ] , cat , cDesc , 0.1 , 0.01 , 1.0 ) );
|
||||
|
||||
// Vacation mode
|
||||
cDesc = "Initial vacation credits.";
|
||||
|
@ -155,7 +153,7 @@ public class ConstantsRegistrarBean
|
|||
// Ticker
|
||||
cDesc = "Interval between ticks with the highest frequency, in milliseconds.";
|
||||
defs.add( new ConstantDefinition( "ticker.interval" , "Ticker" , cDesc , 5000.0 , 1000.0 , true ) );
|
||||
|
||||
|
||||
// Accounts
|
||||
cDesc = "Minimal interval between address change requests (seconds)";
|
||||
defs.add( new ConstantDefinition( "accounts.acrDelay" , "Accounts" , cDesc , 14400.0 , 1.0 , true ) );
|
||||
|
@ -169,32 +167,43 @@ public class ConstantsRegistrarBean
|
|||
defs.add( new ConstantDefinition( "accounts.banDelay" , "Accounts" , cDesc , 178000.0 , 3600.0 , true ) );
|
||||
cDesc = "Delay before a ban request expires (seconds)";
|
||||
defs.add( new ConstantDefinition( "accounts.banExpiration" , "Accounts" , cDesc , oneWeek , 3600.0 , true ) );
|
||||
|
||||
|
||||
// Accounts - warnings
|
||||
cDesc = "Amount of warnings that triggers an automatic ban request.";
|
||||
defs.add( new ConstantDefinition( "accounts.warnings.autoBan" , "Accounts - Warnings" , cDesc , 3.0 , 1.0 , true ) );
|
||||
defs.add( new ConstantDefinition( "accounts.warnings.autoBan" , "Accounts - Warnings" , cDesc , 3.0 , 1.0 ,
|
||||
true ) );
|
||||
cDesc = "Period after a warning is received during which additional warnings will be ignored (seconds).";
|
||||
defs.add( new ConstantDefinition( "accounts.warnings.grace" , "Accounts - Warnings" , cDesc , 7200.0 , 60.0 , true ) );
|
||||
defs.add( new ConstantDefinition( "accounts.warnings.grace" , "Accounts - Warnings" , cDesc , 7200.0 , 60.0 ,
|
||||
true ) );
|
||||
cDesc = "Time after which warnings are decreased (expressed in units as defined by a.w.expiration.units).";
|
||||
defs.add( new ConstantDefinition( "accounts.warnings.expiration" , "Accounts - Warnings" , cDesc , 60.0 , 1.0 , true ) );
|
||||
defs.add( new ConstantDefinition( "accounts.warnings.expiration" , "Accounts - Warnings" , cDesc , 60.0 , 1.0 ,
|
||||
true ) );
|
||||
cDesc = "Units used to express warning expiration time (seconds).";
|
||||
defs.add( new ConstantDefinition( "accounts.warnings.expiration.units" , "Accounts - Warnings" , cDesc , 86400.0 , 1.0 , true ) );
|
||||
|
||||
defs.add( new ConstantDefinition( "accounts.warnings.expiration.units" , "Accounts - Warnings" , cDesc ,
|
||||
86400.0 , 1.0 , true ) );
|
||||
|
||||
// Account inactivity
|
||||
cDesc = "Time units (seconds)";
|
||||
defs.add( new ConstantDefinition( "accounts.inactivity.units" , "Accounts - Inactivity" , cDesc , oneWeek , 3600.0 , true ) );
|
||||
defs.add( new ConstantDefinition( "accounts.inactivity.units" , "Accounts - Inactivity" , cDesc , oneWeek ,
|
||||
3600.0 , true ) );
|
||||
cDesc = "Time after which the inactivity warning e-mail is to be sent, expressed using units defined by a.i.units.";
|
||||
defs.add( new ConstantDefinition( "accounts.inactivity.warningMail" , "Accounts - Inactivity" , cDesc , 3.0 , 1.0 , true ) );
|
||||
defs.add( new ConstantDefinition( "accounts.inactivity.warningMail" , "Accounts - Inactivity" , cDesc , 3.0 ,
|
||||
1.0 , true ) );
|
||||
cDesc = "Time between the inactivity warning e-mail and actual account deletion, expressed using units defined by a.i.units.";
|
||||
defs.add( new ConstantDefinition( "accounts.inactivity.deletion" , "Accounts - Inactivity" , cDesc , 1.0 , 1.0 , true ) );
|
||||
|
||||
defs.add( new ConstantDefinition( "accounts.inactivity.deletion" , "Accounts - Inactivity" , cDesc , 1.0 , 1.0 ,
|
||||
true ) );
|
||||
|
||||
// Bug reports
|
||||
cDesc = "Amount of credits granted for low priority bug reports.";
|
||||
defs.add( new ConstantDefinition( "bugtracker.lowCredits" , "Bug tracking system" , cDesc , 1.0 , 1.0 , true ) );
|
||||
cDesc = "Amount of credits granted for normal bug reports.";
|
||||
defs.add( new ConstantDefinition( "bugtracker.mediumCredits" , "Bug tracking system" , cDesc , 2.0 , 1.0 , true ) );
|
||||
defs
|
||||
.add( new ConstantDefinition( "bugtracker.mediumCredits" , "Bug tracking system" , cDesc , 2.0 , 1.0 ,
|
||||
true ) );
|
||||
cDesc = "Amount of credits granted for critical bug reports.";
|
||||
defs.add( new ConstantDefinition( "bugtracker.highCredits" , "Bug tracking system" , cDesc , 3.0 , 1.0 , true ) );
|
||||
defs
|
||||
.add( new ConstantDefinition( "bugtracker.highCredits" , "Bug tracking system" , cDesc , 3.0 , 1.0 ,
|
||||
true ) );
|
||||
|
||||
cm.registerConstants( defs );
|
||||
}
|
||||
|
|
|
@ -10,8 +10,6 @@ import javax.sql.DataSource;
|
|||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.jdbc.core.RowMapper;
|
||||
import org.springframework.jdbc.core.SqlOutParameter;
|
||||
import org.springframework.jdbc.core.simple.SimpleJdbcCall;
|
||||
import org.springframework.jdbc.core.simple.SimpleJdbcTemplate;
|
||||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
import org.springframework.transaction.TransactionStatus;
|
||||
|
@ -44,13 +42,14 @@ public class SystemStatusBean
|
|||
/** Current maintenance mode record */
|
||||
private MaintenanceData maintenance = null;
|
||||
|
||||
private SimpleJdbcCall doStartTick;
|
||||
private SimpleJdbcCall doCheckTick;
|
||||
|
||||
private StoredProc fEnterMaintenanceMode;
|
||||
private StoredProc fExtendMaintenanceMode;
|
||||
private StoredProc fExitMaintenanceMode;
|
||||
|
||||
private StoredProc fCheckTick;
|
||||
private StoredProc fStartTick;
|
||||
private StoredProc fEndTick;
|
||||
|
||||
|
||||
@Autowired( required = true )
|
||||
public void setDataSource( DataSource dataSource )
|
||||
|
@ -72,16 +71,14 @@ public class SystemStatusBean
|
|||
this.fExitMaintenanceMode.addParameter( "admin_id" , Types.INTEGER );
|
||||
this.fExitMaintenanceMode.addOutput( "success" , Types.BOOLEAN );
|
||||
|
||||
this.doStartTick = new SimpleJdbcCall( dataSource );
|
||||
this.doStartTick.withCatalogName( "sys" ).withFunctionName( "start_tick" );
|
||||
this.doStartTick.withoutProcedureColumnMetaDataAccess( );
|
||||
this.doStartTick.addDeclaredParameter( new SqlOutParameter( "tick_id" , Types.BIGINT ) );
|
||||
this.fCheckTick = new StoredProc( dataSource , "sys" , "check_stuck_tick" );
|
||||
this.fCheckTick.addOutput( "tick_id" , Types.BIGINT );
|
||||
|
||||
this.doCheckTick = new SimpleJdbcCall( dataSource );
|
||||
this.doCheckTick.withCatalogName( "sys" ).withFunctionName( "check_stuck_tick" );
|
||||
this.doCheckTick.withoutProcedureColumnMetaDataAccess( );
|
||||
this.doCheckTick.addDeclaredParameter( new SqlOutParameter( "tick_id" , Types.BIGINT ) );
|
||||
this.fStartTick = new StoredProc( dataSource , "sys" , "start_tick" );
|
||||
this.fStartTick.addOutput( "tick_id" , Types.BIGINT );
|
||||
|
||||
this.fEndTick = new StoredProc( dataSource , "sys" , "end_tick" );
|
||||
this.fEndTick.addParameter( "tick_id" , Types.BIGINT );
|
||||
}
|
||||
|
||||
|
||||
|
@ -246,6 +243,31 @@ public class SystemStatusBean
|
|||
}
|
||||
|
||||
|
||||
/* Documented in interface */
|
||||
@Override
|
||||
public Long checkStuckTick( )
|
||||
throws MaintenanceStatusException
|
||||
{
|
||||
Long tid = this.tTemplate.execute( new TransactionCallback< Long >( ) {
|
||||
|
||||
@Override
|
||||
public Long doInTransaction( TransactionStatus status )
|
||||
{
|
||||
Map< String , Object > m = fCheckTick.execute( );
|
||||
loadStatus( );
|
||||
return (Long) m.get( "tick_id" );
|
||||
}
|
||||
|
||||
} );
|
||||
|
||||
if ( tid == null && this.maintenance != null ) {
|
||||
throw new MaintenanceStatusException( this.maintenance );
|
||||
}
|
||||
|
||||
return tid;
|
||||
}
|
||||
|
||||
|
||||
/* Documented in interface */
|
||||
@Override
|
||||
synchronized public long startTick( )
|
||||
|
@ -256,7 +278,7 @@ public class SystemStatusBean
|
|||
@Override
|
||||
public Long doInTransaction( TransactionStatus status )
|
||||
{
|
||||
Map< String , Object > m = doStartTick.execute( );
|
||||
Map< String , Object > m = fStartTick.execute( );
|
||||
loadStatus( );
|
||||
return (Long) m.get( "tick_id" );
|
||||
}
|
||||
|
@ -277,26 +299,28 @@ public class SystemStatusBean
|
|||
|
||||
/* Documented in interface */
|
||||
@Override
|
||||
public Long checkStuckTick( )
|
||||
throws MaintenanceStatusException
|
||||
public void endTick( )
|
||||
throws TickStatusException , MaintenanceStatusException
|
||||
{
|
||||
Long tid = this.tTemplate.execute( new TransactionCallback< Long >( ) {
|
||||
|
||||
@Override
|
||||
public Long doInTransaction( TransactionStatus status )
|
||||
{
|
||||
Map< String , Object > m = doCheckTick.execute( );
|
||||
loadStatus( );
|
||||
return (Long) m.get( "tick_id" );
|
||||
}
|
||||
|
||||
} );
|
||||
|
||||
if ( tid == null && this.maintenance != null ) {
|
||||
if ( this.maintenance != null ) {
|
||||
throw new MaintenanceStatusException( this.maintenance );
|
||||
}
|
||||
|
||||
return tid;
|
||||
final Long tid = this.status.getCurrentTick( );
|
||||
if ( tid == null ) {
|
||||
throw new TickStatusException( );
|
||||
}
|
||||
|
||||
this.tTemplate.execute( new TransactionCallbackWithoutResult( ) {
|
||||
|
||||
@Override
|
||||
protected void doInTransactionWithoutResult( TransactionStatus status )
|
||||
{
|
||||
fEndTick.execute( tid );
|
||||
loadStatus( );
|
||||
}
|
||||
|
||||
} );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
package com.deepclone.lw.beans.sys;
|
||||
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.springframework.beans.factory.DisposableBean;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -101,9 +98,7 @@ public class TickerBean
|
|||
this.mainThread = new TickerThread( this.logger , this.tickerManager );
|
||||
|
||||
// Register thread as a constants user
|
||||
Set< String > use = new HashSet< String >( );
|
||||
use.add( "ticker.interval" );
|
||||
this.constantsManager.registerUser( this.mainThread , use );
|
||||
this.constantsManager.registerUser( this.mainThread , "ticker.interval" );
|
||||
}
|
||||
|
||||
|
||||
|
|
Reference in a new issue