Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature jobqueue #291

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ db/*.db-*
# Ignore debug logs
debug_log.txt

# Ignore build log
build.log

# Ignore customized configs
rippled.cfg
validators.txt
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ script:
# Set so any failing command will abort the build
- set -e
# If only we could do -j12 ;)
- scons
- scons
# See what we've actually built
- ldd ./build/rippled
# Run unittests (under gdb)
Expand Down
17 changes: 15 additions & 2 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ HONOR_ENVS = ['CC', 'CXX', 'PATH']
env = Environment(
tools = ['default', 'protoc'],
#ENV = dict((k, os.environ[k]) for k in HONOR_ENVS)
ENV = dict((k, os.environ[k]) for k in HONOR_ENVS if k in os.environ)
ENV = dict((k, os.environ[k]) for k in HONOR_ENVS if k in os.environ)
)

# Use a newer gcc on FreeBSD
Expand Down Expand Up @@ -138,18 +138,31 @@ else:
# output
#-------------------------------------------------------------------------------

BuildLogFile = None

def print_cmd_line(s, target, src, env):
global BuildLogFile

if BuildLogFile is None:
BuildLogFile = open('build.log', 'w')

Tgt = (''.join([str(x) for x in target]))

if BuildLogFile is not None:
BuildLogFile.write("%s\n" % s);

if ('build/rippled' == Tgt):
sys.stdout.write("Linking '\033[94m%s\033[0m'...\n" % Tgt)
sys.stdout.write("%s\n" % s)
elif ('tags' == Tgt):
sys.stdout.write("Generating tags...\n")
else:
sys.stdout.write("Compiling '\033[94m%s\033[0m'...\n" % \
(' and '.join([str(x) for x in src])))
sys.stdout.write("%s\n" % s)

env['PRINT_CMD_LINE_FUNC'] = print_cmd_line
if os.environ.get('TRAVIS') is None:
env['PRINT_CMD_LINE_FUNC'] = print_cmd_line

#-------------------------------------------------------------------------------
#
Expand Down
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