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 * Renames the tree from the old to the new name. 046 * 047 * @param oldName 048 * the old tree name 049 * @param newName 050 * the new tree name 051 */ 052 void renameTree(TreeName oldName, TreeName newName); 053 054 /** 055 * Deletes the tree identified by the provided name. 056 * 057 * @param name 058 * the tree name 059 */ 060 void deleteTree(TreeName name); 061 062 /** 063 * Adds a record with the provided key and value, replacing any existing record having the same 064 * key. 065 * 066 * @param treeName 067 * the tree name 068 * @param key 069 * the key of the new record 070 * @param value 071 * the value of the new record 072 */ 073 void put(TreeName treeName, ByteSequence key, ByteSequence value); 074 075 /** 076 * Atomically adds, deletes, or replaces a record with the provided key according to the new value 077 * computed by the update function. 078 * 079 * @param treeName 080 * the tree name 081 * @param key 082 * the key of the new record 083 * @param f 084 * the update function 085 * @return {@code true} if an update was performed, {@code false} otherwise 086 * @see UpdateFunction#computeNewValue(ByteSequence) 087 */ 088 boolean update(TreeName treeName, ByteSequence key, UpdateFunction f); 089 090 /** 091 * Deletes the record with the provided key, in the tree whose name is provided. 092 * 093 * @param treeName 094 * the tree name 095 * @param key 096 * the key of the record to delete 097 * @return {@code true} if the record could be deleted, {@code false} otherwise 098 */ 099 boolean delete(TreeName treeName, ByteSequence key); 100}