DeveelDB  20151217
complete SQL database system, primarly developed for .NET/Mono frameworks
Public Member Functions | Properties | Private Member Functions | Private Attributes | List of all members
Deveel.Data.Client.ConnectionClient Class Reference
Inheritance diagram for Deveel.Data.Client.ConnectionClient:

Public Member Functions

 ConnectionClient (DeveelDbConnectionStringBuilder settings)
 
 ConnectionClient (IClientConnector connector, DeveelDbConnectionStringBuilder settings)
 
void Connect ()
 
void Disconnect ()
 
bool Authenticate ()
 
IQueryResponse[] ExecuteQuery (int commitId, SqlQuery query)
 
QueryResultPart GetResultPart (int resultId, int rowIndex, int count)
 
void DisposeResult (int resultId)
 
int BeginTransaction (System.Data.IsolationLevel isolationLevel)
 
int BeginTransaction (IsolationLevel isolationLevel)
 
void CommitTransaction (int transactionId)
 
void RollbackTransaction (int transactionId)
 
void DisposeLargeObject (long objId)
 
void Dispose ()
 

Properties

DeveelDbConnectionStringBuilder Settings [get, private set]
 
IClientConnector Connector [get, private set]
 
bool OwnsConnector [get, set]
 
IMessageProcessor Processor [get, private set]
 
bool IsClosed [get, private set]
 
string ServerVersion [get, private set]
 

Private Member Functions

 ~ConnectionClient ()
 
IClientConnector CreateNetworkConnector ()
 
IClientConnector CreateConnector ()
 
IMessage SendMessage (IMessage message)
 
ConnectionEndPoint MakeRemoteEndPoint ()
 
IsolationLevel MapIsolationLevel (System.Data.IsolationLevel isolationLevel)
 
void Dispose (bool disposing)
 

Private Attributes

ConnectionEndPoint remoteEndPoint
 
IDictionary< string, object > serverMetadata
 

Detailed Description

Definition at line 30 of file ConnectionClient.cs.

Constructor & Destructor Documentation

Deveel.Data.Client.ConnectionClient.ConnectionClient ( DeveelDbConnectionStringBuilder  settings)
inline

Definition at line 43 of file ConnectionClient.cs.

43  {
44  Settings = settings;
45  }
DeveelDbConnectionStringBuilder Settings
Deveel.Data.Client.ConnectionClient.ConnectionClient ( IClientConnector  connector,
DeveelDbConnectionStringBuilder  settings 
)
inline

Definition at line 47 of file ConnectionClient.cs.

47  {
48  if (connector == null)
49  throw new ArgumentNullException("connector");
50 
51  Settings = settings;
52  Connector = connector;
53  Processor = connector.CreateProcessor();
54  OwnsConnector = false;
55  }
IMessageProcessor CreateProcessor()
This processes _queries from a client and dispatches the _queries to the database.
Definition: Processor.cs:41
DeveelDbConnectionStringBuilder Settings
Deveel.Data.Client.ConnectionClient.~ConnectionClient ( )
inlineprivate

Definition at line 57 of file ConnectionClient.cs.

57  {
58  Dispose(false);
59  }

Member Function Documentation

bool Deveel.Data.Client.ConnectionClient.Authenticate ( )
inline
int Deveel.Data.Client.ConnectionClient.BeginTransaction ( System.Data.IsolationLevel  isolationLevel)
inline

Definition at line 243 of file ConnectionClient.cs.

243  {
244  var isolation = MapIsolationLevel(isolationLevel);
245  return BeginTransaction(isolation);
246  }
int BeginTransaction(System.Data.IsolationLevel isolationLevel)
IsolationLevel MapIsolationLevel(System.Data.IsolationLevel isolationLevel)
int Deveel.Data.Client.ConnectionClient.BeginTransaction ( IsolationLevel  isolationLevel)
inline

Definition at line 261 of file ConnectionClient.cs.

