Package org.xtreemfs.babudb.log

Examples of org.xtreemfs.babudb.log.LogEntry


                        accessCounter.notify();
                    }
                }
               
                LSN assignedByDiskLogger = localFuture.getAssignedLSN();
                LogEntry le = new LogEntry(payload, new ListenerWrapper(future, result),
                                           PAYLOAD_TYPE_TRANSACTION);
                le.assignId(assignedByDiskLogger.getViewId(), assignedByDiskLogger.getSequenceNo());
               
                ReplicateResponse rp = replMan.replicate(le);
                if (!rp.hasFailed()) {
                    replMan.subscribeListener(rp);
                }
               
                le.free();
            }
           
            @Override
            public void failed(BabuDBException error, Object context) {
               
View Full Code Here


                        accessCounter.notify();
                    }
                }
               
                LSN assignedByDiskLogger = localFuture.getAssignedLSN();
                LogEntry le = new LogEntry(payload, new ListenerWrapper(future, result),
                                           PAYLOAD_TYPE_TRANSACTION);
                le.assignId(assignedByDiskLogger.getViewId(), assignedByDiskLogger.getSequenceNo());
               
                ReplicateResponse rp = replMan.replicate(le);
                if (!rp.hasFailed()) {
                    replMan.subscribeListener(rp);
                }
               
                le.free();
            }
           
            @Override
            public void failed(BabuDBException error, Object context) {
               
View Full Code Here

            final AtomicInteger count = new AtomicInteger(logEntries.length);
            // insert all logEntries
            LSN check = null;
            for (ReusableBuffer le : logEntries) {
                try {
                    final LogEntry logentry = LogEntry.deserialize(le, this.checksum);
                    final LSN lsn = logentry.getLSN();
                   
                    // assertion whether the received entry does match the order
                    // or not
                    assert (check == null ||
                           (check.getViewId() == lsn.getViewId() &&
View Full Code Here

       
        assert (firstEntry.compareTo(end) < 0) :
            "At least one LogEntry has to be requested!";
       
        DiskLogIterator it = null;
        LogEntry le = null;
        synchronized (babuInterface.getCheckpointerLock()) {
            try {  
                // wait, if there is a checkpoint in proceeding
                babuInterface.waitForCheckpoint();
               
                it = fileIO.getLogEntryIterator(start);
               
                while (it.hasNext() &&
                       result.getLogEntriesCount() <
                       MAX_LOGENTRIES_PER_REQUEST && (le = it.next())
                           .getLSN().compareTo(end) < 0) {
                   
                    try {
                        // we are not at the right position yet -> skip
                        if (le.getLSN().compareTo(firstEntry) < 0) continue;
                   
                        // the first entry was not available ... bad
                        if (le.getLSN().compareTo(firstEntry) > 0 &&
                            result.getLogEntriesCount() == 0) {
                            break;
                        }
                         
                        // add the logEntry to result list
                        assert (le.getPayload().array().length > 0) :
                            "Empty log-entries are not allowed!";
                        ReusableBuffer buf = le.serialize(checksum);
                        result.addLogEntries(
                                org.xtreemfs.babudb.pbrpc.GlobalTypes.LogEntry
                                .newBuilder().setLength(buf.remaining()));
                        int newSize = resultPayLoad.remaining() +
                                      buf.remaining();
                        if (!resultPayLoad.enlarge(newSize)) {
                            ReusableBuffer tmp = BufferPool.allocate(newSize);
                           
                            tmp.put(resultPayLoad);
                            BufferPool.free(resultPayLoad);
                            resultPayLoad = tmp;
                        }
                        resultPayLoad.put(buf);
                        BufferPool.free(buf);
                       
                    } finally {
                        checksum.reset();
                        if (le != null) {
                            le.free();
                            le = null;
                        }
                    }
                }
               
                if (result.getLogEntriesCount() > 0) {
                    // send the response, if the requested log entries are found
                    Logging.logMessage(Logging.LEVEL_DEBUG, this,
                            "REQUEST: returning %d log-entries to %s.",
                            result.getLogEntriesCount(), rq.getSenderAddress().toString());
                   
                    resultPayLoad.flip();
                    rq.sendSuccess(result.build(), resultPayLoad);
                } else {
                    rq.sendSuccess(result.setErrorCode(
                            ErrorCode.LOG_UNAVAILABLE).build());
                }
            } catch (Exception e) {
                Logging.logError(Logging.LEVEL_INFO, this, e);
               
                // clear result
                BufferPool.free(resultPayLoad);
               
                rq.sendSuccess(result.setErrorCode(ErrorCode.BUSY).build());
            } finally {
                if (le != null) le.free();
               
                if (it != null) {
                    try {
                        it.destroy();
                    } catch (IOException e) { /* ignored */ }
View Full Code Here

               
                assertTrue(args.length == 2);
                LSN receivedLSN = (LSN) args[0];
                assertEquals(testLSN, receivedLSN);
               
                LogEntry receivedEntry = (LogEntry) args[1];
                assertEquals(testEntry.getPayloadType(), receivedEntry.getPayloadType());
                assertEquals(testType, receivedEntry.getPayloadType());
                assertEquals(testEntry.getPayload().capacity(), receivedEntry.getPayload().capacity());
                assertEquals(testEntry.getPayload().remaining(), receivedEntry.getPayload().remaining());
                assertEquals(testEntry.getPayload().position(), receivedEntry.getPayload().position());
                assertEquals(new String(testEntry.getPayload().array()),
                             new String(receivedEntry.getPayload().array()));
               
                // clean up
                receivedEntry.free();
            }
           
            @Override
            public void createStableState(LSN lastOnView, InetSocketAddress master) {
                fail("Operation should not have been accessed by this test!");
View Full Code Here

     *          processRequest(org.xtreemfs.babudb.replication.transmission.dispatcher.Request)
     */
    @Override
    public void processRequest(Request rq) {
       
        LogEntry le = (LogEntry) rq.getAttachment();
        final LSN lsn = le.getLSN();
        try {
           
            Logging.logMessage(Logging.LEVEL_DEBUG, this, "ReplicateOperation:" +
                    " received %s", le.toString());
            rqMan.enqueueOperation(new Object[]{ lsn, le });
            rq.sendSuccess(ErrorCodeResponse.getDefaultInstance());
        } catch (Exception e) {
            if (le!=null) le.free();
            rq.sendSuccess(ErrorCodeResponse.newBuilder().setErrorCode(ErrorCode.BUSY).build());
        }
    }
View Full Code Here

            DiskLogIterator it = new DiskLogIterator(logFiles, from);
            LSN nextLSN = null;
           
            // apply log entries to databases ...
            while (it.hasNext()) {
                LogEntry le = null;
                try {
                    le = it.next();
                    byte type = le.getPayloadType();
                   
                    Logging.logMessage(Logging.LEVEL_DEBUG, this,
                        "Reading entry LSN(%s) of type (%d) with %d bytes payload from log.", le.getLSN()
                                .toString(), (int) type, le.getPayload().remaining());
                   
                    // in normal there are only transactions to be replayed
                    if (type == PAYLOAD_TYPE_TRANSACTION) {
                        txnMan.replayTransaction(le);
                       
                        // create, copy and delete are not replayed (this block
                        // is for backward
                        // compatibility)
                    } else if (type != PAYLOAD_TYPE_CREATE && type != PAYLOAD_TYPE_COPY
                        && type != PAYLOAD_TYPE_DELETE) {
                       
                        // get the processing logic for the dedicated logEntry
                        // type
                        InMemoryProcessing processingLogic = txnMan.getProcessingLogic().get(type);
                       
                        // deserialize the arguments retrieved from the logEntry
                        OperationInternal operation = processingLogic.convertToOperation(processingLogic
                                .deserializeRequest(le.getPayload()));
                       
                        // execute the in-memory logic
                        try {
                            processingLogic.process(operation);
                        } catch (BabuDBException be) {
                           
                            // there might be false positives if a snapshot to
                            // delete has already been deleted, a snapshot to
                            // create has already been created, or an insertion
                            // has been applied to a database that has already
                            // been deleted
                           
                            // FIXME: A clean solution needs to be provided that
                            // is capable of distinguishing between a corrupted
                            // database and a "false positive". False positives
                            // may occur because management operations are
                            // immediately applied to the persistent database
                            // state rather than being applied when the log is
                            // replayed.
                            // A clean solution would involve a single immutable
                            // configuration file per database/snapshot, which
                            // resides in the database directory and is written
                            // when the first checkpoint is created. When a
                            // database/snapshot gets deleted, an additional
                            // (empty) file is created that indicates the
                            // deletion. When old log files are removed in
                            // response to a checkpoint, the system disposes of
                            // all directories of databases and snapshots that
                            // were deleted in these log files.
                            if (!(type == PAYLOAD_TYPE_SNAP && (be.getErrorCode() == ErrorCode.SNAP_EXISTS || be
                                    .getErrorCode() == ErrorCode.NO_SUCH_DB))
                                && !(type == PAYLOAD_TYPE_SNAP_DELETE && be.getErrorCode() == ErrorCode.NO_SUCH_SNAPSHOT)
                                && !(type == PAYLOAD_TYPE_INSERT && be.getErrorCode().equals(
                                    ErrorCode.NO_SUCH_DB))) {
                               
                                throw be;
                            }
                        }
                    }
                   
                    // set LSN
                    nextLSN = new LSN(le.getViewId(), le.getLogSequenceNo() + 1L);
                } finally {
                    if (le != null) {
                        le.free();
                    }
                }
               
            }
           
View Full Code Here

            DiskLogIterator it = new DiskLogIterator(logFiles, from);
            LSN nextLSN = null;
           
            // apply log entries to databases ...
            while (it.hasNext()) {
                LogEntry le = null;
                try {
                    le = it.next();
                    byte type = le.getPayloadType();
                   
                    Logging.logMessage(Logging.LEVEL_DEBUG, this,
                        "Reading entry LSN(%s) of type (%d) with %d bytes payload from log.", le.getLSN()
                                .toString(), (int) type, le.getPayload().remaining());
                   
                    // in normal there are only transactions to be replayed
                    if (type == PAYLOAD_TYPE_TRANSACTION) {
                        txnMan.replayTransaction(le);
                       
                        // create, copy and delete are not replayed (this block
                        // is for backward
                        // compatibility)
                    } else if (type != PAYLOAD_TYPE_CREATE && type != PAYLOAD_TYPE_COPY
                        && type != PAYLOAD_TYPE_DELETE) {
                       
                        // get the processing logic for the dedicated logEntry
                        // type
                        InMemoryProcessing processingLogic = txnMan.getProcessingLogic().get(type);
                       
                        // deserialize the arguments retrieved from the logEntry
                        OperationInternal operation = processingLogic.convertToOperation(processingLogic
                                .deserializeRequest(le.getPayload()));
                       
                        // execute the in-memory logic
                        try {
                            processingLogic.process(operation);
                        } catch (BabuDBException be) {
                           
                            // there might be false positives if a snapshot to
                            // delete has already been deleted, a snapshot to
                            // create has already been created, or an insertion
                            // has been applied to a database that has already
                            // been deleted
                           
                            // FIXME: A clean solution needs to be provided that
                            // is capable of distinguishing between a corrupted
                            // database and a "false positive". False positives
                            // may occur because management operations are
                            // immediately applied to the persistent database
                            // state rather than being applied when the log is
                            // replayed.
                            // A clean solution would involve a single immutable
                            // configuration file per database/snapshot, which
                            // resides in the database directory and is written
                            // when the first checkpoint is created. When a
                            // database/snapshot gets deleted, an additional
                            // (empty) file is created that indicates the
                            // deletion. When old log files are removed in
                            // response to a checkpoint, the system disposes of
                            // all directories of databases and snapshots that
                            // were deleted in these log files.
                            if (!(type == PAYLOAD_TYPE_SNAP && (be.getErrorCode() == ErrorCode.SNAP_EXISTS || be
                                    .getErrorCode() == ErrorCode.NO_SUCH_DB))
                                && !(type == PAYLOAD_TYPE_SNAP_DELETE && be.getErrorCode() == ErrorCode.NO_SUCH_SNAPSHOT)
                                && !(type == PAYLOAD_TYPE_INSERT && be.getErrorCode().equals(
                                    ErrorCode.NO_SUCH_DB))) {
                               
                                throw be;
                            }
                        }
                    }
                   
                    // set LSN
                    nextLSN = new LSN(le.getViewId(), le.getLogSequenceNo() + 1L);
                } finally {
                    if (le != null) {
                        le.free();
                    }
                }
               
            }
           
View Full Code Here

                txn.toString());
       
        try {
                   
            Object[] result = inMemory(txn, payload);
            LogEntry entry = generateLogEntry(txn, payload, future, result);
                       
            onDisk(txn, entry);
                       
            // notify listeners (async)
            if (isAsync) {
View Full Code Here

     */
   private final LogEntry generateLogEntry(final TransactionInternal txn,
           ReusableBuffer payload, final BabuDBRequestResultImpl<Object> listener,
           final Object[] results) {
       
        LogEntry result = new LogEntry(payload, new SyncListener() {
           
            @Override
            public void synced(LSN lsn) {
       
                try {
View Full Code Here

TOP

Related Classes of org.xtreemfs.babudb.log.LogEntry

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.