Search in sources :

Example 1 with DefaultKieCompilationResponse

use of org.kie.workbench.common.services.backend.compiler.impl.DefaultKieCompilationResponse in project kie-wb-common by kiegroup.

the class KieAfterDecorator method handleKieMavenPlugin.

private KieCompilationResponse handleKieMavenPlugin(CompilationRequest req, CompilationResponse res) {
    KieTuple kieModuleMetaInfoTuple = readKieModuleMetaInfo(req);
    KieTuple kieModuleTuple = readKieModule(req);
    if (kieModuleMetaInfoTuple.getOptionalObject().isPresent() && kieModuleTuple.getOptionalObject().isPresent()) {
        AFClassLoaderProvider provider = new ClassLoaderProviderImpl();
        Optional<List<URI>> optionalDeps = provider.getURISFromAllDependencies(req.getInfo().getPrjPath().toAbsolutePath().toString());
        List<URI> uris = Collections.emptyList();
        if (optionalDeps.isPresent()) {
            uris = optionalDeps.get();
        }
        if (req.getKieCliRequest().isLogRequested()) {
            return new DefaultKieCompilationResponse(Boolean.TRUE, (KieModuleMetaInfo) kieModuleMetaInfoTuple.getOptionalObject().get(), (KieModule) kieModuleTuple.getOptionalObject().get(), res.getMavenOutput().get(), uris);
        } else {
            return new DefaultKieCompilationResponse(Boolean.TRUE, (KieModuleMetaInfo) kieModuleMetaInfoTuple.getOptionalObject().get(), (KieModule) kieModuleTuple.getOptionalObject().get(), uris);
        }
    } else {
        StringBuilder sb = new StringBuilder();
        if (kieModuleMetaInfoTuple.getErrorMsg().isPresent()) {
            sb.append(" Error in the kieModuleMetaInfo from the kieMap:").append(kieModuleMetaInfoTuple.getErrorMsg().get());
        }
        if (kieModuleTuple.getErrorMsg().isPresent()) {
            sb.append(" Error in the kieModule:").append(kieModuleTuple.getErrorMsg().get());
        }
        if (req.getKieCliRequest().isLogRequested()) {
            return new DefaultKieCompilationResponse(Boolean.FALSE, sb.toString(), res.getMavenOutput().get());
        } else {
            return new DefaultKieCompilationResponse(Boolean.FALSE, sb.toString());
        }
    }
}
Also used : DefaultKieCompilationResponse(org.kie.workbench.common.services.backend.compiler.impl.DefaultKieCompilationResponse) ClassLoaderProviderImpl(org.kie.workbench.common.services.backend.compiler.nio.impl.ClassLoaderProviderImpl) AFClassLoaderProvider(org.kie.workbench.common.services.backend.compiler.AFClassLoaderProvider) List(java.util.List) URI(java.net.URI)

Example 2 with DefaultKieCompilationResponse

use of org.kie.workbench.common.services.backend.compiler.impl.DefaultKieCompilationResponse in project kie-wb-common by kiegroup.

the class CompilerChronicleCoordinatorTest method offProcessOneBuildTest.

@Test
@Ignore("https://issues.redhat.com/browse/AF-2892")
public void offProcessOneBuildTest() {
    CompilerIPCCoordinator compiler = new CompilerIPCCoordinatorImpl(queueProvider);
    WorkspaceCompilationInfo info = new WorkspaceCompilationInfo(prjPath);
    String uuid = UUID.randomUUID().toString();
    CompilationRequest req = new DefaultCompilationRequest(mavenRepo, info, new String[] { MavenCLIArgs.COMPILE, MavenCLIArgs.ALTERNATE_USER_SETTINGS + alternateSettingsAbsPath }, Boolean.FALSE, uuid);
    CompilationResponse res = compiler.compile(req);
    logger.info("offProcessOneBuildTest first build completed");
    assertThat(res).isNotNull();
    assertThat(res.isSuccessful()).isTrue();
    assertThat(res.getMavenOutput()).isNotEmpty();
    DefaultKieCompilationResponse kres = (DefaultKieCompilationResponse) res;
    assertThat(uuid).isEqualToIgnoringCase(kres.getRequestUUID());
}
Also used : DefaultKieCompilationResponse(org.kie.workbench.common.services.backend.compiler.impl.DefaultKieCompilationResponse) WorkspaceCompilationInfo(org.kie.workbench.common.services.backend.compiler.impl.WorkspaceCompilationInfo) DefaultCompilationRequest(org.kie.workbench.common.services.backend.compiler.impl.DefaultCompilationRequest) CompilationResponse(org.kie.workbench.common.services.backend.compiler.CompilationResponse) DefaultKieCompilationResponse(org.kie.workbench.common.services.backend.compiler.impl.DefaultKieCompilationResponse) CompilationRequest(org.kie.workbench.common.services.backend.compiler.CompilationRequest) DefaultCompilationRequest(org.kie.workbench.common.services.backend.compiler.impl.DefaultCompilationRequest) CompilerIPCCoordinatorImpl(org.kie.workbench.common.services.backend.compiler.offprocess.impl.CompilerIPCCoordinatorImpl) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 3 with DefaultKieCompilationResponse

