Search in sources :

Example 6 with CommonPublicationData2

use of io.codekvast.javaagent.model.v2.CommonPublicationData2 in project codekvast by crispab.

the class ImportDAOImpl method ensureInitialInvocations.

private void ensureInitialInvocations(CommonPublicationData2 data, long customerId, long appId, long environmentId, long jvmId, Collection<CodeBaseEntry2> entries, Map<String, Long> existingMethods, Set<Long> existingInvocations) {
    long startedAtMillis = System.currentTimeMillis();
    int importCount = 0;
    for (CodeBaseEntry2 entry : entries) {
        long methodId = existingMethods.get(entry.getSignature());
        if (!existingInvocations.contains(methodId)) {
            SignatureStatus2 initialStatus = calculateInitialStatus(data, entry);
            jdbcTemplate.update(new InsertInvocationStatement(customerId, appId, environmentId, jvmId, methodId, initialStatus, 0L, 0L));
            existingInvocations.add(methodId);
            importCount += 1;
        }
    }
    logger.debug("Imported {} invocations in {} ms", importCount, System.currentTimeMillis() - startedAtMillis);
}
Also used : SignatureStatus2(io.codekvast.javaagent.model.v2.SignatureStatus2) CodeBaseEntry2(io.codekvast.javaagent.model.v2.CodeBaseEntry2)

Example 7 with CommonPublicationData2

use of io.codekvast.javaagent.model.v2.CommonPublicationData2 in project codekvast by crispab.

the class CodeBasePublication2Test method should_transform_from_v1_format.

@SuppressWarnings("deprecation")
@Test
public void should_transform_from_v1_format() {
    CodeBasePublication pub1 = CodeBasePublication.builder().commonData(CommonPublicationData.sampleCommonPublicationData()).entries(Collections.singletonList(CodeBaseEntry.sampleCodeBaseEntry())).overriddenSignatures(Collections.singletonMap("key1", "value1")).strangeSignatures(Collections.singletonMap("key2", "value2")).build();
    CodeBasePublication2 pub2 = CodeBasePublication2.fromV1Format(pub1);
    assertThat(pub2.getCommonData(), is(CommonPublicationData2.sampleCommonPublicationData()));
    assertThat(pub2.getEntries(), hasItems(CodeBaseEntry2.sampleCodeBaseEntry()));
}
Also used : CodeBasePublication2(io.codekvast.javaagent.model.v2.CodeBasePublication2) CodeBasePublication(io.codekvast.javaagent.model.v1.CodeBasePublication) Test(org.junit.Test)

Example 8 with CommonPublicationData2

use of io.codekvast.javaagent.model.v2.CommonPublicationData2 in project codekvast by crispab.

the class CommonPublicationData2Test method should_transform_from_v1_format.

@SuppressWarnings("deprecation")
@Test
public void should_transform_from_v1_format() {
    CommonPublicationData cd1 = CommonPublicationData.sampleCommonPublicationData();
    CommonPublicationData2 cd2 = CommonPublicationData2.sampleCommonPublicationData();
    assertThat(CommonPublicationData2.fromV1format(cd1), is(cd2));
}
Also used : CommonPublicationData(io.codekvast.javaagent.model.v1.CommonPublicationData) CommonPublicationData2(io.codekvast.javaagent.model.v2.CommonPublicationData2) Test(org.junit.Test)

Example 9 with CommonPublicationData2

use of io.codekvast.javaagent.model.v2.CommonPublicationData2 in project codekvast by crispab.

the class InvocationDataImporterImpl method importPublication.

@Override
@Transactional(rollbackFor = Exception.class)
public boolean importPublication(InvocationDataPublication2 publication) {
    logger.info("Importing {}", publication);
    CommonPublicationData2 commonData = publication.getCommonData();
    long customerId = commonData.getCustomerId();
    long appId = importDAO.importApplication(commonData);
    long environmentId = importDAO.importEnvironment(commonData);
    long jvmId = importDAO.importJvm(commonData, appId, environmentId);
    importDAO.importInvocations(customerId, appId, environmentId, jvmId, publication.getRecordingIntervalStartedAtMillis(), new TreeSet<>(publication.getInvocations()));
    return true;
}
Also used : CommonPublicationData2(io.codekvast.javaagent.model.v2.CommonPublicationData2) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

Test (org.junit.Test)6 CommonPublicationData2 (io.codekvast.javaagent.model.v2.CommonPublicationData2)5 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)4 InvocationDataPublication2 (io.codekvast.javaagent.model.v2.InvocationDataPublication2)3 CodeBaseEntry2 (io.codekvast.javaagent.model.v2.CodeBaseEntry2)2 CodeBasePublication2 (io.codekvast.javaagent.model.v2.CodeBasePublication2)2 CodeBaseEntry3 (io.codekvast.javaagent.model.v3.CodeBaseEntry3)2 CodeBasePublication3 (io.codekvast.javaagent.model.v3.CodeBasePublication3)2 Transactional (org.springframework.transaction.annotation.Transactional)2 CodeBasePublication (io.codekvast.javaagent.model.v1.CodeBasePublication)1 CommonPublicationData (io.codekvast.javaagent.model.v1.CommonPublicationData)1 SignatureStatus2 (io.codekvast.javaagent.model.v2.SignatureStatus2)1 File (java.io.File)1 HashSet (java.util.HashSet)1 lombok.val (lombok.val)1