mirror of
https://github.com/usatiuk/dhfs.git
synced 2025-10-29 04:57:48 +01:00
cleanup ref cleanup
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.usatiuk.dhfs.storage.objects.jrepository;
|
||||
|
||||
import com.google.common.collect.Streams;
|
||||
import com.google.protobuf.ByteString;
|
||||
import com.usatiuk.dhfs.storage.SerializationHelper;
|
||||
import com.usatiuk.dhfs.storage.objects.repository.distributed.ObjectMetadata;
|
||||
@@ -20,6 +21,7 @@ import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@ApplicationScoped
|
||||
public class JObjectManagerImpl implements JObjectManager {
|
||||
@@ -211,25 +213,20 @@ public class JObjectManagerImpl implements JObjectManager {
|
||||
Log.info("Quick delete of " + m.getName());
|
||||
m.delete();
|
||||
|
||||
if (!m.getSavedRefs().isEmpty()) {
|
||||
for (var c : m.getSavedRefs()) {
|
||||
get(c).ifPresent(ref -> ref.runWriteLocked(JObject.ResolutionStrategy.LOCAL_ONLY, (mc, dc, bc, ic) -> {
|
||||
mc.removeRef(object.getName());
|
||||
tryQuickDelete(ref);
|
||||
return null;
|
||||
}));
|
||||
}
|
||||
}
|
||||
Stream<String> refs = Stream.empty();
|
||||
|
||||
if (d != null) {
|
||||
for (var c : d.extractRefs()) {
|
||||
get(c).ifPresent(ref -> ref.runWriteLocked(JObject.ResolutionStrategy.LOCAL_ONLY, (mc, dc, bc, ic) -> {
|
||||
mc.removeRef(object.getName());
|
||||
tryQuickDelete(ref);
|
||||
return null;
|
||||
}));
|
||||
}
|
||||
}
|
||||
if (!m.getSavedRefs().isEmpty())
|
||||
refs = m.getSavedRefs().stream();
|
||||
if (d != null)
|
||||
refs = Streams.concat(refs, d.extractRefs().stream());
|
||||
|
||||
refs.forEach(c -> {
|
||||
get(c).ifPresent(ref -> ref.runWriteLocked(JObject.ResolutionStrategy.LOCAL_ONLY, (mc, dc, bc, ic) -> {
|
||||
mc.removeRef(object.getName());
|
||||
tryQuickDelete(ref);
|
||||
return null;
|
||||
}));
|
||||
});
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.usatiuk.dhfs.storage.objects.jrepository;
|
||||
|
||||
import com.google.common.collect.Streams;
|
||||
import com.usatiuk.dhfs.storage.objects.repository.persistence.ObjectPersistentStore;
|
||||
import io.quarkus.logging.Log;
|
||||
import io.quarkus.runtime.Shutdown;
|
||||
@@ -8,6 +9,7 @@ import jakarta.enterprise.context.ApplicationScoped;
|
||||
import jakarta.inject.Inject;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@ApplicationScoped
|
||||
public class JObjectRefProcessor {
|
||||
@@ -77,22 +79,20 @@ public class JObjectRefProcessor {
|
||||
|
||||
Log.info("Deleting " + m.getName());
|
||||
m.delete();
|
||||
//FIXME:
|
||||
if (!m.getSavedRefs().isEmpty()) {
|
||||
for (var c : m.getSavedRefs()) {
|
||||
jObjectManager.get(c).ifPresent(ref -> ref.runWriteLocked(JObject.ResolutionStrategy.LOCAL_ONLY, (mc, dc, bc, ic) -> {
|
||||
mc.removeRef(m.getName());
|
||||
return null;
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
Stream<String> refs = Stream.empty();
|
||||
|
||||
if (!m.getSavedRefs().isEmpty())
|
||||
refs = m.getSavedRefs().stream();
|
||||
if (d != null)
|
||||
for (var c : d.extractRefs()) {
|
||||
jObjectManager.get(c).ifPresent(ref -> ref.runWriteLocked(JObject.ResolutionStrategy.LOCAL_ONLY, (mc, dc, bc, ic) -> {
|
||||
mc.removeRef(m.getName());
|
||||
return null;
|
||||
}));
|
||||
}
|
||||
refs = Streams.concat(refs, d.extractRefs().stream());
|
||||
|
||||
refs.forEach(c -> {
|
||||
jObjectManager.get(c).ifPresent(ref -> ref.runWriteLocked(JObject.ResolutionStrategy.LOCAL_ONLY, (mc, dc, bc, ic) -> {
|
||||
mc.removeRef(m.getName());
|
||||
return null;
|
||||
}));
|
||||
});
|
||||
|
||||
return null;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user