8000 provide method to test if an entity instance is stored · Issue #311 · eclipse-store/store · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

provide method to test if an entity instance is stored #311

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

Open
nimo23 opened this issue Oct 16, 2024 · 5 comments
Open

provide method to test if an entity instance is stored #311

nimo23 opened this issue Oct 16, 2024 · 5 comments

Comments

@nimo23
Copy link
nimo23 commented Oct 16, 2024

Is your feature request related to a problem? Please describe.

I want to write test cases to check if an entity instance is stored. However, it seems that there is no method in eclipse-store to check if an entity instance is stored. Such method can be also useful for other cases.

Describe the solution you'd like

Please provide a method something like

long StorageManager#isStored(Object o), which returns

  • 0 if entity instance is not stored
  • a UTC timestamp in milliseconds indicating when the data was last saved (or updated).
@zdenek-jonas
Copy link
Contributor

Small tip: You can use storageManager.persistenceManager().objectRegistry().lookupObjectId(s);. This returns the objectId if the object is stored, and -1 if the object is not in storage yet.

@nimo23
Copy link
Author
nimo23 commented Oct 16, 2024

@zdenek-jonas Thanks! I think this solves this issue, but we should keep in mind that in case of lazy storage (which is the default), the object ID is not always returned immediately. However, that's okay as I can switch to eager storage for test cases.

Is there a way to get a UTC timestamp in milliseconds indicating when the data was last saved (or updated) by eclipse-store? Maybe it's already stored somewhere internally for administration.

@hg-ms
Copy link
Contributor
hg-ms commented Oct 17, 2024

There is a time stamp but no simple way to get that. We write a time stamp to the storage transaction log file at every store. The time stamp is produced by a org.eclipse.store.storage.types.StorageTimestampProvider. The default implementation is org.eclipse.store.storage.types.StorageTimestampProvider.MonotonicTime.
You may replace that with a custom implementation that allows you to get the last generated value.
The StorageFoundation has a setter to setup that custom one:

EmbeddedStorageFoundation.New()
.setTimestampProvider(...)

@nimo23
Copy link
Author
nimo23 commented Oct 17, 2024

There is a time stamp but no simple way to get that.

It would be good if it could be done in a simpler way, for example with a method in storageManger#persistenceManager().objectRegistry():

lastStored(Object o) or getLastSync(Object o) with

  • 0 if entity instance is currently not stored
  • a UTC timestamp in milliseconds indicating when the data was last saved (or updated).

What do you think?

@hg-ms
Copy link
Contributor
hg-ms commented Oct 18, 2024

Many thanks for your proposal.

Adding an object specific time stamp would be a bigger feature that requires a detailed requirement analysis, I doubt that we will implement that in the near future.

I’m not sure if it helps but there is a logger available that can log every object store.
To do so you need to enable the ‘org.eclipse.serializer.persistence.binary.types.BinaryStorer’ logger with log level ‘debug’

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
0