Search in sources :

Example 6 with DefaultIndyConfiguration

use of org.commonjava.indy.conf.DefaultIndyConfiguration in project indy by Commonjava.

the class ExpiringMemoryNotFoundCacheTest method expireUsingConfiguredValue_DirectCheckDoesntAffectAggregateChecks.

@Test
public void expireUsingConfiguredValue_DirectCheckDoesntAffectAggregateChecks() 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));
    Set<String> locMissing = nfc.getMissing(res.getLocation());
    assertThat(locMissing == null || locMissing.isEmpty(), equalTo(true));
    Map<Location, Set<String>> allMissing = nfc.getAllMissing();
    assertThat(allMissing == null || allMissing.isEmpty(), equalTo(true));
    assertThat(nfc.isMissing(res), equalTo(false));
    locMissing = nfc.getMissing(res.getLocation());
    assertThat(locMissing == null || locMissing.isEmpty(), equalTo(true));
    allMissing = nfc.getAllMissing();
    assertThat(allMissing == null || allMissing.isEmpty(), equalTo(true));
}
Also used : Set(java.util.Set) ConcreteResource(org.commonjava.maven.galley.model.ConcreteResource) SimpleLocation(org.commonjava.maven.galley.model.SimpleLocation) DefaultIndyConfiguration(org.commonjava.indy.conf.DefaultIndyConfiguration) SimpleLocation(org.commonjava.maven.galley.model.SimpleLocation) Location(org.commonjava.maven.galley.model.Location) Test(org.junit.Test)

Example 7 with DefaultIndyConfiguration

use of org.commonjava.indy.conf.DefaultIndyConfiguration in project indy by Commonjava.

the class LegacyDataMigrationActionTest method setup.

@Before
public void setup() throws Exception {
    dfm = new DataFileManager(temp.newFolder("stores"), new DataFileEventManager());
    IndyObjectMapper mapper = new IndyObjectMapper(true);
    final StoreEventDispatcher sed = new StoreEventDispatcherStub();
    action = new LegacyDataMigrationAction(dfm, new DataFileStoreDataManager(dfm, mapper, sed, new DefaultIndyConfiguration()), mapper);
}
Also used : StoreEventDispatcher(org.commonjava.indy.data.StoreEventDispatcher) IndyObjectMapper(org.commonjava.indy.model.core.io.IndyObjectMapper) DataFileEventManager(org.commonjava.indy.subsys.datafile.change.DataFileEventManager) DataFileManager(org.commonjava.indy.subsys.datafile.DataFileManager) StoreEventDispatcherStub(org.commonjava.indy.core.data.testutil.StoreEventDispatcherStub) DefaultIndyConfiguration(org.commonjava.indy.conf.DefaultIndyConfiguration) Before(org.junit.Before)

Example 8 with DefaultIndyConfiguration

use of org.commonjava.indy.conf.DefaultIndyConfiguration in project indy by Commonjava.

the class ConcurrencyTest method deadlockOnListAllDuringDelete.

@BMRules(rules = { @BMRule(name = "init rendezvous", targetClass = "MemoryStoreDataManager", targetMethod = "<init>", targetLocation = "ENTRY", action = "createRendezvous($0, 2)"), @BMRule(name = "delete call", targetClass = "MemoryStoreDataManager", targetMethod = "deleteArtifactStore", targetLocation = "EXIT", action = "rendezvous($0); debug(Thread.currentThread().getName() + \": deletion thread proceeding.\")"), @BMRule(name = "streamArtifactStores call", targetClass = "MemoryStoreDataManager", targetMethod = "streamArtifactStores", targetLocation = "ENTRY", action = "rendezvous($0); debug(Thread.currentThread().getName() + \": streamArtifactStores() thread proceeding.\")") })
@Test
public void deadlockOnListAllDuringDelete() throws IndyDataException, InterruptedException, ExecutionException {
    ExecutorService executor = Executors.newFixedThreadPool(2);
    ExecutorCompletionService<String> completionService = new ExecutorCompletionService<>(executor);
    RemoteRepository repo = new RemoteRepository(MAVEN_PKG_KEY, "central", "http://repo.maven.apache.org/maven2");
    TestDeletingEventDispatcher dispatcher = new TestDeletingEventDispatcher(completionService);
    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());
    dataManager.deleteArtifactStore(repo.getKey(), new ChangeSummary(ChangeSummary.SYSTEM_USER, "Test deletion"), new EventMetadata());
    Future<String> future = completionService.take();
    assertThat(future.get(), nullValue());
}
Also used : ExecutorService(java.util.concurrent.ExecutorService) ExecutorCompletionService(java.util.concurrent.ExecutorCompletionService) RemoteRepository(org.commonjava.indy.model.core.RemoteRepository) ChangeSummary(org.commonjava.indy.audit.ChangeSummary) DefaultIndyConfiguration(org.commonjava.indy.conf.DefaultIndyConfiguration) EventMetadata(org.commonjava.maven.galley.event.EventMetadata) Test(org.junit.Test) BMRules(org.jboss.byteman.contrib.bmunit.BMRules)

Aggregations

DefaultIndyConfiguration (org.commonjava.indy.conf.DefaultIndyConfiguration)8 Test (org.junit.Test)4 IndyObjectMapper (org.commonjava.indy.model.core.io.IndyObjectMapper)3 DataFileManager (org.commonjava.indy.subsys.datafile.DataFileManager)3 DataFileConfiguration (org.commonjava.indy.subsys.datafile.conf.DataFileConfiguration)3 IOException (java.io.IOException)2 Set (java.util.Set)2 ExecutorCompletionService (java.util.concurrent.ExecutorCompletionService)2 ExecutorService (java.util.concurrent.ExecutorService)2 PostConstruct (javax.annotation.PostConstruct)2 ChangeSummary (org.commonjava.indy.audit.ChangeSummary)2 StoreEventDispatcherStub (org.commonjava.indy.core.data.testutil.StoreEventDispatcherStub)2 RemoteRepository (org.commonjava.indy.model.core.RemoteRepository)2 DataFileEventManager (org.commonjava.indy.subsys.datafile.change.DataFileEventManager)2 EventMetadata (org.commonjava.maven.galley.event.EventMetadata)2 StandardTypeMapper (org.commonjava.maven.galley.maven.internal.type.StandardTypeMapper)2 XMLInfrastructure (org.commonjava.maven.galley.maven.parse.XMLInfrastructure)2 ConcreteResource (org.commonjava.maven.galley.model.ConcreteResource)2 Location (org.commonjava.maven.galley.model.Location)2 SimpleLocation (org.commonjava.maven.galley.model.SimpleLocation)2