List of usage examples for javax.ejb TransactionAttributeType NOT_SUPPORTED
TransactionAttributeType NOT_SUPPORTED
To view the source code for javax.ejb TransactionAttributeType NOT_SUPPORTED.
Click Source Link
NOT_SUPPORTED
with an unspecified transaction context. From source file:be.isl.desamouryv.sociall.service.FileServiceImpl.java
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) @Override//ww w . j a v a 2 s . co m public String storeFile(InputStream input, String fileName, String uploadPath) throws IOException { logger.log(Level.INFO, "uploadPath: {0}", uploadPath); String prefix = FilenameUtils.getBaseName(fileName).replaceAll(" ", ""); String suffix = FilenameUtils.getExtension(fileName); File tempFile = File.createTempFile(prefix + "-", "." + suffix, new File(uploadPath)); OutputStream output = new FileOutputStream(tempFile); try { IOUtils.copy(input, output); } finally { IOUtils.closeQuietly(output); IOUtils.closeQuietly(input); } logger.log(Level.INFO, "file uploaded at: {0}", tempFile.getAbsolutePath()); return tempFile.getName(); }
From source file:be.isl.desamouryv.sociall.service.FileServiceImpl.java
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) @Override/*from w w w . ja v a 2 s .c o m*/ public void deleteFile(String fileName, String path) throws Exception { logger.log(Level.INFO, "delete file: {0}...", fileName); File file = new File(path + "\\" + fileName); boolean delete = file.delete(); logger.log(Level.INFO, "... file deleted: {0}", delete); if (!delete) { throw new Exception("Failed to delete file"); } }
From source file:eu.europa.ec.fisheries.uvms.rules.service.bean.TemplateEngine.java
@PostConstruct @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) public void initialize() { log.info("[START] Initializing templates and rules..."); try {/*from w w w . jav a 2 s . com*/ Stopwatch stopwatch = Stopwatch.createStarted(); List<TemplateRuleMapDto> templatesAndRules = rulesDb.getAllFactTemplatesAndRules(); ruleEvaluator.initializeRules(templatesAndRules); rulesStatusUpdaterBean.updateRulesStatus(ruleEvaluator.getFailedRules()); log.info("[END] It took " + stopwatch + " to initialize the rules."); } catch (RulesModelException e) { log.error(e.getMessage(), e); } }
From source file:org.hawkular.component.availcreator.AvailPublisher.java
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) public void sendToMetricsViaRest(List<SingleAvail> availabilities) { // Send it to metrics via rest HttpClient client = HttpClientBuilder.create().build(); for (SingleAvail avr : availabilities) { String rid = avr.id;//w w w. jav a 2 s . c om String tenantId = avr.tenantId; HttpPost request = new HttpPost(METRICS_BASE_URI + "/availability/" + rid + "/data"); request.addHeader("Hawkular-Tenant", tenantId); Availability availability = new Availability(avr.timestamp, avr.avail.toLowerCase()); List<Availability> list = new ArrayList<>(1); list.add(availability); String payload = new Gson().toJson(list); request.setEntity(new StringEntity(payload, ContentType.APPLICATION_JSON)); try { HttpResponse response = client.execute(request); if (response.getStatusLine().getStatusCode() > 399) { Log.LOG.wAvailPostStatus(response.getStatusLine().toString()); } } catch (IOException e) { Log.LOG.wAvailPostStatus(e.getMessage()); } } }
From source file:eu.europa.ec.fisheries.uvms.rules.service.bean.TemplateEngine.java
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) public void reInitialize() { initialize(); }
From source file:eu.europa.ec.fisheries.uvms.rules.service.bean.FactRuleEvaluator.java
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) public void initializeRules(Collection<TemplateRuleMapDto> templates) { Map<String, String> drlsAndRules = new HashMap<>(); for (TemplateRuleMapDto template : templates) { String templateFile = TemplateFactory.getTemplateFileName(template.getTemplateType().getType()); String templateName = template.getTemplateType().getTemplateName(); drlsAndRules.putAll(generateRulesFromTemplate(templateName, templateFile, template.getRules())); drlsAndRules.putAll(generateExternalRulesFromTemplate(template.getExternalRules())); }// www. j a v a 2s . c om createAllPackages(drlsAndRules); }
From source file:io.hops.hopsworks.common.dao.tensorflow.config.TensorBoardProcessMgr.java
/** * Start the TensorBoard process/*w ww. j av a 2 s . c o m*/ * @param project * @param user * @param hdfsUser * @param hdfsLogdir * @return * @throws IOException */ @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) public TensorBoardDTO startTensorBoard(Project project, Users user, HdfsUsers hdfsUser, String hdfsLogdir) throws IOException { String prog = settings.getHopsworksDomainDir() + "/bin/tensorboard.sh"; Process process = null; Integer port = 0; BigInteger pid = null; String tbBasePath = settings.getStagingDir() + Settings.TENSORBOARD_DIRS + File.separator; String projectUserUniquePath = project.getName() + "_" + hdfsUser.getName(); String tbPath = tbBasePath + DigestUtils.sha256Hex(projectUserUniquePath); String certsPath = "\"\""; File tbDir = new File(tbPath); if (tbDir.exists()) { for (File file : tbDir.listFiles()) { if (file.getName().endsWith(".pid")) { String pidContents = com.google.common.io.Files.readFirstLine(file, Charset.defaultCharset()); try { pid = BigInteger.valueOf(Long.parseLong(pidContents)); if (pid != null && ping(pid) == 0) { killTensorBoard(pid); } } catch (NumberFormatException nfe) { LOGGER.log(Level.WARNING, "Expected number in pidfile " + file.getAbsolutePath() + " got " + pidContents); } } } FileUtils.deleteDirectory(tbDir); } tbDir.mkdirs(); DistributedFileSystemOps dfso = dfsService.getDfsOps(); try { certsPath = tbBasePath + DigestUtils.sha256Hex(projectUserUniquePath + "_certs"); File certsDir = new File(certsPath); certsDir.mkdirs(); HopsUtils.materializeCertificatesForUserCustomDir(project.getName(), user.getUsername(), settings.getHdfsTmpCertDir(), dfso, certificateMaterializer, settings, certsPath); } catch (IOException ioe) { LOGGER.log(Level.SEVERE, "Failed in materializing certificates for " + hdfsUser + " in directory " + certsPath, ioe); HopsUtils.cleanupCertificatesForUserCustomDir(user.getUsername(), project.getName(), settings.getHdfsTmpCertDir(), certificateMaterializer, certsPath, settings); } finally { if (dfso != null) { dfsService.closeDfsClient(dfso); } } String anacondaEnvironmentPath = settings.getAnacondaProjectDir(project.getName()); int retries = 3; while (retries > 0) { if (retries == 0) { throw new IOException( "Failed to start TensorBoard for project=" + project.getName() + ", user=" + user.getUid()); } // use pidfile to kill any running servers port = ThreadLocalRandom.current().nextInt(40000, 59999); String[] command = new String[] { "/usr/bin/sudo", prog, "start", hdfsUser.getName(), hdfsLogdir, tbPath, port.toString(), anacondaEnvironmentPath, settings.getHadoopVersion(), certsPath, settings.getJavaHome() }; LOGGER.log(Level.INFO, Arrays.toString(command)); ProcessBuilder pb = new ProcessBuilder(command); try { // Send both stdout and stderr to the same stream pb.redirectErrorStream(true); process = pb.start(); synchronized (pb) { try { // Wait until the launcher bash script has finished process.waitFor(20l, TimeUnit.SECONDS); } catch (InterruptedException ex) { LOGGER.log(Level.SEVERE, "Woken while waiting for the TensorBoard to start: {0}", ex.getMessage()); } } int exitValue = process.exitValue(); String pidPath = tbPath + File.separator + port + ".pid"; File pidFile = new File(pidPath); // Read the pid for TensorBoard server if (pidFile.exists()) { String pidContents = com.google.common.io.Files.readFirstLine(pidFile, Charset.defaultCharset()); pid = BigInteger.valueOf(Long.parseLong(pidContents)); } if (exitValue == 0 && pid != null) { int maxWait = 10; String logFilePath = tbPath + File.separator + port + ".log"; File logFile = new File(logFilePath); while (maxWait > 0) { String logFileContents = com.google.common.io.Files.readFirstLine(logFile, Charset.defaultCharset()); // It is not possible to have a fixed wait time before showing the TB, we need to be sure it has started if (logFile.length() > 0 && (logFileContents.contains("Loaded") | logFileContents.contains("Reloader") | logFileContents.contains("event")) | maxWait == 1) { Thread.currentThread().sleep(5000); TensorBoardDTO tensorBoardDTO = new TensorBoardDTO(); String host = null; try { host = InetAddress.getLocalHost().getHostAddress(); } catch (UnknownHostException ex) { Logger.getLogger(TensorBoardProcessMgr.class.getName()).log(Level.SEVERE, null, ex); } tensorBoardDTO.setEndpoint(host + ":" + port); tensorBoardDTO.setPid(pid); return tensorBoardDTO; } else { Thread.currentThread().sleep(1000); maxWait--; } } TensorBoardDTO tensorBoardDTO = new TensorBoardDTO(); tensorBoardDTO.setPid(pid); String host = null; try { host = InetAddress.getLocalHost().getHostAddress(); } catch (UnknownHostException ex) { Logger.getLogger(TensorBoardProcessMgr.class.getName()).log(Level.SEVERE, null, ex); } tensorBoardDTO.setEndpoint(host + ":" + port); return tensorBoardDTO; } else { LOGGER.log(Level.SEVERE, "Failed starting TensorBoard got exitcode " + exitValue + " retrying on new port"); if (pid != null) { this.killTensorBoard(pid); } pid = null; } } catch (Exception ex) { LOGGER.log(Level.SEVERE, "Problem starting TensorBoard: {0}", ex); if (process != null) { process.destroyForcibly(); } } finally { retries--; } } //Failed to start TensorBoard, make sure there is no process running for it! (This should not be needed) if (pid != null && this.ping(pid) == 0) { this.killTensorBoard(pid); } //Certificates cleanup in case they were materialized but no TB started successfully dfso = dfsService.getDfsOps(); certsPath = tbBasePath + DigestUtils.sha256Hex(projectUserUniquePath + "_certs"); File certsDir = new File(certsPath); certsDir.mkdirs(); try { HopsUtils.cleanupCertificatesForUserCustomDir(user.getUsername(), project.getName(), settings.getHdfsTmpCertDir(), certificateMaterializer, certsPath, settings); } finally { if (dfso != null) { dfsService.closeDfsClient(dfso); } } return null; }
From source file:eu.europa.ec.fisheries.uvms.rules.service.bean.FactRuleEvaluator.java
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) private Map<String, String> generateRulesFromTemplate(String templateName, String templateFile, List<RuleType> rules) { if (CollectionUtils.isEmpty(rules)) { return Collections.emptyMap(); }/* ww w.ja v a 2 s .c om*/ InputStream templateStream = this.getClass().getResourceAsStream(templateFile); TemplateContainer tc = new DefaultTemplateContainer(templateStream); Map<String, String> drlsAndBrId = new HashMap<>(); TemplateDataListener listener = new TemplateDataListener(tc); int rowNum = 0; for (RuleType ruleDto : rules) { listener.newRow(rowNum, 0); listener.newCell(rowNum, 0, templateName, 0); listener.newCell(rowNum, 1, ruleDto.getExpression(), 0); listener.newCell(rowNum, 2, ruleDto.getBrId(), 0); listener.newCell(rowNum, 3, ruleDto.getMessage(), 0); listener.newCell(rowNum, 4, ruleDto.getErrorType().value(), 0); listener.newCell(rowNum, 5, ruleDto.getLevel(), 0); listener.newCell(rowNum, 6, ruleDto.getPropertyNames(), 0); rowNum++; } listener.finishSheet(); String drl = listener.renderDRL(); log.debug(drl); drlsAndBrId.put(drl, templateName); return drlsAndBrId; }
From source file:pl.psnc.synat.wrdz.mdz.integrity.IntegrityProcessorBean.java
@Override @Asynchronous//w w w .ja v a 2 s . c o m @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) public Future<Void> processAll() { if (waitingForIdentifier != null) { logger.warn( "Processing started, but processor is waiting for an object. This can cause synchronization problems."); } IntegrityProcessor proxy = ctx.getBusinessObject(IntegrityProcessor.class); boolean finished = false; while (!ctx.wasCancelCalled() && !finished) { IntegrityProcessingResult result = proxy.processOne(); switch (result) { case PROCESSED: finished = false; break; case PAUSED: finished = true; break; case FINISHED: finished = true; proxy.finishCycle(); break; default: throw new WrdzRuntimeException("Unexpected result: " + result); } } return new AsyncResult<Void>(null); }
From source file:edu.harvard.iq.dvn.core.study.StudyFileServiceBean.java
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) public List<FileMetadata> getStudyFilesByExtension(String extension) { String queryStr = "SELECT fm from FileMetadata sf where lower(sf.fileName) LIKE :extension"; Query query = em.createQuery(queryStr); query.setParameter("extension", "%." + extension.toLowerCase()); List<FileMetadata> fmdList = query.getResultList(); Iterator it = fmdList.iterator(); while (it.hasNext()) { FileMetadata fmd = (FileMetadata) it.next(); if (!fmd.getStudyVersion().isLatestVersion()) { it.remove();/* w ww. j a va 2 s . co m*/ } } return fmdList; }