private RemoteFetchData InternalFetch(Schema.IRowType rowType, Guid[] bookmarks, int count, bool skipCurrent) { Row[] rows = new Row[Math.Abs(count)]; try { for (int index = 0; index < rows.Length; index++) { rows[index] = new Row(_plan.Process.ServerProcess.ValueManager, rowType); rows[index].ValuesOwned = false; } CursorGetFlags flags; int localCount = _serverCursor.Fetch(rows, bookmarks, count, skipCurrent, out flags); RemoteFetchData fetchData = new RemoteFetchData(); fetchData.Body = new RemoteRowBody[localCount]; for (int index = 0; index < localCount; index++) { fetchData.Body[index].Data = rows[index].AsPhysical; } fetchData.Flags = flags; return(fetchData); } finally { for (int index = 0; index < rows.Length; index++) { if (rows[index] != null) { rows[index].Dispose(); } } } }
// OpenCursor public IRemoteServerCursor OpenCursor ( string expression, ref RemoteParamData paramsValue, out IRemoteServerExpressionPlan plan, out PlanDescriptor planDescriptor, out ProgramStatistics executeTime, ProcessCallInfo callInfo, RemoteProcessCleanupInfo cleanupInfo, out Guid[] bookmarks, int count, out RemoteFetchData fetchData ) { ProcessCallInfo(callInfo); plan = PrepareExpression(expression, paramsValue.Params, null, out planDescriptor, cleanupInfo); try { IRemoteServerCursor cursor = plan.Open(ref paramsValue, out executeTime, EmptyCallInfo()); fetchData = cursor.Fetch(out bookmarks, count, true, EmptyCallInfo()); return(cursor); } catch { UnprepareExpression(plan); plan = null; throw; } }
protected void SourceFetch(bool isFirst, bool skipCurrent) { // Execute fetch on the remote cursor, selecting all columns, requesting FFetchCount rows from the current position Guid[] bookmarks; RemoteFetchData fetchData = _cursor.Fetch(out bookmarks, _fetchCount * (int)_bufferDirection, skipCurrent, _plan._process.GetProcessCallInfo()); ProcessFetchData(fetchData, bookmarks, isFirst); _plan._programStatisticsCached = false; }
public rrd4n.DataAccess.Data.FetchData GetData(rrd4n.DataAccess.Data.FetchRequest request) { RrdServerInterface remoteAccessor = GetServerAccessor(); RemoteFetchData remoteData = remoteAccessor.FetchData(request.DatabasePath, request.FetchStart, request.FetchEnd, request.ConsolidateFunctionName, request.Resolution); rrd4n.DataAccess.Data.FetchData localData = new rrd4n.DataAccess.Data.FetchData(remoteData.ArchiveSteps, remoteData.ArchiveEndTimeTicks, remoteData.DatasourceNames); localData.Timestamps = remoteData.Timestamps; localData.Values = remoteData.Values; return(localData); }
public RemoteFetchData FetchData(string databaseName, long startTimeTick, long endTimeTick, string consolFunctionName, long resolution) { RrdDb database = null; try { log.DebugFormat("Read data from {0}", databaseName); var nameValueCollection = (NameValueCollection)ConfigurationManager.GetSection("rrdbfileserver"); string dataBasePath = nameValueCollection["databasepath"]; log.DebugFormat("Database path:{0}", dataBasePath + databaseName); database = new RrdDb(dataBasePath + databaseName, true); FetchRequest fetchRequest = new FetchRequest(null, consolFunctionName, startTimeTick, endTimeTick, resolution); FetchData data = database.fetchData(fetchRequest); database.close(); RemoteFetchData remoteData = new RemoteFetchData(); remoteData.Timestamps = data.getTimestamps(); remoteData.Values = data.getValues(); remoteData.ArchiveEndTimeTicks = data.getArcEndTime(); remoteData.ArchiveSteps = data.getArcStep(); remoteData.DatasourceNames = data.getDsNames(); if (debugEnabled) { log.DebugFormat("Read data from {0} to {1}.", rrd4n.Common.Util.getDate(startTimeTick), rrd4n.Common.Util.getDate(endTimeTick)); } return(remoteData); } catch (Exception ex) { log.Error("Fetchdata exception", ex); throw; } finally { if (database != null) { database.close(); } } }
public IRemoteServerCursor Open(ref RemoteParamData paramsValue, out ProgramStatistics executeTime, out Guid[] bookmarks, int count, out RemoteFetchData fetchData, ProcessCallInfo callInfo) { IRemoteServerCursor serverCursor = Open(ref paramsValue, out executeTime, callInfo); fetchData = serverCursor.Fetch(out bookmarks, count, true, _process.EmptyCallInfo()); return(serverCursor); }
public IRemoteServerCursor OpenCursor(string expression, ref RemoteParamData paramsValue, out IRemoteServerExpressionPlan plan, out PlanDescriptor planDescriptor, out ProgramStatistics executeTime, ProcessCallInfo callInfo, RemoteProcessCleanupInfo cleanupInfo, out Guid[] bookmarks, int count, out RemoteFetchData fetchData) { try { var channel = GetServiceInterface(); IAsyncResult result = channel.BeginOpenCursorWithFetch(ProcessHandle, GetCleanupInfo(cleanupInfo), callInfo, expression, paramsValue, count, null, null); result.AsyncWaitHandle.WaitOne(); DirectCursorWithFetchResult cursorResult = channel.EndOpenCursorWithFetch(result); paramsValue.Data = cursorResult.ParamData; planDescriptor = cursorResult.PlanDescriptor; executeTime = cursorResult.ExecuteTime; bookmarks = cursorResult.Bookmarks; fetchData = cursorResult.FetchData; plan = new ClientExpressionPlan(this, planDescriptor); return(new ClientCursor((ClientExpressionPlan)plan, cursorResult.CursorDescriptor)); } catch (FaultException <DataphorFault> fault) { throw DataphorFaultUtility.FaultToException(fault.Detail); } catch (CommunicationException ce) { ReportCommunicationError(); throw new ServerException(ServerException.Codes.CommunicationFailure, ErrorSeverity.Environment, ce); } }
public void ProcessFetchData(RemoteFetchData fetchData, Guid[] bookmarks, bool isFirst) { _buffer.BufferDirection = _bufferDirection; Schema.IRowType rowType = DataType.RowType; if (_bufferDirection == BufferDirection.Forward) { for (int index = 0; index < fetchData.Body.Length; index++) { LocalRow row = new LocalRow(new Row(_plan._process.ValueManager, rowType), bookmarks[index]); row.Row.AsPhysical = fetchData.Body[index].Data; _buffer.Add(row); AddBookmarkIfNotEmpty(bookmarks[index]); } if ((fetchData.Body.Length > 0) && !isFirst) { _bufferIndex = 0; } else { _bufferIndex = -1; } if ((fetchData.Flags & CursorGetFlags.EOF) != 0) { _sourceCursorIndex = _buffer.Count; } else { _sourceCursorIndex = _buffer.Count - 1; } } else { for (int index = 0; index < fetchData.Body.Length; index++) { LocalRow row = new LocalRow(new Row(_plan._process.ValueManager, rowType), bookmarks[index]); row.Row.AsPhysical = fetchData.Body[index].Data; _buffer.Insert(0, row); AddBookmarkIfNotEmpty(bookmarks[index]); } if ((fetchData.Body.Length > 0) && !isFirst) { _bufferIndex = _buffer.Count - 1; } else { _bufferIndex = _buffer.Count; } if ((fetchData.Flags & CursorGetFlags.BOF) != 0) { _sourceCursorIndex = -1; } else { _sourceCursorIndex = 0; } } SetFlags(fetchData.Flags); _bufferFull = true; }
public IRemoteServerCursor Open(ref RemoteParamData paramsValue, out ProgramStatistics executeTime, out Guid[] bookmarks, int count, out RemoteFetchData fetchData, ProcessCallInfo callInfo) { try { var channel = GetServiceInterface(); IAsyncResult result = channel.BeginOpenPlanCursorWithFetch(PlanHandle, callInfo, paramsValue, count, null, null); result.AsyncWaitHandle.WaitOne(); CursorWithFetchResult cursorResult = channel.EndOpenPlanCursorWithFetch(result); executeTime = cursorResult.ExecuteTime; _programStatistics = executeTime; paramsValue.Data = cursorResult.ParamData; bookmarks = cursorResult.Bookmarks; fetchData = cursorResult.FetchData; return(new ClientCursor(this, cursorResult.CursorDescriptor)); } catch (FaultException <DataphorFault> fault) { throw DataphorFaultUtility.FaultToException(fault.Detail); } catch (CommunicationException ce) { ReportCommunicationError(); throw new ServerException(ServerException.Codes.CommunicationFailure, ErrorSeverity.Environment, ce); } }