Skip to content

Commit

Permalink
Refactor Job tracking and statistics gathering
Browse files Browse the repository at this point in the history
  • Loading branch information
nbougalis authored and vinniefalco committed Feb 23, 2014
1 parent 616a538 commit 7cd6348
Show file tree
Hide file tree
Showing 7 changed files with 634 additions and 440 deletions.
72 changes: 0 additions & 72 deletions src/ripple_core/functional/Job.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,6 @@ Job::Job (JobType type, uint64 index)
{
}

#if 0
Job::Job (Job const& other)
: m_cancelCallback (other.m_cancelCallback)
, mType (other.mType)
, mJobIndex (other.mJobIndex)
, mJob (other.mJob)
, m_loadEvent (other.m_loadEvent)
, mName (other.mName)
, m_queue_time (other.m_queue_time)
{
}
#endif

Job::Job (JobType type,
std::string const& name,
uint64 index,
Expand All @@ -60,19 +47,6 @@ Job::Job (JobType type,
m_loadEvent = boost::make_shared <LoadEvent> (boost::ref (lm), name, false);
}

/*
Job& Job::operator= (Job const& other)
{
mType = other.mType;
mJobIndex = other.mJobIndex;
mJob = other.mJob;
m_loadEvent = other.m_loadEvent;
mName = other.mName;
m_cancelCallback = other.m_cancelCallback;
return *this;
}
*/

JobType Job::getType () const
{
return mType;
Expand Down Expand Up @@ -109,52 +83,6 @@ void Job::rename (std::string const& newName)
mName = newName;
}

const char* Job::toString (JobType t)
{
switch (t)
{
case jtINVALID: return "invalid";
case jtPACK: return "peerLedgerReq";
case jtPUBOLDLEDGER: return "publishAcqLedger";
case jtVALIDATION_ut: return "untrustedValidation";
case jtPROOFWORK: return "proofOfWork";
case jtTRANSACTION_l: return "localTransaction";
case jtPROPOSAL_ut: return "untrustedProposal";
case jtLEDGER_DATA: return "ledgerData";
case jtUPDATE_PF: return "updatePaths";
case jtCLIENT: return "clientCommand";
case jtRPC: return "RPC";
case jtTRANSACTION: return "transaction";
case jtUNL: return "unl";
case jtADVANCE: return "advanceLedger";
case jtPUBLEDGER: return "publishNewLedger";
case jtTXN_DATA: return "fetchTxnData";
case jtWAL: return "writeAhead";
case jtVALIDATION_t: return "trustedValidation";
case jtWRITE: return "writeObjects";
case jtACCEPT: return "acceptLedger";
case jtPROPOSAL_t: return "trustedProposal";
case jtSWEEP: return "sweep";
case jtNETOP_CLUSTER: return "clusterReport";
case jtNETOP_TIMER: return "heartbeat";

case jtADMIN: return "administration";

// special types not dispatched by the job pool
case jtPEER: return "peerCommand";
case jtDISK: return "diskAccess";
case jtTXN_PROC: return "processTransaction";
case jtOB_SETUP: return "orderBookSetup";
case jtPATH_FIND: return "pathFind";
case jtHO_READ: return "nodeRead";
case jtHO_WRITE: return "nodeWrite";
case jtGENERIC: return "generic";
default:
assert (false);
return "unknown";
}
}

bool Job::operator> (const Job& j) const
{
if (mType < j.mType)
Expand Down
88 changes: 45 additions & 43 deletions src/ripple_core/functional/Job.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,48 +24,51 @@ namespace ripple {

// Note that this queue should only be used for CPU-bound jobs
// It is primarily intended for signature checking

enum JobType
{
// must be in priority order, low to high
jtINVALID = -1,
jtPACK = 1, // Make a fetch pack for a peer
jtPUBOLDLEDGER = 2, // An old ledger has been accepted
jtVALIDATION_ut = 3, // A validation from an untrusted source
jtPROOFWORK = 4, // A proof of work demand from another server
jtTRANSACTION_l = 5, // A local transaction
jtPROPOSAL_ut = 6, // A proposal from an untrusted source
jtLEDGER_DATA = 7, // Received data for a ledger we're acquiring
jtUPDATE_PF = 8, // Update pathfinding requests
jtCLIENT = 9, // A websocket command from the client
jtRPC = 10, // A websocket command from the client
jtTRANSACTION = 11, // A transaction received from the network
jtUNL = 12, // A Score or Fetch of the UNL (DEPRECATED)
jtADVANCE = 13, // Advance validated/acquired ledgers
jtPUBLEDGER = 14, // Publish a fully-accepted ledger
jtTXN_DATA = 15, // Fetch a proposed set
jtWAL = 16, // Write-ahead logging
jtVALIDATION_t = 17, // A validation from a trusted source
jtWRITE = 18, // Write out hashed objects
jtACCEPT = 19, // Accept a consensus ledger
jtPROPOSAL_t = 20, // A proposal from a trusted source
jtSWEEP = 21, // Sweep for stale structures
jtNETOP_CLUSTER = 22, // NetworkOPs cluster peer report
jtNETOP_TIMER = 23, // NetworkOPs net timer processing
jtADMIN = 24, // An administrative operation

// special types not dispatched by the job pool
jtPEER = 30,
jtDISK = 31,
jtTXN_PROC = 32,
jtOB_SETUP = 33,
jtPATH_FIND = 34,
jtHO_READ = 35,
jtHO_WRITE = 36,
jtGENERIC = 37, // Used just to measure time
}; // CAUTION: If you add new types, add them to Job.cpp too

// VFALCO TODO move this into the enum so it calculates itself?
#define NUM_JOB_TYPES 48 // why 48 and not 38?
// Special type indicating an invalid job - will go away soon.
jtINVALID = -1,

// Job types - the position in this enum indicates the job priority with
// earlier jobs having lower priority than later jobs. If you wish to
// insert a job at a specific priority, simply add it at the right location.

jtPACK, // Make a fetch pack for a peer
jtPUBOLDLEDGER, // An old ledger has been accepted
jtVALIDATION_ut, // A validation from an untrusted source
jtPROOFWORK, // A proof of work demand from another server
jtTRANSACTION_l, // A local transaction
jtPROPOSAL_ut, // A proposal from an untrusted source
jtLEDGER_DATA, // Received data for a ledger we're acquiring
jtUPDATE_PF, // Update pathfinding requests
jtCLIENT, // A websocket command from the client
jtRPC, // A websocket command from the client
jtTRANSACTION, // A transaction received from the network
jtUNL, // A Score or Fetch of the UNL (DEPRECATED)
jtADVANCE, // Advance validated/acquired ledgers
jtPUBLEDGER, // Publish a fully-accepted ledger
jtTXN_DATA, // Fetch a proposed set
jtWAL, // Write-ahead logging
jtVALIDATION_t, // A validation from a trusted source
jtWRITE, // Write out hashed objects
jtACCEPT, // Accept a consensus ledger
jtPROPOSAL_t, // A proposal from a trusted source
jtSWEEP, // Sweep for stale structures
jtNETOP_CLUSTER, // NetworkOPs cluster peer report
jtNETOP_TIMER, // NetworkOPs net timer processing
jtADMIN, // An administrative operation

// Special job types which are not dispatched by the job pool
jtPEER ,
jtDISK ,
jtTXN_PROC ,
jtOB_SETUP ,
jtPATH_FIND ,
jtHO_READ ,
jtHO_WRITE ,
jtGENERIC , // Used just to measure time
};

class Job
{
Expand Down Expand Up @@ -113,14 +116,13 @@ class Job

void rename (const std::string& n);

// These comparison operators make the jobs sort in priority order in the job set
// These comparison operators make the jobs sort in priority order
// in the job set
bool operator< (const Job& j) const;
bool operator> (const Job& j) const;
bool operator<= (const Job& j) const;
bool operator>= (const Job& j) const;

static const char* toString (JobType);

private:
CancelCallback m_cancelCallback;
JobType mType;
Expand Down
Loading

0 comments on commit 7cd6348

Please sign in to comment.