{
String msg = localStrings.getString( "admin.server.core.mbean.config.cannot_restart_admin_instance" );
throw new IllegalStateException( msg );
}
*/
final RMIClient rmiClient = AdminChannel.getRMIClient(mInstanceName);
if (rmiClient.getInstanceStatusCode() != Status.kInstanceRunningCode)
{
String msg = localStrings.getString( "admin.server.core.mbean.config.instance_not_running_cannot_restart" );
throw new IllegalStateException( msg );
}
try
{
/* calling restart script */
sLogger.log(Level.INFO, "mbean.restart_instance", mInstanceName);
InstanceDefinition instance = new InstanceDefinition(
mInstanceName,
getHostAndPort().getPort());
ServerManager.instance().restartServerInstance(instance);
/*
* There is certain time lapse between executing the subprocess
* and updating the instance stub file on the disk. The following
* check compensates for this time lapse. Moreover this check
* seems to be more definitive than waiting for a random interval,
* say 5 seconds.
*/
int i = 0; int MAX_TIMES = 3;
while ((rmiClient.getInstanceStatusCode() !=
Status.kInstanceNotRunningCode) && (i < MAX_TIMES))
{
Thread.currentThread().sleep(5000);
i++;
}
}
catch (Exception e)
{
throw new ControlException(e.getMessage());
}
ManagedInstanceTimer tt = new ManagedInstanceTimer(
TIME_OUT_SECONDS, 0,
new TimerCallback()
{
public boolean check() throws Exception
{
return (rmiClient.getInstanceStatusCode() ==
Status.kInstanceRunningCode);
}
} );
tt.run(); //synchronous
if (rmiClient.getInstanceStatusCode() != Status.kInstanceRunningCode)
{
String msg = localStrings.getString( "admin.server.core.mbean.config.timeout_while_restarting_server" );
try
{
stop(TIME_OUT_SECONDS);