Package com.sun.messaging.jmq.jmsserver.persist.jdbc.comm

Examples of com.sun.messaging.jmq.jmsserver.persist.jdbc.comm.BaseDAO


            itr = tableDAOs.iterator();
        } else {
            itr = mgr.allDAOIterator();
        }
        while ( itr.hasNext() ) {
            BaseDAO dao = (BaseDAO)itr.next();
            try {
                Util.RetryStrategy retry = null;
                do {
                    try {
                        dao.createTable( conn );
                        break; // table created so break from retry loop
                    } catch ( Exception e ) {
                        // Exception will be log & re-throw if operation cannot be retry
                        if ( retry == null ) {
                            retry = new Util.RetryStrategy(mgr);
                        }
                        retry.assertShouldRetry( e );
                    }
                } while ( true );
            } catch (BrokerException be) {
                if ( Globals.getHAEnabled() ||
                     (mgr instanceof ShareConfigChangeDBManager) ) {
                    // Paused for a few secs to prevent race condition when two
                    // or more brokers try to create the tables at the same time
                    try {
                        Thread.sleep(5000);
                    } catch (InterruptedException e) {}
                }

                // Verify if the store has already been created
                if ( mgr.checkStoreExists( conn ) > 0 ) {
                    if (tableDAOs == null) {
                    Globals.getLogger().log(Logger.WARNING,
                        BrokerResources.E_CREATE_DATABASE_TABLE_FAILED,
                        Globals.getBrokerResources().getString(
                            BrokerResources.E_DATABASE_TABLE_ALREADY_CREATED));
                    continueOnError = true;
                    } else {
                    Globals.getLogger().log(Logger.WARNING,
                        BrokerResources.E_CREATE_DATABASE_TABLE_FAILED,
                        Globals.getBrokerResources().getString(
                            BrokerResources.E_THE_DATABASE_TABLE_ALREADY_CREATED, dao.getTableName()));
                    }
                    break;
                } else if (continueOnError) {
                    // Just log msg and continue
                    Globals.getLogger().log(Logger.WARNING, be.toString(), be.getCause());
                } else {
                    throw be;
                }
            }
        }

        if ( tableDAOs != null || !(mgr instanceof DBManager) ) {
            return;
        }

        DAOFactory daoFactory = ((DBManager)mgr).getDAOFactory();

      // Insert version info in the version table
        VersionDAO versionDAO = daoFactory.getVersionDAO();
        try {
            if ( continueOnError ) {
                // Do this only if version is missing from version table
                int storeVersion = versionDAO.getStoreVersion( conn );
                if ( storeVersion != JDBCStore.STORE_VERSION ) {
                    versionDAO.insert( conn, JDBCStore.STORE_VERSION );
                }
            } else {
                versionDAO.insert( conn, JDBCStore.STORE_VERSION );
            }
        } catch (BrokerException be) {
            if ( Globals.getHAEnabled() ) {
                // Re-check if version info has been added by another broker
                int storeVersion = versionDAO.getStoreVersion( conn );
                if ( storeVersion != JDBCStore.STORE_VERSION ) {
                    throw be; // Re-throw the exception
                }
            } else {
                throw be; // Re-throw the exception
            }
        }

        // Insert a unique store session for the stand-alone broker
        if ( !Globals.getHAEnabled() ) {
            // Do this only if store session is missing from session table
            String brokerID = Globals.getBrokerID();
            StoreSessionDAO sessionDAO = daoFactory.getStoreSessionDAO();
            if ( sessionDAO.getStoreSession( conn, brokerID ) <= 0 ) {
                sessionDAO.insert( conn, brokerID, new UID().longValue(), true );
            }
        }

        PropertyDAO dao = daoFactory.getPropertyDAO();
        dao.update( conn, STORE_PROPERTY_SUPPORT_JMSBRIDGE, Boolean.valueOf(true));
    }
View Full Code Here


                    Util.close( null, stmt, null, myex, mgr );
                }
            } else {
                Iterator itr = mgr.allDAOIterator();
                while ( itr.hasNext() ) {
                    BaseDAO dao = (BaseDAO)itr.next();
                    try {
                        Util.RetryStrategy retry = null;
                        do {
                            try {
                                dao.dropTable( conn );
                                break; // table dropped so break from retry loop
                            } catch ( Exception e ) {
                                // Exception will be log & re-throw if operation cannot be retry
                                if ( retry == null ) {
                                    retry = new Util.RetryStrategy(mgr);
View Full Code Here

            }
        } else {
            // Starting in 4.0, use info from BaseDAO.getDebugInfo()
            Iterator itr = mgr.allDAOIterator();
            while ( itr.hasNext() ) {
                BaseDAO dao = (BaseDAO)itr.next();
                System.out.println( dao.getDebugInfo( dbconn ).toString() );

            }
        }
    }
View Full Code Here

                        daoFactory.getJMSBGDAO().deleteAll(conn);
                    } else {
                        List daos = daoFactory.getAllDAOs();
                        Iterator itr = daos.iterator();
                        while (itr.hasNext()) {
                            BaseDAO dao = (BaseDAO)itr.next();
                            if ( !(dao instanceof VersionDAO ||
                                   dao instanceof BrokerDAO ||
                                   dao instanceof StoreSessionDAO) ) {
                                dao.deleteAll(conn);
                            }
                        }
                    }
                    conn.commit();
                    return;
View Full Code Here

TOP

Related Classes of com.sun.messaging.jmq.jmsserver.persist.jdbc.comm.BaseDAO

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.