public boolean blockOnOutputBuffer(RequestWorkItem item) { synchronized (waitingPlans) { if (!waitingPlans.isEmpty()) { return false; } if (item.useCallingThread || item.getDqpWorkContext().getSession().isEmbedded()) { return false; } } return true; }
@Override public Void call() throws Exception { DQPWorkContext workContext = DQPWorkContext.getWorkContext(); getTransactionService().rollback(workContext.getSessionId(),xid, workContext.getSession().isEmbedded()); return null; } };
public ResultsFuture<?> end(XidImpl xid, int flags) throws XATransactionException { DQPWorkContext workContext = DQPWorkContext.getWorkContext(); this.getTransactionService().end(workContext.getSessionId(), xid, flags, workContext.getSession().isEmbedded()); return ResultsFuture.NULL_FUTURE; } // global txn
public boolean blockOnOutputBuffer(RequestWorkItem item) { synchronized (waitingPlans) { if (!waitingPlans.isEmpty()) { return false; } if (item.useCallingThread || item.getDqpWorkContext().getSession().isEmbedded()) { return false; } } return true; }
@Override public Void call() throws Exception { DQPWorkContext workContext = DQPWorkContext.getWorkContext(); getTransactionService().commit(workContext.getSessionId(), xid, onePhase, workContext.getSession().isEmbedded()); return null; } };
@Override public void finishedDeployment(String name, CompositeVDB cvdb) { VDBMetaData vdb = cvdb.getVDB(); if (workContext.getSession().getVdb().getName().equals(vdb.getName()) && workContext.getSession().getVdb().getVersion().equals(vdb.getVersion())) { reconnect = true; } } }
public ResultsFuture<?> forget(XidImpl xid) throws XATransactionException { DQPWorkContext workContext = DQPWorkContext.getWorkContext(); this.getTransactionService().forget(workContext.getSessionId(), xid, workContext.getSession().isEmbedded()); return ResultsFuture.NULL_FUTURE; }
public static DQPWorkContext example() { DQPWorkContext message = new DQPWorkContext(); message.getSession().setVDBName("vdbName"); //$NON-NLS-1$ message.getSession().setVDBVersion(1); message.getSession().setApplicationName("querybuilder"); //$NON-NLS-1$ message.getSession().setSessionId(String.valueOf(5)); message.getSession().setUserName("userName"); //$NON-NLS-1$ return message; }
public ResultsFuture<?> forget(XidImpl xid) throws XATransactionException { DQPWorkContext workContext = DQPWorkContext.getWorkContext(); this.getTransactionService().forget(workContext.getSessionId(), xid, workContext.getSession().isEmbedded()); return ResultsFuture.NULL_FUTURE; }
@BeforeClass public static void setUpOnce() { token.getSession().setVDBName("foo"); //$NON-NLS-1$ token.getSession().setVDBVersion(1); token2.getSession().setVDBName("foo"); //$NON-NLS-1$ token2.getSession().setVDBVersion(2); }
@Override public Integer call() throws Exception { DQPWorkContext workContext = DQPWorkContext.getWorkContext(); return getTransactionService().prepare(workContext.getSessionId(),xid, workContext.getSession().isEmbedded()); } };
private ResultsMessage execute(String userName, int sessionid, RequestMessage reqMsg) throws InterruptedException, ExecutionException, TimeoutException, TeiidProcessingException { DQPWorkContext.getWorkContext().getSession().setSessionId(String.valueOf(sessionid)); DQPWorkContext.getWorkContext().getSession().setUserName(userName); Future<ResultsMessage> message = core.executeRequest(reqMsg.getExecutionId(), reqMsg); assertNotNull(core.getClientState(String.valueOf(sessionid), false)); ResultsMessage results = message.get(500000, TimeUnit.MILLISECONDS); return results; } }
public ResultsFuture<?> end(XidImpl xid, int flags) throws XATransactionException { DQPWorkContext workContext = DQPWorkContext.getWorkContext(); this.getTransactionService().end(workContext.getSessionId(), xid, flags, workContext.getSession().isEmbedded()); return ResultsFuture.NULL_FUTURE; } // global txn
private void processMessagePacket(Message packet) { if (LogManager.isMessageToBeRecorded(LogConstants.CTX_TRANSPORT, MessageLevel.DETAIL)) { LogManager.logDetail(LogConstants.CTX_TRANSPORT, "processing message:" + packet); //$NON-NLS-1$ } workContext.getSession().setLastPingTime(System.currentTimeMillis()); if (this.workContext.getSecurityHelper() != null) { this.workContext.getSecurityHelper().clearSecurityContext(); } final ServerWorkItem work = new ServerWorkItem(this, packet.getMessageKey(), packet, this.csr); this.workContext.runInContext(work); }
@Override public Void call() throws Exception { DQPWorkContext workContext = DQPWorkContext.getWorkContext(); getTransactionService().commit(workContext.getSessionId(), xid, onePhase, workContext.getSession().isEmbedded()); return null; } };
public ResultsFuture<Xid[]> recover(int flag) throws XATransactionException { ResultsFuture<Xid[]> result = new ResultsFuture<Xid[]>(); DQPWorkContext workContext = DQPWorkContext.getWorkContext(); result.getResultsReceiver().receiveResults(this.getTransactionService().recover(flag, workContext.getSession().isEmbedded())); return result; } // global txn
public ResultsFuture<?> forget(XidImpl xid) throws XATransactionException { DQPWorkContext workContext = DQPWorkContext.getWorkContext(); this.getTransactionService().forget(workContext.getSessionId(), xid, workContext.getSession().isEmbedded()); return ResultsFuture.NULL_FUTURE; }
@Test public void testInsertWithQueryExpression() throws TeiidException { String sql = "INSERT /*+ sh:'append' */ into pm1.g1 (e1) select e1 from pm2.g1"; //$NON-NLS-1$ BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities(); CommandContext context = new CommandContext(); context.setDQPWorkContext(new DQPWorkContext()); context.getDQPWorkContext().getSession().setVdb(RealMetadataFactory.example1VDB()); ProcessorPlan plan = helpGetPlan(helpParse(sql), RealMetadataFactory.example1Cached(), new DefaultCapabilitiesFinder(caps), context); HardcodedDataManager manager = manager("append", null); manager.addData("SELECT /*+sh:'append' */ g_0.e1 FROM pm2.g1 AS g_0", Arrays.asList("a")); manager.addData("INSERT /*+sh:'append' */ INTO pm1.g1 (e1) VALUES ('a')", Arrays.asList(1)); helpProcess(plan, manager, new List[] {Arrays.asList(1)}); }
@Test public void testWithHintPushdown() throws TeiidException { String sql = "WITH x as /*+ no_inline */ (SELECT /*+ sh:'x' */ e1 from pm1.g2) " + "SELECT /*+ sh:'foo' bar:'leading' */ g1.e1 from pm1.g1, x where g1.e1 = x.e1 order by g1.e1 limit 1"; //$NON-NLS-1$ BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities(); caps.setCapabilitySupport(Capability.COMMON_TABLE_EXPRESSIONS, true); CommandContext context = new CommandContext(); context.setDQPWorkContext(new DQPWorkContext()); context.getDQPWorkContext().getSession().setVdb(RealMetadataFactory.example1VDB()); ProcessorPlan plan = helpGetPlan(helpParse(sql), RealMetadataFactory.example1Cached(), new DefaultCapabilitiesFinder(caps), context); List<?>[] expected = new List[] {}; helpProcess(plan, manager("foo x", "leading"), expected); }
@Test public void testUnionHintPushdown() throws TeiidException { String sql = "SELECT /*+ sh:'foo' bar:'leading' */ g1.e1 from pm1.g1 " + "UNION ALL SELECT * from (SELECT /*+ sh:'x' bar:'z' */ g1.e1 from pm1.g1) as x"; //$NON-NLS-1$ BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities(); caps.setCapabilitySupport(Capability.QUERY_UNION, true); CommandContext context = new CommandContext(); context.setDQPWorkContext(new DQPWorkContext()); context.getDQPWorkContext().getSession().setVdb(RealMetadataFactory.example1VDB()); ProcessorPlan plan = helpGetPlan(helpParse(sql), RealMetadataFactory.example1Cached(), new DefaultCapabilitiesFinder(caps), context); List<?>[] expected = new List[] {}; helpProcess(plan, manager("foo x", "leading z"), expected); }