Package com.dotmarketing.common.db

Examples of com.dotmarketing.common.db.DotConnect


        dc.loadResult();
    }

    @Override
    protected void deleteReindexEntryForServer(IndexJournal<T> iJournal) throws DotDataException {
        DotConnect dc = new DotConnect();
        dc.setSQL("DELETE FROM dist_reindex_journal where id = ?");
        dc.addParam(iJournal.getId());
        dc.loadResult();
    }
View Full Code Here


        dc.loadResult();
    }

    @Override
    protected void deleteReindexEntryForServer(List<IndexJournal<T>> recordsToDelete) throws DotDataException {
        DotConnect dc = new DotConnect();
        StringBuilder sql=new StringBuilder().append("DELETE FROM dist_reindex_journal where id in (");
        boolean first=true;
        for(IndexJournal<T> idx : recordsToDelete) {
            if(!first) sql.append(','); else first=false;
            sql.append(idx.getId());
        }
        sql.append(')');

        dc.setSQL(sql.toString());
        Connection con = null;
    try {
      con = DbConnectionFactory.getDataSource().getConnection();
      con.setAutoCommit(true);
      dc.loadResult(con);
    } catch (SQLException e) {
      Logger.error(ESDistributedJournalFactoryImpl.class,e.getMessage(),e);
    }finally{
      try {
        con.close();
View Full Code Here

public class Task03042AddLicenseRepoModel extends AbstractJDBCStartupTask {

    @Override
    public boolean forceRun() {
        try {
            DotConnect dc=new DotConnect();
            dc.setSQL("select * from sitelic");
            dc.loadResult();
            return false;
        }
        catch(Exception ex) {
            return true;
        }
View Full Code Here

                " (SELECT i.inode FROM inode i,contentlet c " +
                "  WHERE type = 'contentlet' AND i.inode=c.inode AND c.identifier = ident_to_index)");

        reindexJournalCleanupSql.append(" AND serverid = ?");

        DotConnect dc = new DotConnect();
        String serverId = ConfigUtils.getServerId();
        dc.setSQL(reindexJournalCleanupSql.toString());
        dc.addParam(serverId);
        dc.loadResult();
    }
View Full Code Here

        dc.loadResult();
    }

    private void deleteCacheEntries(String serverId, long id, Connection con)
            throws DotDataException {
        DotConnect dc = new DotConnect();
        try {
            dc.setSQL("DELETE FROM dist_journal where serverid = ? and journal_type = ? and id < ?");
            dc.addParam(serverId);
            dc.addParam(JOURNAL_TYPE_CACHE);
            dc.addParam(id + 1);
            dc.loadResult(con);
        } catch (Exception e1) {
            throw new DotDataException(e1.getMessage(), e1);
        }
    }
View Full Code Here

        }
    }

    @Override
    protected List<String> findCacheEntriesToRemove() throws DotDataException {
        DotConnect dc = new DotConnect();
        List<String> x = new ArrayList<String>();
        Connection con = null;
        String serverId = ConfigUtils.getServerId();

        try {
            con = DbConnectionFactory.getConnection();
            con.setAutoCommit(false);
            dc.setSQL("SELECT object_to_index , max(id) as id from dist_journal " +
                " where journal_type = ? and serverid = ? GROUP BY id, object_to_index,time_entered ORDER BY time_entered ASC");
            dc.addParam(JOURNAL_TYPE_CACHE);
            dc.addParam(serverId);

            List<Map<String, String>> results = dc.loadResults(con);
            long id = 0;
            for (Map<String, String> r : results) {
                x.add(r.get("object_to_index"));
                id = new Long(r.get("id"));
            }
View Full Code Here

    }

    @Override
    protected List<IndexJournal<T>> findContentReindexEntriesToReindex()
            throws DotDataException {
        DotConnect dc = new DotConnect();
        List<IndexJournal<T>> x = new ArrayList<IndexJournal<T>>();
        List<Map<String, Object>> results;
        Connection con = null;
        String serverId = ConfigUtils.getServerId();

        try {
            con = DbConnectionFactory.getConnection();
            con.setAutoCommit(false);
            if(DbConnectionFactory.isOracle()) {
                CallableStatement call = con.prepareCall("{ ? = call load_records_to_index(?,?) }");
                call.registerOutParameter(1, OracleTypes.CURSOR);
                call.setString(2, serverId);
                call.setInt(3, 50);
                call.execute();
                ResultSet r = (ResultSet)call.getObject(1);
                results = new ArrayList<Map<String,Object>>();
                while(r.next()) {
                    Map<String,Object> m=new HashMap<String,Object>();
                    m.put("id", r.getInt("id"));
                    m.put("inode_to_index", r.getString("inode_to_index"));
                    m.put("ident_to_index", r.getString("ident_to_index"));
                    m.put("priority", r.getInt("priority"));
                    results.add(m);
                }
                r.close();
                call.close();
            } else if(DbConnectionFactory.isMsSql()) {
                // we need to make sure this setting is ON because of the READPAST we use
                // in the stored procedure
                dc.setSQL("SET TRANSACTION ISOLATION LEVEL READ COMMITTED;");
                dc.loadResult();

                dc.setSQL("load_records_to_index @server_id='"+serverId+"', @records_to_fetch=50");
                dc.setForceQuery(true);
                results = dc.loadObjectResults(con);
            } else if(DbConnectionFactory.isH2()) {
                dc.setSQL("call load_records_to_index(?,?)");
                dc.addParam(serverId);
                dc.addParam(50);
                results = dc.loadObjectResults();
            } else {
                dc.setSQL(REINDEXENTRIESSELECTSQL);
                dc.addParam(serverId);
                dc.addParam(50);
                results = dc.loadObjectResults(con);
            }

            for (Map<String, Object> r : results) {
                IndexJournal<T> ij = new IndexJournal<T>();
                ij.setId(((Number)r.get("id")).longValue());
View Full Code Here

        return Config.getBooleanProperty("DIST_INDEXATION_ENABLED", false);
    }

    @Override
    protected void processJournalEntries() throws DotDataException {
        DotConnect dc = new DotConnect();
        Connection con = null;
        ClusterMutex mutex = null;
        try {
            con = DbConnectionFactory.getConnection();
            con.setAutoCommit(false);
            mutex = new ClusterMutex(con);
            mutex.lockTable();
            dc.setSQL("SELECT max(id) as max FROM dist_process");
            ArrayList<Map<String, String>> ret = dc.loadResults(con);
            if (ret != null && ret.size() > 0
                    && UtilMethods.isSet(ret.get(0).get("max"))) {

                Long max = Long.parseLong(ret.get(0).get("max"));

                dc.setSQL("INSERT INTO dist_journal (object_to_index, time_entered, serverid, journal_type) " +
                    " SELECT object_to_index, min(time_entered),  serverid, journal_type FROM dist_process p1 " +
                    " WHERE NOT EXISTS (SELECT p.id FROM dist_process p, dist_journal j " +
                                      " WHERE p.object_to_index = j.object_to_index AND  p.serverid=j.serverid AND " +
                                      " p.journal_type=j.journal_type AND p1.id = p.id) " +
                           " AND id <=? GROUP BY object_to_index, serverid, journal_type");
                dc.addParam(max);
                dc.loadResult(con);

                dc.setSQL("DELETE FROM dist_process WHERE id<=?");
                dc.addParam(max);
                dc.loadResult(con);
            }

        } catch (SQLException e1) {
            throw new DotDataException(e1.getMessage(), e1);
        } finally {
View Full Code Here

        return recordsLeftToIndexForServer(DbConnectionFactory.getConnection());
    }

    @Override
    protected long recordsLeftToIndexForServer(Connection conn) throws DotDataException {
        DotConnect dc = new DotConnect();
        dc.setSQL("select count(*) as count from dist_reindex_journal");
        List<Map<String, String>> results = results = dc.loadResults(conn);
        String c = results.get(0).get("count");
        return Long.parseLong(c);
    }
View Full Code Here

    protected void refreshContentUnderFolder(Folder folder) throws DotDataException {
        final String sql = " INSERT INTO dist_reindex_journal(inode_to_index,ident_to_index,priority,dist_action) "+
                           " SELECT distinct identifier.id, identifier.id, ?, ? " +
                           " FROM contentlet join identifier ON contentlet.identifier=identifier.id "+
                           " WHERE identifier.host_inode=? AND identifier.parent_path LIKE ? ";
        DotConnect dc = new DotConnect();
        dc.setSQL(sql);
        dc.addParam(REINDEX_JOURNAL_PRIORITY_CONTENT_REINDEX);
        dc.addParam(REINDEX_ACTION_REINDEX_OBJECT);
        dc.addParam(folder.getHostId());
        String folderPath = APILocator.getIdentifierAPI().find(folder).getPath();
        dc.addParam(folderPath+"%");
        dc.loadResult();
    }
View Full Code Here

TOP

Related Classes of com.dotmarketing.common.db.DotConnect

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.