summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xcpp/slice/Freeze/Connection.ice10
-rw-r--r--cpp/slice/Freeze/Exception.ice10
-rw-r--r--cpp/src/Freeze/.depend1
-rw-r--r--cpp/src/Freeze/ConnectionI.cpp33
-rw-r--r--cpp/src/Freeze/ConnectionI.h2
-rw-r--r--cpp/src/Freeze/Makefile10
-rw-r--r--cpp/src/Freeze/MapI.cpp7
-rw-r--r--cpp/src/Freeze/SharedDb.cpp127
-rw-r--r--cpp/src/Freeze/SharedDb.h4
-rw-r--r--cpp/src/Freeze/SharedDbEnv.cpp7
-rw-r--r--cpp/src/Freeze/SharedDbEnv.h8
11 files changed, 201 insertions, 18 deletions
diff --git a/cpp/slice/Freeze/Connection.ice b/cpp/slice/Freeze/Connection.ice
index dcd22afc4b6..73ffdb6e5af 100755
--- a/cpp/slice/Freeze/Connection.ice
+++ b/cpp/slice/Freeze/Connection.ice
@@ -61,6 +61,16 @@ local interface Connection
**/
["cpp:const"] Transaction currentTransaction();
+
+ /**
+ *
+ * Remove an old unused Freeze Map index
+ * @throws IndexNotFoundException Raised if this index
+ * does not exist
+ *
+ **/
+ void removeMapIndex(string mapName, string indexName);
+
/**
*
diff --git a/cpp/slice/Freeze/Exception.ice b/cpp/slice/Freeze/Exception.ice
index cf8a84547cc..ed14de1e174 100644
--- a/cpp/slice/Freeze/Exception.ice
+++ b/cpp/slice/Freeze/Exception.ice
@@ -61,6 +61,16 @@ local exception InvalidPositionException
{
};
+/**
+ *
+ * Exception raised when Freeze fails to locate an index
+ *
+ **/
+local exception IndexNotFoundException
+{
+ string mapName;
+ string indexName;
+};
};
diff --git a/cpp/src/Freeze/.depend b/cpp/src/Freeze/.depend
index 2d8e7de007f..8886573779f 100644
--- a/cpp/src/Freeze/.depend
+++ b/cpp/src/Freeze/.depend
@@ -2,6 +2,7 @@ BackgroundSaveEvictor$(OBJEXT): BackgroundSaveEvictor.cpp ../../include/Freeze/B
BackgroundSaveEvictorI$(OBJEXT): BackgroundSaveEvictorI.cpp ../Freeze/BackgroundSaveEvictorI.h ../Freeze/EvictorI.h ../../include/IceUtil/IceUtil.h ../../include/IceUtil/Config.h ../../include/IceUtil/AbstractMutex.h ../../include/IceUtil/Lock.h ../../include/IceUtil/ThreadException.h ../../include/IceUtil/Exception.h ../../include/IceUtil/Algorithm.h ../../include/IceUtil/ArgVector.h ../../include/IceUtil/Base64.h ../../include/IceUtil/Cache.h ../../include/IceUtil/Handle.h ../../include/IceUtil/Mutex.h ../../include/IceUtil/CountDownLatch.h ../../include/IceUtil/Cond.h ../../include/IceUtil/Time.h ../../include/IceUtil/CtrlCHandler.h ../../include/IceUtil/Functional.h ../../include/IceUtil/InputUtil.h ../../include/IceUtil/Iterator.h ../../include/IceUtil/MD5.h ../../include/IceUtil/Monitor.h ../../include/IceUtil/Options.h ../../include/IceUtil/RecMutex.h ../../include/IceUtil/Shared.h ../../include/IceUtil/OutputUtil.h ../../include/IceUtil/RWRecMutex.h ../../include/IceUtil/Thread.h ../../include/IceUtil/Random.h ../../include/IceUtil/ScopedArray.h ../../include/IceUtil/StaticMutex.h ../../include/IceUtil/StringUtil.h ../../include/IceUtil/UUID.h ../../include/IceUtil/Unicode.h ../../include/IceUtil/Timer.h ../../include/Ice/Ice.h ../../include/Ice/Initialize.h ../../include/Ice/CommunicatorF.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Handle.h ../../include/Ice/Config.h ../../include/Ice/ProxyHandle.h ../../include/Ice/ProxyF.h ../../include/Ice/ObjectF.h ../../include/Ice/GCCountMap.h ../../include/Ice/GCShared.h ../../include/Ice/Exception.h ../../include/Ice/LocalObject.h ../../include/Ice/UndefSysMacros.h ../../include/Ice/PropertiesF.h ../../include/Ice/Proxy.h ../../include/Ice/ProxyFactoryF.h ../../include/Ice/ConnectionIF.h ../../include/Ice/EndpointIF.h ../../include/Ice/Endpoint.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/ReferenceF.h ../../include/Ice/OutgoingAsyncF.h ../../include/Ice/Current.h ../../include/Ice/ConnectionF.h ../../include/Ice/Identity.h ../../include/Ice/StreamF.h ../../include/Ice/Object.h ../../include/Ice/IncomingAsyncF.h ../../include/Ice/InstanceF.h ../../include/Ice/LoggerF.h ../../include/Ice/StatsF.h ../../include/Ice/StringConverter.h ../../include/Ice/BuiltinSequences.h ../../include/Ice/LocalException.h ../../include/Ice/Properties.h ../../include/Ice/Outgoing.h ../../include/Ice/BasicStream.h ../../include/Ice/ObjectFactoryF.h ../../include/Ice/Buffer.h ../../include/Ice/Protocol.h ../../include/Ice/Incoming.h ../../include/Ice/ServantLocatorF.h ../../include/Ice/ServantManagerF.h ../../include/Ice/Direct.h ../../include/Ice/Logger.h ../../include/Ice/LoggerUtil.h ../../include/Ice/Stats.h ../../include/Ice/Communicator.h ../../include/Ice/RouterF.h ../../include/Ice/LocatorF.h ../../include/Ice/PluginF.h ../../include/Ice/ImplicitContextF.h ../../include/Ice/ObjectFactory.h ../../include/Ice/ObjectAdapter.h ../../include/Ice/FacetMap.h ../../include/Ice/ServantLocator.h ../../include/Ice/OutgoingAsync.h ../../include/Ice/IncomingAsync.h ../../include/Ice/Process.h ../../include/Ice/Application.h ../../include/Ice/Connection.h ../../include/Ice/Functional.h ../../include/Ice/Stream.h ../../include/Ice/ImplicitContext.h ../../include/Ice/Locator.h ../../include/Ice/UserExceptionFactory.h ../../include/Ice/FactoryTable.h ../../include/Ice/FactoryTableDef.h ../../include/Ice/UserExceptionFactoryF.h ../../include/Ice/ProcessF.h ../../include/Ice/Router.h ../../include/Ice/DispatchInterceptor.h ../../include/Ice/IconvStringConverter.h ../../include/Freeze/Freeze.h ../../include/Freeze/Initialize.h ../../include/Freeze/EvictorF.h ../../include/Freeze/ConnectionF.h ../../include/Freeze/Index.h ../../include/Freeze/DB.h ../../include/Freeze/Transaction.h ../../include/Freeze/BackgroundSaveEvictor.h ../../include/Freeze/Evictor.h ../../include/Freeze/Exception.h ../../include/Freeze/TransactionalEvictor.h ../../include/Freeze/Map.h ../../include/Freeze/Connection.h ../../include/Freeze/TransactionHolder.h ../Freeze/ObjectStore.h ../../include/Freeze/EvictorStorage.h ../Freeze/TransactionI.h ../Freeze/EvictorIteratorI.h ../Freeze/SharedDbEnv.h ../../include/IceUtil/DisableWarnings.h ../Freeze/Util.h
CatalogData$(OBJEXT): CatalogData.cpp ../../include/Freeze/CatalogData.h ../../include/Ice/LocalObjectF.h ../../include/IceUtil/Shared.h ../../include/IceUtil/Config.h ../../include/Ice/Handle.h ../../include/IceUtil/Handle.h ../../include/IceUtil/Exception.h ../../include/Ice/Config.h ../../include/Ice/ProxyHandle.h ../../include/Ice/ProxyF.h ../../include/Ice/ObjectF.h ../../include/Ice/GCCountMap.h ../../include/Ice/GCShared.h ../../include/Ice/Exception.h ../../include/Ice/LocalObject.h ../../include/Ice/UndefSysMacros.h ../../include/Ice/BasicStream.h ../../include/Ice/InstanceF.h ../../include/Ice/ObjectFactoryF.h ../../include/Ice/Buffer.h ../../include/Ice/Protocol.h ../../include/Ice/StringConverter.h ../../include/IceUtil/Unicode.h ../../include/Ice/Object.h ../../include/IceUtil/Mutex.h ../../include/IceUtil/Lock.h ../../include/IceUtil/ThreadException.h ../../include/Ice/IncomingAsyncF.h ../../include/Ice/Current.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/ConnectionF.h ../../include/Ice/Identity.h ../../include/Ice/StreamF.h ../../include/IceUtil/Iterator.h ../../include/IceUtil/ScopedArray.h ../../include/IceUtil/DisableWarnings.h
Catalog$(OBJEXT): Catalog.cpp ../../include/Ice/BasicStream.h ../../include/Ice/InstanceF.h ../../include/IceUtil/Shared.h ../../include/IceUtil/Config.h ../../include/Ice/Handle.h ../../include/IceUtil/Handle.h ../../include/IceUtil/Exception.h ../../include/Ice/Config.h ../../include/Ice/ProxyHandle.h ../../include/Ice/ObjectF.h ../../include/Ice/GCCountMap.h ../../include/Ice/GCShared.h ../../include/Ice/ProxyF.h ../../include/Ice/ObjectFactoryF.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Exception.h ../../include/Ice/LocalObject.h ../../include/Ice/UndefSysMacros.h ../../include/Ice/Buffer.h ../../include/Ice/Protocol.h ../../include/Ice/StringConverter.h ../../include/IceUtil/Unicode.h ../../include/Freeze/Catalog.h ../../include/Freeze/Map.h ../../include/Ice/Ice.h ../../include/Ice/Initialize.h ../../include/Ice/CommunicatorF.h ../../include/Ice/PropertiesF.h ../../include/Ice/Proxy.h ../../include/IceUtil/Mutex.h ../../include/IceUtil/Lock.h ../../include/IceUtil/ThreadException.h ../../include/Ice/ProxyFactoryF.h ../../include/Ice/ConnectionIF.h ../../include/Ice/EndpointIF.h ../../include/Ice/Endpoint.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/ReferenceF.h ../../include/Ice/OutgoingAsyncF.h ../../include/Ice/Current.h ../../include/Ice/ConnectionF.h ../../include/Ice/Identity.h ../../include/Ice/StreamF.h ../../include/Ice/Object.h ../../include/Ice/IncomingAsyncF.h ../../include/Ice/LoggerF.h ../../include/Ice/StatsF.h ../../include/Ice/BuiltinSequences.h ../../include/Ice/LocalException.h ../../include/Ice/Properties.h ../../include/Ice/Outgoing.h ../../include/IceUtil/Monitor.h ../../include/IceUtil/Cond.h ../../include/IceUtil/Time.h ../../include/Ice/Incoming.h ../../include/Ice/ServantLocatorF.h ../../include/Ice/ServantManagerF.h ../../include/Ice/Direct.h ../../include/Ice/Logger.h ../../include/Ice/LoggerUtil.h ../../include/Ice/Stats.h ../../include/Ice/Communicator.h ../../include/Ice/RouterF.h ../../include/Ice/LocatorF.h ../../include/Ice/PluginF.h ../../include/Ice/ImplicitContextF.h ../../include/Ice/ObjectFactory.h ../../include/Ice/ObjectAdapter.h ../../include/Ice/FacetMap.h ../../include/Ice/ServantLocator.h ../../include/Ice/OutgoingAsync.h ../../include/IceUtil/RecMutex.h ../../include/Ice/IncomingAsync.h ../../include/Ice/Process.h ../../include/Ice/Application.h ../../include/Ice/Connection.h ../../include/Ice/Functional.h ../../include/IceUtil/Functional.h ../../include/Ice/Stream.h ../../include/Ice/ImplicitContext.h ../../include/Ice/Locator.h ../../include/Ice/UserExceptionFactory.h ../../include/Ice/FactoryTable.h ../../include/Ice/FactoryTableDef.h ../../include/IceUtil/StaticMutex.h ../../include/Ice/UserExceptionFactoryF.h ../../include/Ice/ProcessF.h ../../include/Ice/Router.h ../../include/Ice/DispatchInterceptor.h ../../include/Ice/IconvStringConverter.h ../../include/Freeze/DB.h ../../include/Freeze/Exception.h ../../include/Freeze/Connection.h ../../include/Freeze/Transaction.h ../../include/Freeze/CatalogData.h
+CatalogIndexList$(OBJEXT): CatalogIndexList.cpp ../../include/Ice/BasicStream.h ../../include/Ice/InstanceF.h ../../include/IceUtil/Shared.h ../../include/IceUtil/Config.h ../../include/Ice/Handle.h ../../include/IceUtil/Handle.h ../../include/IceUtil/Exception.h ../../include/Ice/Config.h ../../include/Ice/ProxyHandle.h ../../include/Ice/ObjectF.h ../../include/Ice/GCCountMap.h ../../include/Ice/GCShared.h ../../include/Ice/ProxyF.h ../../include/Ice/ObjectFactoryF.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Exception.h ../../include/Ice/LocalObject.h ../../include/Ice/UndefSysMacros.h ../../include/Ice/Buffer.h ../../include/Ice/Protocol.h ../../include/Ice/StringConverter.h ../../include/IceUtil/Unicode.h ../../include/Freeze/CatalogIndexList.h ../../include/Freeze/Map.h ../../include/Ice/Ice.h ../../include/Ice/Initialize.h ../../include/Ice/CommunicatorF.h ../../include/Ice/PropertiesF.h ../../include/Ice/Proxy.h ../../include/IceUtil/Mutex.h ../../include/IceUtil/Lock.h ../../include/IceUtil/ThreadException.h ../../include/Ice/ProxyFactoryF.h ../../include/Ice/ConnectionIF.h ../../include/Ice/EndpointIF.h ../../include/Ice/Endpoint.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/ReferenceF.h ../../include/Ice/OutgoingAsyncF.h ../../include/Ice/Current.h ../../include/Ice/ConnectionF.h ../../include/Ice/Identity.h ../../include/Ice/StreamF.h ../../include/Ice/Object.h ../../include/Ice/IncomingAsyncF.h ../../include/Ice/LoggerF.h ../../include/Ice/StatsF.h ../../include/Ice/BuiltinSequences.h ../../include/Ice/LocalException.h ../../include/Ice/Properties.h ../../include/Ice/Outgoing.h ../../include/IceUtil/Monitor.h ../../include/IceUtil/Cond.h ../../include/IceUtil/Time.h ../../include/Ice/Incoming.h ../../include/Ice/ServantLocatorF.h ../../include/Ice/ServantManagerF.h ../../include/Ice/Direct.h ../../include/Ice/Logger.h ../../include/Ice/LoggerUtil.h ../../include/Ice/Stats.h ../../include/Ice/Communicator.h ../../include/Ice/RouterF.h ../../include/Ice/LocatorF.h ../../include/Ice/PluginF.h ../../include/Ice/ImplicitContextF.h ../../include/Ice/ObjectFactory.h ../../include/Ice/ObjectAdapter.h ../../include/Ice/FacetMap.h ../../include/Ice/ServantLocator.h ../../include/Ice/OutgoingAsync.h ../../include/IceUtil/RecMutex.h ../../include/Ice/IncomingAsync.h ../../include/Ice/Process.h ../../include/Ice/Application.h ../../include/Ice/Connection.h ../../include/Ice/Functional.h ../../include/IceUtil/Functional.h ../../include/Ice/Stream.h ../../include/Ice/ImplicitContext.h ../../include/Ice/Locator.h ../../include/Ice/UserExceptionFactory.h ../../include/Ice/FactoryTable.h ../../include/Ice/FactoryTableDef.h ../../include/IceUtil/StaticMutex.h ../../include/Ice/UserExceptionFactoryF.h ../../include/Ice/ProcessF.h ../../include/Ice/Router.h ../../include/Ice/DispatchInterceptor.h ../../include/Ice/IconvStringConverter.h ../../include/Freeze/DB.h ../../include/Freeze/Exception.h ../../include/Freeze/Connection.h ../../include/Freeze/Transaction.h
ConnectionI$(OBJEXT): ConnectionI.cpp ../Freeze/ConnectionI.h ../../include/Freeze/Connection.h ../../include/Ice/LocalObjectF.h ../../include/IceUtil/Shared.h ../../include/IceUtil/Config.h ../../include/Ice/Handle.h ../../include/IceUtil/Handle.h ../../include/IceUtil/Exception.h ../../include/Ice/Config.h ../../include/Ice/ProxyHandle.h ../../include/Ice/ProxyF.h ../../include/Ice/ObjectF.h ../../include/Ice/GCCountMap.h ../../include/Ice/GCShared.h ../../include/Ice/Exception.h ../../include/Ice/LocalObject.h ../../include/Freeze/Transaction.h ../../include/Ice/UndefSysMacros.h ../../include/Ice/CommunicatorF.h ../../include/Freeze/Initialize.h ../../include/Ice/Ice.h ../../include/Ice/Initialize.h ../../include/Ice/PropertiesF.h ../../include/Ice/Proxy.h ../../include/IceUtil/Mutex.h ../../include/IceUtil/Lock.h ../../include/IceUtil/ThreadException.h ../../include/Ice/ProxyFactoryF.h ../../include/Ice/ConnectionIF.h ../../include/Ice/EndpointIF.h ../../include/Ice/Endpoint.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/ReferenceF.h ../../include/Ice/OutgoingAsyncF.h ../../include/Ice/Current.h ../../include/Ice/ConnectionF.h ../../include/Ice/Identity.h ../../include/Ice/StreamF.h ../../include/Ice/Object.h ../../include/Ice/IncomingAsyncF.h ../../include/Ice/InstanceF.h ../../include/Ice/LoggerF.h ../../include/Ice/StatsF.h ../../include/Ice/StringConverter.h ../../include/Ice/BuiltinSequences.h ../../include/Ice/LocalException.h ../../include/Ice/Properties.h ../../include/Ice/Outgoing.h ../../include/IceUtil/Monitor.h ../../include/IceUtil/Cond.h ../../include/IceUtil/Time.h ../../include/Ice/BasicStream.h ../../include/Ice/ObjectFactoryF.h ../../include/Ice/Buffer.h ../../include/Ice/Protocol.h ../../include/IceUtil/Unicode.h ../../include/Ice/Incoming.h ../../include/Ice/ServantLocatorF.h ../../include/Ice/ServantManagerF.h ../../include/Ice/Direct.h ../../include/Ice/Logger.h ../../include/Ice/LoggerUtil.h ../../include/Ice/Stats.h ../../include/Ice/Communicator.h ../../include/Ice/RouterF.h ../../include/Ice/LocatorF.h ../../include/Ice/PluginF.h ../../include/Ice/ImplicitContextF.h ../../include/Ice/ObjectFactory.h ../../include/Ice/ObjectAdapter.h ../../include/Ice/FacetMap.h ../../include/Ice/ServantLocator.h ../../include/Ice/OutgoingAsync.h ../../include/IceUtil/RecMutex.h ../../include/Ice/IncomingAsync.h ../../include/Ice/Process.h ../../include/Ice/Application.h ../../include/Ice/Connection.h ../../include/Ice/Functional.h ../../include/IceUtil/Functional.h ../../include/Ice/Stream.h ../../include/Ice/ImplicitContext.h ../../include/Ice/Locator.h ../../include/Ice/UserExceptionFactory.h ../../include/Ice/FactoryTable.h ../../include/Ice/FactoryTableDef.h ../../include/IceUtil/StaticMutex.h ../../include/Ice/UserExceptionFactoryF.h ../../include/Ice/ProcessF.h ../../include/Ice/Router.h ../../include/Ice/DispatchInterceptor.h ../../include/Ice/IconvStringConverter.h ../../include/Freeze/EvictorF.h ../../include/Freeze/ConnectionF.h ../../include/Freeze/Index.h ../../include/Freeze/DB.h ../Freeze/TransactionI.h ../Freeze/SharedDbEnv.h ../Freeze/MapI.h ../../include/Freeze/Map.h ../../include/Freeze/Exception.h ../Freeze/SharedDb.h
Connection$(OBJEXT): Connection.cpp ../../include/Freeze/Connection.h ../../include/Ice/LocalObjectF.h ../../include/IceUtil/Shared.h ../../include/IceUtil/Config.h ../../include/Ice/Handle.h ../../include/IceUtil/Handle.h ../../include/IceUtil/Exception.h ../../include/Ice/Config.h ../../include/Ice/ProxyHandle.h ../../include/Ice/ProxyF.h ../../include/Ice/ObjectF.h ../../include/Ice/GCCountMap.h ../../include/Ice/GCShared.h ../../include/Ice/Exception.h ../../include/Ice/LocalObject.h ../../include/Freeze/Transaction.h ../../include/Ice/UndefSysMacros.h ../../include/Ice/CommunicatorF.h ../../include/IceUtil/Iterator.h ../../include/IceUtil/ScopedArray.h ../../include/IceUtil/DisableWarnings.h
DB$(OBJEXT): DB.cpp ../../include/Freeze/DB.h ../../include/Ice/LocalObjectF.h ../../include/IceUtil/Shared.h ../../include/IceUtil/Config.h ../../include/Ice/Handle.h ../../include/IceUtil/Handle.h ../../include/IceUtil/Exception.h ../../include/Ice/Config.h ../../include/Ice/ProxyHandle.h ../../include/Ice/ProxyF.h ../../include/Ice/ObjectF.h ../../include/Ice/GCCountMap.h ../../include/Ice/GCShared.h ../../include/Ice/Exception.h ../../include/Ice/LocalObject.h ../../include/Ice/UndefSysMacros.h ../../include/Ice/BasicStream.h ../../include/Ice/InstanceF.h ../../include/Ice/ObjectFactoryF.h ../../include/Ice/Buffer.h ../../include/Ice/Protocol.h ../../include/Ice/StringConverter.h ../../include/IceUtil/Unicode.h ../../include/Ice/Object.h ../../include/IceUtil/Mutex.h ../../include/IceUtil/Lock.h ../../include/IceUtil/ThreadException.h ../../include/Ice/IncomingAsyncF.h ../../include/Ice/Current.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/ConnectionF.h ../../include/Ice/Identity.h ../../include/Ice/StreamF.h ../../include/IceUtil/Iterator.h ../../include/IceUtil/ScopedArray.h ../../include/IceUtil/DisableWarnings.h
diff --git a/cpp/src/Freeze/ConnectionI.cpp b/cpp/src/Freeze/ConnectionI.cpp
index 7bd9a114f13..824fc167c9c 100644
--- a/cpp/src/Freeze/ConnectionI.cpp
+++ b/cpp/src/Freeze/ConnectionI.cpp
@@ -40,6 +40,39 @@ Freeze::ConnectionI::currentTransaction() const
}
void
+Freeze::ConnectionI::removeMapIndex(const string& mapName, const string& indexName)
+{
+ if(_dbEnv == 0)
+ {
+ throw DatabaseException(__FILE__, __LINE__, "Closed connection");
+ }
+
+ string filename = mapName + "." + indexName;
+
+ DbTxn* txn = dbTxn();
+ try
+ {
+ _dbEnv->getEnv()->dbremove(txn, filename.c_str(), 0, txn != 0 ? 0 : DB_AUTO_COMMIT);
+ }
+ catch(const DbDeadlockException& dx)
+ {
+ throw DeadlockException(__FILE__, __LINE__, dx.what());
+ }
+ catch(const DbException& dx)
+ {
+ if(dx.get_errno() == ENOENT)
+ {
+ throw IndexNotFoundException(__FILE__, __LINE__, mapName, indexName);
+ }
+ else
+ {
+ throw DatabaseException(__FILE__, __LINE__, dx.what());
+ }
+ }
+}
+
+
+void
Freeze::ConnectionI::close()
{
if(_transaction)
diff --git a/cpp/src/Freeze/ConnectionI.h b/cpp/src/Freeze/ConnectionI.h
index 38b85aa9d2b..6bc33377fd4 100644
--- a/cpp/src/Freeze/ConnectionI.h
+++ b/cpp/src/Freeze/ConnectionI.h
@@ -40,6 +40,8 @@ public:
virtual TransactionPtr currentTransaction() const;
+ virtual void removeMapIndex(const std::string&, const std::string&);
+
virtual void close();
virtual Ice::CommunicatorPtr getCommunicator() const;
diff --git a/cpp/src/Freeze/Makefile b/cpp/src/Freeze/Makefile
index f4257c2040e..9008b44d8a8 100644
--- a/cpp/src/Freeze/Makefile
+++ b/cpp/src/Freeze/Makefile
@@ -20,6 +20,7 @@ OBJS = BackgroundSaveEvictor.o \
BackgroundSaveEvictorI.o \
CatalogData.o \
Catalog.o \
+ CatalogIndexList.o \
ConnectionI.o \
Connection.o \
DB.o \
@@ -78,6 +79,15 @@ $(HDIR)/Catalog.h Catalog.cpp: $(SLICE2FREEZE) $(SDIR)/CatalogData.ice
clean::
-rm -f $(HDIR)/Catalog.h Catalog.cpp
+$(HDIR)/CatalogIndexList.h CatalogIndexList.cpp: $(SLICE2FREEZE) $(slicedir)/Ice/BuiltinSequences.ice
+ rm -f $(HDIR)/CatalogIndexList.h CatalogIndexList.cpp
+ $(SLICE2FREEZE) $(SLICE2CPPFLAGS) --dict Freeze::CatalogIndexList,string,Ice::StringSeq \
+ CatalogIndexList ../../slice/Ice/BuiltinSequences.ice
+ mv CatalogIndexList.h $(HDIR)/CatalogIndexList.h
+
+clean::
+ -rm -f $(HDIR)/CatalogIndexList.h CatalogIndexList.cpp
+
$(libdir)/$(LIBFILENAME): $(OBJS)
rm -f $@
$(call mkshlib,$@,$(SONAME),$(OBJS),$(LINKWITH))
diff --git a/cpp/src/Freeze/MapI.cpp b/cpp/src/Freeze/MapI.cpp
index 390b4253ccb..5388dc56b4d 100644
--- a/cpp/src/Freeze/MapI.cpp
+++ b/cpp/src/Freeze/MapI.cpp
@@ -1671,3 +1671,10 @@ Freeze::InvalidPositionException::ice_print(ostream& out) const
Exception::ice_print(out);
out << ":\ninvalid position";
}
+
+void
+Freeze::IndexNotFoundException::ice_print(ostream& out) const
+{
+ Exception::ice_print(out);
+ out << ":\ncould not find index \"" << indexName << "\" on map \"" << mapName << "\"";
+}
diff --git a/cpp/src/Freeze/SharedDb.cpp b/cpp/src/Freeze/SharedDb.cpp
index 62756d57115..570cbc8a3c8 100644
--- a/cpp/src/Freeze/SharedDb.cpp
+++ b/cpp/src/Freeze/SharedDb.cpp
@@ -12,6 +12,8 @@
#include <Freeze/Exception.h>
#include <Freeze/Util.h>
#include <Freeze/Catalog.h>
+#include <Freeze/CatalogIndexList.h>
+#include <algorithm>
using namespace std;
using namespace IceUtil;
@@ -25,6 +27,7 @@ StaticMutex _mapMutex = ICE_STATIC_MUTEX_INITIALIZER;
StaticMutex _refCountMutex = ICE_STATIC_MUTEX_INITIALIZER;
const string _catalogName = "__catalog";
+const string _catalogIndexListName = "__catalogIndexList";
inline void
checkTypes(const SharedDb& sharedDb, const string& key, const string& value)
@@ -85,6 +88,12 @@ Freeze::SharedDb::get(const ConnectionIPtr& connection,
checkTypes(*result, key, value);
return result;
}
+ else if(dbName == _catalogIndexListName)
+ {
+ SharedDbPtr result = connection->dbEnv()->getCatalogIndexList();
+ checkTypes(*result, key, value);
+ return result;
+ }
StaticMutex::Lock lock(_mapMutex);
@@ -124,8 +133,8 @@ Freeze::SharedDb::get(const ConnectionIPtr& connection,
return result.release();
}
-Freeze::SharedDbPtr
-Freeze::SharedDb::openCatalog(SharedDbEnv& dbEnv)
+void
+Freeze::SharedDb::openCatalogs(SharedDbEnv& dbEnv, SharedDbPtr& catalog, SharedDbPtr& catalogIndexList)
{
StaticMutex::Lock lock(_mapMutex);
@@ -139,26 +148,41 @@ Freeze::SharedDb::openCatalog(SharedDbEnv& dbEnv)
mapKey.communicator = dbEnv.getCommunicator();
mapKey.dbName = _catalogName;
- auto_ptr<SharedDb> result(new SharedDb(mapKey, dbEnv.getEnv()));
+
+ auto_ptr<SharedDb> newCatalog(new SharedDb(mapKey, CatalogKeyCodec::typeId(),
+ CatalogValueCodec::typeId(), dbEnv.getEnv()));
//
// Insert it into the map
//
pair<SharedDbMap::iterator, bool> insertResult
- = sharedDbMap->insert(SharedDbMap::value_type(mapKey, result.get()));
+ = sharedDbMap->insert(SharedDbMap::value_type(mapKey, newCatalog.get()));
if(!insertResult.second)
{
//
- // That's very wrong: the catalog is associated with another env
+ // That's very wrong
//
assert(0);
- DatabaseException ex(__FILE__, __LINE__);
- ex.message = "Catalog already opened";
- throw ex;
+ throw DatabaseException(__FILE__, __LINE__, "Catalog already opened");
}
+
+ mapKey.dbName = _catalogIndexListName;
+
+ auto_ptr<SharedDb> newCatalogIndexList(new SharedDb(mapKey, CatalogIndexListKeyCodec::typeId(),
+ CatalogIndexListValueCodec::typeId(), dbEnv.getEnv()));
+
+ insertResult
+ = sharedDbMap->insert(SharedDbMap::value_type(mapKey, newCatalogIndexList.get()));
- return result.release();
+ if(!insertResult.second)
+ {
+ assert(0);
+ throw DatabaseException(__FILE__, __LINE__, "CatalogIndexList already opened");
+ }
+
+ catalog = newCatalog.release();
+ catalogIndexList = newCatalogIndexList.release();
}
@@ -255,7 +279,7 @@ Freeze::SharedDb::SharedDb(const MapKey& mapKey,
ConnectionPtr catalogConnection =
createConnection(_mapKey.communicator, connection->dbEnv()->getEnvName());
Catalog catalog(catalogConnection, _catalogName);
-
+
Catalog::iterator ci = catalog.find(_mapKey.dbName);
if(ci != catalog.end())
@@ -339,6 +363,22 @@ Freeze::SharedDb::SharedDb(const MapKey& mapKey,
}
open(txn, _mapKey.dbName.c_str(), 0, DB_BTREE, flags, FREEZE_DB_MODE);
+
+ Ice::StringSeq oldIndices;
+ Ice::StringSeq newIndices;
+ size_t oldSize = 0;
+ CatalogIndexList catalogIndexList(catalogConnection, _catalogIndexListName);
+
+ if(createDb)
+ {
+ CatalogIndexList::iterator cil = catalogIndexList.find(_mapKey.dbName);
+ if(cil != catalogIndexList.end())
+ {
+ oldIndices = cil->second;
+ oldSize = oldIndices.size();
+ }
+ }
+
for(vector<MapIndexBasePtr>::const_iterator p = indices.begin();
p != indices.end(); ++p)
{
@@ -356,6 +396,12 @@ Freeze::SharedDb::SharedDb(const MapKey& mapKey,
assert(inserted);
indexBase->_impl = indexI.release();
+
+ if(createDb)
+ {
+ newIndices.push_back(indexBase->name());
+ oldIndices.erase(std::remove(oldIndices.begin(), oldIndices.end(), indexBase->name()), oldIndices.end());
+ }
}
if(ci == catalog.end())
@@ -366,6 +412,61 @@ Freeze::SharedDb::SharedDb(const MapKey& mapKey,
catalogData.value = value;
catalog.put(Catalog::value_type(_mapKey.dbName, catalogData));
}
+
+ if(createDb)
+ {
+ //
+ // Remove old indices and write the new ones
+ //
+ for(Ice::StringSeq::const_iterator q = oldIndices.begin(); q != oldIndices.end(); ++q)
+ {
+ const string& index = *q;
+
+ if(_trace >= 1)
+ {
+ Trace out(_mapKey.communicator->getLogger(), "Freeze.Map");
+ out << "removing old index \"" << index << "\" on Db \"" << _mapKey.dbName << "\"";
+ }
+
+ try
+ {
+ catalogConnection->removeMapIndex(_mapKey.dbName, *q);
+ }
+ catch(const IndexNotFoundException&)
+ {
+ // Ignored
+
+ if(_trace >= 1)
+ {
+ Trace out(_mapKey.communicator->getLogger(), "Freeze.Map");
+ out << "index \"" << index << "\" on Db \"" << _mapKey.dbName << "\" does not exist";
+ }
+ }
+ }
+
+ if(oldSize != newIndices.size())
+ {
+ if(newIndices.size() == 0)
+ {
+ catalogIndexList.erase(_mapKey.dbName);
+ if(_trace >= 1)
+ {
+ Trace out(_mapKey.communicator->getLogger(), "Freeze.Map");
+ out << "Removed catalogIndexList entry for Db \"" << _mapKey.dbName << "\"";
+ }
+
+ }
+ else
+ {
+ catalogIndexList.put(CatalogIndexList::value_type(_mapKey.dbName, newIndices));
+ if(_trace >= 1)
+ {
+ Trace out(_mapKey.communicator->getLogger(), "Freeze.Map");
+ out << "Updated catalogIndexList entry for Db \"" << _mapKey.dbName << "\"";
+ }
+ }
+ }
+ }
tx->commit();
}
@@ -418,11 +519,11 @@ Freeze::SharedDb::SharedDb(const MapKey& mapKey,
}
-Freeze::SharedDb::SharedDb(const MapKey& mapKey, DbEnv* env) :
+Freeze::SharedDb::SharedDb(const MapKey& mapKey, const string& keyTypeId, const string& valueTypeId, DbEnv* env) :
Db(env, 0),
_mapKey(mapKey),
- _key(CatalogKeyCodec::typeId()),
- _value(CatalogValueCodec::typeId()),
+ _key(keyTypeId),
+ _value(valueTypeId),
_refCount(0)
{
_trace = _mapKey.communicator->getProperties()->getPropertyAsInt("Freeze.Trace.Map");
diff --git a/cpp/src/Freeze/SharedDb.h b/cpp/src/Freeze/SharedDb.h
index 3576f51fa23..388ea3ea40b 100644
--- a/cpp/src/Freeze/SharedDb.h
+++ b/cpp/src/Freeze/SharedDb.h
@@ -77,7 +77,7 @@ public:
const KeyCompareBasePtr&,
const std::vector<MapIndexBasePtr>&, bool);
- static SharedDbPtr openCatalog(SharedDbEnv&);
+ static void openCatalogs(SharedDbEnv&, SharedDbPtr&, SharedDbPtr&);
~SharedDb();
@@ -125,7 +125,7 @@ private:
const ConnectionIPtr&, const KeyCompareBasePtr&,
const std::vector<MapIndexBasePtr>&, bool);
- SharedDb(const MapKey&, DbEnv*);
+ SharedDb(const MapKey&, const std::string&, const std::string&, DbEnv*);
void connectIndices(const std::vector<MapIndexBasePtr>&) const;
void cleanup(bool);
diff --git a/cpp/src/Freeze/SharedDbEnv.cpp b/cpp/src/Freeze/SharedDbEnv.cpp
index 39df230f32c..9b430ed1806 100644
--- a/cpp/src/Freeze/SharedDbEnv.cpp
+++ b/cpp/src/Freeze/SharedDbEnv.cpp
@@ -136,9 +136,10 @@ Freeze::SharedDbEnv::~SharedDbEnv()
}
//
- // Release catalog (to close it)
+ // Release catalogs (to close it)
//
_catalog = 0;
+ _catalogIndexList = 0;
//
// First terminate checkpointing thread
@@ -449,9 +450,9 @@ Freeze::SharedDbEnv::SharedDbEnv(const std::string& envName,
}
//
- // Get catalog
+ // Get catalogs
//
- _catalog = SharedDb::openCatalog(*this);
+ SharedDb::openCatalogs(*this, _catalog, _catalogIndexList);
}
Freeze::CheckpointThread::CheckpointThread(SharedDbEnv& dbEnv, const Time& checkpointPeriod, Int kbyte, Int trace) :
diff --git a/cpp/src/Freeze/SharedDbEnv.h b/cpp/src/Freeze/SharedDbEnv.h
index 072d03e5d86..ebbf0129653 100644
--- a/cpp/src/Freeze/SharedDbEnv.h
+++ b/cpp/src/Freeze/SharedDbEnv.h
@@ -55,6 +55,7 @@ public:
const std::string& getEnvName() const;
const Ice::CommunicatorPtr& getCommunicator() const;
const SharedDbPtr& getCatalog() const;
+ const SharedDbPtr& getCatalogIndexList() const;
private:
SharedDbEnv(const std::string&, const Ice::CommunicatorPtr&, DbEnv* env);
@@ -64,6 +65,7 @@ private:
const std::string _envName;
const Ice::CommunicatorPtr _communicator;
SharedDbPtr _catalog;
+ SharedDbPtr _catalogIndexList;
int _refCount;
int _trace;
@@ -101,6 +103,12 @@ SharedDbEnv::getCatalog() const
return _catalog;
}
+inline const SharedDbPtr&
+SharedDbEnv::getCatalogIndexList() const
+{
+ return _catalogIndexList;
+}
+
}
#endif