@ManagedAttribute(description="Set transaction timeout in miliseconds. 0 means no timeout") public void setTransactionTimeout(long txTimeout) { try { txMgr.setTransactionTimeout(txTimeout); } catch (BagriException ex) { logger.error("setTransactionTimeout.error: " + ex.getMessage(), ex); } }
@ManagedOperation(description="Returns Module functions") public String[] getDeclaredFunctions() { Module module = getEntity(); try { List<String> list = xqComp.getModuleFunctions(module); return list.toArray(new String[list.size()]); } catch (BagriException ex) { throw new RuntimeException(ex.getMessage()); } }
public void afterInsert(Document doc, SchemaRepository repo) { logger.info("afterInsert.enter; doc: {}; repo: {}", doc, repo); try { Properties props = new Properties(); props.setProperty(pn_document_data_format, "XML"); DocumentAccessor da = repo.getDocumentManagement().getDocument(doc.getUri(), props); Security sec = da.getContent(); logger.info("afterInsert.exit; got security: {}/{}/{}", sec.getName(), sec.getSymbol(), sec.getId()); } catch (BagriException ex) { logger.info("afterInsert.error; got exception: {}", ex.getMessage()); } }
@ManagedOperation(description="Rollback in-flight transaction") @ManagedOperationParameters({ @ManagedOperationParameter(name = "txId", description = "Tx identifier")}) public boolean rollbackTransaction(long txId) { try { txMgr.rollbackTransaction(txId); return true; } catch (BagriException ex) { logger.error("rollbackTransaction.error: " + ex.getMessage(), ex); } return false; }
@ManagedOperation(description="Commit in-flight transaction") @ManagedOperationParameters({ @ManagedOperationParameter(name = "txId", description = "Tx identifier")}) public boolean commitTransaction(long txId) { try { txMgr.commitTransaction(txId); return true; } catch (BagriException ex) { logger.error("commitTransaction.error: " + ex.getMessage(), ex); } return false; } @ManagedOperation(description="Rollback in-flight transaction")
@ManagedOperation(description="Compiles registered Module") public boolean compileModule() { Module module = getEntity(); try { boolean result = true; xqComp.compileModule(module); ModuleReloader task = new ModuleReloader(module); Map<Member, Future<Boolean>> futures = execService.submitToMembers(task, new MemberSelector() { @Override public boolean select(Member member) { return !"admin".equalsIgnoreCase(member.getStringAttribute(pn_cluster_node_role)); } }); try { for (Map.Entry<Member, Future<Boolean>> e: futures.entrySet()) { if (!e.getValue().get()) { result = false; } } } catch (InterruptedException | ExecutionException ex) { logger.error("compileModule.error; {}", ex); result = false; } return result; } catch (BagriException ex) { throw new RuntimeException(ex.getMessage()); } }
@ManagedOperation(description="Return Document Location Info") @ManagedOperationParameters({ @ManagedOperationParameter(name = "uri", description = "Document identifier")}) public CompositeData getDocumentLocation(String uri) { try { Properties props = new Properties(); props.setProperty("bdb.document.headers", String.valueOf(DocumentAccessor.HDR_URI)); DocumentAccessor doc = docManager.getDocument(uri, props); CompositeData result = null; if (doc != null) { int hash = schemaManager.getRepository().getDistributionStrategy().getDistributionHash(uri); Partition part = hzClient.getPartitionService().getPartition(hash); Map<String, Object> location = new HashMap<>(2); location.put("partition", part.getPartitionId()); location.put("owner", part.getOwner().toString()); result = JMXUtils.mapToComposite("document", "Document Location", location); } logger.debug("getDocumentLocation; returning: {}", result); return result; } catch (BagriException ex) { logger.error("getDocumentLocation.error: {}", ex.getMessage(), ex); throw new RuntimeException(ex.getMessage()); } }
return result; } catch (BagriException ex) { logger.error("getDocumentInfo.error: {}", ex.getMessage(), ex); throw new RuntimeException(ex.getMessage());
@ManagedOperation(description="Starts new transaction") @ManagedOperationParameters({ @ManagedOperationParameter(name = "txIsolation", description = "Tx isolation level")}) public long beginTransaction(String txIsolation) { try { if (txIsolation == null || txIsolation.length() == 0) { return txMgr.beginTransaction(); } return txMgr.beginTransaction(TransactionIsolation.valueOf(txIsolation)); } catch (BagriException ex) { logger.error("beginTransaction.error: " + ex.getMessage(), ex); } return 0; }
} catch (BagriException ex) { logger.error("apply.error: ", ex); return Response.serverError().entity(ex.getMessage()).build();
throw new XQException(ex.getMessage());