Search in sources :

Example 1 with TransactionMetadata

use of org.teiid.adminapi.impl.TransactionMetadata in project teiid by teiid.

the class TransactionServerImpl method getTransactions.

@Override
public Collection<TransactionMetadata> getTransactions() {
    Set<TransactionContext> txnSet = Collections.newSetFromMap(new IdentityHashMap<TransactionContext, Boolean>());
    synchronized (this.transactions) {
        txnSet.addAll(this.transactions.threadToTransactionContext.values());
        txnSet.addAll(this.transactions.xidToTransactionContext.values());
    }
    Collection<TransactionMetadata> result = new ArrayList<TransactionMetadata>(txnSet.size());
    for (TransactionContext transactionContext : txnSet) {
        if (transactionContext.getTransactionType() == Scope.NONE) {
            continue;
        }
        TransactionMetadata txnImpl = new TransactionMetadata();
        txnImpl.setAssociatedSession(transactionContext.getThreadId());
        txnImpl.setCreatedTime(transactionContext.getCreationTime());
        txnImpl.setScope(transactionContext.getTransactionType().toString());
        txnImpl.setId(transactionContext.getTransactionId());
        result.add(txnImpl);
    }
    return result;
}
Also used : TransactionContext(org.teiid.dqp.service.TransactionContext) ArrayList(java.util.ArrayList) TransactionMetadata(org.teiid.adminapi.impl.TransactionMetadata)

Example 2 with TransactionMetadata

use of org.teiid.adminapi.impl.TransactionMetadata in project teiid by teiid.

the class TestTransactionMetadata method testMapping.

@Test
public void testMapping() {
    TransactionMetadata tm = new TransactionMetadata();
    tm.setAssociatedSession("x");
    tm.setCreatedTime(1234);
    tm.setId("tnx-id");
    tm.setScope("scope");
    ModelNode node = VDBMetadataMapper.TransactionMetadataMapper.INSTANCE.wrap(tm, new ModelNode());
    TransactionMetadata tm1 = VDBMetadataMapper.TransactionMetadataMapper.INSTANCE.unwrap(node);
    assertEquals(tm.getAssociatedSession(), tm1.getAssociatedSession());
    assertEquals(tm.getCreatedTime(), tm1.getCreatedTime());
    assertEquals(tm.getId(), tm1.getId());
    assertEquals(tm.getScope(), tm1.getScope());
}
Also used : ModelNode(org.jboss.dmr.ModelNode) TransactionMetadata(org.teiid.adminapi.impl.TransactionMetadata) Test(org.junit.Test)

Aggregations

TransactionMetadata (org.teiid.adminapi.impl.TransactionMetadata)2 ArrayList (java.util.ArrayList)1 ModelNode (org.jboss.dmr.ModelNode)1 Test (org.junit.Test)1 TransactionContext (org.teiid.dqp.service.TransactionContext)1