Search in sources :

Example 76 with ModuleAssembly

use of org.qi4j.bootstrap.ModuleAssembly in project qi4j-sdk by Qi4j.

the class AbstractEntityStorePerformanceTest method warmup.

@Before
public void warmup() throws Exception {
    try {
        Assembler assembler = new Assembler() {

            @Override
            public void assemble(ModuleAssembly module) throws AssemblyException {
                module.entities(SimpleProduct.class);
            }
        };
        createQi4jRuntime(assembler);
        for (int i = 0; i < 10000; i++) {
            try (UnitOfWork uow = module.newUnitOfWork(newUsecase("Warmup " + i))) {
                SimpleProduct product = uow.newEntity(SimpleProduct.class);
                String id = product.identity().get();
            }
        }
    } catch (Exception ex) {
        logger.error("Unable to warmup: {}", ex.getMessage(), ex);
        throw ex;
    } finally {
        cleanUp();
    }
}
Also used : ModuleAssembly(org.qi4j.bootstrap.ModuleAssembly) UnitOfWork(org.qi4j.api.unitofwork.UnitOfWork) Assembler(org.qi4j.bootstrap.Assembler) IOException(java.io.IOException) AssemblyException(org.qi4j.bootstrap.AssemblyException) Before(org.junit.Before)

Example 77 with ModuleAssembly

use of org.qi4j.bootstrap.ModuleAssembly in project qi4j-sdk by Qi4j.

the class JdbmEntityStorePerformanceTest method createAssembler.

private static Assembler createAssembler() {
    return new Assembler() {

        @Override
        public void assemble(ModuleAssembly module) throws AssemblyException {
            new JdbmEntityStoreAssembler().assemble(module);
            new OrgJsonValueSerializationAssembler().assemble(module);
            ModuleAssembly configModule = module.layer().module("Config");
            configModule.entities(JdbmConfiguration.class).visibleIn(Visibility.layer);
            new EntityTestAssembler().assemble(configModule);
            module.services(EhCachePoolService.class);
            configModule.entities(EhCacheConfiguration.class).visibleIn(Visibility.layer);
        }
    };
}
Also used : ModuleAssembly(org.qi4j.bootstrap.ModuleAssembly) JdbmConfiguration(org.qi4j.entitystore.jdbm.JdbmConfiguration) EntityTestAssembler(org.qi4j.test.EntityTestAssembler) EhCacheConfiguration(org.qi4j.cache.ehcache.EhCacheConfiguration) JdbmEntityStoreAssembler(org.qi4j.entitystore.jdbm.assembly.JdbmEntityStoreAssembler) Assembler(org.qi4j.bootstrap.Assembler) EntityTestAssembler(org.qi4j.test.EntityTestAssembler) OrgJsonValueSerializationAssembler(org.qi4j.valueserialization.orgjson.OrgJsonValueSerializationAssembler) JdbmEntityStoreAssembler(org.qi4j.entitystore.jdbm.assembly.JdbmEntityStoreAssembler) OrgJsonValueSerializationAssembler(org.qi4j.valueserialization.orgjson.OrgJsonValueSerializationAssembler)

Example 78 with ModuleAssembly

use of org.qi4j.bootstrap.ModuleAssembly in project qi4j-sdk by Qi4j.

the class MemoryEntityStorePerformanceTest method createAssembler.

private static Assembler createAssembler() {
    return new Assembler() {

        @Override
        public void assemble(ModuleAssembly module) throws AssemblyException {
            new MemoryEntityStoreAssembler().assemble(module);
            new OrgJsonValueSerializationAssembler().assemble(module);
        }
    };
}
Also used : ModuleAssembly(org.qi4j.bootstrap.ModuleAssembly) MemoryEntityStoreAssembler(org.qi4j.entitystore.memory.MemoryEntityStoreAssembler) MemoryEntityStoreAssembler(org.qi4j.entitystore.memory.MemoryEntityStoreAssembler) OrgJsonValueSerializationAssembler(org.qi4j.valueserialization.orgjson.OrgJsonValueSerializationAssembler) Assembler(org.qi4j.bootstrap.Assembler) OrgJsonValueSerializationAssembler(org.qi4j.valueserialization.orgjson.OrgJsonValueSerializationAssembler)

Example 79 with ModuleAssembly

use of org.qi4j.bootstrap.ModuleAssembly in project qi4j-sdk by Qi4j.

the class DerbySQLEntityStorePerformanceTest method createAssembler.

