Exemplo n.º 1
0
        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();
                    }
                }
            }
        }
Exemplo n.º 2
0
 // 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;
     }
 }
Exemplo n.º 3
0
        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;
        }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
        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();
                }
            }
        }
Exemplo n.º 6
0
        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);
        }
Exemplo n.º 7
0
 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);
     }
 }
Exemplo n.º 8
0
        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;
        }
Exemplo n.º 9
0
 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);
     }
 }