create() and close() to not throw an IOException.

This commit is contained in:
Peter Lawrey
2014-11-15 10:40:09 +00:00
parent 014a5fd154
commit 524834f1c2
6 changed files with 18 additions and 24 deletions
@@ -23,7 +23,6 @@ import net.openhft.chronicle.set.ChronicleSet;
import java.io.Closeable;
import java.io.File;
import java.io.IOException;
/**
* This interface defines common {@link ChronicleMap} and {@link ChronicleSet}, related to off-heap
@@ -61,5 +60,5 @@ public interface ChronicleHash extends Closeable {
* <i>any</i> exception, or even JVM crash. Shortly speaking, don't call use map closing.
*/
@Override
void close() throws IOException;
void close();
}
@@ -782,7 +782,7 @@ public abstract class AbstractChronicleMapBuilder<K, V,
}
@Override
public ChronicleMap<K, V> create() throws IOException {
public ChronicleMap<K, V> create() {
// clone() to make this builder instance thread-safe, because createWithoutFile() method
// computes some state based on configurations, but doesn't synchronize on configuration
// changes.
@@ -856,12 +856,17 @@ public abstract class AbstractChronicleMapBuilder<K, V,
}
ChronicleMap<K, V> createWithoutFile(
SingleChronicleHashReplication singleHashReplication, ReplicationChannel channel) throws IOException {
VanillaChronicleMap<K, ?, ?, V, ?, ?> map = newMap(singleHashReplication, channel);
BytesStore bytesStore = new DirectStore(JDKObjectSerializer.INSTANCE,
map.sizeInBytes(), true);
map.createMappedStoreAndSegments(bytesStore);
return establishReplication(map, singleHashReplication, channel);
SingleChronicleHashReplication singleHashReplication, ReplicationChannel channel) {
try {
VanillaChronicleMap<K, ?, ?, V, ?, ?> map = newMap(singleHashReplication, channel);
BytesStore bytesStore = new DirectStore(JDKObjectSerializer.INSTANCE,
map.sizeInBytes(), true);
map.createMappedStoreAndSegments(bytesStore);
return establishReplication(map, singleHashReplication, channel);
} catch (IOException e) {
// file-less version should never trigger an IOException.
throw new AssertionError(e);
}
}
ChronicleMap<K, V> createStatelessMap(StatelessMapConfig<K, V> statelessBuilder)
@@ -123,7 +123,7 @@ class SetFromMap<E> extends AbstractSet<E>
}
@Override
public void close() throws IOException {
public void close() {
m.close();
}
}