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);
}
}
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);
}
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;
}
}
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;
}
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);
}
Aggregations