use of org.commonjava.indy.model.core.Group in project indy by Commonjava.
the class AbstractSkimFunctionalTest method setupTestStores.
@Before
public void setupTestStores() throws Exception {
final String changelog = "Create test structures";
final String url = server.formatUrl(TEST_REPO);
final RemoteRepository testRepo = client.stores().create(new RemoteRepository(MavenPackageTypeDescriptor.MAVEN_PKG_KEY, TEST_REPO, url), changelog, RemoteRepository.class);
Group g;
final StoreKey groupKey = new StoreKey(MavenPackageTypeDescriptor.MAVEN_PKG_KEY, group, PUBLIC);
if (client.stores().exists(groupKey)) {
System.out.println("Loading pre-existing public group.");
g = client.stores().load(groupKey, Group.class);
} else {
System.out.println("Creating new group 'public'");
g = client.stores().create(new Group(MavenPackageTypeDescriptor.MAVEN_PKG_KEY, PUBLIC), changelog, Group.class);
}
g.setConstituents(Collections.singletonList(testRepo.getKey()));
client.stores().update(g, changelog);
}
use of org.commonjava.indy.model.core.Group in project indy by Commonjava.
the class StoreContentListener method clearPaths.
/**
* List the paths in target store and clean up the paths in affected groups.
*
* If groups are given, use them (for group update since all members share same group hierarchy). Otherwise,
* query the affected groups (for store deletion and dis/enable event).
*/
private void clearPaths(final Set<StoreKey> keys, Predicate<? super String> pathFilter, final Set<Group> groups, final boolean deleteOriginPath) {
// NOSSUP-76 we still need to use synchronized/drain way to clean the paths now, because sometimes the new used metadata
// not updated in time when some builds want to consume them as the obsolete metadata not cleared under
// async way.
DrainingExecutorCompletionService<Integer> clearService = new DrainingExecutorCompletionService<>(cleanupExecutor);
keys.forEach(key -> {
ArtifactStore origin;
try {
origin = storeDataManager.getArtifactStore(key);
} catch (IndyDataException e) {
logger.error("Failed to retrieve store: " + key, e);
return;
}
Set<Group> affected = groups;
if (affected == null) {
try {
affected = (storeDataManager.query().getGroupsAffectedBy(key));
} catch (IndyDataException e) {
logger.error("Failed to retrieve groups affected by: " + key, e);
return;
}
}
logger.debug("Submit clean job for origin: {}", origin);
final Set<Group> affectedGroups = affected;
clearService.submit(clearPathsProcessor(origin, pathFilter, affectedGroups, deleteOriginPath));
});
drainAndCount(clearService, "stores: " + keys);
}
use of org.commonjava.indy.model.core.Group in project indy by Commonjava.
the class DefaultContentManager method retrieve.
@Override
@Measure
public Transfer retrieve(final ArtifactStore store, final String path, final EventMetadata eventMetadata) throws IndyWorkflowException {
Transfer item;
if (group == store.getKey().getType()) {
List<ArtifactStore> members = getOrderedConcreteStoresAndFilter((Group) store, path);
if (logger.isDebugEnabled()) {
logger.debug("{} is a group. Attempting downloads from (in order):\n {}", store.getKey(), StringUtils.join(members, "\n "));
}
item = contentGeneratorManager.generateGroupFileContent((Group) store, members, path, eventMetadata);
boolean generated = (item != null);
if (!generated) {
if (PathMaskChecker.checkMask(store, path)) {
for (final ArtifactStore member : members) {
try {
item = doRetrieve(member, path, eventMetadata);
} catch (IndyWorkflowException e) {
logger.error("Failed to retrieve artifact from for path {} from {} in group {}, error is: {}", path, member, store, e.getMessage());
}
if (item != null) {
// get the item from the first member store
break;
}
}
}
}
} else {
item = doRetrieve(store, path, eventMetadata);
}
if (item != null) {
logger.info("Returning transfer {} from {}", item, store.getKey());
} else {
logger.trace("Not found path {} from {}", path, store.getKey());
}
return item;
}
use of org.commonjava.indy.model.core.Group in project indy by Commonjava.
the class DefaultContentManager method clearNFCEntries.
@Measure
protected void clearNFCEntries(final KeyedLocation kl, final String path, EventMetadata eventMetadata) {
try {
Set<Group> groups = storeManager.affectedBy(Arrays.asList(kl.getKey()), eventMetadata);
groups.stream().map((g) -> new ConcreteResource(LocationUtils.toLocation(g), path)).forEach((cr) -> nfc.clearMissing(cr));
nfc.clearMissing(new ConcreteResource(kl, path));
} catch (IndyDataException e) {
logger.error(String.format("Failed to clear NFC entries affected by upload of: %s to: %s. Reason: %s", path, kl.getKey(), e.getMessage()), e);
}
}
use of org.commonjava.indy.model.core.Group in project indy by Commonjava.
the class DefaultContentManager method exists.
@Override
@Measure
public // TODO: to add content generation handling here, for things like merged metadata, checksum files, etc.
boolean exists(ArtifactStore store, String path) throws IndyWorkflowException {
Logger logger = LoggerFactory.getLogger(getClass());
logger.trace("Checking existence of: {} in: {}", path, store.getKey());
if (store instanceof Group) {
List<ArtifactStore> members = getOrderedConcreteStoresAndFilter((Group) store, path);
logger.trace("Trying to retrieve suitable transfer for: {} in group: {}", path, store.getName());
logger.trace("Members in group {}: {}", store.getName(), members);
for (ArtifactStore member : members) {
if (exists(member, path)) {
return true;
}
}
return false;
} else {
return downloadManager.exists(store, path);
}
}
Aggregations