Package org.jboss.cache

Examples of org.jboss.cache.OptimisticTransactionEntry


                    randomSleep(minSleep, maxSleep);

                    cache.put("/one/two", "key2", pojo);

                    OptimisticTransactionEntry entry = (OptimisticTransactionEntry) cache.getTransactionTable().get(cache.getCurrentTransaction());
                    assertEquals(3, entry.getTransactionWorkSpace().getNodes().size());
                    assertTrue(entry.getTransactionWorkSpace().getNode(Fqn.fromString("/")) != null);
                    assertTrue(entry.getTransactionWorkSpace().getNode(Fqn.fromString("/one")) != null);
                    assertTrue(entry.getTransactionWorkSpace().getNode(Fqn.fromString("/one/two")) != null);
                    mgr.commit();
                    resetInvocationCtx(cache);
                }
                catch (Exception e)
                {
View Full Code Here


                    mgr.setTransaction(tx);
                    SamplePojo pojo = new SamplePojo(21, "test");

                    setTransactionsInInvocationCtx(mgr, cache);
                    cache.put("/one", "key1", pojo);
                    OptimisticTransactionEntry entry = (OptimisticTransactionEntry) cache.getTransactionTable().get(cache.getCurrentTransaction());

                    randomSleep(minSleep, maxSleep);

                    cache.put("/one/two", "key2", pojo);
                    assertEquals(3, entry.getTransactionWorkSpace().getNodes().size());
                    assertTrue(entry.getTransactionWorkSpace().getNode(Fqn.fromString("/")) != null);
                    assertTrue(entry.getTransactionWorkSpace().getNode(Fqn.fromString("/one")) != null);
                    assertTrue(entry.getTransactionWorkSpace().getNode(Fqn.fromString("/one/two")) != null);
                }
                catch (Exception e)
                {
                    e.printStackTrace();
                }
View Full Code Here

        cache.put("/one/two", "key1", pojo);

        GlobalTransaction gtx = cache.getCurrentTransaction(tx);
        TransactionTable table = cache.getTransactionTable();
        OptimisticTransactionEntry entry = (OptimisticTransactionEntry) table.get(gtx);
        assertEquals(tx, mgr.getTransaction());

        //now send the remote prepare

        GlobalTransaction remoteGtx = new GlobalTransaction();

        remoteGtx.setAddress(new Address()
        {
            public boolean isMulticastAddress()
            {

                return false;
            }

            public void readExternal(ObjectInput arg0)
            {
            }

            public void writeExternal(ObjectOutput arg0)
            {
            }

            public int compareTo(Object arg0)
            {

                return 0;
            }

            public int size()
            {

                return 0;
            }

            public void writeTo(DataOutputStream arg0)
            {
            }

            public void readFrom(DataInputStream arg0)
            {
            }
        });
        //hack the method call to make it have the remote gtx
        MethodCall meth = (MethodCall) entry.getModifications().get(0);

        meth.getArgs()[0] = remoteGtx;
        //call our remote method
        MethodCall prepareMethod = MethodCallFactory.create(MethodDeclarations.optimisticPrepareMethod, new Object[]{remoteGtx, injectDataVersion(entry.getModifications()), null, remoteGtx.getAddress(), Boolean.FALSE});
        try
        {
            cache._replicate(prepareMethod);
        }
        catch (Throwable t)
View Full Code Here

        cache.put("/one/two", "key1", pojo);

        GlobalTransaction gtx = cache.getCurrentTransaction(tx);
        TransactionTable table = cache.getTransactionTable();
        OptimisticTransactionEntry entry = (OptimisticTransactionEntry) table.get(gtx);
        assertNotNull(mgr.getTransaction());
        mgr.commit();

        //test local calls
        List calls = dummy.getAllCalled();
        assertEquals(MethodDeclarations.optimisticPrepareMethod, calls.get(0));
        assertEquals(MethodDeclarations.commitMethod, calls.get(1));

        assertNull(mgr.getTransaction());

        assertEquals(0, cache.getTransactionTable().getNumGlobalTransactions());
        assertEquals(0, cache.getTransactionTable().getNumLocalTransactions());


        GlobalTransaction remoteGtx = new GlobalTransaction();

        remoteGtx.setAddress(new Address()
        {
            public boolean isMulticastAddress()
            {

                return false;
            }

            public void readExternal(ObjectInput arg0)
            {
            }

            public void writeExternal(ObjectOutput arg0)
            {
            }

            public int compareTo(Object arg0)
            {

                return 0;
            }

            public int size()
            {

                return 0;
            }

            public void writeTo(DataOutputStream arg0)
            {
            }

            public void readFrom(DataInputStream arg0)
            {
            }
        });

