From: <bra...@us...> - 2008-06-05 21:58:00
|
Revision: 2287 http://archive-access.svn.sourceforge.net/archive-access/?rev=2287&view=rev Author: bradtofel Date: 2008-06-05 14:58:07 -0700 (Thu, 05 Jun 2008) Log Message: ----------- INITIAL REV: failed to add new ResourceFileLocationDB interface last checkin. Changed log append method name to addName() Modified Paths: -------------- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/resourcestore/locationdb/BDBResourceFileLocationDB.java trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/resourcestore/locationdb/ResourceFileLocationDBLog.java Added Paths: ----------- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/resourcestore/locationdb/ResourceFileLocationDB.java Modified: trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/resourcestore/locationdb/BDBResourceFileLocationDB.java =================================================================== --- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/resourcestore/locationdb/BDBResourceFileLocationDB.java 2008-06-05 21:52:54 UTC (rev 2286) +++ trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/resourcestore/locationdb/BDBResourceFileLocationDB.java 2008-06-05 21:58:07 UTC (rev 2287) @@ -29,8 +29,8 @@ import java.io.InputStreamReader; import org.archive.wayback.bdb.BDBRecordSet; -import org.archive.wayback.resourcestore.locationdb2.ResourceFileLocationDB; -import org.archive.wayback.resourcestore.locationdb2.ResourceFileLocationDBLog; +import org.archive.wayback.resourcestore.locationdb.ResourceFileLocationDB; +import org.archive.wayback.resourcestore.locationdb.ResourceFileLocationDBLog; import org.archive.wayback.util.CloseableIterator; import com.sleepycat.je.DatabaseException; @@ -146,7 +146,7 @@ } else { // null or empty value newValue = url; - if(oldValue == null) log.addFile(name); + if(oldValue == null) log.addName(name); } // did we find a value? Added: trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/resourcestore/locationdb/ResourceFileLocationDB.java =================================================================== --- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/resourcestore/locationdb/ResourceFileLocationDB.java (rev 0) +++ trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/resourcestore/locationdb/ResourceFileLocationDB.java 2008-06-05 21:58:07 UTC (rev 2287) @@ -0,0 +1,59 @@ +/* ResourceFileLocationDB + * + * $Id$ + * + * Created on 2:01:29 PM Jun 5, 2008. + * + * Copyright (C) 2008 Internet Archive. + * + * This file is part of wayback. + * + * wayback is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * any later version. + * + * wayback is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser Public License for more details. + * + * You should have received a copy of the GNU Lesser Public License + * along with wayback; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package org.archive.wayback.resourcestore.locationdb; + +import java.io.IOException; + +import org.archive.wayback.util.CloseableIterator; + +/** + * Interface to a database that maps file key Strings to zero or more value + * Strings. Additionally, the database supports a "getCurrentMark" call that + * will return an long value. The results of two independent calls to + * getCurrentMark() can be passed to getNamesBetweenMarks() to retrieve an + * Iterator listing all key Strings added to the database between the two calls + * to getCurrentMark() + * + * @author brad + * @version $Date$, $Revision$ + */ +public interface ResourceFileLocationDB { + + public void shutdown() throws IOException; + + public String[] nameToUrls(final String name) + throws IOException; + + public void addNameUrl(final String name, final String url) + throws IOException; + + public void removeNameUrl(final String name, final String url) + throws IOException; + + public CloseableIterator<String> getNamesBetweenMarks(long start, long end) + throws IOException; + + public long getCurrentMark() throws IOException; +} Modified: trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/resourcestore/locationdb/ResourceFileLocationDBLog.java =================================================================== --- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/resourcestore/locationdb/ResourceFileLocationDBLog.java 2008-06-05 21:52:54 UTC (rev 2286) +++ trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/resourcestore/locationdb/ResourceFileLocationDBLog.java 2008-06-05 21:58:07 UTC (rev 2287) @@ -31,7 +31,6 @@ import java.io.IOException; import java.io.RandomAccessFile; -import org.archive.wayback.exception.ConfigurationException; import org.archive.wayback.util.CloseableIterator; import org.archive.wayback.util.flatfile.RecordIterator; @@ -55,23 +54,23 @@ /** * @param pathname - * @throws ConfigurationException + * @throws IOException */ - public ResourceFileLocationDBLog(String pathname) throws ConfigurationException { + public ResourceFileLocationDBLog(String pathname) throws IOException { super(pathname); if (!isFile()) { if (exists()) { - throw new ConfigurationException("path(" + pathname + throw new IOException("path(" + pathname + ") exists but is not a file!"); } try { if (!createNewFile()) { - throw new ConfigurationException( + throw new IOException( "Unable to create empty file " + pathname); } } catch (IOException e) { e.printStackTrace(); - throw new ConfigurationException("Unable to create empty file " + throw new IOException("Unable to create empty file " + pathname); } } @@ -87,10 +86,10 @@ /** * @param start * @param end - * @return CleanableIterator that returns all arcs between start and end + * @return CleanableIterator that returns all names between start and end * @throws IOException */ - public CloseableIterator<String> getArcsBetweenMarks(long start, long end) + public CloseableIterator<String> getNamesBetweenMarks(long start, long end) throws IOException { RandomAccessFile raf = new RandomAccessFile(this, "r"); @@ -100,12 +99,12 @@ } /** - * @param arcName + * @param name * @throws IOException */ - public synchronized void addArc(String arcName) throws IOException { + public synchronized void addName(String name) throws IOException { FileWriter writer = new FileWriter(this, true); - writer.write(arcName + "\n"); + writer.write(name + "\n"); writer.flush(); writer.close(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |