naming service shutdown stuff

This commit is contained in:
zzz
2011-03-16 00:37:54 +00:00
parent 0352ca3ef6
commit 5095e8a1d6
4 changed files with 21 additions and 2 deletions

View File

@ -412,6 +412,8 @@ public class BlockfileNamingService extends DummyNamingService {
}
props.setProperty(PROP_ADDED, Long.toString(_context.clock().now()));
synchronized(_bf) {
if (_isClosed)
return false;
try {
SkipList sl = _bf.getIndex(listname, _stringSerializer, _destSerializer);
if (sl == null)
@ -450,6 +452,8 @@ public class BlockfileNamingService extends DummyNamingService {
}
}
synchronized(_bf) {
if (_isClosed)
return false;
try {
SkipList sl = _bf.getIndex(listname, _stringSerializer, _destSerializer);
if (sl == null)
@ -518,6 +522,8 @@ public class BlockfileNamingService extends DummyNamingService {
" starting with " + startsWith + " search string " + search +
" limit=" + limit + " skip=" + skip);
synchronized(_bf) {
if (_isClosed)
return Collections.EMPTY_MAP;
try {
SkipList sl = _bf.getIndex(listname, _stringSerializer, _destSerializer);
if (sl == null) {
@ -575,6 +581,8 @@ public class BlockfileNamingService extends DummyNamingService {
}
}
synchronized(_bf) {
if (_isClosed)
return 0;
try {
SkipList sl = _bf.getIndex(listname, _stringSerializer, _destSerializer);
if (sl == null)
@ -590,6 +598,10 @@ public class BlockfileNamingService extends DummyNamingService {
}
}
public void shutdown() {
close();
}
////////// End NamingService API
private void dumpDB() {
@ -619,7 +631,7 @@ public class BlockfileNamingService extends DummyNamingService {
}
}
public void close() {
private void close() {
synchronized(_bf) {
try {
_bf.close();

View File

@ -179,4 +179,10 @@ public class MetaNamingService extends DummyNamingService {
}
return rv;
}
public void shutdown() {
for (NamingService ns : _services) {
ns.shutdown();
}
}
}

View File

@ -412,7 +412,7 @@ public abstract class NamingService {
* Should not be called by others.
* @since 0.8.5
*/
public void stop() {}
public void shutdown() {}
//// End New API

View File

@ -934,6 +934,7 @@ public class Router {
}
}
try { _context.clientManager().shutdown(); } catch (Throwable t) { _log.log(Log.CRIT, "Error shutting down the client manager", t); }
try { _context.namingService().shutdown(); } catch (Throwable t) { _log.log(Log.CRIT, "Error shutting down the naming service", t); }
try { _context.jobQueue().shutdown(); } catch (Throwable t) { _log.log(Log.CRIT, "Error shutting down the job queue", t); }
//try { _context.adminManager().shutdown(); } catch (Throwable t) { _log.log(Log.CRIT, "Error shutting down the admin manager", t); }
try { _context.statPublisher().shutdown(); } catch (Throwable t) { _log.log(Log.CRIT, "Error shutting down the stats manager", t); }