Refine search
@Override public void deleteRecursively( File directory ) throws IOException { FileUtils.deleteRecursively( directory ); }
copyRecursively( toMove, target ); deleteRecursively( toMove ); copyFile( toMove, target ); deleteFile( toMove );
@Override public long getTotalStoreSize() { return databaseDirectory == null ? 0 : FileUtils.size( fs, databaseDirectory ); }
public static void copyRecursively( File fromDirectory, File toDirectory, FileFilter filter ) throws IOException { File[] files = fromDirectory.listFiles( filter ); if ( files != null ) { for ( File fromFile : files ) { File toFile = new File( toDirectory, fromFile.getName() ); if ( fromFile.isDirectory() ) { Files.createDirectories( toFile.toPath() ); copyRecursively( fromFile, toFile, filter ); } else { copyFile( fromFile, toFile ); } } } }
@Test public void sizeOfDirector() throws Exception { File dir = directory( "dir" ); File file1 = new File( dir, "file1" ); File file2 = new File( dir, "file2" ); try ( FileWriter fileWriter = new FileWriter( file1 ) ) { fileWriter.append( 'a' ).append( 'b' ); } try ( FileWriter fileWriter = new FileWriter( file2 ) ) { fileWriter.append( 'a' ); } assertThat( size( fs, dir ), is( 3L ) ); }
@Test public void shouldReportMissingSchemaIndex() throws Exception { // given DatabaseLayout databaseLayout = testDirectory.databaseLayout(); GraphDatabaseService gds = getGraphDatabaseService( databaseLayout.databaseDirectory() ); Label label = Label.label( "label" ); String propKey = "propKey"; createIndex( gds, label, propKey ); gds.shutdown(); // when File schemaDir = findFile( databaseLayout, "schema" ); FileUtils.deleteRecursively( schemaDir ); ConsistencyCheckService service = new ConsistencyCheckService(); Config configuration = Config.defaults( settings() ); Result result = runFullConsistencyCheck( service, configuration, databaseLayout ); // then assertTrue( result.isSuccessful() ); File reportFile = result.reportFile(); assertTrue( "Consistency check report file should be generated.", reportFile.exists() ); assertThat( "Expected to see report about schema index not being online", Files.readAllLines( reportFile.toPath() ).toString(), allOf( containsString( "schema rule" ), containsString( "not online" ) ) ); }
@Test public void reportNotCleanNativeIndexWithCorrectData() throws IOException, ConsistencyCheckIncompleteException { DatabaseLayout databaseLayout = db.databaseLayout(); someData(); resolveComponent( CheckPointer.class ).forceCheckPoint( new SimpleTriggerInfo( "forcedCheckpoint" ) ); File indexesCopy = databaseLayout.file( "indexesCopy" ); File indexSources = resolveComponent( DefaultIndexProviderMap.class ).getDefaultProvider().directoryStructure().rootDirectory(); copyRecursively( indexSources, indexesCopy, SOURCE_COPY_FILE_FILTER ); db.shutdownAndKeepStore(); copyRecursively( indexesCopy, indexSources ); ConsistencyCheckService.Result result = fullConsistencyCheck(); assertTrue( "Expected consistency check to fail", result.isSuccessful() ); assertThat( readReport( result ), hasItem( containsString("WARN : Index was not properly shutdown and rebuild is required.") ) ); }
@Test public void reportNotCleanLabelIndexWithCorrectData() throws IOException, ConsistencyCheckIncompleteException { DatabaseLayout databaseLayout = db.databaseLayout(); someData(); db.resolveDependency( CheckPointer.class ).forceCheckPoint( new SimpleTriggerInfo( "forcedCheckpoint" ) ); File labelIndexFileCopy = databaseLayout.file( "label_index_copy" ); copyFile( databaseLayout.labelScanStore(), labelIndexFileCopy ); db.shutdownAndKeepStore(); copyFile( labelIndexFileCopy, databaseLayout.labelScanStore() ); ConsistencyCheckService.Result result = fullConsistencyCheck(); assertTrue( "Expected consistency check to fail", result.isSuccessful() ); assertThat( readReport( result ), hasItem( containsString("WARN : Label index was not properly shutdown and rebuild is required.") ) ); }
FileUtils.deleteRecursively( IndexDirectoryStructure.baseSchemaIndexFolder( dir ) ); db = new TestGraphDatabaseFactory() .removeKernelExtensions( INDEX_PROVIDERS_FILTER ) containsString( "The index is in a failed state:" ), containsString( INITIAL_STATE_FAILURE_MESSAGE ) ) );
@Override public boolean deleteFile( File fileName ) { return FileUtils.deleteFile( fileName ); }
@Override public void copyRecursively( File fromDirectory, File toDirectory ) throws IOException { FileUtils.copyRecursively( fromDirectory, toDirectory ); }
public static String[] parseFileArgumentList( File file ) throws IOException { List<String> arguments = new ArrayList<>(); readTextFile( file, line -> arguments.addAll( asList( tokenizeStringWithQuotes( line, true, true, false ) ) ) ); return arguments.toArray( new String[arguments.size()] ); }
@Override public boolean highIO() { return defaultHighIO != null ? defaultHighIO : FileUtils.highIODevice( storeDir.toPath(), false ); }
@Override public void copyFile( File from, File to ) throws IOException { FileUtils.copyFile( from, to ); }
@Test public void reportNotCleanNativeIndex() throws IOException, ConsistencyCheckIncompleteException { DatabaseLayout databaseLayout = db.databaseLayout(); someData(); resolveComponent( CheckPointer.class ).forceCheckPoint( new SimpleTriggerInfo( "forcedCheckpoint" ) ); File indexesCopy = databaseLayout.file( "indexesCopy" ); File indexSources = resolveComponent( DefaultIndexProviderMap.class ).getDefaultProvider().directoryStructure().rootDirectory(); copyRecursively( indexSources, indexesCopy, SOURCE_COPY_FILE_FILTER ); try ( Transaction tx = db.beginTx() ) { createNewNode( new Label[]{LABEL_ONE} ); tx.success(); } db.shutdownAndKeepStore(); copyRecursively( indexesCopy, indexSources ); ConsistencyCheckService.Result result = fullConsistencyCheck(); assertFalse( "Expected consistency check to fail", result.isSuccessful() ); assertThat( readReport( result ), hasItem( containsString("WARN : Index was not properly shutdown and rebuild is required.") ) ); }
@Test public void reportNotCleanLabelIndex() throws IOException, ConsistencyCheckIncompleteException { DatabaseLayout databaseLayout = db.databaseLayout(); someData(); db.resolveDependency( CheckPointer.class ).forceCheckPoint( new SimpleTriggerInfo( "forcedCheckpoint" ) ); File labelIndexFileCopy = databaseLayout.file( "label_index_copy" ); copyFile( databaseLayout.labelScanStore(), labelIndexFileCopy ); try ( Transaction tx = db.beginTx() ) { db.createNode( LABEL_ONE ); tx.success(); } db.shutdownAndKeepStore(); copyFile( labelIndexFileCopy, databaseLayout.labelScanStore() ); ConsistencyCheckService.Result result = fullConsistencyCheck(); assertFalse( "Expected consistency check to fail", result.isSuccessful() ); assertThat( readReport( result ), hasItem( containsString("WARN : Label index was not properly shutdown and rebuild is required.") ) ); }
private static void copyIndex(File source, File target) throws IOException { final File indexFile = new File(source, "index.db"); if (indexFile.exists()) { FileUtils.copyFile(indexFile, new File(target, "index.db")); } final File indexDir = new File(source, "index"); if (indexDir.exists()) { FileUtils.copyRecursively(indexDir, new File(target, "index")); } }
private void removeMessagesLog( Config config ) { FileUtils.deleteFile( new File( config.get( database_path ), "messages.log" ) ); } }
public static void copyRecursively( File fromDirectory, File toDirectory ) throws IOException { copyRecursively( fromDirectory, toDirectory, null ); }