-
Notifications
You must be signed in to change notification settings - Fork 61
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
Implemented #221, called tronstore #258
Implemented #221, called tronstore #258
Conversation
@@ -426,7 +438,7 @@ def validate_jobs_and_services(config, config_context): | |||
config_utils.unique_names(fmt_string, config['jobs'], config['services']) | |||
|
|||
|
|||
DEFAULT_STATE_PERSISTENCE = ConfigState('tron_state', 'shelve', None, 1) | |||
DEFAULT_STATE_PERSISTENCE = ConfigState('tron_state', 'shelve', 'pickle', 1, 'json', 'pickle') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This first pickle
should still be None. It's ignored so we don't want it set to anything.
…es accordingly to match other tron patterns
Okay, so the post at the top is still pretty accurate, but here's what's changed:
|
|
scheduled = self.job_runs.get_scheduled() | ||
for job_run in scheduled: | ||
self._set_callback(job_run) | ||
scheduled = [run for run in self.job_runs.get_scheduled()] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is just to get a list,
scheduled = list(self.job_runs.get_scheduled()
is probably more appropriate.
Implemented #221, called tronstore
This is what is hopefully a really close to final version of tronstore, a new process to be run as a child alongside of trond that will parallelize state serialization for #221. Trond will now spawn this process as part of the
PersistenceManagerFactory
by default, rather than independently creating each store type class.Here's a basic overview of what's happened structurally:
tron/serialize/runstate
, calledtronstore
. This, obviously, holds all the new files related to tronstore.ParallelStore
objects, a new, top level class that implements the same front facing methods as the old *Store objects (ShelveStore, YamlStore, etc), as well as one new front facing method,update_from_config
.update_from_config
method that calls ParallelStore's update_from_config method, andStateChangeWatcher.update_from_config
has been updated to use this.StoreProcessProtocol
object (located intronstore/process.py
) that handles all low level process management and communication. It does couple with ProcessProtocol in assuming that everything sent to tronstore is going to be either a StoreRequest or a StoreResponse (more on that later), and relying on the ParallelStore object to update itsStoreRequestFactory
whenever the configuration is updated.tronstore.main()
fromtronstore/tronstore.py
as a daemonized process, passing in a Pipe object for message communication. Pipes, by default, use pickle (not cPickle) for serialization, so instead, there are factories for request and response objects, which are serialized based on the Tron configuration given at runtime. The raw, serialized text is what is actually sent over the Pipe object. Pipes work somewhat like a two-way Queue, so there's no need to deal with chunking (despite there being some chunking related code left over intronstore/chunking.py
).StoreRequestFactory
andStoreResponseFactory
live intronstore/messages.py
. They deal with constructing and reconstructingStoreRequest
s andStoreResponse
s to and from tronstore, respectively. There's not too much here- just an id for matching the requests and responses together (which is actually done by the StoreProcessProtocol), and a serialization class mapping (the actual methods for serialization/deserialization live intronstore/transport.py
; the mapping references these classes).tronstore/msg_enums.py
. They are SAVE, RESTORE, CONFIG, and SHUTDOWN. Which type is sent is controlled by ParallelStore, which constructs requests according to whatever method was called. SAVE is a non-blocking requests, while RESTORE, CONFIG and SHUTDOWN are. Blocking requests time out, after which a log entry is written and a failure is returned.SIGINT
,SIGTERM
, andSIGHUP
, which are the three signals also registered to custom handlers in trond. The handlers do nothing, so that trond can take the correct, complete action when one of the signals is recieved. This is necessary, as signals are sent to all processes in a process group, and tronstore is spawned in the same group as trond. To allow for multiple processes with signal handling, a flag,installSignalHandlers
, had to be switched off on the Twisted reactor.state_persistence
section of the config, calledtransport_method
anddb_store_method
. Both must be set to one one ofjson
,msgpack
,pickle
, oryaml
, but db_store_method isn't actually enforced unlessstore_type
is set tosql
ormongo
. store_type is still the same as before, but is now instead used by tronstore to set up its own internal store object (new store objects are located intronstore/store.py
). transport_method determines what serialization method tronstore uses to send requests and responses, while db_store_method determines what serialization method tronstore uses to store data within a database (only for SQLAlchemy and MongoDB configurations, obviously). Everything else in the state_persistence is effectively the same as before.tools/
that will migrate the stored state of Tron from 0.6.1 to 0.6.2. It's got a really long docstring describing how to use it. The old migrate_state.py script has been updated to migrate state for tronstore state objects.