@ -64,36 +64,36 @@ public class ResourceObserver {
public void resourceObserverJob ( ) {
MemoryControl . setProperMbyte ( getMinFreeMemory ( ) ) ;
normalizedDiskFree = getNormalizedDiskFree ( ) ;
normalizedMemoryFree = getNormalizedMemoryFree ( ) ;
this . normalizedDiskFree = getNormalizedDiskFree ( ) ;
this . normalizedMemoryFree = getNormalizedMemoryFree ( ) ;
if ( normalizedDiskFree. compareTo ( Space . HIGH ) < 0 | | normalizedMemoryFree. compareTo ( Space . HIGH ) < 0 ) {
if ( this . normalizedDiskFree. compareTo ( Space . HIGH ) < 0 | | this . normalizedMemoryFree. compareTo ( Space . HIGH ) < 0 ) {
if ( normalizedDiskFree. compareTo ( Space . HIGH ) < 0 ) { // pause crawls
if ( ! sb. crawlJobIsPaused ( SwitchboardConstants . CRAWLJOB_LOCAL_CRAWL ) ) {
if ( this . normalizedDiskFree. compareTo ( Space . HIGH ) < 0 ) { // pause crawls
if ( ! this . sb. crawlJobIsPaused ( SwitchboardConstants . CRAWLJOB_LOCAL_CRAWL ) ) {
log . logInfo ( "pausing local crawls" ) ;
sb. pauseCrawlJob ( SwitchboardConstants . CRAWLJOB_LOCAL_CRAWL ) ;
this . sb. pauseCrawlJob ( SwitchboardConstants . CRAWLJOB_LOCAL_CRAWL ) ;
}
if ( ! sb. crawlJobIsPaused ( SwitchboardConstants . CRAWLJOB_REMOTE_TRIGGERED_CRAWL ) ) {
if ( ! this . sb. crawlJobIsPaused ( SwitchboardConstants . CRAWLJOB_REMOTE_TRIGGERED_CRAWL ) ) {
log . logInfo ( "pausing remote triggered crawls" ) ;
sb. pauseCrawlJob ( SwitchboardConstants . CRAWLJOB_REMOTE_TRIGGERED_CRAWL ) ;
this . sb. pauseCrawlJob ( SwitchboardConstants . CRAWLJOB_REMOTE_TRIGGERED_CRAWL ) ;
}
}
if ( ( normalizedDiskFree = = Space . LOW | | normalizedMemoryFree. compareTo ( Space . HIGH ) < 0 ) & & sb. getConfigBool ( SwitchboardConstants . INDEX_RECEIVE_ALLOW , false ) ) {
if ( ( this . normalizedDiskFree = = Space . LOW | | this . normalizedMemoryFree. compareTo ( Space . HIGH ) < 0 ) & & this . sb. getConfigBool ( SwitchboardConstants . INDEX_RECEIVE_ALLOW , false ) ) {
log . logInfo ( "disabling index receive" ) ;
sb. setConfig ( SwitchboardConstants . INDEX_RECEIVE_ALLOW , false ) ;
sb. peers . mySeed ( ) . setFlagAcceptRemoteIndex ( false ) ;
sb. setConfig ( SwitchboardConstants . INDEX_RECEIVE_AUTODISABLED , true ) ;
this . sb. setConfig ( SwitchboardConstants . INDEX_RECEIVE_ALLOW , false ) ;
this . sb. peers . mySeed ( ) . setFlagAcceptRemoteIndex ( false ) ;
this . sb. setConfig ( SwitchboardConstants . INDEX_RECEIVE_AUTODISABLED , true ) ;
}
}
else {
if ( sb. getConfigBool ( SwitchboardConstants . INDEX_RECEIVE_AUTODISABLED , false ) ) { // we were wrong!
if ( this . sb. getConfigBool ( SwitchboardConstants . INDEX_RECEIVE_AUTODISABLED , false ) ) { // we were wrong!
log . logInfo ( "enabling index receive" ) ;
sb. setConfig ( SwitchboardConstants . INDEX_RECEIVE_ALLOW , true ) ;
sb. peers . mySeed ( ) . setFlagAcceptRemoteIndex ( true ) ;
sb. setConfig ( SwitchboardConstants . INDEX_RECEIVE_AUTODISABLED , false ) ;
this . sb. setConfig ( SwitchboardConstants . INDEX_RECEIVE_ALLOW , true ) ;
this . sb. peers . mySeed ( ) . setFlagAcceptRemoteIndex ( true ) ;
this . sb. setConfig ( SwitchboardConstants . INDEX_RECEIVE_AUTODISABLED , false ) ;
}
log . logInfo ( "resources ok" ) ;
}
@ -114,10 +114,11 @@ public class ResourceObserver {
Space ret = Space . HIGH ;
if ( currentSpace < getMinFreeDiskSpace ( ) ) {
log . logWarning ( "Volume " + this . path . toString ( ) + ": free space (" + ( currentSpace / 1024 / 1024 ) + " MB) is too low (< " + ( getMinFreeDiskSpace ( ) / 1024 / 1024 ) + " MB)" ) ;
log . logWarning ( "Volume " + this . path . toString ( ) + ": free space (" + ( currentSpace / 1024 / 1024 ) + " MB) is low (< " + ( getMinFreeDiskSpace ( ) / 1024 / 1024 ) + " MB)" ) ;
ret = Space . MEDIUM ;
}
if ( currentSpace < getMinFreeDiskSpace_hardlimit ( ) ) {
log . logWarning ( "Volume " + this . path . toString ( ) + ": free space (" + ( currentSpace / 1024 / 1024 ) + " MB) is too low (< " + ( getMinFreeDiskSpace ( ) / 1024 / 1024 ) + " MB)" ) ;
ret = Space . LOW ;
}
return ret ;
@ -132,35 +133,35 @@ public class ResourceObserver {
* @return < code > true < / code > if disk space is available
* /
public boolean getDiskAvailable ( ) {
return normalizedDiskFree = = Space . HIGH ;
return this . normalizedDiskFree = = Space . HIGH ;
}
/ * *
* @return < code > true < / code > if memory is available
* /
public boolean getMemoryAvailable ( ) {
return normalizedMemoryFree = = Space . HIGH ;
return this . normalizedMemoryFree = = Space . HIGH ;
}
/ * *
* @return amount of space ( bytes ) that should be kept free
* /
public long getMinFreeDiskSpace ( ) {
return sb. getConfigLong ( SwitchboardConstants . DISK_FREE , 3000 ) /* MiB */ * 1024L * 1024L ;
return this . sb. getConfigLong ( SwitchboardConstants . DISK_FREE , 3000 ) /* MiB */ * 1024L * 1024L ;
}
/ * *
* @return amount of space ( bytes ) that should at least be kept free
* /
public long getMinFreeDiskSpace_hardlimit ( ) {
return sb. getConfigLong ( SwitchboardConstants . DISK_FREE_HARDLIMIT , 100 ) /* MiB */ * 1024L * 1024L ;
return this . sb. getConfigLong ( SwitchboardConstants . DISK_FREE_HARDLIMIT , 100 ) /* MiB */ * 1024L * 1024L ;
}
/ * *
* @return amount of space ( MiB ) that should at least be free
* /
public long getMinFreeMemory ( ) {
return sb. getConfigLong ( SwitchboardConstants . MEMORY_ACCEPTDHT , 0 ) ;
return this . sb. getConfigLong ( SwitchboardConstants . MEMORY_ACCEPTDHT , 0 ) ;
}