Changeset 182fe90


Ignore:
Timestamp:
Jun 7, 2013 5:26:20 PM (7 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
3b7daaf, 68d25af
Parents:
0fb4f6a
Message:
  • BlockfileNamingService?:
    • Fix bug that kept reverse index from being updated
    • Bump DB version to 3 to trigger repopulation of the reverse index
    • Make metaindex final
    • Add freelist check to the main() test
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • core/java/src/net/i2p/client/naming/BlockfileNamingService.java

    r0fb4f6a r182fe90  
    3333import net.i2p.util.Log;
    3434import net.i2p.util.SecureFileOutputStream;
     35import net.i2p.util.VersionComparator;
    3536
    3637import net.metanotion.io.RAIFile;
     
    113114    private static final String PROP_CREATED = "created";
    114115    private static final String PROP_UPGRADED = "upgraded";
    115     private static final String VERSION = "2";
    116     private static final String OLD_VERSION = "1";
     116    private static final String VERSION = "3";
    117117
    118118    private static final String PROP_ADDED = "a";
     
    332332     */
    333333    private boolean needsUpgrade(BlockFile bf, String version) throws IOException {
    334         if (VERSION.equals(version))
     334        if (version != null && VersionComparator.comp(version, VERSION) >= 0)
    335335            return false;
    336         if (!OLD_VERSION.equals(version))
    337             throw new IOException("Bad db version: " + version);
    338336        if (!bf.file.canWrite()) {
    339337            if (_log.shouldLog(Log.WARN))
     
    346344    /**
    347345     *  Blockfile must be writable of course.
     346     *
     347     *  Version 1->2: Add reverse skiplist and populate
     348     *  Version 2->3: Re-populate reverse skiplist as version 2 didn't keep it updated
     349     *                after the upgrade. No change to format.
     350     *
    348351     *  @return true if upgraded successfully
    349352     *  @since 0.8.9
     
    351354    private boolean upgrade() {
    352355        try {
    353             // shouldn't ever be there...
     356            // wasn't there in version 1, is there in version 2
    354357            SkipList rev = _bf.getIndex(REVERSE_SKIPLIST, _hashIndexSerializer, _infoSerializer);
    355             if (rev == null)
     358            if (rev == null) {
     359                if (_log.shouldLog(Log.WARN))
     360                    _log.warn("Created reverse index");
    356361                rev = _bf.makeIndex(REVERSE_SKIPLIST, _hashIndexSerializer, _infoSerializer);
     362            }
    357363            Map<String, Destination> entries = getEntries();
    358364            long start = System.currentTimeMillis();
     
    362368                 i++;
    363369            }
     370            // i may be greater than skiplist keys if there are dups
    364371            if (_log.shouldLog(Log.WARN))
    365                 _log.warn("Created reverse index with " + i + " entries");
     372                _log.warn("Updated reverse index with " + i + " entries");
    366373            SkipList hdr = _bf.getIndex(INFO_SKIPLIST, _stringSerializer, _infoSerializer);
    367374            if (hdr == null)
     
    724731                if (changed) {
    725732                    removeCache(hostname);
    726                     addReverseEntry(key, d);
     733                    // removeReverseEntry(key, oldDest) ???
    727734                }
     735                addReverseEntry(key, d);
    728736                for (NamingServiceListener nsl : _listeners) {
    729737                    if (changed)
     
    11891197     *  force = force writable
    11901198     */
    1191 /****
    11921199    public static void main(String[] args) {
    11931200        Properties ctxProps = new Properties();
     
    11961203        I2PAppContext ctx = new I2PAppContext(ctxProps);
    11971204        BlockfileNamingService bns = new BlockfileNamingService(ctx);
     1205/****
    11981206        List<String> names = null;
    11991207        Properties props = new Properties();
     
    12691277
    12701278        //bns.dumpDB();
     1279****/
    12711280        bns.close();
     1281/****
    12721282        if (true) return;
    12731283
     
    12851295        System.out.println("HTNS took " + DataHelper.formatDuration(System.currentTimeMillis() - start));
    12861296        System.out.println("found " + found + " notfound " + notfound);
    1287     }
    12881297****/
     1298    }
    12891299}
  • core/java/src/net/metanotion/io/block/BlockFile.java

    r0fb4f6a r182fe90  
    9191        private final boolean _wasMounted;
    9292
    93         private BSkipList metaIndex;
     93        private final BSkipList metaIndex;
     94        private boolean _isClosed;
    9495        /** cached list of free pages, only valid if freListStart > 0 */
    9596        private FreeListBlock flb;
     
    121122
    122123        /**
    123          *  Run an integrity check on the blockfile and all the skiplists in it
     124         *  Run an integrity check on the blockfile and all the skiplists in it.
     125         *
     126         *  WARNING:
     127         *  This only works on skiplists using UTF8StringBytes as a key
     128         *  serializer, unless the exception has been coded in bfck below.
     129         *  Will CORRUPT other skiplists.
    124130         */
    125131        public static void main(String args[]) {
     
    471477        public void close() throws IOException {
    472478                // added I2P
    473                 if (metaIndex == null)
     479                if (_isClosed)
    474480                        return;
    475 
     481                _isClosed = true;
    476482                metaIndex.close();
    477                 metaIndex = null;
    478483
    479484                Set oi = openIndices.keySet();
     
    498503         */
    499504        public boolean bfck(boolean fix) {
    500                 log.info("magic bytes " + magicBytes);
    501                 log.info("fileLen " + fileLen);
    502                 log.info("freeListStart " + freeListStart);
    503                 log.info("mounted " + mounted);
    504                 log.info("spanSize " + spanSize);
    505                 log.info("Metaindex");
    506                 log.info("Checking meta index in blockfile " + file);
     505                if (log.shouldLog(Log.INFO)) {
     506                        log.info("magic bytes " + magicBytes);
     507                        log.info("fileLen " + fileLen);
     508                        log.info("freeListStart " + freeListStart);
     509                        log.info("mounted " + mounted);
     510                        log.info("spanSize " + spanSize);
     511                        log.info("Metaindex");
     512                        log.info("Checking meta index in blockfile " + file);
     513                }
    507514                boolean rv = metaIndex.bslck(fix, true);
    508                 if (rv)
    509                         log.warn("Repaired meta index in blockfile " + file);
    510                 else
    511                         log.info("No errors in meta index in blockfile " + file);
     515                if (rv) {
     516                        if (log.shouldLog(Log.WARN))
     517                                log.warn("Repaired meta index in blockfile " + file);
     518                } else {
     519                        if (log.shouldLog(Log.INFO))
     520                                log.info("No errors in meta index in blockfile " + file);
     521                }
    512522                int items = 0;
    513523                for (SkipIterator iter = metaIndex.iterator(); iter.hasNext(); ) {
    514524                        String slname = (String) iter.nextKey();
    515525                        Integer page = (Integer) iter.next();
    516                         log.info("List " + slname + " page " + page);
     526                        if (log.shouldLog(Log.INFO))
     527                                log.info("List " + slname + " page " + page);
    517528                        try {
    518                                 // This uses IdentityBytes, so the value class won't be right
    519                                 //Serializer ser = slname.equals("%%__REVERSE__%%") ? new IntBytes() : new UTF8StringBytes();
    520                                 BSkipList bsl = getIndex(slname, new UTF8StringBytes(), new IdentityBytes());
     529                                // This uses IdentityBytes, so the value class won't be right, but at least
     530                                // it won't fail the out-of-order check
     531                                Serializer keyser = slname.equals("%%__REVERSE__%%") ? new IntBytes() : new UTF8StringBytes();
     532                                BSkipList bsl = getIndex(slname, keyser, new IdentityBytes());
    521533                                if (bsl == null) {
    522534                                        log.error("Can't find list? " + slname);
     
    531543                }
    532544                log.info("Checked meta index and " + items + " skiplists");
     545                if(freeListStart != 0) {
     546                        try {
     547                               if (flb == null)
     548                                        flb = new FreeListBlock(file, freeListStart);
     549                                flb.flbck(true);
     550                        } catch (IOException ioe) {
     551                                log.error("Free list error", ioe);
     552                        }
     553                } else {
     554                        if (log.shouldLog(Log.INFO))
     555                                log.info("No freelist");
     556                }
    533557                return rv;
    534558        }
  • core/java/src/net/metanotion/io/block/FreeListBlock.java

    r0fb4f6a r182fe90  
    198198        }
    199199
     200        /**
     201         * Recursive.
     202         * @since 0.9.7
     203         */
     204        public boolean flbck(boolean fix) throws IOException {
     205                Log log = I2PAppContext.getGlobalContext().logManager().getLog(BlockFile.class);
     206                log.info(toString());
     207                if (nextPage > 0)
     208                        (new FreeListBlock(file, nextPage)).flbck(fix);
     209                return true;
     210        }
     211
    200212        @Override
    201213        public String toString() {
  • history.txt

    r0fb4f6a r182fe90  
     12013-06-07 zzz
     2 * BlockfileNamingService:
     3   - Fix bug that kept reverse index from being updated
     4   - Bump DB version to 3 to trigger repopulation of the reverse index
     5   - Make metaindex final
     6   - Add freelist check to the main() test
     7
     82013-06-06 zzz
     9 * BuildRequestRecord: Don't waste entropy on bytes we will overwrite
     10
    1112013-06-05 zzz
    212 * DatabaseLookupMessage: Change format for encrypted reply request
  • router/java/src/net/i2p/router/RouterVersion.java

    r0fb4f6a r182fe90  
    1919    public final static String ID = "Monotone";
    2020    public final static String VERSION = CoreVersion.VERSION;
    21     public final static long BUILD = 5;
     21    public final static long BUILD = 6;
    2222
    2323    /** for example "-test" */
Note: See TracChangeset for help on using the changeset viewer.