private static Assembler createAssembler() {
    return new Assembler() {

        @Override
        public void assemble(ModuleAssembly module) throws AssemblyException {
            ModuleAssembly config = module.layer().module("config");
            new EntityTestAssembler().assemble(config);
            new OrgJsonValueSerializationAssembler().assemble(module);
            // DataSourceService
            new DBCPDataSourceServiceAssembler().identifiedBy("derby-datasource-service").visibleIn(Visibility.module).withConfig(config, Visibility.layer).assemble(module);
            // DataSource
            new DataSourceAssembler().withDataSourceServiceIdentity("derby-datasource-service").identifiedBy("derby-datasource").withCircuitBreaker().assemble(module);
            // SQL EntityStore
            new DerbySQLEntityStoreAssembler().withConfig(config, Visibility.layer).assemble(module);
        }
    };
}
Also used : ModuleAssembly(org.qi4j.bootstrap.ModuleAssembly) DataSourceAssembler(org.qi4j.library.sql.assembly.DataSourceAssembler) EntityTestAssembler(org.qi4j.test.EntityTestAssembler) DBCPDataSourceServiceAssembler(org.qi4j.library.sql.dbcp.DBCPDataSourceServiceAssembler) DBCPDataSourceServiceAssembler(org.qi4j.library.sql.dbcp.DBCPDataSourceServiceAssembler) DerbySQLEntityStoreAssembler(org.qi4j.entitystore.sql.assembly.DerbySQLEntityStoreAssembler) Assembler(org.qi4j.bootstrap.Assembler) DataSourceAssembler(org.qi4j.library.sql.assembly.DataSourceAssembler) EntityTestAssembler(org.qi4j.test.EntityTestAssembler) OrgJsonValueSerializationAssembler(org.qi4j.valueserialization.orgjson.OrgJsonValueSerializationAssembler) DerbySQLEntityStoreAssembler(org.qi4j.entitystore.sql.assembly.DerbySQLEntityStoreAssembler) OrgJsonValueSerializationAssembler(org.qi4j.valueserialization.orgjson.OrgJsonValueSerializationAssembler)

Example 80 with ModuleAssembly

use of org.qi4j.bootstrap.ModuleAssembly in project qi4j-sdk by Qi4j.

the class AbstractEntityStorePerformanceTest method whenCreateEntityWithSinglePropertyThenRecordIterationsPerSecond.

@Test
public void whenCreateEntityWithSinglePropertyThenRecordIterationsPerSecond() throws Exception {
    try {
        Assembler assembler = new Assembler() {

            @Override
            public void assemble(ModuleAssembly module) throws AssemblyException {
                module.entities(SimpleProduct.class);
            }
        };
        createQi4jRuntime(assembler);
        profile(new Callable<Void>() {

            @Override
            public Void call() throws Exception {
                Report report = new Report(storeName);
                report.start("createEntityWithSingleProperty");
                for (int i = 0; i < ITERATIONS; i++) {
                    try (UnitOfWork uow = module.newUnitOfWork(newUsecase("createEntityWithSingleProperty " + i))) {
                        SimpleProduct product = uow.newEntity(SimpleProduct.class);
                        String id = product.identity().get();
                        uow.complete();
                    }
                    if (i % 1000 == 0) {
                        logger.info("Iteration {}", i);
                    }
                }
                report.stop(ITERATIONS);
                writeReport(report);
                return null;
            }
        });
    } finally {
        cleanUp();
    }
}
Also used : ModuleAssembly(org.qi4j.bootstrap.ModuleAssembly) UnitOfWork(org.qi4j.api.unitofwork.UnitOfWork) Assembler(org.qi4j.bootstrap.Assembler) IOException(java.io.IOException) AssemblyException(org.qi4j.bootstrap.AssemblyException) Test(org.junit.Test)

Aggregations

ModuleAssembly (org.qi4j.bootstrap.ModuleAssembly)191 SingletonAssembler (org.qi4j.bootstrap.SingletonAssembler)87 Test (org.junit.Test)82 EntityTestAssembler (org.qi4j.test.EntityTestAssembler)59 AssemblyException (org.qi4j.bootstrap.AssemblyException)27 Application (org.qi4j.api.structure.Application)26 OrgJsonValueSerializationAssembler (org.qi4j.valueserialization.orgjson.OrgJsonValueSerializationAssembler)24 Assembler (org.qi4j.bootstrap.Assembler)23 Module (org.qi4j.api.structure.Module)19 LayerAssembly (org.qi4j.bootstrap.LayerAssembly)15 Before (org.junit.Before)12 UnitOfWork (org.qi4j.api.unitofwork.UnitOfWork)12 Energy4Java (org.qi4j.bootstrap.Energy4Java)12 DataSourceAssembler (org.qi4j.library.sql.assembly.DataSourceAssembler)11 DBCPDataSourceServiceAssembler (org.qi4j.library.sql.dbcp.DBCPDataSourceServiceAssembler)9 IOException (java.io.IOException)8 ApplicationAssemblerAdapter (org.qi4j.bootstrap.ApplicationAssemblerAdapter)8 ApplicationAssembly (org.qi4j.bootstrap.ApplicationAssembly)8 File (java.io.File)7 OrgJsonValueSerializationService (org.qi4j.valueserialization.orgjson.OrgJsonValueSerializationService)7