Is there any way to persist data between stopping and starting appscale sessions?

Asked by Vladimir Kiva

 Is it possible to change drop_all_tables script or somethig like this?

Question information

Language:
English Edit question
Status:
Solved
For:
AppScale Edit question
Assignee:
No assignee Edit question
Solved by:
Navraj Chohan
Solved:
Last query:
Last reply:

This question was reopened

Revision history for this message
Navraj Chohan (nchohan) said :
#1

Hello Vladimir,
Each datastore, either upon starting or termination, will clear out the datastore. If you go into appscale/AppDB/<your db>/<your db>_helper.rb and comment out the lines which do the removing of the data, then it should be possible to persist it. The drop_all_tables script is not used for this. This is uncharted territory, so you may have issues upon startup because it's assuming a clean db. Another option is to dump the contents of the db, and reload it after startup.

Thanks for your question.
-Raj

Revision history for this message
Vladimir Kiva (vladimirkiva) said :
#2

Hello Raj,

Thank you for the comment. It seams like it works but the problem is that my code relies on AppEngine function to assign Id's for entities. In case of restarting the application AppScale starts assigning id's from the beginning... I'm rewriting the code to assign id's randomly...

Thanks,
Vladimir

Revision history for this message
Navraj Chohan (nchohan) said :
#3

This is because ZooKeeper is being cleared out upon restart. If it is not cleared out, then the ids should resume from where they left off.

-Raj

Revision history for this message
Vladimir Kiva (vladimirkiva) said :
#4

Thank you, Raj for the explanation.
It seams like I have worse problem. It looks like AppScale doesn't persist session for the connection. I use the following approach:

public class GetListOfLatestVersionsHandler implements ActionHandler<GetListOfLatestVersionsAction, GetListOfLatestVersionsResult> {
 final private Provider<HttpSession> sessionProvider;

 @Inject
 public GetListOfLatestVersionsHandler(Provider<HttpSession> sessionProvider) {
  this.sessionProvider = sessionProvider;
 }

 @Override
 public GetListOfLatestVersionsResult execute(GetListOfLatestVersionsAction action, ExecutionContext context) throws ActionException {
  Key<CompanyContext> companyContextKey = (Key<CompanyContext>) sessionProvider.getAttribute(Fields.COMPANY_ROOT.toString());

This code retrieves companyContextKey which is stored is HttpSession object while logging in. It works fine while local running and running on AppEngine. But what I see is that companyContextKey became null running on AppScale... No idea what it is...

Revision history for this message
Best Navraj Chohan (nchohan) said :
#5

Sessions are currently not implemented but are on the road map:
https://bugs.launchpad.net/appscale/+bug/793349

Revision history for this message
Vladimir Kiva (vladimirkiva) said :
#6

Thanks Navraj Chohan, that solved my question.