Skip to content
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

Add logging and move test to the right package #104

Merged
merged 4 commits into from
Aug 7, 2024

Conversation

aihuaxu
Copy link
Contributor

@aihuaxu aihuaxu commented Aug 7, 2024

Description

Add the logging and also move the PolarisEclipseLinkMetaStoreTest.java since it's in incorrect package.

Fixes #45

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Update PolarisEclipseLinkMetaStoreTest unit test
  • Test B

Test Configuration:

  • Firmware version:
  • Hardware:
  • Toolchain:
  • SDK:

Checklist:

Please delete options that are not relevant.

  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules
  • If adding new functionality, I have discussed my implementation with the community using the linked GitHub issue
  • I have signed and submitted the ICLA and if needed, the CCLA. See Contributing for details.

@aihuaxu aihuaxu requested a review from a team as a code owner August 7, 2024 01:05
@aihuaxu aihuaxu force-pushed the aixu-add-logs-reuse-factory branch from 6c0a9a2 to c7bbb3d Compare August 7, 2024 01:10
@@ -146,16 +164,24 @@ private EntityManagerFactory createEntityManagerFactory(
properties.put(ECLIPSELINK_PERSISTENCE_XML, confFile);

return Persistence.createEntityManagerFactory(persistenceUnitName, properties);
} catch (Exception e) {
} catch (IOException e) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@collado-mike Didn't get your original comment "catch RuntimeException separately and just rethrow".

@aihuaxu aihuaxu changed the title Add logging and reuse created EntityManagerFactory Add logging and update the package for the test Aug 7, 2024
@aihuaxu aihuaxu force-pushed the aixu-add-logs-reuse-factory branch from cb23532 to c6f41a9 Compare August 7, 2024 01:38
@aihuaxu aihuaxu changed the title Add logging and update the package for the test Add logging and move test to the right package Aug 7, 2024
Copy link
Contributor

@flyrain flyrain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM overall. Left minor comments. For the cache we added, do we need to invalidate it in certain condition?

Comment on lines 64 to 65
// Clear to test out EntityManagerFactory creation, otherwise cached EntityManagerFactory would
// get reused
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor suggestion: -> Clear cache to prevent reuse

@@ -82,6 +84,10 @@ public class PolarisEclipseLinkMetaStoreSessionImpl implements PolarisMetaStoreS
private static final Logger LOG =
LoggerFactory.getLogger(PolarisEclipseLinkMetaStoreSessionImpl.class);

// Cache to hold the EntityManagerFactory for each realm. Each realm needs a separate
// EntityManagerFactory since it connects to different databases
private static ConcurrentHashMap<String, EntityManagerFactory> realmFactories =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-> static final as we don't want any object of this class to reassign a new realmFactories

*/
private EntityManagerFactory createEntityManagerFactory(
@NotNull RealmContext realmContext,
@Nullable String confFile,
@Nullable String persistenceUnitName) {
String realm = realmContext.getRealmIdentifier();
EntityManagerFactory factory =
realmFactories.getOrDefault(realmContext.getRealmIdentifier(), null);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor: realmContext.getRealmIdentifier() -> realm

@aihuaxu
Copy link
Contributor Author

aihuaxu commented Aug 7, 2024

LGTM overall. Left minor comments. For the cache we added, do we need to invalidate it in certain condition?

@flyrain Thanks for reviewing. Updated based on the comments. Each realm communicates with its dedicated database and doesn't change. For now, I don't see the cases which we need to invalidate it.

Copy link
Contributor

@flyrain flyrain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

@flyrain flyrain merged commit 46dfeb1 into apache:main Aug 7, 2024
3 checks passed
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

Successfully merging this pull request may close these issues.

[DOCUMENTATION]: missing documentation on how to load conf-file from other locations
3 participants