use of org.commonjava.indy.conf.DefaultIndyConfiguration in project indy by Commonjava.
the class ExpiringMemoryNotFoundCacheTest method expireUsingConfiguredValue.
@Test
public void expireUsingConfiguredValue() throws Exception {
final DefaultIndyConfiguration config = new DefaultIndyConfiguration();
config.setNotFoundCacheTimeoutSeconds(1);
final ExpiringMemoryNotFoundCache nfc = new ExpiringMemoryNotFoundCache(config);
final ConcreteResource res = new ConcreteResource(new SimpleLocation("test:uri"), "/path/to/expired/object");
nfc.addMissing(res);
assertThat(nfc.isMissing(res), equalTo(true));
Thread.sleep(TimeUnit.SECONDS.toMillis(1));
assertThat(nfc.isMissing(res), equalTo(false));
final Set<String> locMissing = nfc.getMissing(res.getLocation());
assertThat(locMissing == null || locMissing.isEmpty(), equalTo(true));
final Map<Location, Set<String>> allMissing = nfc.getAllMissing();
assertThat(allMissing == null || allMissing.isEmpty(), equalTo(true));
}
use of org.commonjava.indy.conf.DefaultIndyConfiguration in project indy by Commonjava.
the class ConcurrencyTest method deadlockOnGroupContains.
@BMRules(rules = { @BMRule(name = "init rendezvous", targetClass = "MemoryStoreDataManager", targetMethod = "<init>", targetLocation = "ENTRY", action = "createRendezvous($0, 2, true)"), @BMRule(name = "getGroupsContaining call", targetClass = "MemoryStoreDataManager", targetMethod = "getGroupsContaining", targetLocation = "ENTRY", action = "rendezvous($0); debug(Thread.currentThread().getName() + \": thread proceeding.\")") })
@Test
public void deadlockOnGroupContains() throws IndyDataException, InterruptedException, ExecutionException {
ExecutorService executor = Executors.newFixedThreadPool(2);
ExecutorCompletionService<String> completionService = new ExecutorCompletionService<>(executor);
AtomicInteger count = new AtomicInteger(0);
RemoteRepository repo = new RemoteRepository(MAVEN_PKG_KEY, "central", "http://repo.maven.apache.org/maven2");
TestUpdatingEventDispatcher dispatcher = new TestUpdatingEventDispatcher(repo, completionService, count);
MemoryStoreDataManager dataManager = new MemoryStoreDataManager(dispatcher, new DefaultIndyConfiguration());
dispatcher.setDataManager(dataManager);
ChangeSummary summary = new ChangeSummary(ChangeSummary.SYSTEM_USER, "Test init");
dataManager.storeArtifactStore(repo, summary, false, false, new EventMetadata());
for (int i = 0; i < 2; i++) {
Group group = new Group(MAVEN_PKG_KEY, "group" + i);
if (i % 2 == 0) {
group.addConstituent(repo);
}
dataManager.storeArtifactStore(group, summary, false, false, new EventMetadata());
}
for (int i = 0; i < count.get(); i++) {
Future<String> future = completionService.take();
assertThat(future.get(), nullValue());
}
}
use of org.commonjava.indy.conf.DefaultIndyConfiguration in project indy by Commonjava.
the class TestProvider method init.
@PostConstruct
public void init() {
try {
this.storageProviderConfig = new DefaultStorageProviderConfiguration(TEMP.newFolder("storage"));
this.dataConfig = new DataFileConfiguration(TEMP.newFolder("data"), TEMP.newFolder("work"));
} catch (final IOException e) {
e.printStackTrace();
Assert.fail("Failed to setup temporary directory structures: " + e.getMessage());
}
this.nfc = new MemoryNotFoundCache();
this.xmlInfra = new XMLInfrastructure();
this.typeMapper = new StandardTypeMapper();
this.indyConfig = new DefaultIndyConfiguration();
this.objectMapper = new IndyObjectMapper(true);
}
use of org.commonjava.indy.conf.DefaultIndyConfiguration in project indy by Commonjava.
the class CoreServerProvider method init.
@PostConstruct
public void init() {
try {
folder.create();
this.nfc = new MemoryNotFoundCache();
this.dataFileManager = new DataFileManager(new DataFileConfiguration(folder.newFolder("indy-data")), dataFileEvents);
this.storeManager = new DataFileStoreDataManager(dataFileManager, objectMapper, storeDispatch, new DefaultIndyConfiguration());
storageConfig.setStorageRootDirectory(folder.newFolder("indy-storage"));
this.xml = new XMLInfrastructure();
this.typeMapper = new StandardTypeMapper();
} catch (IOException e) {
throw new IllegalStateException("Failed to start core server provider: " + e.getMessage(), e);
} finally {
}
}
use of org.commonjava.indy.conf.DefaultIndyConfiguration in project indy by Commonjava.
the class DataFileStoreDataManagerTest method setup.
@Before
public void setup() throws Exception {
fileCfg = new DataFileConfiguration(temp.newFolder("data"), temp.newFolder("work"));
final DataFileManager fileMgr = new DataFileManager(fileCfg, new DataFileEventManager());
mgr = new DataFileStoreDataManager(fileMgr, new IndyObjectMapper(false), new StoreEventDispatcherStub(), new DefaultIndyConfiguration());
}
Aggregations