All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.netflix.astyanax.WriteAheadLog Maven / Gradle / Ivy

There is a newer version: 3.9.0
Show newest version
/**
 * Copyright 2013 Netflix, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.netflix.astyanax;

import com.netflix.astyanax.connectionpool.exceptions.WalException;

/**
 * Base interface for a write ahead log. The purpose of the WAL is to provide
 * atomicity and durability when writing to Cassandra. Before writing to
 * cassandra a record is written to the WAL which is assumed to stable storage
 * able to survive from a crash or hardware failure. After a crash the system
 * will inspect the WAL for records and replay them. If a record is successfully
 * written to cassandra it will be removed from the WAL.
 * 
 * @author elandau
 * 
 */
public interface WriteAheadLog {
    /**
     * Add an entry to WAL before it is sent to Cassandra.
     * 
     * @param batch
     * @return
     */
    WriteAheadEntry createEntry() throws WalException;

    /**
     * Remove an entry from the WAL after it was successfully written to
     * cassandra
     * 
     * @param entry
     */
    void removeEntry(WriteAheadEntry entry);

    /**
     * Read the next entry to retry from the wall. Call remove if successful or
     * retryEntry if unable to write to cassandra.
     * 
     * @return
     */
    WriteAheadEntry readNextEntry();

    /**
     * Retry an entry retrieved by calling getNextEntry();
     * 
     * @param entry
     */
    void retryEntry(WriteAheadEntry entry);
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy