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