// @(#)root/proofplayer:$Id$
// Author: Maarten Ballintijn    18/03/02

/*************************************************************************
 * Copyright (C) 1995-2002, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

#ifndef ROOT_TPacketizer
#define ROOT_TPacketizer

//////////////////////////////////////////////////////////////////////////
//                                                                      //
// TPacketizer                                                          //
//                                                                      //
// This class generates packets to be processed on PROOF slave servers. //
// A packet is an event range (begin entry and number of entries) or    //
// object range (first object and number of objects) in a TTree         //
// (entries) or a directory (objects) in a file.                        //
// Packets are generated taking into account the performance of the     //
// remote machine, the time it took to process a previous packet on     //
// the remote machine, the locality of the database files, etc.         //
//                                                                      //
//////////////////////////////////////////////////////////////////////////

#ifndef ROOT_TVirtualPacketizer
#include "TVirtualPacketizer.h"
#endif


class TMessage;
class TTimer;
class TTree;
class TMap;
class TProofStats;


class TPacketizer : public TVirtualPacketizer {

public:              // public because of Sun CC bug
   class TFileNode;
   class TFileStat;
   class TSlaveStat;

private:
   TList    *fPackets;      // all processed packets

   TList    *fFileNodes;    // nodes with files
   TList    *fUnAllocated;  // nodes with unallocated files
   TList    *fActive;       // nodes with unfinished files
   TMap     *fSlaveStats;   // slave status, keyed by correspondig TSlave

   Long64_t  fPacketSize;   // global base packet size
                                 // It can be set with PROOF_PacketSize
                                 // parameter, in the input list.
   Int_t     fMaxPerfIdx;   // maximum of our slaves' performance index

   Long_t    fMaxSlaveCnt;  // maximum number of workers per filenode (Long_t to avoid
                            // warnings from backward compatibility support)
   Int_t     fPacketAsAFraction; // used to calculate the packet size
                                 // fPacketSize = fTotalEntries / (fPacketAsAFraction * nslaves)
                                 // fPacketAsAFraction can be interpreted as follows:
                                 // assuming all slaves have equal processing rate, packet size
                                 // is (#events processed by 1 slave) / fPacketSizeAsAFraction.
                                 // It can be set with PROOF_PacketAsAFraction in input list.

   TPacketizer();
   TPacketizer(const TPacketizer&);     // no implementation, will generate
   void operator=(const TPacketizer&);  // error on accidental usage

   TFileNode     *NextUnAllocNode();
   void           RemoveUnAllocNode(TFileNode *);

   TFileNode     *NextActiveNode();
   void           RemoveActiveNode(TFileNode *);

   TFileStat     *GetNextUnAlloc(TFileNode *node = 0);
   TFileStat     *GetNextActive();
   void           RemoveActive(TFileStat *file);

   void           Reset();
   void           ValidateFiles(TDSet *dset, TList *slaves, Long64_t maxent = -1, Bool_t byfile = kFALSE);

public:
   TPacketizer(TDSet *dset, TList *slaves, Long64_t first, Long64_t num,
                TList *input, TProofProgressStatus *st);
   virtual ~TPacketizer();

   TDSetElement *GetNextPacket(TSlave *sl, TMessage *r);
   Long64_t      GetEntriesProcessed(TSlave *sl) const;

   Float_t       GetCurrentRate(Bool_t &all);
   Int_t         GetActiveWorkers();

   ClassDef(TPacketizer,0)  //Generate work packets for parallel processing
};

#endif
 TPacketizer.h:1
 TPacketizer.h:2
 TPacketizer.h:3
 TPacketizer.h:4
 TPacketizer.h:5
 TPacketizer.h:6
 TPacketizer.h:7
 TPacketizer.h:8
 TPacketizer.h:9
 TPacketizer.h:10
 TPacketizer.h:11
 TPacketizer.h:12
 TPacketizer.h:13
 TPacketizer.h:14
 TPacketizer.h:15
 TPacketizer.h:16
 TPacketizer.h:17
 TPacketizer.h:18
 TPacketizer.h:19
 TPacketizer.h:20
 TPacketizer.h:21
 TPacketizer.h:22
 TPacketizer.h:23
 TPacketizer.h:24
 TPacketizer.h:25
 TPacketizer.h:26
 TPacketizer.h:27
 TPacketizer.h:28
 TPacketizer.h:29
 TPacketizer.h:30
 TPacketizer.h:31
 TPacketizer.h:32
 TPacketizer.h:33
 TPacketizer.h:34
 TPacketizer.h:35
 TPacketizer.h:36
 TPacketizer.h:37
 TPacketizer.h:38
 TPacketizer.h:39
 TPacketizer.h:40
 TPacketizer.h:41
 TPacketizer.h:42
 TPacketizer.h:43
 TPacketizer.h:44
 TPacketizer.h:45
 TPacketizer.h:46
 TPacketizer.h:47
 TPacketizer.h:48
 TPacketizer.h:49
 TPacketizer.h:50
 TPacketizer.h:51
 TPacketizer.h:52
 TPacketizer.h:53
 TPacketizer.h:54
 TPacketizer.h:55
 TPacketizer.h:56
 TPacketizer.h:57
 TPacketizer.h:58
 TPacketizer.h:59
 TPacketizer.h:60
 TPacketizer.h:61
 TPacketizer.h:62
 TPacketizer.h:63
 TPacketizer.h:64
 TPacketizer.h:65
 TPacketizer.h:66
 TPacketizer.h:67
 TPacketizer.h:68
 TPacketizer.h:69
 TPacketizer.h:70
 TPacketizer.h:71
 TPacketizer.h:72
 TPacketizer.h:73
 TPacketizer.h:74
 TPacketizer.h:75
 TPacketizer.h:76
 TPacketizer.h:77
 TPacketizer.h:78
 TPacketizer.h:79
 TPacketizer.h:80
 TPacketizer.h:81
 TPacketizer.h:82
 TPacketizer.h:83
 TPacketizer.h:84
 TPacketizer.h:85
 TPacketizer.h:86
 TPacketizer.h:87
 TPacketizer.h:88
 TPacketizer.h:89
 TPacketizer.h:90
 TPacketizer.h:91
 TPacketizer.h:92
 TPacketizer.h:93
 TPacketizer.h:94
 TPacketizer.h:95
 TPacketizer.h:96
 TPacketizer.h:97
 TPacketizer.h:98
 TPacketizer.h:99
 TPacketizer.h:100
 TPacketizer.h:101