Java Code Examples for org.apache.distributedlog.DLSN#getLogSegmentSequenceNo()

The following examples show how to use org.apache.distributedlog.DLSN#getLogSegmentSequenceNo() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ClusterStateOpLog.java    From Elasticsearch with Apache License 2.0 6 votes vote down vote up
public void truncateLogBeforeDLSN(final DLSN dlsn) {
    if (dlsn.getLogSegmentSequenceNo() <= truncatedDlsn.getLogSegmentSequenceNo()) {
        return;
    }
    this.logWriter.truncate(dlsn).addEventListener(new FutureEventListener<Boolean>() {

        @Override
        public void onFailure(Throwable t) {
            logger.error("errors while truncate log after DLSN [{}]", t, dlsn);
        }

        @Override
        public void onSuccess(Boolean isSuccess) {
            if (isSuccess) {
                truncatedDlsn = dlsn;
                logger.info("truncate log before [{}]", dlsn);
            }
        }
    });
}
 
Example 2
Source File: DistributedTranslog.java    From Elasticsearch with Apache License 2.0 6 votes vote down vote up
public void truncateLogBeforeDLSN(final DLSN dlsn) {
    if (dlsn.getLogSegmentSequenceNo() <= truncatedDlsn.getLogSegmentSequenceNo()) {
        logger.info("previous truncate dlsn is [{}], current dlsn is [{}], segment no not change not call truncate", truncatedDlsn, dlsn);
        return;
    }
    if (this.logWriter == null) {
        logger.error("log writer is closed, maybe not primary any more, skip truncate");
        return;
    }
    this.logWriter.truncate(dlsn).addEventListener(new FutureEventListener<Boolean>() {

        @Override
        public void onFailure(Throwable t) {
            logger.error("errors while truncate log after DLSN [{}]", t, dlsn);
        }

        @Override
        public void onSuccess(Boolean isSuccess) {
            if (isSuccess) {
                truncatedDlsn = dlsn;
                logger.info("truncate log before [{}] successfully", dlsn);
            }
        }
    });
}
 
Example 3
Source File: ClusterStateOpLog.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
public static boolean shouldDump(DLSN currentDlsn, DLSN previousDlsn, long threshold) {
    if (previousDlsn == null || currentDlsn == null) {
        return true;
    }
    if (currentDlsn.getLogSegmentSequenceNo() != previousDlsn.getLogSegmentSequenceNo()) {
        return true;
    }
    if (currentDlsn.getEntryId() - previousDlsn.getEntryId() > threshold) {
        return true;
    }
    return false;
}