Package org.voltdb.catalog

Examples of org.voltdb.catalog.ConflictSet


     * @param proc1
     * @return
     */
    public static Collection<ConflictPair> getAllConflictPairs(Procedure proc0, Procedure proc1) {
        Set<ConflictPair> conflicts = new HashSet<ConflictPair>();
        ConflictSet cset = proc0.getConflicts().get(proc1.getName());
        if (cset != null) {
            conflicts.addAll(cset.getReadwriteconflicts());
            conflicts.addAll(cset.getWritewriteconflicts());
        }
        return (conflicts);
    }
View Full Code Here


     */
    public static Collection<Procedure> getWriteWriteConflicts(Procedure catalog_proc) {
        List<Procedure> conflicts = new ArrayList<Procedure>();
        Database catalog_db = CatalogUtil.getDatabase(catalog_proc);
        for (String procName : catalog_proc.getConflicts().keySet()) {
            ConflictSet cs = catalog_proc.getConflicts().get(procName);
            if (cs.getWritewriteconflicts().isEmpty() == false) {
                conflicts.add(catalog_db.getProcedures().get(procName));
            }
        } // FOR
        return (conflicts);
    }
View Full Code Here

   
    private void updateCatalog(ProcedureInfo pInfo,
                               Map<Procedure, Collection<Conflict>> conflicts,
                               boolean readWrite) {
        for (Procedure conflict_proc : conflicts.keySet()) {
            ConflictSet cSet = pInfo.proc.getConflicts().get(conflict_proc.getName());
            if (cSet == null) {
                cSet = pInfo.proc.getConflicts().add(conflict_proc.getName());
                cSet.setProcedure(conflict_proc);
            }
            CatalogMap<ConflictPair> procConflicts = null;
            ConflictType cType = null;
            if (readWrite) {
                procConflicts = cSet.getReadwriteconflicts();
                cType = ConflictType.READ_WRITE;
            } else {
                procConflicts = cSet.getWritewriteconflicts();
                cType = ConflictType.WRITE_WRITE;
            }
            for (Conflict c : conflicts.get(conflict_proc)) {
                ConflictPair cp = procConflicts.add(c.toString());
                cp.setAlwaysconflicting(c.alwaysConflicting);
View Full Code Here

            Procedure dest_proc = dest_db.getProcedures().get(src_proc.getName());
            assert(dest_proc != null) : src_proc;
           
            for (ConflictSet src_conflicts : src_proc.getConflicts()) {
                Procedure dest_otherProc = dest_db.getProcedures().get(src_conflicts.getProcedure().getName());
                ConflictSet dest_conflicts = dest_proc.getConflicts().add(src_conflicts.getName());
                dest_conflicts.setProcedure(dest_otherProc);
               
                for (ConflictPair src_pair : src_conflicts.getReadwriteconflicts()) {
                    ConflictPair dest_pair = clone(src_pair, dest_db.getCatalog());
                    dest_pair.setStatement0(dest_proc.getStatements().get(src_pair.getStatement0().getName()));
                    dest_pair.setStatement1(dest_otherProc.getStatements().get(src_pair.getStatement1().getName()));
View Full Code Here

                LOG.debug(String.format("No conflicts between %s<->%s",
                          dtxn, candidate));
            return (false);
        }

        final ConflictSet dtxn_conflicts = dtxn_proc.getConflicts().get(ts_proc.getName());
        final ConflictSet ts_conflicts = ts_proc.getConflicts().get(dtxn_proc.getName());
       
        // If TS is going to write to something that DTXN will read or write, then
        // we can let that slide as long as DTXN hasn't read from or written to those tables yet
        if (dtxn_hasRWConflict || dtxn_hasWWConflict) {
            assert(dtxn_conflicts != null) :
                String.format("Unexpected null DTXN ConflictSet for %s -> %s",
                              dtxn_proc.getName(), ts_proc.getName());
           
            // READ-WRITE
            if (debug.val && dtxn_conflicts.getReadwriteconflicts().isEmpty() == false)
                LOG.debug(String.format("Examining %d R-W Conflicts from %s -> %s",
                          dtxn_conflicts.getReadwriteconflicts().size(), dtxn_proc.getName(), ts_proc.getName()));
            for (ConflictPair conflict : dtxn_conflicts.getReadwriteconflicts().values()) {
                assert(conflict != null) :
                    String.format("Unexpected null DTXN R/W ConflictSet tables for %s [candidate=%s]",
                                  dtxn_proc.getName(), ts_proc.getName());
                for (TableRef ref : conflict.getTables().values()) {
                    assert(ref.getTable() != null) :
                        String.format("Unexpected null table reference %s [%s -> %s]",
                                      ref.fullName(), dtxn_proc.getName(), ts_proc.getName());
                    if (dtxn.isTableReadOrWritten(partitionId, ref.getTable())) {
                        return (true);
                    }
                } // FOR
            } // FOR (R-W)
           
            // WRITE-WRITE
            if (debug.val && dtxn_conflicts.getWritewriteconflicts().isEmpty() == false)
                LOG.debug(String.format("Examining %d W-W Conflicts from %s -> %s",
                          dtxn_conflicts.getWritewriteconflicts().size(), dtxn_proc.getName(), ts_proc.getName()));
            for (ConflictPair conflict : dtxn_conflicts.getWritewriteconflicts().values()) {
                assert(conflict != null) :
                    String.format("Unexpected null ConflictSet for %s [candidate=%s]",
                                  dtxn_proc.getName(), ts_proc.getName());
                for (TableRef ref : conflict.getTables().values()) {
                    assert(ref.getTable() != null) :
                        String.format("Unexpected null table reference %s [%s -> %s]",
                                      ref.fullName(), dtxn_proc.getName(), ts_proc.getName());
                    if (dtxn.isTableReadOrWritten(partitionId, ref.getTable())) {
                        return (true);
                    }
                }
            } // FOR (W-W)
        }
       
        // Similarly, if the TS needs to read from (but not write to) a table that DTXN
        // writes to, then we can allow TS to execute if DTXN hasn't written anything to
        // those tables yet
        if (ts_hasRWConflict && ts_hasWWConflict == false) {
            assert(ts_conflicts != null) :
                String.format("Unexpected null ConflictSet for %s -> %s",
                              ts_proc.getName(), dtxn_proc.getName());
            if (debug.val) LOG.debug(String.format("%s has R-W conflict with %s. Checking read/write sets", candidate, dtxn));
            for (ConflictPair conflict : ts_conflicts.getReadwriteconflicts().values()) {
                assert(conflict != null) :
                    String.format("Unexpected null ConflictSet for %s [candidate=%s]",
                                  dtxn_proc.getName(), ts_proc.getName());
                for (TableRef ref : conflict.getTables().values()) {
                    assert(ref.getTable() != null) :
View Full Code Here

                break;
            }
        } // FOR
        assertNotNull(proc);
       
        ConflictSet cs = proc.getConflicts().get(dtxnProc.getName());
        assertNotNull(cs);
        Collection<Table> conflictTables = ConflictSetUtil.getAllTables(cs.getWritewriteconflicts());
        assertFalse(conflictTables.isEmpty());
       
        // First time we should be able to get through
        LocalTransaction ts = new LocalTransaction(this.hstore_site);
        ts.testInit(this.idManager.getNextUniqueTransactionId(), BASE_PARTITION, null, catalogContext.getPartitionSetSingleton(BASE_PARTITION), proc);
View Full Code Here

                break;
            }
        } // FOR
        assertNotNull(proc);
       
        ConflictSet cs = proc.getConflicts().get(dtxnProc.getName());
        assertNotNull(cs);
        Collection<Table> conflictTables = ConflictSetUtil.getAllTables(cs.getReadwriteconflicts());
        assertFalse(conflictTables.isEmpty());
       
        LocalTransaction ts = new LocalTransaction(this.hstore_site);
        ts.testInit(this.idManager.getNextUniqueTransactionId(), BASE_PARTITION, null, catalogContext.getPartitionSetSingleton(BASE_PARTITION), proc);
        assertTrue(ts.isPredictSinglePartition());
View Full Code Here

   
    private void checkProcedureConflicts(Procedure catalog_proc, CatalogMap<ConflictSet> conflicts0, CatalogMap<ConflictSet> conflicts1) {
        assertEquals(catalog_proc.toString(), conflicts0.size(), conflicts1.size());
        for (String procName : conflicts0.keySet()) {
            assertNotNull(procName);
            ConflictSet cs0 = conflicts0.get(procName);
            assertNotNull(cs0);
            ConflictSet cs1 = conflicts1.get(procName);
            assertNotNull(cs1);
           
            assertEquals(cs0.getReadwriteconflicts().size(), cs1.getReadwriteconflicts().size());
            for (ConflictPair conflict0 : cs0.getReadwriteconflicts()) {
                ConflictPair conflict1 = cs1.getReadwriteconflicts().get(conflict0.getName());
                assertNotNull(conflict0.fullName(), conflict1);
                assertEquals(conflict0.fullName(), conflict0.getStatement0().getName(), conflict1.getStatement0().getName());
                assertEquals(conflict0.fullName(), conflict0.getStatement1().getName(), conflict1.getStatement1().getName());
                assertEquals(conflict0.fullName(), conflict0.getAlwaysconflicting(), conflict1.getAlwaysconflicting());
                assertEquals(conflict0.fullName(), conflict0.getConflicttype(), conflict1.getConflicttype());
                for (TableRef ref0 : conflict0.getTables()) {
                    TableRef ref1 = conflict1.getTables().get(ref0.getName());
                    assertNotNull(ref0.fullName(), ref1);
                    assertEquals(ref0.fullName(), ref0.getTable().getName(), ref1.getTable().getName());
                } // FOR
            } // FOR
           
            assertEquals(cs0.getWritewriteconflicts().size(), cs1.getWritewriteconflicts().size());
            for (ConflictPair conflict0 : cs0.getWritewriteconflicts()) {
                ConflictPair conflict1 = cs1.getWritewriteconflicts().get(conflict0.getName());
                assertNotNull(conflict0.fullName(), conflict1);
                assertEquals(conflict0.fullName(), conflict0.getStatement0().getName(), conflict1.getStatement0().getName());
                assertEquals(conflict0.fullName(), conflict0.getStatement1().getName(), conflict1.getStatement1().getName());
                assertEquals(conflict0.fullName(), conflict0.getAlwaysconflicting(), conflict1.getAlwaysconflicting());
                assertEquals(conflict0.fullName(), conflict0.getConflicttype(), conflict1.getConflicttype());
View Full Code Here

TOP

Related Classes of org.voltdb.catalog.ConflictSet

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.