Search in sources :

Example 1 with DefaultIndyConfiguration

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));
}
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 2 with DefaultIndyConfiguration

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());
    }
}
Also used : Group(org.commonjava.indy.model.core.Group) ExecutorCompletionService(java.util.concurrent.ExecutorCompletionService) RemoteRepository(org.commonjava.indy.model.core.RemoteRepository) EventMetadata(org.commonjava.maven.galley.event.EventMetadata) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ExecutorService(java.util.concurrent.ExecutorService) ChangeSummary(org.commonjava.indy.audit.ChangeSummary) DefaultIndyConfiguration(org.commonjava.indy.conf.DefaultIndyConfiguration) Test(org.junit.Test) BMRules(org.jboss.byteman.contrib.bmunit.BMRules)

Example 3 with DefaultIndyConfiguration

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);
}
Also used : DefaultStorageProviderConfiguration(org.commonjava.indy.filer.def.conf.DefaultStorageProviderConfiguration) IndyObjectMapper(org.commonjava.indy.model.core.io.IndyObjectMapper) DataFileConfiguration(org.commonjava.indy.subsys.datafile.conf.DataFileConfiguration) XMLInfrastructure(org.commonjava.maven.galley.maven.parse.XMLInfrastructure) MemoryNotFoundCache(org.commonjava.maven.galley.nfc.MemoryNotFoundCache) IOException(java.io.IOException) StandardTypeMapper(org.commonjava.maven.galley.maven.internal.type.StandardTypeMapper) DefaultIndyConfiguration(org.commonjava.indy.conf.DefaultIndyConfiguration) PostConstruct(javax.annotation.PostConstruct)

Example 4 with DefaultIndyConfiguration

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 {
    }
}
Also used : DataFileStoreDataManager(org.commonjava.indy.flat.data.DataFileStoreDataManager) DataFileManager(org.commonjava.indy.subsys.datafile.DataFileManager) DataFileConfiguration(org.commonjava.indy.subsys.datafile.conf.DataFileConfiguration) XMLInfrastructure(org.commonjava.maven.galley.maven.parse.XMLInfrastructure) MemoryNotFoundCache(org.commonjava.maven.galley.nfc.MemoryNotFoundCache) IOException(java.io.IOException) DefaultIndyConfiguration(org.commonjava.indy.conf.DefaultIndyConfiguration) StandardTypeMapper(org.commonjava.maven.galley.maven.internal.type.StandardTypeMapper) PostConstruct(javax.annotation.PostConstruct)

Example 5 with DefaultIndyConfiguration

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());
}
Also used : IndyObjectMapper(org.commonjava.indy.model.core.io.IndyObjectMapper) DataFileEventManager(org.commonjava.indy.subsys.datafile.change.DataFileEventManager) DataFileManager(org.commonjava.indy.subsys.datafile.DataFileManager) DataFileConfiguration(org.commonjava.indy.subsys.datafile.conf.DataFileConfiguration) StoreEventDispatcherStub(org.commonjava.indy.core.data.testutil.StoreEventDispatcherStub) DefaultIndyConfiguration(org.commonjava.indy.conf.DefaultIndyConfiguration) Before(org.junit.Before)

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