001/* 002 * The contents of this file are subject to the terms of the Common Development and 003 * Distribution License (the License). You may not use this file except in compliance with the 004 * License. 005 * 006 * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the 007 * specific language governing permission and limitations under the License. 008 * 009 * When distributing Covered Software, include this CDDL Header Notice in each file and include 010 * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL 011 * Header, with the fields enclosed by brackets [] replaced by your own identifying 012 * information: "Portions Copyright [year] [name of copyright owner]". 013 * 014 * Copyright 2014-2015 ForgeRock AS. 015 */ 016package org.opends.server.backends.pluggable.spi; 017 018import org.forgerock.opendj.ldap.ByteSequence; 019 020/** 021 * Represents a writeable transaction on a storage engine. 022 */ 023public interface WriteableTransaction extends ReadableTransaction 024{ 025 /** 026 * Opens the tree identified by the provided name. 027 * 028 * @param name 029 * the tree name 030 * @param createOnDemand true if the tree should be created if it does not exist 031 */ 032 void openTree(TreeName name, boolean createOnDemand); 033 034 /** 035 * Deletes the tree identified by the provided name. 036 * 037 * @param name 038 * the tree name 039 */ 040 void deleteTree(TreeName name); 041 042 /** 043 * Adds a record with the provided key and value, replacing any existing record having the same 044 * key. 045 * 046 * @param treeName 047 * the tree name 048 * @param key 049 * the key of the new record 050 * @param value 051 * the value of the new record 052 */ 053 void put(TreeName treeName, ByteSequence key, ByteSequence value); 054 055 /** 056 * Atomically adds, deletes, or replaces a record with the provided key according to the new value 057 * computed by the update function. 058 * 059 * @param treeName 060 * the tree name 061 * @param key 062 * the key of the new record 063 * @param f 064 * the update function 065 * @return {@code true} if an update was performed, {@code false} otherwise 066 * @see UpdateFunction#computeNewValue(ByteSequence) 067 */ 068 boolean update(TreeName treeName, ByteSequence key, UpdateFunction f); 069 070 /** 071 * Deletes the record with the provided key, in the tree whose name is provided. 072 * 073 * @param treeName 074 * the tree name 075 * @param key 076 * the key of the record to delete 077 * @return {@code true} if the record could be deleted, {@code false} otherwise 078 */ 079 boolean delete(TreeName treeName, ByteSequence key); 080}