Search in sources :

Example 1 with DefaultKieCompilationResponseOffProcess

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

the class ClientIPCImpl method loopOverQueue.

private DefaultKieCompilationResponseOffProcess loopOverQueue(ExcerptTailer tailer, String uuid, long previousIndex) {
    long currentIndex = tailer.index();
    if (logger.isDebugEnabled()) {
        logger.debug("current index on loopOverQueue:{}", currentIndex);
    }
    DefaultKieCompilationResponseOffProcess res = readThisDocument(tailer);
    if (uuid.equals(res.getRequestUUID())) {
        return res;
    } else {
        if (currentIndex == previousIndex) {
            // No more elements in the queue
            return new DefaultKieCompilationResponseOffProcess(false, "");
        }
        return loopOverQueue(tailer, uuid, currentIndex);
    }
}
Also used : DefaultKieCompilationResponseOffProcess(org.kie.workbench.common.services.backend.compiler.impl.DefaultKieCompilationResponseOffProcess)

Example 2 with DefaultKieCompilationResponseOffProcess

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

the class ServerIPCImpl method build.

private static DefaultKieCompilationResponseOffProcess build(String prjPath, String mavenRepo, String alternateSettingsAbsPath, String uuid) {
    final AFCompiler compiler = KieMavenCompilerFactory.getCompiler(EnumSet.of(KieDecorator.ENABLE_LOGGING, KieDecorator.STORE_KIE_OBJECTS));
    WorkspaceCompilationInfo info = new WorkspaceCompilationInfo(Paths.get("file://" + prjPath));
    CompilationRequest req;
    if (StringUtils.isNotEmpty(alternateSettingsAbsPath)) {
        req = new DefaultCompilationRequest(mavenRepo, info, new String[] { MavenCLIArgs.DEPENDENCY_RESOLVE, MavenCLIArgs.COMPILE, MavenCLIArgs.ALTERNATE_USER_SETTINGS + alternateSettingsAbsPath }, Boolean.FALSE, uuid);
    } else {
        req = new DefaultCompilationRequest(mavenRepo, info, new String[] { MavenCLIArgs.DEPENDENCY_RESOLVE, MavenCLIArgs.COMPILE }, Boolean.FALSE, uuid);
    }
    KieCompilationResponse res = (KieCompilationResponse) compiler.compile(req);
    return new DefaultKieCompilationResponseOffProcess(res);
}
Also used : DefaultKieCompilationResponseOffProcess(org.kie.workbench.common.services.backend.compiler.impl.DefaultKieCompilationResponseOffProcess) WorkspaceCompilationInfo(org.kie.workbench.common.services.backend.compiler.impl.WorkspaceCompilationInfo) DefaultCompilationRequest(org.kie.workbench.common.services.backend.compiler.impl.DefaultCompilationRequest) AFCompiler(org.kie.workbench.common.services.backend.compiler.AFCompiler) 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)

Example 3 with DefaultKieCompilationResponseOffProcess

use of org.kie.workbench.common.services.backend.compiler.impl.DefaultKieCompilationResponseOffProcess 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)

Example 4 with DefaultKieCompilationResponseOffProcess

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

the class ClientIPCImpl method readThisDocument.

private DefaultKieCompilationResponseOffProcess readThisDocument(ExcerptTailer tailer) {
    if (logger.isDebugEnabled()) {
        logger.debug("current index on readThisDocument:{}", tailer.index());
    }
    DefaultKieCompilationResponseOffProcess res = null;
    try (DocumentContext dc = tailer.readingDocument()) {
        if (dc.isPresent()) {
            if (logger.isDebugEnabled()) {
                logger.debug("Document Context index:{}", dc.index());
            }
            Wire wire = dc.wire();
            Bytes bytes = wire.bytes();
            if (!bytes.isEmpty()) {
                try {
                    Object obj = deserialize(bytes.toByteArray());
                    res = (DefaultKieCompilationResponseOffProcess) obj;
                } catch (Exception e) {
                    logger.error(e.getMessage(), e);
                }
            }
        }
    }
    if (res == null) {
        res = new DefaultKieCompilationResponseOffProcess(false, "");
    }
    return res;
}
Also used : Bytes(net.openhft.chronicle.bytes.Bytes) DefaultKieCompilationResponseOffProcess(org.kie.workbench.common.services.backend.compiler.impl.DefaultKieCompilationResponseOffProcess) DocumentContext(net.openhft.chronicle.wire.DocumentContext) Wire(net.openhft.chronicle.wire.Wire) IOException(java.io.IOException)

Example 5 with DefaultKieCompilationResponseOffProcess

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

the class ServerIPCImpl method execute.

public static void execute(String workingDir, String mavenRepo, String alternateSettingsAbsPath, String uuid, QueueProvider provider) throws Exception {
    DefaultKieCompilationResponseOffProcess res = build(workingDir, mavenRepo, alternateSettingsAbsPath, uuid);
    byte[] bytez = serialize(res);
    if (bytez == null) {
        logger.warn("The serialized response is null, working dir:{}\n mavenrepo:{} \n alternateSettingsAbsPath:{} \n uuid:{}", workingDir, mavenRepo, alternateSettingsAbsPath, uuid);
        return;
    }
    writeOnQueue(bytez, provider);
}
Also used : DefaultKieCompilationResponseOffProcess(org.kie.workbench.common.services.backend.compiler.impl.DefaultKieCompilationResponseOffProcess)

Aggregations

DefaultKieCompilationResponseOffProcess (org.kie.workbench.common.services.backend.compiler.impl.DefaultKieCompilationResponseOffProcess)5 IOException (java.io.IOException)1 Bytes (net.openhft.chronicle.bytes.Bytes)1 ExcerptTailer (net.openhft.chronicle.queue.ExcerptTailer)1 DocumentContext (net.openhft.chronicle.wire.DocumentContext)1 Wire (net.openhft.chronicle.wire.Wire)1 AFCompiler (org.kie.workbench.common.services.backend.compiler.AFCompiler)1 CompilationRequest (org.kie.workbench.common.services.backend.compiler.CompilationRequest)1 DefaultCompilationRequest (org.kie.workbench.common.services.backend.compiler.impl.DefaultCompilationRequest)1 DefaultKieCompilationResponse (org.kie.workbench.common.services.backend.compiler.impl.DefaultKieCompilationResponse)1 WorkspaceCompilationInfo (org.kie.workbench.common.services.backend.compiler.impl.WorkspaceCompilationInfo)1 KieCompilationResponse (org.kie.workbench.common.services.backend.compiler.impl.kie.KieCompilationResponse)1