vldpyatkov commented on a change in pull request #8759:
URL: https://github.com/apache/ignite/pull/8759#discussion_r574747470
##########
File path:
modules/core/src/main/java/org/apache/ignite/spi/deployment/local/LocalDeploymentSpi.java
##########
@@ -146,6 +154,68 @@
return null;
}
+ /** {@inheritDoc} */
+ @Nullable @Override public DeploymentResource findResource(String
rsrcName, @Nullable ClassLoader clsLdr) {
Review comment:
Please say to me honest: does this method can look for remote resource?
##########
File path:
modules/core/src/main/java/org/apache/ignite/spi/deployment/local/LocalDeploymentSpi.java
##########
@@ -111,35 +110,60 @@
}
/** {@inheritDoc} */
- @Nullable @Override public DeploymentResource findResource(String
rsrcName) {
+ @Nullable @Override public DeploymentResource findResource(String
rsrcName, @Nullable ClassLoader clsLdr) {
assert rsrcName != null;
- // Last updated class loader has highest priority in search.
- for (Entry<ClassLoader, ConcurrentMap<String, String>> e :
ldrRsrcs.descendingEntrySet()) {
+ if (clsLdr != null) {
+ ConcurrentMap<String, String> rsrcs = ldrRsrcs.get(clsLdr);
+
+ if (rsrcs == null)
+ return null;
+
+ return findResource0(rsrcs, rsrcName, clsLdr);
+ }
+
+ for (Entry<ClassLoader, ConcurrentMap<String, String>> e :
ldrRsrcs.entrySet()) {
ClassLoader ldr = e.getKey();
ConcurrentMap<String, String> rsrcs = e.getValue();
- String clsName = rsrcs.get(rsrcName);
+ DeploymentResourceAdapter res = findResource0(rsrcs, rsrcName,
ldr);
- // Return class if it was found in resources map.
- if (clsName != null) {
- // Recalculate resource name in case if access is performed by
- // class name and not the resource name.
- rsrcName = getResourceName(clsName, rsrcs);
+ if (res != null)
+ return res;
+ }
- assert clsName != null;
+ return null;
+ }
- try {
- Class<?> cls = Class.forName(clsName, true, ldr);
+ /**
+ * Finds appropriate resource.
+ *
+ * @param rsrcs Resources.
+ * @param rsrcName Class name or class alias to find class loader for.
+ * @param clsLdr desired class loader.
+ * @return Deployed class loader, or {@code null} if not deployed.
+ */
+ @Nullable private DeploymentResourceAdapter findResource0(Map<String,
String> rsrcs, String rsrcName, ClassLoader clsLdr) {
+ String clsName = rsrcs.get(rsrcName);
- assert cls != null;
+ // Return class if it was found in resources map.
+ if (clsName != null) {
+ // Recalculate resource name in case if access is performed by
+ // class name and not the resource name.
+ rsrcName = getResourceName(clsName, rsrcs);
- // Return resource.
- return new DeploymentResourceAdapter(rsrcName, cls, ldr);
- }
- catch (ClassNotFoundException ignored) {
- // No-op.
- }
+ assert clsName != null;
+
+ try {
+ Class<?> cls = Class.forName(clsName, true, clsLdr);
+
+ assert cls != null;
+
+ // Return resource.
+ return new DeploymentResourceAdapter(rsrcName, cls, clsLdr);
+ }
+ catch (ClassNotFoundException ignored) {
Review comment:
Ok. What do you think about handling exception with WARN message?
##########
File path:
modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentLocalStore.java
##########
@@ -109,12 +109,10 @@
@Override public Collection<GridDeployment> getDeployments() {
Collection<GridDeployment> deps = new ArrayList<>();
- synchronized (mux) {
Review comment:
Do you think this mux is excess here?
I think, it was here because you can get a list from the map, but other
thread remove the list.
##########
File path:
modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentLocalStore.java
##########
@@ -232,23 +230,33 @@
/** {@inheritDoc} */
@Override public GridDeployment
searchDeploymentCache(GridDeploymentMetadata meta) {
- return deployment(meta.alias());
+ return deployment(meta);
}
/**
- * @param alias Class alias.
+ * @param meta Deployment meta.
* @return Deployment.
*/
- @Nullable private GridDeployment deployment(String alias) {
- Deque<GridDeployment> deps = cache.get(alias);
+ @Nullable private GridDeployment deployment(final GridDeploymentMetadata
meta) {
+ Deque<GridDeployment> deps = cache.get(meta.alias());
if (deps != null) {
- GridDeployment dep = deps.peekFirst();
+ for (GridDeployment dep : deps) {
+ // local or remote deployment.
Review comment:
Yes, I realized it. Thanks.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]