01: /*
02:
03: Derby - Class org.apache.derby.io.WritableStorageFactory
04:
05: Licensed to the Apache Software Foundation (ASF) under one or more
06: contributor license agreements. See the NOTICE file distributed with
07: this work for additional information regarding copyright ownership.
08: The ASF licenses this file to You under the Apache License, Version 2.0
09: (the "License"); you may not use this file except in compliance with
10: the License. You may obtain a copy of the License at
11:
12: http://www.apache.org/licenses/LICENSE-2.0
13:
14: Unless required by applicable law or agreed to in writing, software
15: distributed under the License is distributed on an "AS IS" BASIS,
16: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17: See the License for the specific language governing permissions and
18: limitations under the License.
19:
20: */
21:
22: package org.apache.derby.io;
23:
24: import java.io.OutputStream;
25: import java.io.IOException;
26: import java.io.SyncFailedException;
27:
28: /**
29: * This interface extends StorageFactory to provide read/write access to storage.
30: *<p>
31: * The database engine will call this interface's methods from its own privilege blocks.
32: *<p>
33: * Each WritableStorageFactory instance may be concurrently used by multiple threads.
34: *
35: */
36: public interface WritableStorageFactory extends StorageFactory {
37:
38: /**
39: * Force the data of an output stream out to the underlying storage. That is, ensure that
40: * it has been made persistent. If the database is to be transient, that is, if the database
41: * does not survive a restart, then the sync method implementation need not do anything.
42: *
43: * @param stream The stream to be synchronized.
44: * @param metaData If true then this method must force both changes to the file's
45: * contents and metadata to be written to storage; if false, it need only force file content changes
46: * to be written. The implementation is allowed to ignore this parameter and always force out
47: * metadata changes.
48: *
49: * @exception IOException if an I/O error occurs.
50: * @exception SyncFailedException Thrown when the buffers cannot be flushed,
51: * or because the system cannot guarantee that all the buffers have been
52: * synchronized with physical media.
53: */
54: public void sync(OutputStream stream, boolean metaData)
55: throws IOException, SyncFailedException;
56:
57: /**
58: * This method tests whether the StorageRandomAccessFile "rws" and "rwd" modes
59: * are implemented. If the "rws" method is supported then the database
60: * engine will conclude that the write methods of "rws" mode
61: * StorageRandomAccessFiles are slow but the sync method is fast and optimize
62: * accordingly.
63: *
64: * @return <b>true</b> if an StIRandomAccess file opened with "rws" or "rwd" modes immediately writes data to the
65: * underlying storage, <b>false</b> if not.
66: */
67: public boolean supportsRws();
68: }
|