use of org.kie.workbench.common.services.backend.compiler.impl.DefaultKieCompilationResponse in project kie-wb-common by kiegroup.

the class CompilerChronicleCoordinatorTest method offProcessTwoBuildTest.

@Test
@Ignore("https://issues.redhat.com/browse/AF-2892")
public void offProcessTwoBuildTest() {
    CompilerIPCCoordinator compiler = new CompilerIPCCoordinatorImpl(queueProvider);
    WorkspaceCompilationInfo info = new WorkspaceCompilationInfo(prjPath);
    // First Build
    String uuid = UUID.randomUUID().toString();
    CompilationRequest req = new DefaultCompilationRequest(mavenRepo, info, new String[] { MavenCLIArgs.COMPILE, MavenCLIArgs.ALTERNATE_USER_SETTINGS + alternateSettingsAbsPath }, Boolean.FALSE, uuid);
    CompilationResponse res = compiler.compile(req);
    logger.info("offProcessTwoBuildTest first build completed");
    assertThat(res).isNotNull();
    assertThat(res.isSuccessful()).isTrue();
    assertThat(res.getMavenOutput()).isNotEmpty();
    DefaultKieCompilationResponse kres = (DefaultKieCompilationResponse) res;
    assertThat(uuid).isEqualToIgnoringCase(kres.getRequestUUID());
    // Second Build
    String secondUuid = UUID.randomUUID().toString();
    DefaultCompilationRequest secondRequest = new DefaultCompilationRequest(mavenRepo, info, new String[] { MavenCLIArgs.COMPILE, MavenCLIArgs.ALTERNATE_USER_SETTINGS + alternateSettingsAbsPath }, Boolean.FALSE, secondUuid);
    CompilationResponse secondRes = compiler.compile(secondRequest);
    logger.info("offProcessTwoBuildTest second build completed");
    assertThat(secondRes).isNotNull();
    assertThat(secondRes.isSuccessful()).isTrue();
    DefaultKieCompilationResponse secondKres = (DefaultKieCompilationResponse) secondRes;
    assertThat(secondUuid).isEqualToIgnoringCase(secondKres.getRequestUUID());
}
Also used : DefaultKieCompilationResponse(org.kie.workbench.common.services.backend.compiler.impl.DefaultKieCompilationResponse) WorkspaceCompilationInfo(org.kie.workbench.common.services.backend.compiler.impl.WorkspaceCompilationInfo) DefaultCompilationRequest(org.kie.workbench.common.services.backend.compiler.impl.DefaultCompilationRequest) CompilationResponse(org.kie.workbench.common.services.backend.compiler.CompilationResponse) DefaultKieCompilationResponse(org.kie.workbench.common.services.backend.compiler.impl.DefaultKieCompilationResponse) CompilationRequest(org.kie.workbench.common.services.backend.compiler.CompilationRequest) DefaultCompilationRequest(org.kie.workbench.common.services.backend.compiler.impl.DefaultCompilationRequest) CompilerIPCCoordinatorImpl(org.kie.workbench.common.services.backend.compiler.offprocess.impl.CompilerIPCCoordinatorImpl) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 4 with DefaultKieCompilationResponse

use of org.kie.workbench.common.services.backend.compiler.impl.DefaultKieCompilationResponse in project kie-wb-common by kiegroup.

the class CompilerOffProcessServiceTest method offProcessServiceCompileAsyncTest.

