use of io.atlasmap.api.AtlasSession in project atlasmap by atlasmap.
the class ConcurrencyChaosMonkeyTest method chaosMonkeyTestManyThreads.
// many threads, one context
@Test
public void chaosMonkeyTestManyThreads() throws Exception {
long startTime = System.nanoTime();
URI mappingURI = generateMappingURI();
Status twitterStatus = generateTwitterStatus();
AtlasContext context = atlasContextFactory.createContext(mappingURI);
for (int i = 0; i < 256; i++) {
Thread chaosMonkeyThread = new Thread("ChaosMonkeyThread-" + i) {
public void run() {
LOG.info(this.getName() + " starting.");
for (int j = 0; j < 100000; j++) {
try {
AtlasSession session = context.createSession();
session.setDefaultSourceDocument(twitterStatus);
context.process(session);
Random rand = new Random(System.currentTimeMillis() % 13);
int randSleep;
randSleep = rand.nextInt(20000);
Thread.sleep(randSleep);
context.process(session);
Thread.sleep(randSleep);
} catch (Throwable e) {
LOG.error("ERROR", e);
}
}
LOG.info(this.getName() + " thread completed.");
}
};
chaosMonkeyThread.start();
}
Thread.sleep(600000L);
long difference = System.nanoTime() - startTime;
LOG.info(String.format("Total time: %d minutes to process 100000 mappings with one context shared with 256 threads", TimeUnit.NANOSECONDS.toMinutes(difference)));
}
use of io.atlasmap.api.AtlasSession in project atlasmap by atlasmap.
the class ConcurrencyChaosMonkeyTest method chaosMonkeyTestManyContexts.
// one thread, many contexts
@Test
public void chaosMonkeyTestManyContexts() throws Exception {
long startTime = System.nanoTime();
URI mappingURI = generateMappingURI();
Status twitterStatus = generateTwitterStatus();
for (int i = 0; i < 256; i++) {
Thread chaosMonkeyThread = new Thread("ChaosMonkeyThread-" + i) {
public void run() {
LOG.info(this.getName() + " starting.");
for (int j = 0; j < 100000; j++) {
try {
AtlasContext context = atlasContextFactory.createContext(mappingURI);
AtlasSession session = context.createSession();
session.setDefaultSourceDocument(twitterStatus);
context.process(session);
Random rand = new Random(System.currentTimeMillis() % 13);
int randSleep;
randSleep = rand.nextInt(20000);
Thread.sleep(randSleep);
context.process(session);
Thread.sleep(randSleep);
} catch (Throwable e) {
LOG.error("ERROR", e);
}
}
LOG.info(this.getName() + " thread completed.");
}
};
chaosMonkeyThread.start();
}
Thread.sleep(600000L);
long difference = System.nanoTime() - startTime;
LOG.info(String.format("Total time: %d minutes to process 100000 mappings with one context per execution", TimeUnit.NANOSECONDS.toMinutes(difference)));
}
use of io.atlasmap.api.AtlasSession in project atlasmap by atlasmap.
the class DefaultAtlasContextTest method testProcessAtlasExceptionOtherContext.
@Test(expected = AtlasException.class)
public void testProcessAtlasExceptionOtherContext() throws AtlasException {
AtlasSession session = new DefaultAtlasSession(mapping);
session.setAtlasContext(new DefaultAtlasContext(DefaultAtlasContextFactory.getInstance(), mapping));
context.process(session);
}
use of io.atlasmap.api.AtlasSession in project atlasmap by atlasmap.
the class DefaultAtlasContextTest method testProcessValidationAtlasException.
@Test(expected = AtlasException.class)
public void testProcessValidationAtlasException() throws AtlasException {
File file = Paths.get("src" + File.separator + "test" + File.separator + "resources" + File.separator + "atlasmapping.xml").toFile();
DefaultAtlasContextFactory factory = new DefaultAtlasContextFactory();
factory.init();
DefaultAtlasContext context = new DefaultAtlasContext(factory, file.toURI());
context.init();
AtlasSession mockAtlasSession = mock(AtlasSession.class);
context.processValidation(mockAtlasSession);
}
use of io.atlasmap.api.AtlasSession in project atlasmap by atlasmap.
the class JavaJavaFlatMappingTest method testProcessJavaJavaFlatFieldMappingPrimitivesBoxedValues.
@Test
public void testProcessJavaJavaFlatFieldMappingPrimitivesBoxedValues() throws Exception {
AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/javaToJava/atlasmapping-flatprimitive.xml").toURI());
AtlasSession session = context.createSession();
BaseFlatPrimitiveClass sourceClass = generateFlatPrimitiveClassPrimitiveFieldsBoxedValues(SourceFlatPrimitiveClass.class);
session.setDefaultSourceDocument(sourceClass);
context.process(session);
Object object = session.getDefaultTargetDocument();
assertNotNull(object);
assertTrue(object instanceof TargetFlatPrimitiveClass);
validateFlatPrimitiveClassPrimitiveFields((TargetFlatPrimitiveClass) object);
Validations validations = session.getValidations();
for (Validation v : validations.getValidation()) {
printValidation(v);
}
}
Aggregations