NSAmelchev commented on code in PR #11539:
URL: https://github.com/apache/ignite/pull/11539#discussion_r1773845493
##########
modules/core/src/test/java/org/apache/ignite/internal/processors/service/IgniteServiceDeploymentClassLoadingDefaultMarshallerTest.java:
##########
@@ -152,6 +163,29 @@ public void testServiceDeployment3() throws Exception {
startClientGrid(CLIENT_NODE_WITH_EXT_CLASS_LOADER).services().deploy(serviceConfig());
}
+ /** @throws Exception If failed. */
+ @Test
+ public void testFailWhenNodeFilterClassNotFound() throws Exception {
+ IgniteEx srv = startGrid(SERVER_NODE);
+ IgniteEx cli = startClientGrid(CLIENT_NODE);
+
+ ServiceConfiguration svcCfg = new ServiceConfiguration()
+ .setName("TestDeploymentService")
+
.setService(((Class<Service>)extClsLdr.loadClass(NOOP_SERVICE_CLS_NAME)).getDeclaredConstructor().newInstance())
+
.setNodeFilter(((Class<IgnitePredicate<ClusterNode>>)extClsLdr.loadClass(NODE_FILTER_CLS_NAME))
+ .getConstructor(UUID.class)
+ .newInstance(cli.context().localNodeId()))
+ .setTotalCount(1);
+
+ assertThrowsWithCause(() -> cli.services().deploy(svcCfg),
ServiceDeploymentException.class);
+
+ assertTrue(cli.services().serviceDescriptors().isEmpty());
+ assertTrue(srv.services().serviceDescriptors().isEmpty());
+
+ // Check node alive.
+ srv.createCache(DEFAULT_CACHE_NAME).put(1, 1);
Review Comment:
Fixed
##########
modules/core/src/test/java/org/apache/ignite/internal/processors/service/IgniteServiceDeploymentClassLoadingDefaultMarshallerTest.java:
##########
@@ -152,6 +163,29 @@ public void testServiceDeployment3() throws Exception {
startClientGrid(CLIENT_NODE_WITH_EXT_CLASS_LOADER).services().deploy(serviceConfig());
}
+ /** @throws Exception If failed. */
+ @Test
+ public void testFailWhenNodeFilterClassNotFound() throws Exception {
+ IgniteEx srv = startGrid(SERVER_NODE);
+ IgniteEx cli = startClientGrid(CLIENT_NODE);
+
+ ServiceConfiguration svcCfg = new ServiceConfiguration()
+ .setName("TestDeploymentService")
+
.setService(((Class<Service>)extClsLdr.loadClass(NOOP_SERVICE_CLS_NAME)).getDeclaredConstructor().newInstance())
+
.setNodeFilter(((Class<IgnitePredicate<ClusterNode>>)extClsLdr.loadClass(NODE_FILTER_CLS_NAME))
+ .getConstructor(UUID.class)
+ .newInstance(cli.context().localNodeId()))
+ .setTotalCount(1);
+
+ assertThrowsWithCause(() -> cli.services().deploy(svcCfg),
ServiceDeploymentException.class);
+
+ assertTrue(cli.services().serviceDescriptors().isEmpty());
+ assertTrue(srv.services().serviceDescriptors().isEmpty());
+
+ // Check node alive.
Review Comment:
Fixed
##########
modules/core/src/main/java/org/apache/ignite/internal/processors/service/IgniteServiceProcessor.java:
##########
@@ -1764,11 +1781,21 @@ else if (req instanceof ServiceUndeploymentRequest)
"exists : [" + "srvcId" + reqSrvcId + ", srvcTop=" +
oldDesc.topologySnapshot() + ']');
}
else {
- ServiceConfiguration cfg =
((ServiceDeploymentRequest)req).configuration();
+ LazyServiceConfiguration cfg =
((ServiceDeploymentRequest)req).configuration();
if (ctx.security().enabled())
err =
checkPermissions(((ServiceDeploymentRequest)req).configuration().getName(),
SERVICE_DEPLOY);
+ if (err == null) {
+ try {
+ unmarshalNodeFilterIfNeeded(cfg);
+ }
+ catch (IgniteCheckedException e) {
+ err = new IgniteCheckedException("Failed to deploy
service, " +
+ "unable to unmarshal node filter, cfg=" + cfg,
e);
+ }
Review Comment:
Fixed
##########
modules/core/src/test/java/org/apache/ignite/internal/processors/service/IgniteServiceDeployUnknownClassTest.java:
##########
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ignite.internal.processors.service;
+
+import java.util.UUID;
+import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.failure.StopNodeFailureHandler;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.lang.IgnitePredicate;
+import org.apache.ignite.services.Service;
+import org.apache.ignite.services.ServiceConfiguration;
+import org.apache.ignite.services.ServiceDeploymentException;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.junit.Test;
+
+import static
org.apache.ignite.testframework.GridTestUtils.assertThrowsWithCause;
+
+/**
+ * Tests that not all nodes in cluster need user's service definition (only
nodes according to filter).
+ */
+public class IgniteServiceDeployUnknownClassTest extends
GridCommonAbstractTest {
Review Comment:
Fixed
##########
modules/core/src/main/java/org/apache/ignite/internal/processors/service/IgniteServiceProcessor.java:
##########
@@ -1134,7 +1136,21 @@ public <T> Collection<T> services(String name) {
Map<UUID, Integer> reassign(@NotNull IgniteUuid srvcId, @NotNull
ServiceConfiguration cfg,
@NotNull AffinityTopologyVersion topVer,
@Nullable TreeMap<UUID, Integer> oldTop) throws IgniteCheckedException
{
- Object nodeFilter = cfg.getNodeFilter();
+ IgnitePredicate<ClusterNode> nodeFilter = cfg.getNodeFilter();
+
+ if (cfg instanceof LazyServiceConfiguration) {
+ LazyServiceConfiguration srvcCfg = (LazyServiceConfiguration)cfg;
+
+ if (nodeFilter == null && srvcCfg.nodeFilterBytes() != null) {
Review Comment:
Fixed
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]