/**
 * Copyright (c) 2002-2011 "Neo Technology,"
 * Network Engine for Objects in Lund AB [http://neotechnology.com]
 *
 * This file is part of Neo4j.
 *
 * Neo4j is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package org.neo4j.kernel.impl.storemigration;

import java.io.File;
import java.io.IOException;
import java.util.HashMap;

import org.neo4j.kernel.CommonFactories;
import org.neo4j.kernel.EmbeddedGraphDatabase;
import org.neo4j.kernel.IdGeneratorFactory;
import org.neo4j.kernel.impl.nioneo.store.FileSystemAbstraction;
import org.neo4j.kernel.impl.nioneo.store.NeoStore;

public class StoreMigrationTool
{
    public static void main( String[] args ) throws IOException
    {
        String legacyStoreDirectory = args[0];
        String targetStoreDirectory = args[1];

        new StoreMigrationTool().run( legacyStoreDirectory, targetStoreDirectory );
    }

    private void run( String legacyStoreDirectory, String targetStoreDirectory ) throws IOException
    {
        LegacyStore legacyStore = new LegacyStore( new File( new File( legacyStoreDirectory ), "neostore" ).getPath() );

        HashMap config = new HashMap();
        config.put( IdGeneratorFactory.class, CommonFactories.defaultIdGeneratorFactory() );
        config.put( FileSystemAbstraction.class, CommonFactories.defaultFileSystemAbstraction() );

        File targetStoreDirectoryFile = new File( targetStoreDirectory );
        if ( targetStoreDirectoryFile.exists() )
        {
            throw new IllegalStateException( "Cannot migrate to a directory that already exists, please delete first and re-run" );
        }
        boolean success = targetStoreDirectoryFile.mkdirs();
        if ( !success )
        {
            throw new IllegalStateException( "Failed to create directory" );
        }

        File targetStoreFile = new File( targetStoreDirectory, "neostore" );
        config.put( "neo_store", targetStoreFile.getPath() );
        NeoStore.createStore( targetStoreFile.getPath(), config );
        NeoStore neoStore = new NeoStore( config );

        new StoreMigrator( legacyStore ).migrateTo( neoStore );

        neoStore.close();

        EmbeddedGraphDatabase database = new EmbeddedGraphDatabase( targetStoreDirectoryFile.getPath() );
        database.shutdown();
    }
}

@@ -2643,60 +2643,258 @@
     
-new StoreMigrator( legacyStore ).migrateTo( neoStore
+long startTime = System.currentTimeMillis();%0A%0A        new StoreMigrator( legacyStore ).migrateTo( neoStore );%0A%0A        long duration = System.currentTimeMillis() - startTime;%0A        System.out.printf( %22Migration completed in %25d s%25n%22, duration / 1000
  );%0A

Print out timing of the migration process