261  {
262  var response = SendMessage(new BeginRequest(isolationLevel))
263  as BeginResponse;
264 
265  if (response == null)
266  throw new InvalidOperationException();
267 
268  return response.CommitId;
269  }
IMessage SendMessage(IMessage message)
void Deveel.Data.Client.ConnectionClient.CommitTransaction ( int  transactionId)
inline

Definition at line 271 of file ConnectionClient.cs.

271  {
272  var response = SendMessage(new CommitRequest(transactionId))
274 
275  if (response == null)
276  throw new InvalidOperationException();
277 
278  if (!response.State)
279  throw new DeveelDbServerException("Unable to commit the transaction on the server.", -1, -1);
280  }
IMessage SendMessage(IMessage message)
void Deveel.Data.Client.ConnectionClient.Connect ( )
inline

Definition at line 157 of file ConnectionClient.cs.

157  {
158  if (Connector == null) {
161  }
162 
164 
166  DatabaseName = Settings.Database,
167  Timeout = Settings.QueryTimeout,
168  IgnoreIdentifiersCase = Settings.IgnoreIdentifiersCase,
169  ParameterStyle = Settings.ParameterStyle,
170  AutoCommit = Settings.AutoCommit
171  };
172 
173  var response = SendMessage(request) as ConnectResponse;
174  if (response == null)
175  throw new ProtocolException("The returned message is invalid");
176 
177  if (!response.Opened)
178  throw new DeveelDbServerException("Was not able to open the connection on the server.", -1, -1);
179 
180  if (response.IsEncryted)
181  Connector.SetEncrypton(response.EncryptionData);
182 
183  IsClosed = false;
184  ServerVersion = response.Version;
185  }
IMessageProcessor CreateProcessor()
This processes _queries from a client and dispatches the _queries to the database.
Definition: Processor.cs:41
DeveelDbConnectionStringBuilder Settings
IMessage SendMessage(IMessage message)
ConnectionEndPoint LocalEndPoint
Definition: IConnector.cs:27
IClientConnector Deveel.Data.Client.ConnectionClient.CreateConnector ( )
inlineprivate

Definition at line 69 of file ConnectionClient.cs.

69  {
70  if (Connector != null)
71  return Connector;
72 
73  IConfiguration configuration = null;
74 
75  /*
76  TODO:
77  if (IsInMemory(Settings.DataSource) && controlDatabase == null) {
78  if (controlSystem == null)
79  controlSystem = CreateEmbeddedControlSystem();
80 
81  // TODO: handle the case the connection string does not specify a database name
82  var databaseName = Settings.Database;
83  if (String.IsNullOrEmpty(databaseName))
84  throw new InvalidOperationException();
85 
86  Configuration = new Configuration(controlSystem.Config);
87  Configuration.DatabaseName(databaseName);
88 
89  var defaultSchema = Settings.Schema;
90  if (!String.IsNullOrEmpty(defaultSchema))
91  Configuration.DefaultSchema(defaultSchema);
92 
93  controlDatabase = controlSystem.ControlDatabase(databaseName);
94  } else if (IsInFileSystem(Settings) && controlDatabase == null) {
95  if (controlSystem == null)
96  controlSystem = CreateEmbeddedControlSystem();
97 
98  // TODO: handle the case the connection string does not specify a database name
99  var databaseName = Settings.Database;
100  if (String.IsNullOrEmpty(databaseName))
101  throw new InvalidOperationException();
102 
103  Configuration = new Configuration(controlSystem.Config);
104  Configuration.StorageSystem(ConfigDefaultValues.FileStorageSystem);
105 
106  var dbPath = settings.DataSource;
107  if (String.Equals(dbPath, "local", StringComparison.OrdinalIgnoreCase))
108  dbPath = settings.Path;
109  if (String.IsNullOrEmpty(dbPath))
110  dbPath = databaseName;
111 
112  Configuration.DatabasePath(dbPath);
113 
114  var defaultSchema = settings.Schema;
115  if (!String.IsNullOrEmpty(defaultSchema))
116  Configuration.DefaultSchema(defaultSchema);
117 
118 
119  controlDatabase = controlSystem.ControlDatabase(databaseName);
120  } else if (controlDatabase == null) {
121  return CreateNetworkConnector();
122  }
123 
124  if (controlDatabase != null)
125  return CreateLocalDatabaseConnector(Configuration);
126 
127  throw new InvalidOperationException("Unable to create a connector to the database");
128  */
129 
130  throw new NotImplementedException();
131  }
Defines the contract for the configuration node of a component within the system or of the system its...
IClientConnector Deveel.Data.Client.ConnectionClient.CreateNetworkConnector ( )
inlineprivate

