rca.setRemoteHost( server.substring( 0, server.indexOf( ":" ) ) );
rca.setRemotePort( Integer.parseInt( server.substring( server.indexOf( ":" ) + 1 ) ) );
RemoteCacheManager rcm = RemoteCacheManager.getInstance( rca );
log.debug( "RemoteCacheAttributes for failover = " + rca.toString() );
// add a listener if there are none, need to tell rca what number it is at
ICache ic = rcm.getCache( rca.getCacheName() );
if ( ic != null )
{
if ( ic.getStatus() == ic.STATUS_ALIVE )
{
// may need to do this more gracefully
log.debug( "reseting no wait" );
facade.noWaits = new RemoteCacheNoWait[1];
facade.noWaits[0] = ( RemoteCacheNoWait ) ic;
facade.rca.setFailoverIndex( i );
synchronized ( this )
{
log.debug( "setting ALRIGHT to true, moving to Primary Recovery Mode" );
alright = true;
log.debug( "CONNECTED to " + rca.getRemoteHost() + ":" + rca.getRemotePort() + "\n\n" );
}
}
}
else
{
//p( "noWait is null" );
}
}
catch ( Exception ex )
{
bad();
log.debug( "FAILED to connect to " + rca.getRemoteHost() + ":" + rca.getRemotePort() );
// Problem encountered in fixing the caches managed by a RemoteCacheManager instance.
// Soldier on to the next RemoteCacheManager instance.
log.error( ex.toString() );
}
}
}
// end if !alright
else
{
log.warn( "ALRIGHT is true -- failover runner is in primary recovery mode" );
}
//try to move back to the primary
String[] failovers = facade.rca.getFailovers();
String server = failovers[0];
try
{
RemoteCacheAttributes rca = ( RemoteCacheAttributes ) facade.rca.copy();
rca.setRemoteHost( server.substring( 0, server.indexOf( ":" ) ) );
rca.setRemotePort( Integer.parseInt( server.substring( server.indexOf( ":" ) + 1 ) ) );
RemoteCacheManager rcm = RemoteCacheManager.getInstance( rca );
// add a listener if there are none, need to tell rca what number it is at
ICache ic = rcm.getCache( rca.getCacheName() );
if ( ic != null )
{
if ( ic.getStatus() == ic.STATUS_ALIVE )
{
// may need to do this more gracefully
log.debug( "reseting no wait to PRIMARY" );
facade.noWaits = new RemoteCacheNoWait[1];
facade.noWaits[0] = ( RemoteCacheNoWait ) ic;