Class LocalDatastoreHelper (2.25.2)
Stay organized with collections
Save and categorize content based on your preferences.
publicclass LocalDatastoreHelperextendsBaseEmulatorHelper<DatastoreOptions>Utility to start and stop local Google Cloud Datastore emulators.
This class is unstable.
Inherited Members
Static Methods
create()
publicstaticLocalDatastoreHelpercreate()Creates a local Datastore helper with a placeholder project ID and the default consistency setting of 0.9. Consistency refers to the fraction of Datastore writes that are immediately visible to global queries, with 0.0 meaning no writes are immediately visible and 1.0 meaning all writes are immediately visible.
| Returns | |
|---|---|
| Type | Description |
LocalDatastoreHelper |
|
create(double consistency)
publicstaticLocalDatastoreHelpercreate(doubleconsistency)Creates a local Datastore helper with the specified settings for project ID and consistency.
| Parameter | |
|---|---|
| Name | Description |
consistency |
double the fraction of Datastore writes that are immediately visible to global queries, with 0.0 meaning no writes are immediately visible and 1.0 meaning all writes are immediately visible. Note that setting this to 1.0 may mask incorrect assumptions about the consistency of non-ancestor queries; non-ancestor queries are eventually consistent. |
| Returns | |
|---|---|
| Type | Description |
LocalDatastoreHelper |
|
create(double consistency, int port)
publicstaticLocalDatastoreHelpercreate(doubleconsistency,intport)Creates a local Datastore helper with the specified settings for project ID and consistency.
| Parameters | |
|---|---|
| Name | Description |
consistency |
double the fraction of Datastore writes that are immediately visible to global queries, with 0.0 meaning no writes are immediately visible and 1.0 meaning all writes are immediately visible. Note that setting this to 1.0 may mask incorrect assumptions about the consistency of non-ancestor queries; non-ancestor queries are eventually consistent. |
port |
int the port to be used to start the emulator service. Note that setting this to 0 the emulator will search for a free random port. |
| Returns | |
|---|---|
| Type | Description |
LocalDatastoreHelper |
|
create(int port)
publicstaticLocalDatastoreHelpercreate(intport)Creates a local Datastore helper with a placeholder project ID and the default consistency setting of 0.9.
| Parameter | |
|---|---|
| Name | Description |
port |
int the port to be used to start the emulator service. Note that setting this to 0 the emulator will search for a free random port. |
| Returns | |
|---|---|
| Type | Description |
LocalDatastoreHelper |
|
newBuilder()
publicstaticLocalDatastoreHelper.BuildernewBuilder()Returns a builder for LocalDatastoreHelper object.
| Returns | |
|---|---|
| Type | Description |
LocalDatastoreHelper.Builder |
|
Methods
getConsistency()
publicdoublegetConsistency()Returns the consistency setting for the local Datastore emulator.
| Returns | |
|---|---|
| Type | Description |
double |
|
getEmulatorRunners()
protectedList<BaseEmulatorHelper.EmulatorRunner>getEmulatorRunners()| Returns | |
|---|---|
| Type | Description |
List<com.google.cloud.testing.BaseEmulatorHelper.EmulatorRunner> |
|
getGcdPath()
publicPathgetGcdPath()Returns the data directory path of the local Datastore emulator.
| Returns | |
|---|---|
| Type | Description |
Path |
|
getLogger()
protectedLoggergetLogger()| Returns | |
|---|---|
| Type | Description |
Logger |
|
getOptions()
publicDatastoreOptionsgetOptions()Returns a DatastoreOptions instance that sets the host to use the Datastore emulator on localhost.
| Returns | |
|---|---|
| Type | Description |
DatastoreOptions |
|
getOptions(String namespace)
publicDatastoreOptionsgetOptions(Stringnamespace)Returns a DatastoreOptions instance that sets the host to use the Datastore emulator on
localhost. The default namespace is set to namespace.
Please use setNamespace and then build() instead.
| Parameter | |
|---|---|
| Name | Description |
namespace |
String |
| Returns | |
|---|---|
| Type | Description |
DatastoreOptions |
|
isStoreOnDisk()
publicbooleanisStoreOnDisk()Returns true data persist on disk, otherwise false data not store on disk.
| Returns | |
|---|---|
| Type | Description |
boolean |
|
reset()
publicvoidreset()Resets the internal state of the Datastore emulator.
When running tests, one might reset() before each test, so earlier tests would not
affect later ones.
| Exceptions | |
|---|---|
| Type | Description |
IOException |
|
setNamespace(String namespace)
publicDatastoreOptions.BuildersetNamespace(Stringnamespace)| Parameter | |
|---|---|
| Name | Description |
namespace |
String |
| Returns | |
|---|---|
| Type | Description |
DatastoreOptions.Builder |
|
start()
publicvoidstart()Starts the local Datastore emulator through gcloud, downloads and caches the zip file
if user does not have gcloud or a compatible emulator version installed.
Currently the emulator does not persist any state across runs.
| Exceptions | |
|---|---|
| Type | Description |
IOException |
|
InterruptedException |
|
stop()
publicvoidstop()Stops the Datastore emulator. The same as #stopDuration(java.time.Duration) but with timeout duration of 20 seconds.
It is important to stop the emulator. Since the emulator runs in its own process, not stopping it might cause it to become orphan.
It is not required to call #reset() before stop().
| Exceptions | |
|---|---|
| Type | Description |
IOException |
|
InterruptedException |
|
TimeoutException |
|
stop(Duration timeout)
publicvoidstop(Durationtimeout)This method is obsolete. Use #stopDuration(java.time.Duration) instead
| Parameter | |
|---|---|
| Name | Description |
timeout |
org.threeten.bp.Duration |
| Exceptions | |
|---|---|
| Type | Description |
IOException |
|
InterruptedException |
|
TimeoutException |
|
stopDuration(Duration timeout)
publicvoidstopDuration(Durationtimeout)Stops the Datastore emulator.
It is important to stop the emulator. Since the emulator runs in its own process, not stopping it might cause it to become orphan.
It is not required to call #reset() before stop.
| Parameter | |
|---|---|
| Name | Description |
timeout |
Duration The duration to wait for the emulator process to stop. It is recommended to set this value high to ensure proper shutdown, like 5 seconds or more. |
| Exceptions | |
|---|---|
| Type | Description |
IOException |
|
InterruptedException |
|
TimeoutException |
|
toBuilder()
publicLocalDatastoreHelper.BuildertoBuilder()Returns a builder for LocalDatastoreHelper object.
| Returns | |
|---|---|
| Type | Description |
LocalDatastoreHelper.Builder |
|