Search in sources :

Example 21 with BuildDataCorruptedException

use of org.jetbrains.jps.builders.storage.BuildDataCorruptedException in project intellij-community by JetBrains.

the class ObjectObjectPersistentMultiMaplet method put.

@Override
public void put(final K key, final Collection<V> value) {
    try {
        myCache.remove(key);
        myMap.appendData(key, new PersistentHashMap.ValueDataAppender() {

            public void append(DataOutput out) throws IOException {
                for (V v : value) {
                    myValueExternalizer.save(out, v);
                }
            }
        });
    } catch (IOException e) {
        throw new BuildDataCorruptedException(e);
    }
}
Also used : BuildDataCorruptedException(org.jetbrains.jps.builders.storage.BuildDataCorruptedException) PersistentHashMap(com.intellij.util.io.PersistentHashMap)

Example 22 with BuildDataCorruptedException

use of org.jetbrains.jps.builders.storage.BuildDataCorruptedException in project intellij-community by JetBrains.

the class BackwardReferenceIndexWriter method initialize.

static void initialize(@NotNull final CompileContext context, int attempt) {
    final BuildDataManager dataManager = context.getProjectDescriptor().dataManager;
    final File buildDir = dataManager.getDataPaths().getDataStorageRoot();
    if (isEnabled()) {
        boolean isRebuild = isRebuildInAllJavaModules(context);
        if (!JavaCompilers.JAVAC_ID.equals(JavaBuilder.getUsedCompilerId(context)) || !JavaBuilder.IS_ENABLED.get(context, Boolean.TRUE)) {
            CompilerBackwardReferenceIndex.removeIndexFiles(buildDir);
            return;
        }
        if (isRebuild) {
            CompilerBackwardReferenceIndex.removeIndexFiles(buildDir);
        } else if (CompilerBackwardReferenceIndex.versionDiffers(buildDir)) {
            CompilerBackwardReferenceIndex.removeIndexFiles(buildDir);
            if ((attempt == 0 && areAllJavaModulesAffected(context))) {
                throw new BuildDataCorruptedException("backward reference index should be updated to actual version");
            } else {
            // do not request a rebuild if a project is affected incompletely and version is changed, just disable indices
            }
        }
        if (CompilerBackwardReferenceIndex.exist(buildDir) || isRebuild) {
            ourInstance = new BackwardReferenceIndexWriter(new CompilerBackwardReferenceIndex(buildDir, false));
        }
    } else {
        CompilerBackwardReferenceIndex.removeIndexFiles(buildDir);
    }
}
Also used : BuildDataCorruptedException(org.jetbrains.jps.builders.storage.BuildDataCorruptedException) BuildDataManager(org.jetbrains.jps.incremental.storage.BuildDataManager) File(java.io.File)

Example 23 with BuildDataCorruptedException

use of org.jetbrains.jps.builders.storage.BuildDataCorruptedException in project intellij-community by JetBrains.

the class CompilerBackwardReferenceIndex method saveVersion.

public void saveVersion(@NotNull File buildDir) {
    File versionFile = new File(getIndexDir(buildDir), VERSION_FILE);
    try {
        FileUtil.createIfDoesntExist(versionFile);
        final DataOutputStream os = new DataOutputStream(new FileOutputStream(versionFile));
        try {
            os.writeInt(CompilerIndices.VERSION);
        } finally {
            os.close();
        }
    } catch (IOException ex) {
        LOG.error(ex);
        throw new BuildDataCorruptedException(ex);
    }
}
Also used : BuildDataCorruptedException(org.jetbrains.jps.builders.storage.BuildDataCorruptedException) DataOutputStream(java.io.DataOutputStream)

Example 24 with BuildDataCorruptedException

use of org.jetbrains.jps.builders.storage.BuildDataCorruptedException in project intellij-community by JetBrains.

the class IntIntPersistentMultiMaplet method put.

@Override
public void put(final int key, final TIntHashSet value) {
    try {
        myCache.remove(key);
        myMap.appendData(key, new PersistentHashMap.ValueDataAppender() {

            public void append(final DataOutput out) throws IOException {
                final Ref<IOException> exRef = new Ref<>();
                value.forEach(value1 -> {
                    try {
                        DataInputOutputUtil.writeINT(out, value1);
                    } catch (IOException e) {
                        exRef.set(e);
                        return false;
                    }
                    return true;
                });
                final IOException exception = exRef.get();
                if (exception != null) {
                    throw exception;
                }
            }
        });
    } catch (IOException e) {
        throw new BuildDataCorruptedException(e);
    }
}
Also used : SLRUCache(com.intellij.util.containers.SLRUCache) TIntHashSet(gnu.trove.TIntHashSet) DataExternalizer(com.intellij.util.io.DataExternalizer) TIntObjectProcedure(gnu.trove.TIntObjectProcedure) KeyDescriptor(com.intellij.util.io.KeyDescriptor) BuildDataCorruptedException(org.jetbrains.jps.builders.storage.BuildDataCorruptedException) PersistentHashMap(com.intellij.util.io.PersistentHashMap) TIntProcedure(gnu.trove.TIntProcedure) java.io(java.io) Processor(com.intellij.util.Processor) NotNull(org.jetbrains.annotations.NotNull) Ref(com.intellij.openapi.util.Ref) DataInputOutputUtil(com.intellij.util.io.DataInputOutputUtil) BuildDataCorruptedException(org.jetbrains.jps.builders.storage.BuildDataCorruptedException) Ref(com.intellij.openapi.util.Ref) PersistentHashMap(com.intellij.util.io.PersistentHashMap)

Example 25 with BuildDataCorruptedException

use of org.jetbrains.jps.builders.storage.BuildDataCorruptedException in project intellij-community by JetBrains.

the class IntIntPersistentMultiMaplet method close.

@Override
public void close() {
    try {
        myCache.clear();
        myMap.close();
    } catch (IOException e) {
        throw new BuildDataCorruptedException(e);
    }
}
Also used : BuildDataCorruptedException(org.jetbrains.jps.builders.storage.BuildDataCorruptedException)

Aggregations

BuildDataCorruptedException (org.jetbrains.jps.builders.storage.BuildDataCorruptedException)26 IOException (java.io.IOException)8 PersistentHashMap (com.intellij.util.io.PersistentHashMap)4 File (java.io.File)4 THashSet (gnu.trove.THashSet)3 NotNull (org.jetbrains.annotations.NotNull)3 DataExternalizer (com.intellij.util.io.DataExternalizer)2 DataInputOutputUtil (com.intellij.util.io.DataInputOutputUtil)2 java.io (java.io)2 CompilerMessage (org.jetbrains.jps.incremental.messages.CompilerMessage)2 ProgressMessage (org.jetbrains.jps.incremental.messages.ProgressMessage)2 JpsModule (org.jetbrains.jps.model.module.JpsModule)2 AtomicNotNullLazyValue (com.intellij.openapi.util.AtomicNotNullLazyValue)1 Pair (com.intellij.openapi.util.Pair)1 Ref (com.intellij.openapi.util.Ref)1 Processor (com.intellij.util.Processor)1 MultiMap (com.intellij.util.containers.MultiMap)1 SLRUCache (com.intellij.util.containers.SLRUCache)1 KeyDescriptor (com.intellij.util.io.KeyDescriptor)1 MappingFailedException (com.intellij.util.io.MappingFailedException)1