-
Notifications
You must be signed in to change notification settings - Fork 176
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
Conversation
6c0a9a2
to
c7bbb3d
Compare
@@ -146,16 +164,24 @@ private EntityManagerFactory createEntityManagerFactory( | |||
properties.put(ECLIPSELINK_PERSISTENCE_XML, confFile); | |||
|
|||
return Persistence.createEntityManagerFactory(persistenceUnitName, properties); | |||
} catch (Exception e) { | |||
} catch (IOException e) { |
There was a problem hiding this comment.
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".
… for different realm
cb23532
to
c6f41a9
Compare
There was a problem hiding this 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?
// Clear to test out EntityManagerFactory creation, otherwise cached EntityManagerFactory would | ||
// get reused |
There was a problem hiding this comment.
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 = |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor: realmContext.getRealmIdentifier()
-> realm
@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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
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.
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
Test Configuration:
Checklist:
Please delete options that are not relevant.