@Test
@Ignore("https://issues.redhat.com/browse/AF-2892")
public void offProcessServiceCompileAsyncTest() throws Exception {
    CompilerOffprocessService service = new CompilerOffprocessServiceImpl(executor, queueProvider);
    WorkspaceCompilationInfo info = new WorkspaceCompilationInfo(prjPath);
    String uuid = UUID.randomUUID().toString();
    CompilationRequest req = new DefaultCompilationRequest(mavenRepo, info, new String[] { MavenCLIArgs.COMPILE, MavenCLIArgs.ALTERNATE_USER_SETTINGS + alternateSettingsAbsPath }, Boolean.FALSE, uuid);
    CompletableFuture<KieCompilationResponse> futureRes = service.compile(req);
    logger.info("offProcessOneBuildAsyncTest build completed");
    KieCompilationResponse res = futureRes.get();
    assertThat(res).isNotNull();
    assertThat(res.isSuccessful()).isTrue();
    assertThat(res.getMavenOutput()).isNotEmpty();
    DefaultKieCompilationResponse kres = (DefaultKieCompilationResponse) res;
    assertThat(uuid).isEqualToIgnoringCase(kres.getRequestUUID());
}
Also used : DefaultKieCompilationResponse(org.kie.workbench.common.services.backend.compiler.impl.DefaultKieCompilationResponse) WorkspaceCompilationInfo(org.kie.workbench.common.services.backend.compiler.impl.WorkspaceCompilationInfo) DefaultCompilationRequest(org.kie.workbench.common.services.backend.compiler.impl.DefaultCompilationRequest) CompilerOffprocessServiceImpl(org.kie.workbench.common.services.backend.compiler.offprocess.service.impl.CompilerOffprocessServiceImpl) CompilationRequest(org.kie.workbench.common.services.backend.compiler.CompilationRequest) DefaultCompilationRequest(org.kie.workbench.common.services.backend.compiler.impl.DefaultCompilationRequest) KieCompilationResponse(org.kie.workbench.common.services.backend.compiler.impl.kie.KieCompilationResponse) DefaultKieCompilationResponse(org.kie.workbench.common.services.backend.compiler.impl.DefaultKieCompilationResponse) Ignore(org.junit.Ignore) CompilerChronicleCoordinatorTest(org.kie.workbench.common.services.backend.compiler.offprocess.CompilerChronicleCoordinatorTest) Test(org.junit.Test)

Example 5 with DefaultKieCompilationResponse

use of org.kie.workbench.common.services.backend.compiler.impl.DefaultKieCompilationResponse in project kie-wb-common by kiegroup.

the class ClientIPCImpl method isLoaded.

private boolean isLoaded(String uuid) {
    ExcerptTailer tailer = provider.getQueue().createTailer();
    DefaultKieCompilationResponseOffProcess res = readThisDocument(tailer);
    DefaultKieCompilationResponse kres = new DefaultKieCompilationResponse(res);
    if (uuid.equals(kres.getRequestUUID())) {
        if (!map.contains(kres.getRequestUUID())) {
            map.addResponse(uuid, kres);
            return true;
        }
    } else {
        // we loop in the queue to find our Response by UUID, from the tail of the queue backward
        tailer.toEnd();
        tailer.direction(TailerDirection.BACKWARD);
        res = loopOverQueue(tailer, uuid, 0l);
    }
    kres = new DefaultKieCompilationResponse(res);
    if (!map.contains(kres.getRequestUUID())) {
        map.addResponse(uuid, new DefaultKieCompilationResponse(res));
        return true;
    } else {
        return false;
    }
}
Also used : DefaultKieCompilationResponse(org.kie.workbench.common.services.backend.compiler.impl.DefaultKieCompilationResponse) DefaultKieCompilationResponseOffProcess(org.kie.workbench.common.services.backend.compiler.impl.DefaultKieCompilationResponseOffProcess) ExcerptTailer(net.openhft.chronicle.queue.ExcerptTailer)

Aggregations

DefaultKieCompilationResponse (org.kie.workbench.common.services.backend.compiler.impl.DefaultKieCompilationResponse)5 Ignore (org.junit.Ignore)3 Test (org.junit.Test)3 CompilationRequest (org.kie.workbench.common.services.backend.compiler.CompilationRequest)3 DefaultCompilationRequest (org.kie.workbench.common.services.backend.compiler.impl.DefaultCompilationRequest)3 WorkspaceCompilationInfo (org.kie.workbench.common.services.backend.compiler.impl.WorkspaceCompilationInfo)3 CompilationResponse (org.kie.workbench.common.services.backend.compiler.CompilationResponse)2 CompilerIPCCoordinatorImpl (org.kie.workbench.common.services.backend.compiler.offprocess.impl.CompilerIPCCoordinatorImpl)2 URI (java.net.URI)1 List (java.util.List)1 ExcerptTailer (net.openhft.chronicle.queue.ExcerptTailer)1 AFClassLoaderProvider (org.kie.workbench.common.services.backend.compiler.AFClassLoaderProvider)1 DefaultKieCompilationResponseOffProcess (org.kie.workbench.common.services.backend.compiler.impl.DefaultKieCompilationResponseOffProcess)1 KieCompilationResponse (org.kie.workbench.common.services.backend.compiler.impl.kie.KieCompilationResponse)1 ClassLoaderProviderImpl (org.kie.workbench.common.services.backend.compiler.nio.impl.ClassLoaderProviderImpl)1 CompilerChronicleCoordinatorTest (org.kie.workbench.common.services.backend.compiler.offprocess.CompilerChronicleCoordinatorTest)1 CompilerOffprocessServiceImpl (org.kie.workbench.common.services.backend.compiler.offprocess.service.impl.CompilerOffprocessServiceImpl)1