Skip to content

Commit

Permalink
Merge pull request pentaho#2745 from apratkin/BACKLOG-5920
Browse files Browse the repository at this point in the history
[BACKLOG-5920] - Change Message to the Periodic logger once the compo…
  • Loading branch information
tkafalas committed Dec 23, 2015
2 parents c3f96e6 + 10f5b18 commit 0da2955
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,20 +73,22 @@ public synchronized static void stop() {
public void run() {
setCurrentValues();
while ( !stopFlag ) {
if ( lastMessages != null ) {
//logger.info( "Server State: " + lastServerStatus.name() );
for ( String message : lastMessages ) {
// System.out.println( message );
if ( logger.isInfoEnabled()){
logger.info( message );
} else {
logger.error( message );
}
try {
Thread.sleep( cycleTime );
} catch ( InterruptedException e ) {
// The interrupt will force an immediate recycle. Interrupts occur when the status message is changed
}
logMessages();
try {
Thread.sleep( cycleTime );
} catch ( InterruptedException e ) {
// The interrupt will force an immediate recycle. Interrupts occur when the status message is changed
}
}
}

private void logMessages() {
if ( lastMessages != null ) {
for ( String message : lastMessages ) {
if ( logger.isInfoEnabled() ) {
logger.info( message );
} else {
logger.error( message );
}
}
}
Expand All @@ -113,6 +115,7 @@ public void onStatusChange() {
if ( lastMessages != serverStatusProvider.getStatusMessages()
|| lastServerStatus != serverStatusProvider.getStatus() ) {
setCurrentValues();
logMessages();
if (runThread != null ) {
runThread.interrupt();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,16 +157,25 @@ public void contextInitialized( final ServletContextEvent event ) {
serverStatusProvider.setStatusMessages( new String[] { "Caution, the server is initializing. Do not shut down or restart the server at this time." } );
PeriodicStatusLogger.start();

boolean initOk;
boolean initOk = false;
try {
initOk = PentahoSystem.init( applicationContext );
} finally {
updateStatusMessages( initOk );
PeriodicStatusLogger.stop();
}

this.showInitializationMessage( initOk, fullyQualifiedServerUrl );
}

private void updateStatusMessages( boolean initOk ) {
if ( initOk ) {
serverStatusProvider.setStatusMessages( new String[] { "The system has finished initializing." } );
} else {
serverStatusProvider.setStatusMessages( new String[] { "Warning, one or more errors occurred during the initialization process." } );
}
}

/**
* Provide a simple extension point for someone to be able to override the behavior of the WebApplicationContext. To
* extend or change behavior, you will need to extend WebApplicationContext, and extend SolutionContextListener to
Expand Down

0 comments on commit 0da2955

Please sign in to comment.