Definition at line 65 of file ConnectionClient.cs.

65  {
66  throw new NotSupportedException();
67  }
void Deveel.Data.Client.ConnectionClient.Disconnect ( )
inline

Definition at line 187 of file ConnectionClient.cs.

187  {
188  try {
189  var response = SendMessage(new CloseRequest())
191 
192  if (response == null)
193  throw new InvalidOperationException();
194 
195  if (!response.State)
196  throw new DeveelDbServerException("Unable to close the connection on the server.", -1, -1);
197  } finally {
198  IsClosed = true;
199  }
200  }
IMessage SendMessage(IMessage message)
void Deveel.Data.Client.ConnectionClient.Dispose ( )
inline

Definition at line 305 of file ConnectionClient.cs.

305  {
306  Dispose(true);
307  GC.SuppressFinalize(this);
308  }
void Deveel.Data.Client.ConnectionClient.Dispose ( bool  disposing)
inlineprivate

Definition at line 310 of file ConnectionClient.cs.

310  {
311  if (disposing) {
312  if (OwnsConnector && Connector != null) {
313  Connector.Dispose();
314  }
315  }
316 
317  Connector = null;
318  }
void Deveel.Data.Client.ConnectionClient.DisposeLargeObject ( long  objId)
inline

Definition at line 294 of file ConnectionClient.cs.

294  {
295  var response = SendMessage(new LargeObjectDisposeRequest(objId))
297 
298  if (response == null)
299  throw new InvalidOperationException();
300 
301  if (!response.State)
302  throw new InvalidOperationException("Unable to dispose the large object on the server.");
303  }
IMessage SendMessage(IMessage message)
void Deveel.Data.Client.ConnectionClient.DisposeResult ( int  resultId)
inline

Definition at line 232 of file ConnectionClient.cs.

232  {
233  var response = SendMessage(new DisposeResultRequest(resultId))
235 
236  if (response == null)
237  throw new InvalidOperationException();
238 
239  if (!response.State)
240  throw new DeveelDbServerException(null, -1, -1);
241  }
IMessage SendMessage(IMessage message)
IQueryResponse [] Deveel.Data.Client.ConnectionClient.ExecuteQuery ( int  commitId,
SqlQuery  query 
)
inline

Definition at line 212 of file ConnectionClient.cs.

212  {
213  var response = SendMessage(new QueryExecuteRequest(commitId, query))
215 
216  if (response == null)
217  throw new InvalidOperationException();
218 
219  return response.QueryResponse;
220  }
IMessage SendMessage(IMessage message)
QueryResultPart Deveel.Data.Client.ConnectionClient.GetResultPart ( int  resultId,
int  rowIndex,
int  count 
)
inline

Definition at line 222 of file ConnectionClient.cs.

222  {
223  var response = SendMessage(new QueryResultPartRequest(resultId, rowIndex, count))
225 
226  if (response == null)
227  throw new InvalidOperationException();
228 
229  return response.Part;
230  }
IMessage SendMessage(IMessage message)
ConnectionEndPoint Deveel.Data.Client.ConnectionClient.MakeRemoteEndPoint ( )
inlineprivate

Definition at line 146 of file ConnectionClient.cs.