//      hack the method call to make it have the remote gtx
        MethodCall meth = (MethodCall) entry.getModifications().get(0);

        meth.getArgs()[0] = remoteGtx;
        //call our remote method
        MethodCall prepareMethod = MethodCallFactory.create(MethodDeclarations.optimisticPrepareMethod, new Object[]{remoteGtx, injectDataVersion(entry.getModifications()), null, remoteGtx.getAddress(), Boolean.FALSE});
        try
        {
            cache._replicate(prepareMethod);
        }
        catch (Throwable t)
View Full Code Here

        cache.put("/one/two", "key1", pojo);

        GlobalTransaction gtx = cache.getCurrentTransaction(tx);
        TransactionTable table = cache.getTransactionTable();
        OptimisticTransactionEntry entry = (OptimisticTransactionEntry) table.get(gtx);
        assertNotNull(mgr.getTransaction());
        mgr.commit();

        //test local calls
        List calls = dummy.getAllCalled();
        assertEquals(MethodDeclarations.optimisticPrepareMethod, calls.get(0));
        assertEquals(MethodDeclarations.commitMethod, calls.get(1));

        GlobalTransaction remoteGtx = new GlobalTransaction();

        remoteGtx.setAddress(new Address()
        {
            public boolean isMulticastAddress()
            {

                return false;
            }

            public void readExternal(ObjectInput arg0)
            {
            }

            public void writeExternal(ObjectOutput arg0)
            {
            }

            public int compareTo(Object arg0)
            {

                return 0;
            }

            public int size()
            {

                return 0;
            }

            public void writeTo(DataOutputStream arg0)
            {
            }

            public void readFrom(DataInputStream arg0)
            {
            }
        });

//      hack the method call to make it have the remote gtx
        MethodCall meth = (MethodCall) entry.getModifications().get(0);

        meth.getArgs()[0] = remoteGtx;
        //call our remote method
        MethodCall prepareMethod = MethodCallFactory.create(MethodDeclarations.optimisticPrepareMethod, new Object[]{remoteGtx, injectDataVersion(entry.getModifications()), null, remoteGtx.getAddress(), Boolean.FALSE});
        try
        {
            cache._replicate(prepareMethod);
        }
        catch (Throwable t)
View Full Code Here

        cache.put("/one/two", "key1", pojo);

        GlobalTransaction gtx = cache.getCurrentTransaction(tx);
        TransactionTable table = cache.getTransactionTable();
        OptimisticTransactionEntry entry = (OptimisticTransactionEntry) table.get(gtx);
        assertNotNull(mgr.getTransaction());
        mgr.commit();

        //test local calls
        List calls = dummy.getAllCalled();
        assertEquals(MethodDeclarations.optimisticPrepareMethod, calls.get(0));
        assertEquals(MethodDeclarations.commitMethod, calls.get(1));
        assertNull(mgr.getTransaction());

        assertEquals(0, cache.getTransactionTable().getNumGlobalTransactions());
        assertEquals(0, cache.getTransactionTable().getNumLocalTransactions());


        GlobalTransaction remoteGtx = new GlobalTransaction();

        remoteGtx.setAddress(new Address()
        {
            public boolean isMulticastAddress()
            {

                return false;
            }

            public void readExternal(ObjectInput arg0)
            {
            }

            public void writeExternal(ObjectOutput arg0)
            {
            }

            public int compareTo(Object arg0)
            {

                return 0;
            }

            public int size()
            {

                return 0;
            }

            public void writeTo(DataOutputStream arg0)
            {
            }

            public void readFrom(DataInputStream arg0)
            {
            }
        });
        //hack the method call to make it have the remote gtx
        MethodCall meth = (MethodCall) entry.getModifications().get(0);

        meth.getArgs()[0] = remoteGtx;
        //call our remote method
        MethodCall prepareMethod = MethodCallFactory.create(MethodDeclarations.optimisticPrepareMethod, new Object[]{remoteGtx, injectDataVersion(entry.getModifications()), null, remoteGtx.getAddress(), Boolean.FALSE});
        try
        {
            cache._replicate(prepareMethod);
        }
        catch (Throwable t)
