/// <exception cref="System.IO.IOException"></exception> /// <exception cref="System.TypeLoadException"></exception> public static NeoDatis.Odb.Impl.Core.Transaction.DefaultTransaction Read(string fileName ) { NeoDatis.Tool.Wrappers.IO.OdbFile file = new NeoDatis.Tool.Wrappers.IO.OdbFile(fileName ); if (!file.Exists()) { throw new NeoDatis.Odb.ODBRuntimeException(NeoDatis.Odb.Core.NeoDatisError.FileNotFound .AddParameter(fileName)); } // @TODO check this NeoDatis.Odb.Impl.Core.Transaction.DefaultTransaction transaction = new NeoDatis.Odb.Impl.Core.Transaction.DefaultTransaction (null, fileName); transaction.LoadWriteActions(fileName, false); return(transaction); }
/// <summary> /// TODO Return a list of IO to enable replication or other IO mechanism Used /// by the FileSystemInterface to actual write/read byte to underlying /// storage /// </summary> /// <param name="name">The name of the buffered io</param> /// <param name="parameters">The parameters that define the buffer</param> /// <param name="bufferSize">The size of the buffers</param> /// <returns>The buffer implementation @</returns> public virtual NeoDatis.Odb.Core.Layers.Layer3.IBufferedIO GetIO(string name, NeoDatis.Odb.Core.Layers.Layer3.IBaseIdentification parameters, int bufferSize) { if (parameters is NeoDatis.Odb.Core.Layers.Layer3.IOFileParameter) { NeoDatis.Odb.Core.Layers.Layer3.IOFileParameter fileParameters = (NeoDatis.Odb.Core.Layers.Layer3.IOFileParameter )parameters; // Guarantee that file directory structure exist NeoDatis.Tool.Wrappers.IO.OdbFile f = new NeoDatis.Tool.Wrappers.IO.OdbFile(fileParameters .GetFileName()); NeoDatis.Tool.Wrappers.IO.OdbFile fparent = f.GetParentFile(); if (fparent != null && !fparent.Exists()) { fparent.Mkdirs(); } return(new NeoDatis.Odb.Impl.Core.Layers.Layer3.Buffer.MultiBufferedFileIO(NeoDatis.Odb.OdbConfiguration .GetNbBuffers(), name, fileParameters.GetFileName(), fileParameters.CanWrite(), bufferSize)); } throw new NeoDatis.Odb.ODBRuntimeException(NeoDatis.Odb.Core.NeoDatisError.UnsupportedIoType .AddParameter(parameters.ToString())); }
private NeoDatis.Odb.Core.Server.Layers.Layer3.Engine.Message ManageDeleteBaseCommand (NeoDatis.Odb.Core.Server.Message.DeleteBaseMessage message) { // Gets the base identifier string baseIdentifier = message.GetBaseIdentifier(); NeoDatis.Odb.Core.Server.Connection.ConnectionManager connectionManager = null; try { // Gets the connection manager for this base identifier connectionManager = GetConnectionManager(baseIdentifier, null, null, true); if (connectionManager == null) { string fileName = message.GetBaseIdentifier(); NeoDatis.Tool.Wrappers.IO.OdbFile file = new NeoDatis.Tool.Wrappers.IO.OdbFile(fileName ); System.Text.StringBuilder log = new System.Text.StringBuilder(); try { if (debug) { log.Append("Deleting base " + file.GetFullPath()).Append(" | exists?").Append(file .Exists()); } if (file.Exists()) { bool b = NeoDatis.Tool.IOUtil.DeleteFile(file.GetFullPath()); if (debug) { log.Append("| deleted=").Append(b); } b = !file.Exists(); if (debug) { log.Append("| deleted=").Append(b); } if (b) { return new NeoDatis.Odb.Core.Server.Message.DeleteBaseMessageResponse(baseIdentifier ); } return new NeoDatis.Odb.Core.Server.Message.DeleteBaseMessageResponse(baseIdentifier , "[1] could not delete base " + file.GetFullPath()); } return new NeoDatis.Odb.Core.Server.Message.DeleteBaseMessageResponse(baseIdentifier ); } finally { if (true || debug) { NeoDatis.Tool.DLogger.Info(log.ToString()); } } } NeoDatis.Odb.Core.Layers.Layer3.IStorageEngine engine = connectionManager.GetStorageEngine (); if (!engine.IsClosed()) { // Simulate a session sessionManager.AddSession(NeoDatis.Odb.OdbConfiguration.GetCoreProvider().GetServerSession (engine, "temp")); // engine.rollback(); engine.Close(); sessionManager.RemoveSession(baseIdentifier); } if (NeoDatis.Tool.IOUtil.DeleteFile(message.GetBaseIdentifier())) { return new NeoDatis.Odb.Core.Server.Message.DeleteBaseMessageResponse(baseIdentifier ); } return new NeoDatis.Odb.Core.Server.Message.DeleteBaseMessageResponse(baseIdentifier , "[2] could not delete base " + new NeoDatis.Tool.Wrappers.IO.OdbFile(message.GetBaseIdentifier ()).GetFullPath()); } catch (System.Exception e) { string se = NeoDatis.Tool.Wrappers.OdbString.ExceptionToString(e, false); string msg = baseIdentifier + ":Error while deleting base " + message.GetBaseIdentifier (); NeoDatis.Tool.DLogger.Error(msg, e); return new NeoDatis.Odb.Core.Server.Message.DeleteBaseMessageResponse(baseIdentifier , msg + ":\n" + se); } finally { sessionManager.RemoveSession(baseIdentifier); RemoveConnectionManager(baseIdentifier); connectionIsUp = false; } }
/// <exception cref="System.IO.IOException"></exception> /// <exception cref="System.TypeLoadException"></exception> public static NeoDatis.Odb.Impl.Core.Transaction.DefaultTransaction Read(string fileName ) { NeoDatis.Tool.Wrappers.IO.OdbFile file = new NeoDatis.Tool.Wrappers.IO.OdbFile(fileName ); if (!file.Exists()) { throw new NeoDatis.Odb.ODBRuntimeException(NeoDatis.Odb.Core.NeoDatisError.FileNotFound .AddParameter(fileName)); } // @TODO check this NeoDatis.Odb.Impl.Core.Transaction.DefaultTransaction transaction = new NeoDatis.Odb.Impl.Core.Transaction.DefaultTransaction (null, fileName); transaction.LoadWriteActions(fileName, false); return transaction; }