Google App Engine Datastore Writes: How to enable/disable read-only mode remotely?

走远了吗. 提交于 2019-12-12 14:45:01

问题


In reading up on backing up GAE's Datastore, where:

We strongly recommend that you set your application to read-only mode during a backup or restore...

After a cursory inspection, it appears that the only way to do this is via the GAE web admin UI, where you either Disable or Re-Enable Writes inside a page somewhere.

I would like to write some Ant buildfiles and/or shell and/or Python scripts that would allow me to backup/restore my GAE app's Datastore automatically. This would mean I would need a way to automate the enabling/disabling of writes (putting my app into and out from a "read-only" mode) to my Datastore, all from inside some script (like I said, either Ant, bash or Python).

So I ask: is this even possible? Or is this something that must be done "manually" (via the web admin UI)? Thanks in advance!


回答1:


The Capabilities Python API is the one that you can use yo read the state of some capabilities of your app like DataStore writes. Unfortunately this Api only have methods to read the state, but not for set the state.

edited:


Since the code must consult the Capabilities API to get the state of each functionality in the App-engine, and avoid failures by over-quota, system maintenance etc... One possible solution is to put a kind of interface in front of the Capabilities API within flags to disable each functionality.

pseudo code i.e:

class DatasToreWriteCapabiliti{
  boolean DATASTORE_WRITE = true;

  public disable(){ DATASTORE_WRITE = false;}
  public enable(){ DATASTORE_WRITE = true;}

  public CapabilityStatus status(){
     if(DATASTORE_WRITE == false) return CapabilityStatus.DISABLED;

     CapabilitiesService service = CapabilitiesServiceFactory.getCapabilitiesService();
     return service.getStatus(Capability.DATASTORE_WRITE).getStatus();
  }
}



回答2:


I think you're confused by what it means by saying 'set your application to read-only mode': you think this is a service provided by GAE, but it actually means, in your app, you create a mode to prevent writes while you're performing backup.

I expect the optional read-only mode available from the Web interface is not designed for freezing during backup, but just managing the status of a datastore.



来源:https://stackoverflow.com/questions/13047091/google-app-engine-datastore-writes-how-to-enable-disable-read-only-mode-remotel

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!