146  {
147  var properties = new Dictionary<string, object>();
148  var en = ((IDictionary)Settings).GetEnumerator();
149  while (en.MoveNext()) {
150  var current = en.Entry;
151  properties.Add((string)current.Key, current.Value);
152  }
153 
154  return Connector.MakeEndPoint(properties);
155  }
DeveelDbConnectionStringBuilder Settings
ConnectionEndPoint MakeEndPoint(IDictionary< string, object > properties)
IsolationLevel Deveel.Data.Client.ConnectionClient.MapIsolationLevel ( System.Data.IsolationLevel  isolationLevel)
inlineprivate

Definition at line 248 of file ConnectionClient.cs.

248  {
249  if (isolationLevel == System.Data.IsolationLevel.Serializable)
250  return IsolationLevel.Serializable;
251  if (isolationLevel == System.Data.IsolationLevel.Snapshot)
252  return IsolationLevel.Snapshot;
253  if (isolationLevel == System.Data.IsolationLevel.ReadCommitted)
254  return IsolationLevel.ReadCommitted;
255  if (isolationLevel == System.Data.IsolationLevel.ReadUncommitted)
256  return IsolationLevel.ReadUncommitted;
257 
258  throw new NotSupportedException(String.Format("Isolation Level '{0}' not supported by DeveelDB", isolationLevel));
259  }
A long string in the system.
void Deveel.Data.Client.ConnectionClient.RollbackTransaction ( int  transactionId)
inline

Definition at line 282 of file ConnectionClient.cs.

282  {
283  var response = SendMessage(new RollbackRequest(transactionId))
285 
286  if (response == null)
287  throw new InvalidOperationException();
288 
289  if (!response.State)
290  throw new DeveelDbServerException("Unable to rollback the transaction on the server.", -1, -1);
291 
292  }
IMessage SendMessage(IMessage message)
IMessage Deveel.Data.Client.ConnectionClient.SendMessage ( IMessage  message)
inlineprivate

Definition at line 133 of file ConnectionClient.cs.

133  {
134  var envelope = Connector.CreateEnvelope(serverMetadata, message);
135  var response = Processor.ProcessMessage(envelope);
136  if (response == null)
137  throw new InvalidOperationException("The processor returned no response.");
138 
139  if (response.Error != null)
140  throw new DeveelDbServerException(response.Error.ErrorMessage, response.Error.ErrorClass, response.Error.ErrorCode);
141 
142  serverMetadata = response.Metadata;
143  return response.Message;
144  }
This processes _queries from a client and dispatches the _queries to the database.
Definition: Processor.cs:41
IDictionary< string, object > serverMetadata
IMessageEnvelope CreateEnvelope(IDictionary< string, object > metadata, IMessage message)

Member Data Documentation

ConnectionEndPoint Deveel.Data.Client.ConnectionClient.remoteEndPoint
private

Definition at line 33 of file ConnectionClient.cs.

IDictionary<string, object> Deveel.Data.Client.ConnectionClient.serverMetadata
private

Definition at line 41 of file ConnectionClient.cs.

Property Documentation

IClientConnector Deveel.Data.Client.ConnectionClient.Connector
getprivate set

Definition at line 35 of file ConnectionClient.cs.

bool Deveel.Data.Client.ConnectionClient.IsClosed
getprivate set

Definition at line 61 of file ConnectionClient.cs.

bool Deveel.Data.Client.ConnectionClient.OwnsConnector
getsetprivate

Definition at line 37 of file ConnectionClient.cs.

IMessageProcessor Deveel.Data.Client.ConnectionClient.Processor
getprivate set

Definition at line 39 of file ConnectionClient.cs.

string Deveel.Data.Client.ConnectionClient.ServerVersion
getprivate set

Definition at line 63 of file ConnectionClient.cs.

DeveelDbConnectionStringBuilder Deveel.Data.Client.ConnectionClient.Settings
getprivate set

Definition at line 31 of file ConnectionClient.cs.


The documentation for this class was generated from the following file: