Package bm.core.log

Examples of bm.core.log.Log


    public synchronized int getRecordSize( final int recordId )
            throws RSException,
                   InvalidRecordIDException,
                   RecordStoreFullException
    {
        final Log log = Store.log;
        try
        {
            //log.debug( "getRecordSize( " + recordId + " )" );
            open();
            final RecordLocator locator = this.locator;
            locator.translate( recordId );
            makeCurrent( locator.recordId, false );
            if( currentRecord.isNull( locator.offset ) )
            {
                throw new InvalidRecordIDException( Constants.ERR_STR_GET_RECORD_SIZE, Integer.toString( recordId ) );
            }
            else
            {
                return currentRecord.getSize( locator.offset );
            }
        }
        catch( SerializationException e )
        {
            log.error( e );
            throw new RSException( Constants.ERR_STR_GET_RECORD_SIZE, Integer.toString( recordId ) );
        }
        finally
        {
            close();
View Full Code Here


            throws DBException,
                   RSException,
                   RecordStoreFullException
    {
        open();
        final Log log = Database.log;
        try
        {
            final ByteArrayOutputStream baos = new ByteArrayOutputStream();
            final SerializerOutputStream out = new SerializerOutputStream( baos );
            header.serialize( out );
            final byte[] data = baos.toByteArray();
            final Store rs = this.rs;
            if( rs.getNumRecords() == 0 )
            {
                final int recordId = rs.addRecord( data, 0, data.length );
                if( recordId != 1 )
                {
                    shutdown();
                    Store.safeDeleteRecordStore( name + "_db" );
                    saveHeader();
                }
            }
            else
            {
                rs.setRecord( 1, data, 0, data.length );
            }
        }
        catch( Exception e )
        {
            ErrorLog.addError(
                    "Database",
                    "saveHeader",
                    null,
                    null,
                    e
            );
            log.error( e );
            throw new DBException( Constants.ERR_DB_SAVE_DBHEADER, e );
        }
        finally
        {
            close();
View Full Code Here

        }
    }

    private static synchronized void safeCloseRecordStore( final String name )
    {
        final Log log = ErrorLog.log;
        try
        {
            //noinspection RecordStoreOpenedButNotSafelyClosed
            final RecordStore rs = RecordStore.openRecordStore( name, false );
            while( true )
            {
                try
                {
                    rs.closeRecordStore();
                }
                catch( RecordStoreNotOpenException e )
                {
                    break;
                }
                catch ( RecordStoreException e )
                {
                    log.error( e );
                }
            }
        }
        catch( RecordStoreNotFoundException e )
        {
            log.debug( "RecordStore did not exist" );
        }
        catch( RecordStoreException e )
        {
            log.error( e );
        }
    }
View Full Code Here

    )
            throws DBException,
                   RSException,
                   RecordStoreFullException
    {
        final Log log = Table.log;
        try
        {
            open();
            final byte[] data;
            try
            {
                 data = rs.getRecord( recordId );
            }
            catch( InvalidRecordIDException e )
            {
                log.error( "Row does not exist: " + recordId );
                ErrorLog.addError(
                        "Table",
                        "getRowFromStore",
                        new Object[] { new Integer( recordId ) },
                        tableInfo.getName(),
                        e
                );
                throw new RecordNotFoundException(
                         Constants.ERR_TBL_GET_ROW_FROM_STORE,
                         "table.getRowFromStore(): " +
                         Integer.toString( recordId )
                );
            }
            if( !fetchDeleted && data[Row.STATUS_BYTE] == Row.STATUS_DELETED )
            {
                log.warn( "Deleted row: " + recordId );
                ErrorLog.addError(
                        "Table",
                        "getRowFromStore",
                        new Object[] { new Integer( recordId ) },
                        tableInfo.getName() + ": status deleted",
                        null
                );
                throw new RecordNotFoundException(
                        Constants.ERR_TBL_GET_ROW_FROM_STORE,
                        "table.getRowFromStore(): " +
                        Integer.toString( recordId )
                );
            }
            final Row row = new Row( this );
            row.setRecordId( recordId );
            row.deserialize( new SerializerInputStream( new ByteArrayInputStream(
                    data
            ) ) );
            return row;
        }
        catch( SerializationException e )
        {
            log.error( e );
            ErrorLog.addError(
                    "Table",
                    "getRowFromStore",
                    new Object[] { new Integer( recordId ) },
                    tableInfo.getName(),
View Full Code Here

                   RSException
    {
        final TableInfo tableInfo = this.tableInfo;
        final IndexInfo[] indexInfo = tableInfo.getIndexInfo();
        final int count = indexInfo != null ? indexInfo.length : 0;
        final Log log = Table.log;
        log.debug( "shutdown table: " + tableInfo.getName() );
        for( int i = 0; i < count; i++ )
        {
            //noinspection ConstantConditions
            final Index index = (Index) indexMap.get(
                    indexInfo[i].getFieldExpression().toLowerCase()
            );
            log.debug( "shutdown index: " + index.getName() );
//            index.shutdown();
            index.drop();
        }
        if( rs != null )
        {
            try
            {
                rs.drop();
            }
            catch( RSException e )
            {
                log.error( e );
                ErrorLog.addError(
                        "Table",
                        "drop",
                        null,
                        "Error droping recordstore",
View Full Code Here

            final Node      node,
            final int       parentIndex
    )
            throws DBException
    {
        final Log log = Index.log;

        if( !tableIndex )
        {
            log.warn( "not a table index" );
            return;
        }
        if( node == null )
        {
            log.warn( "node is null" );
            return;
        }
        if( node.isLeaf() )
        {
            final int keyCount = node.getKeyCount();
            for( int i = 0; i < keyCount; i++ )
            {
                final NodeKey key = node.getKey( i );
                if( key != null )
                {
                    final SortedIntArray data = (SortedIntArray) key.getData();
                    if( data != null )
                    {
                        records.addElement( data.toIntArray() );
                        if( keys != null )
                        {
                            keys.addElement( key.getKey() );
                        }
                    }
                    else
                    {
                        log.warn( "data is null" );
                    }
                }
                else
                {
                    log.warn( "key " + i + " is null" );
                }
            }
        }
        else
        {
            System.gc();
            buildSortedList( records, keys, node.getChildNode( 0 ), 0 );
        }
        if( parentIndex != -1 && parentIndex < node.getParent().getKeyCount() )
        {
            final NodeKey key = node.getParent().getKey( parentIndex );
            if( key != null )
            {
                final SortedIntArray data = (SortedIntArray) key.getData();
                if( data != null )
                {
                    records.addElement( data.toIntArray() );
                    if( keys != null )
                    {
                        keys.addElement( key.getKey() );
                    }
                }
                else
                {
                    log.warn( "data at parent index " + parentIndex + " is null" );
                }
            }
            else
            {
                log.warn( "key (parent index)" + parentIndex + " is null" );
            }
            System.gc();
            buildSortedList(
                    records,
                    keys,
View Full Code Here

            throws RSException,
                   RecordStoreFullException
    {
        try
        {
            final Log log = Store.log;
            if( map.containsKey( name ) )
            {
                Store store = (Store) map.get( name );
                store.flush();
                store.openCount = 0;
                store.rs = null;
            }
            //noinspection RecordStoreOpenedButNotSafelyClosed
            final RecordStore rs = RecordStore.openRecordStore( name, false );
            while( true )
            {
                try
                {
                    rs.closeRecordStore();
                }
                catch( RecordStoreNotOpenException e )
                {
                    break;
                }
                catch ( RecordStoreException e )
                {
                    log.error( e );
                    throw new RSException( Constants.ERR_STR_CLOSE, e );
                }
            }
        }
        catch( RecordStoreNotFoundException e )
        {
            //log.debug( "RecordStore did not exist" );
        }
        catch( RecordStoreException e )
        {
            log.error( e );
            throw new RSException( Constants.ERR_STR_CLOSE, e );
        }
    }
View Full Code Here

    )
        throws RSException,
               RecordStoreFullException
    {
        final StoreInfo info = this.info;
        final Log log = Store.log;
//        log.debug( "addRecord( " + (data != null) + ", " + offset + ", " + length + " )" );
        final int assignedRecordId = info.nextId;
        final RecordLocator locator = this.locator;
        try
        {
            open();
//            log.debug( "addRecord, nextId: " + assignedRecordId );
            locator.translate( assignedRecordId );
            makeCurrent( locator.recordId, true );
            currentRecord.set( locator.offset, data, offset, length );
            if( !burstMode )
            {
                flush();
            }
            info.addRecord( length );
            return assignedRecordId;
        }
        catch( RecordStoreFullException e )
        {
            throw e;
        }
        catch( Exception e )
        {
            log.error( e );
            ErrorLog.addError(
                    CLASS_NAME,
                    "addRecord",
                    new Object[] { data, new Integer( offset ), new Integer( length ) },
                    info.name,
View Full Code Here

    public synchronized byte[] getRecord( final int recordId )
            throws RSException,
                   InvalidRecordIDException
    {
        final Log log = Store.log;
        try
        {
            //log.debug( "getRecord( " + recordId + " )" );
            open();
            final RecordLocator locator = this.locator;
            locator.translate( recordId );
            makeCurrent( locator.recordId, false );
            return currentRecord.get( locator.offset );
        }
        catch( InvalidRecordIDException e )
        {
            log.error( locator.toString(), e );
            throw e;
        }
        catch( Exception e )
        {
            log.error( e );
            ErrorLog.addError(
                    CLASS_NAME,
                    "getRecord",
                    new Object[] { new Integer( recordId ) },
                    info.name,
View Full Code Here

     * Start application.
     */
    public void startApplication()
    {
        // Local variable to improve speed on CDC
        final Log log = MainController.log;
        bm.core.ErrorHandler.setHandler( new ErrorHandler() );
        Event.register( this, Event.LANGUAGE_CHANGE );
        ProgressEvent pe = new ProgressEvent( this, new Integer( 4 ), 0 );
        pe.setTitle( ResourceManager.getResource( "main.StartApplication" ) );
        pe.dispatch();
        try
        {
            init();
            pe.increment();
            pe.dispatch();

            log.debug( "Starting application" );
            if( !checkConfig() )
            {
                exitApplication();
                return;
            }
            setup();
            pe.increment();
            pe.dispatch();

            if( LoginManager.getEncryptedPassword() == null )
            {
                createPin();
            }
            else
            {
                promptPin();
            }

            View nextView = startDatabase();
            checkDatabaseSanity();
            pe.increment();
            pe.dispatch();
            final Database database = Model.getDatabase();
            DefaultFieldResolver.setDatabase( database );
            if( nextView == null )
            {
                nextView = restoreLastView();
            }
            if( nextView == null )
            {
                nextView = ViewFactory.getMenu( "mainMenu" );
            }
            Event.unregisterAll( Event.PROGRESS );
            Event.register( progressListener, Event.PROGRESS );
            nextView.show();
        }
        catch( RuntimeException e )
        {
            e.printStackTrace();
            log.error( e );
            Application.getManager().showError(
                    ResourceManager.getResource( "error.cantStartApp" ),
                    e
            );
            exitApplication();
        }
        catch( Throwable e )
        {
            e.printStackTrace();
            log.error( e );
            Application.getManager().showError(
                    ResourceManager.getResource( "error.cantStartApp" ) +
                    ": " + e.toString()
            );
            exitApplication();
View Full Code Here

TOP

Related Classes of bm.core.log.Log

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.