fixed shutdown problem

this fixes the 'inconsistency' messages during start-up

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@3457 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 18 years ago
parent 38b93f8cb8
commit 6ad39bae1e

@ -8,6 +8,7 @@ import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
@ -461,12 +462,13 @@ final class dbTable implements kelondroIndex {
return "dbtest." + theDBConnection.hashCode();
}
public void close() throws IOException {
try {
public void close() {
if (this.theDBConnection != null) try {
this.theDBConnection.close();
} catch (Exception e) {
throw new IOException("Unable to close the database connection.");
} catch (SQLException e) {
e.printStackTrace();
}
this.theDBConnection = null;
}
public int size() throws IOException {

@ -93,7 +93,7 @@ public class blogBoard {
}
public void close() {
try {datbase.close();} catch (IOException e) {}
datbase.close();
}
private static String dateString(Date date) {

@ -93,7 +93,7 @@ public class blogBoardComments {
}
public void close() {
try {datbase.close();} catch (IOException e) {}
datbase.close();
}
private static String dateString(Date date) {

@ -152,29 +152,26 @@ public class bookmarksDB {
}
public void close(){
try {
//flushBookmarkCache();
bookmarksTable.close();
} catch (IOException e) {}
try {
flushTagCache();
tagsTable.close();
} catch (IOException e) {}
try {
datesTable.close();
} catch (IOException e) {}
bookmarksTable.close();
flushTagCache();
tagsTable.close();
datesTable.close();
}
public int bookmarksSize(){
return bookmarksTable.size();
}
public int tagSize(boolean flushed){
if(flushed)
flushTagCache();
return tagsTable.size();
}
public int tagsSize(){
return tagSize(false);
}
public void saveBookmark(Bookmark bookmark){
try {
bookmarksTable.set(bookmark.getUrlHash(), bookmark);

@ -80,7 +80,7 @@ public class messageBoard {
}
public void close() {
try {database.close();} catch (IOException e) {}
database.close();
}
private static String dateString() {

@ -82,18 +82,14 @@ public final class userDB {
void resetDatabase() {
// deletes the database and creates a new one
if (userTable != null) try {
userTable.close();
} catch (IOException e) {}
if (userTable != null) userTable.close();
if (!(userTableFile.delete())) throw new RuntimeException("cannot delete user database");
userTableFile.getParentFile().mkdirs();
userTable = new kelondroMapObjects(kelondroDyn.open(userTableFile, true, true, preloadTime, 256, 512, '_', true, false), 10);
}
public void close() {
try {
userTable.close();
} catch (IOException e) {}
userTable.close();
}
public int size() {

@ -88,8 +88,8 @@ public class wikiBoard {
}
public void close() {
try {datbase.close();} catch (IOException e) {}
try {bkpbase.close();} catch (IOException e) {}
datbase.close();
bkpbase.close();
}
private static String dateString() {

@ -102,7 +102,7 @@ public class kelondroBytesIntMap {
return ki.profile();
}
public synchronized void close() throws IOException {
public synchronized void close() {
ki.close();
}

@ -260,9 +260,17 @@ public class kelondroCache implements kelondroIndex {
}
}
public synchronized void close() throws IOException {
flushUnique();
flushDoubles();
public synchronized void close() {
try {
flushUnique();
} catch (IOException e) {
e.printStackTrace();
}
try {
flushDoubles();
} catch (IOException e) {
e.printStackTrace();
}
index.close();
readHitCache = null;
readMissCache = null;

@ -465,7 +465,7 @@ public class kelondroDyn {
}
}
public synchronized void close() throws IOException {
public synchronized void close() {
index.close();
}

@ -331,9 +331,12 @@ public class kelondroFlexSplitTable implements kelondroIndex {
return new int[]{0,0,0,0,0,0,0,0,0,0};
}
public synchronized void close() throws IOException {
public synchronized void close() {
if (tables == null) return;
Iterator i = tables.values().iterator();
while (i.hasNext()) ((kelondroIndex) i.next()).close();
while (i.hasNext()) {
((kelondroIndex) i.next()).close();
}
tables = null;
}

@ -385,7 +385,7 @@ public class kelondroFlexTable extends kelondroFlexWidthArray implements kelondr
return map;
}
public synchronized void close() throws IOException {
public synchronized void close() {
if (tableTracker.remove(this.filename) == null) {
serverLog.logWarning("kelondroFlexTable", "close(): file '" + this.filename + "' was not tracked with record tracker.");
}
@ -395,4 +395,21 @@ public class kelondroFlexTable extends kelondroFlexWidthArray implements kelondr
super.close();
}
public static void main(String[] args) {
// open a file, add one entry and exit
File f = new File(args[0]);
String name = args[1];
kelondroRow row = new kelondroRow("Cardinal key-4 {b256}, byte[] x-64", kelondroNaturalOrder.naturalOrder, 0);
try {
kelondroFlexTable t = new kelondroFlexTable(f, name, 0, row);
kelondroRow.Entry entry = row.newEntry();
entry.setCol(0, System.currentTimeMillis());
entry.setCol(1, "dummy".getBytes());
t.put(entry);
t.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}

@ -161,7 +161,7 @@ public class kelondroFlexWidthArray implements kelondroArray {
}
}
public void close() throws IOException {
public void close() {
synchronized (col) {
for (int i = 0; i < col.length; i++) {
if (col[i] != null) {

@ -71,5 +71,5 @@ public interface kelondroIndex {
public kelondroRow.Entry remove(byte[] key) throws IOException;
public kelondroRow.Entry removeOne() throws IOException;
public kelondroCloneableIterator rows(boolean up, byte[] firstKey) throws IOException;
public void close() throws IOException;
public void close();
}

@ -306,7 +306,7 @@ public class kelondroMapObjects extends kelondroObjects {
return super.size();
}
public void close() throws IOException {
public void close() {
// close cluster
if (sortClusterMap != null) {
for (int i = 0; i < sortfields.length; i++) sortClusterMap.remove(sortfields[i]);

@ -183,7 +183,7 @@ public class kelondroMapTable {
throw new RuntimeException("kelondroTables.accumulator: table '" + tablename + "' does not exist.");
}
public void close() throws IOException {
public void close() {
Iterator tablesIt = mTables.values().iterator();
while (tablesIt.hasNext()) ((kelondroMapObjects) tablesIt.next()).close();
mTables = null;

@ -150,7 +150,7 @@ public class kelondroObjects {
}
}
public void close() throws IOException {
public void close() {
// finish queue
//writeWorker.terminate(true);

@ -1470,7 +1470,7 @@ public class kelondroRecords {
}
public synchronized void close() throws IOException {
public synchronized void close() {
if (cacheHeaders == null) {
if (recordTracker.get(this.filename) != null) {
theLogger.severe("close(): file '" + this.filename + "' was tracked with record tracker, but it should not.");
@ -1482,19 +1482,20 @@ public class kelondroRecords {
}
if (entryFile == null) {
theLogger.severe("close(): file '" + this.filename + "' was closed before close was called.");
} else {
} else try {
USAGE.writeused(true);
this.entryFile.close();
this.entryFile = null;
this.cacheHeaders = null;
theLogger.fine("file '" + this.filename + "' closed.");
} catch (IOException e) {
theLogger.severe("file '" + this.filename + "': failed to close.");
e.printStackTrace();
}
this.entryFile = null;
this.cacheHeaders = null;
}
public void finalize() {
try {
if (entryFile != null) close();
} catch (IOException e) { }
if (entryFile != null) close();
this.entryFile = null;
}

@ -87,7 +87,7 @@ public class kelondroSplittedTree implements kelondroIndex {
ff = forkfactor;
}
public void close() throws IOException {
public void close() {
for (int i = 0; i < ktfs.length; i++) ktfs[i].close();
}

@ -85,7 +85,7 @@ public class plasmaCrawlBalancer {
ramIndex = null;
while (sizeDomainStacks() > 0) flushOnceDomStacks(true);
try { flushAllRamStack(); } catch (IOException e) {}
try { fileStack.close(); } catch (IOException e) {}
fileStack.close();
fileStack = null;
}

@ -173,10 +173,7 @@ public class plasmaCrawlEURL {
public void close() {
if (urlIndexFile != null) {
try {
urlIndexFile.close();
} catch (IOException e) {
}
urlIndexFile.close();
urlIndexFile = null;
}
}

@ -119,9 +119,9 @@ public final class plasmaCrawlLURL {
}
}
public void close() throws IOException {
public void close() {
if (urlIndexFile != null) {
urlIndexFile.close();
urlIndexFile.close();
urlIndexFile = null;
}
}

@ -175,7 +175,7 @@ public class plasmaCrawlNURL {
private void resetHashCache() {
if (urlIndexFile != null) {
try {urlIndexFile.close();} catch (IOException e) {}
urlIndexFile.close();
urlIndexFile = null;
File cacheFile = new File(cacheStacksPath, "urlNotice2.db");
cacheFile.delete();
@ -188,13 +188,13 @@ public class plasmaCrawlNURL {
limitStack.close();
overhangStack.close();
remoteStack.close();
try {imageStack.close();} catch (IOException e) {}
try {movieStack.close();} catch (IOException e) {}
try {musicStack.close();} catch (IOException e) {}
if (urlIndexFile != null) try {
imageStack.close();
movieStack.close();
musicStack.close();
if (urlIndexFile != null) {
urlIndexFile.close();
urlIndexFile = null;
} catch (IOException e) {}
}
}
public class initStackIndex extends Thread {

@ -75,7 +75,7 @@ public class plasmaCrawlProfile {
private void resetDatabase() {
// deletes the profile database and creates a new one
if (profileTable != null) try { profileTable.close(); } catch (IOException e) {}
if (profileTable != null) profileTable.close();
if (!(profileTableFile.delete())) throw new RuntimeException("cannot delete crawl profile database");
profileTableFile.getParentFile().mkdirs();
kelondroDyn dyn = kelondroDyn.open(profileTableFile, true, true, preloadTime, crawlProfileHandleLength, 2000, '#', true, false);
@ -83,9 +83,7 @@ public class plasmaCrawlProfile {
}
public void close() {
try {
profileTable.close();
} catch (IOException e) {}
profileTable.close();
}
public int size() {

@ -76,18 +76,14 @@ public class plasmaCrawlRobotsTxt {
private void resetDatabase() {
// deletes the robots.txt database and creates a new one
if (robotsTable != null) try {
robotsTable.close();
} catch (IOException e) {}
if (robotsTable != null) robotsTable.close();
if (!(robotsTableFile.delete())) throw new RuntimeException("cannot delete robots.txt database");
robotsTableFile.getParentFile().mkdirs();
robotsTable = new kelondroMapObjects(kelondroDyn.open(robotsTableFile, true, true, preloadTime, 256, 512, '_', true, false), 100);
}
public void close() {
try {
robotsTable.close();
} catch (IOException e) {}
robotsTable.close();
}
public int size() {

@ -188,7 +188,7 @@ public final class plasmaHTCache {
}
private void resetResponseHeaderDB() {
if (this.responseHeaderDB != null) try {this.responseHeaderDB.close();} catch (IOException e) {}
if (this.responseHeaderDB != null) this.responseHeaderDB.close();
File dbfile = new File(this.cachePath, "responseHeader.db");
if (dbfile.exists()) dbfile.delete();
openResponseHeaderDB(0);
@ -397,7 +397,7 @@ public final class plasmaHTCache {
}
// closing DB
try {this.responseHeaderDB.close();} catch (IOException e) {}
this.responseHeaderDB.close();
}
private String ageString(long date, File f) {

@ -1576,7 +1576,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser
userDB.close();
bookmarksDB.close();
messageDB.close();
if (facilityDB != null) try {facilityDB.close();} catch (IOException e) {}
if (facilityDB != null) facilityDB.close();
sbStackCrawlThread.close();
profiles.close();
robots.close();
@ -1588,6 +1588,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser
noticeURL.close();
errorURL.close();
wordIndex.close();
yc.close();
log.logConfig("SWITCHBOARD SHUTDOWN TERMINATED");
}
@ -3160,7 +3161,7 @@ class delayedShutdown extends Thread {
try {
Thread.sleep(delay);
} catch (InterruptedException e) {
e.printStackTrace();
sb.getLog().logInfo("interrupted delayed shutdown");
}
this.sb.terminate();
}

@ -161,9 +161,8 @@ public class plasmaSwitchboardQueue {
}
public void close() {
if (sbQueueStack != null) try {
if (sbQueueStack != null) {
sbQueueStack.close();
} catch (IOException e) {
}
sbQueueStack = null;
}

@ -383,6 +383,7 @@ public final class plasmaWordIndex implements indexRI {
dhtInCache.close();
dhtOutCache.close();
collections.close();
loadedURL.close();
}
}

@ -53,7 +53,6 @@
package de.anomic.plasma;
import java.io.File;
import java.io.IOException;
import java.util.Iterator;
import de.anomic.index.indexContainer;
@ -168,11 +167,7 @@ public final class plasmaWordIndexAssortment {
}
public void close() {
try {
assortment.close();
} catch (IOException e){
log.logSevere("unable to close assortment database: " + e.getMessage(), e);
}
assortment.close();
}
}

@ -148,7 +148,7 @@ public final class plasmaWordIndexFile {
public boolean deleteComplete() {
if (theIndex == null) return false;
try { theIndex.close(); } catch (IOException e) {}
theIndex.close();
// remove file
boolean success = theLocation.delete();
// and also the paren directory if that is empty

@ -249,6 +249,11 @@ public class yacyCore {
}
}
public synchronized void close() {
seedDB.close();
newsPool.close();
}
synchronized static public void triggerOnlineAction() {
lastOnlineTime = System.currentTimeMillis();
}

@ -77,7 +77,7 @@ public class yacyNewsDB {
}
public void close() {
if (news != null) try {news.close();} catch (IOException e) {}
if (news != null) news.close();
news = null;
}

@ -100,6 +100,14 @@ public class yacyNewsPool {
maxDistribution = 30;
}
public synchronized void close() {
newsDB.close();
outgoingNews.close();
publishedNews.close();
incomingNews.close();
processedNews.close();
}
public int dbSize() {
try {
return newsDB.size();

@ -83,7 +83,7 @@ public class yacyNewsQueue {
}
public void close() {
if (queueStack != null) try {queueStack.close();} catch (IOException e) {}
if (queueStack != null) queueStack.close();
queueStack = null;
}

@ -204,14 +204,10 @@ public final class yacySeedDB {
// this is an emergency function that should only be used if any problem with the
// seed.db is detected
yacyCore.log.logFine("seed-db " + seedDBFile.toString() + " reset (on-the-fly)");
try {
seedDB.close();
seedDBFile.delete();
// create new seed database
seedDB = openSeedTable(seedDBFile);
} catch (IOException e) {
yacyCore.log.logFine("resetSeedTable", e);
}
seedDB.close();
seedDBFile.delete();
// create new seed database
seedDB = openSeedTable(seedDBFile);
return seedDB;
}
@ -220,12 +216,9 @@ public final class yacySeedDB {
public synchronized void resetPotentialTable() { seedPotentialDB = resetSeedTable(seedPotentialDB, seedPotentialDBFile); }
public void close() {
try {
seedActiveDB.close();
seedPassiveDB.close();
} catch (IOException e) {
yacyCore.log.logFine("close", e);
}
if (seedActiveDB != null) seedActiveDB.close();
if (seedPassiveDB != null) seedPassiveDB.close();
if (seedPotentialDB != null) seedPotentialDB.close();
}
public void initializeHandler(String mapname, Map map) {

@ -1214,7 +1214,7 @@ public final class yacy {
}
}
sb.close();
try { oldindex.close(); } catch (IOException e) { }
oldindex.close();
System.out.println("MIGRATION OF " + c + " URLs FINISHED");
}
@ -1234,15 +1234,10 @@ public final class yacy {
private static void urldbcleanup(String homePath) {
File root = new File(homePath);
File indexroot = new File(root, "DATA/INDEX");
serverLog log = new serverLog("URLDBCLEANUP");
try {serverLog.configureLogging(new File(homePath, "DATA/LOG/yacy.logging"));} catch (Exception e) {}
try {
plasmaCrawlLURL currentUrlDB = new plasmaCrawlLURL(indexroot, 10000);
currentUrlDB.urldbcleanup();
currentUrlDB.close();
} catch (IOException e) {
log.logSevere("IOException", e);
}
plasmaCrawlLURL currentUrlDB = new plasmaCrawlLURL(indexroot, 10000);
currentUrlDB.urldbcleanup();
currentUrlDB.close();
}
private static void RWIHashList(String homePath, String targetName, String resource, String format) {

Loading…
Cancel
Save