View Full Code Here

        cache.put("/one/two", "key1", pojo);

        GlobalTransaction gtx = cache.getCurrentTransaction(tx);
        TransactionTable table = cache.getTransactionTable();
        OptimisticTransactionEntry entry = (OptimisticTransactionEntry) table.get(gtx);
        assertEquals(tx, mgr.getTransaction());

        //now send the remote prepare

        GlobalTransaction remoteGtx = new GlobalTransaction();

        remoteGtx.setAddress(new Address()
        {
            public boolean isMulticastAddress()
            {

                return false;
            }

            public void readExternal(ObjectInput arg0)
            {
            }

            public void writeExternal(ObjectOutput arg0)
            {
            }

            public int compareTo(Object arg0)
            {

                return 0;
            }

            public int size()
            {

                return 0;
            }

            public void writeTo(DataOutputStream arg0)
            {
            }

            public void readFrom(DataInputStream arg0)
            {
            }
        });
        //hack the method call to make it have the remote gtx
        MethodCall meth = (MethodCall) entry.getModifications().get(0);

        meth.getArgs()[0] = remoteGtx;
        //call our remote method
        MethodCall prepareMethod = MethodCallFactory.create(MethodDeclarations.optimisticPrepareMethod, new Object[]{remoteGtx, injectDataVersion(entry.getModifications()), null, remoteGtx.getAddress(), Boolean.FALSE});
        try
        {
            cache._replicate(prepareMethod);
        }
        catch (Throwable t)
View Full Code Here

        cache.put("/one/two", "key1", pojo);

        GlobalTransaction gtx = cache.getCurrentTransaction(tx);
        TransactionTable table = cache.getTransactionTable();
        OptimisticTransactionEntry entry = (OptimisticTransactionEntry) table.get(gtx);
        assertEquals(tx, mgr.getTransaction());

        //now send the remote prepare

        GlobalTransaction remoteGtx = new GlobalTransaction();

        remoteGtx.setAddress(new Address()
        {
            public boolean isMulticastAddress()
            {

                return false;
            }

            public void readExternal(ObjectInput arg0)
            {
            }

            public void writeExternal(ObjectOutput arg0)
            {
            }

            public int compareTo(Object arg0)
            {

                return 0;
            }

            public int size()
            {

                return 0;
            }

            public void writeTo(DataOutputStream arg0)
            {
            }

            public void readFrom(DataInputStream arg0)
            {
            }
        });
        //hack the method call to make it have the remote gtx
        MethodCall meth = (MethodCall) entry.getModifications().get(0);

        meth.getArgs()[0] = remoteGtx;
        //call our remote method
        MethodCall prepareMethod = MethodCallFactory.create(MethodDeclarations.optimisticPrepareMethod, new Object[]{remoteGtx, injectDataVersion(entry.getModifications()), null, remoteGtx.getAddress(), Boolean.FALSE});
        try
        {
            cache._replicate(prepareMethod);
        }
        catch (Throwable t)
View Full Code Here

            return;
        }

        // get the transaction to create the nodes in
        TransactionEntry baseTransactionEntry = tx_table.get(gtx);
        OptimisticTransactionEntry transactionEntry = (OptimisticTransactionEntry) baseTransactionEntry;

        if (transactionEntry == null)
        {
            throw new CacheException("Unable to map global transaction " + gtx + " to transaction entry");
        }

        WorkspaceNode workspaceNode, childWorkspaceNode = null;
        Object childName;

        List nodesCreated = new ArrayList();
        // how many levels do we have?
        int treeNodeSize = fqn.size();

        InvocationContext ctx = getInvocationContext();

        // try and get the root from the transaction
        TransactionWorkspace workspace = transactionEntry.getTransactionWorkSpace();

        synchronized( workspace )
        {
            DataVersion version = null;
            if (ctx.getOptionOverrides() != null && ctx.getOptionOverrides().getDataVersion() != null)
View Full Code Here

            // under the GlobalTx key
            if (txTable.get(gtx) == null)
            {
                // create a new transaction entry

                TransactionEntry entry = cache.isNodeLockingOptimistic() ? new OptimisticTransactionEntry() : new TransactionEntry();
                entry.setTransaction(ltx);
                log.debug("creating new tx entry");
                txTable.put(gtx, entry);
                if (log.isTraceEnabled()) log.trace("TxTable contents: " + txTable);
            }
View Full Code Here

TOP

Related Classes of org.jboss.cache.OptimisticTransactionEntry

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.