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

IGNITE-7993 Striped pool can't be disabled #4235

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -672,4 +672,9 @@ public interface GridKernalContext extends Iterable<GridComponent> {
* @return subscription processor to manage internal-only (strict node-local) subscriptions between components.
*/
public GridInternalSubscriptionProcessor internalSubscriptionProcessor();

/**
* @return {@code True} if striped executor is disabled.
*/
public boolean isStripedExecutorDisabled();
}
Original file line number Diff line number Diff line change
Expand Up @@ -999,6 +999,8 @@ protected Object readResolve() throws ObjectStreamException {

/** {@inheritDoc} */
@Override public StripedExecutor getStripedExecutorService() {
assert stripedExecSvc != null;

return stripedExecSvc;
}

Expand Down Expand Up @@ -1121,6 +1123,11 @@ void disconnected(boolean disconnected) {
return pdsFolderRslvr;
}

/** {@inheritDoc} */
@Override public boolean isStripedExecutorDisabled() {
return stripedExecSvc == null;
}

/** {@inheritDoc} */
@Override public boolean invalid() {
FailureProcessor failureProc = failure();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1510,6 +1510,9 @@ private void suggestOptimizations(IgniteConfiguration cfg) {

if (BinaryMarshaller.available() && (cfg.getMarshaller() != null && !(cfg.getMarshaller() instanceof BinaryMarshaller)))
perf.add("Use default binary marshaller (do not set 'marshaller' explicitly)");

if (cfg.getStripedPoolSize() < 1)
perf.add("Enable striped pool (set 'stripedPoolSize' to positive value in configuration)");
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1815,22 +1815,22 @@ private void start0(GridStartContext startCtx) throws IgniteCheckedException {

sysExecSvc.allowCoreThreadTimeOut(true);

validateThreadPoolSize(cfg.getStripedPoolSize(), "stripedPool");

WorkersRegistry workerRegistry = new WorkersRegistry();

stripedExecSvc = new StripedExecutor(
cfg.getStripedPoolSize(),
cfg.getIgniteInstanceName(),
"sys",
log,
new IgniteInClosure<Throwable>() {
@Override public void apply(Throwable t) {
if (grid != null)
grid.context().failure().process(new FailureContext(SYSTEM_WORKER_TERMINATION, t));
}
},
workerRegistry);
if (cfg.getStripedPoolSize() > 0) {
stripedExecSvc = new StripedExecutor(
cfg.getStripedPoolSize(),
cfg.getIgniteInstanceName(),
"sys",
log,
new IgniteInClosure<Throwable>() {
@Override public void apply(Throwable t) {
if (grid != null)
grid.context().failure().process(new FailureContext(SYSTEM_WORKER_TERMINATION, t));
}
},
workerRegistry);
}

// Note that since we use 'LinkedBlockingQueue', number of
// maximum threads has no effect.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1107,14 +1107,19 @@ private void processRegularMessage(

if (msg0.processFromNioThread())
c.run();
else
else if (!ctx.isStripedExecutorDisabled())
ctx.getStripedExecutorService().execute(-1, c);
else
ctx.getSystemExecutorService().execute(c);

return;
}

if (plc == GridIoPolicy.SYSTEM_POOL && msg.partition() != GridIoMessage.STRIPE_DISABLED_PART) {
ctx.getStripedExecutorService().execute(msg.partition(), c);
if (!ctx.isStripedExecutorDisabled())
ctx.getStripedExecutorService().execute(msg.partition(), c);
else
ctx.getSystemExecutorService().execute(c);

return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import org.apache.ignite.cluster.ClusterNode;
import org.apache.ignite.failure.FailureContext;
import org.apache.ignite.failure.FailureType;
import org.apache.ignite.internal.GridKernalContext;
import org.apache.ignite.internal.IgniteClientDisconnectedCheckedException;
import org.apache.ignite.internal.IgniteInternalFuture;
import org.apache.ignite.internal.cluster.ClusterTopologyCheckedException;
Expand Down Expand Up @@ -276,11 +277,17 @@ else if (desc.receivedFromStartVersion() != null)
}
};

if (stripe >= 0)
cctx.kernalContext().getStripedExecutorService().execute(stripe, c);
GridKernalContext ctx = cctx.kernalContext();

if (stripe >= 0) {
if (!ctx.isStripedExecutorDisabled())
ctx.getStripedExecutorService().execute(stripe, c);
else
ctx.getSystemExecutorService().execute(c);
}
else {
try {
cctx.kernalContext().pools().poolForPolicy(plc).execute(c);
ctx.pools().poolForPolicy(plc).execute(c);
}
catch (IgniteCheckedException e) {
U.error(cacheMsg.messageLogger(cctx), "Failed to get pool for policy: " + plc, e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import org.apache.ignite.IgniteException;
import org.apache.ignite.IgniteLogger;
import org.apache.ignite.cluster.ClusterNode;
import org.apache.ignite.internal.GridKernalContext;
import org.apache.ignite.internal.IgniteInternalFuture;
import org.apache.ignite.internal.NodeStoppingException;
import org.apache.ignite.internal.cluster.ClusterTopologyCheckedException;
Expand Down Expand Up @@ -3615,7 +3616,12 @@ private class DeferredUpdateTimeout implements GridTimeoutObject, Runnable {

/** {@inheritDoc} */
@Override public void onTimeout() {
ctx.kernalContext().getStripedExecutorService().execute(part, this);
GridKernalContext ctx = GridDhtAtomicCache.this.ctx.kernalContext();

if (!ctx.isStripedExecutorDisabled())
ctx.getStripedExecutorService().execute(part, this);
else
ctx.getSystemExecutorService().execute(this);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,11 @@ protected IgniteConfiguration prepareIgniteConfiguration() {
return null;
}

/** {@inheritDoc} */
@Override public boolean isStripedExecutorDisabled() {
return false;
}

/** {@inheritDoc} */
@Override public PdsFoldersResolver pdsFolderResolver() {
return new PdsFoldersResolver() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -786,8 +786,12 @@ public <T, R1, R2> ComputeTaskInternalFuture<R2> callAsync(IgniteClosure<T, R1>
public void runLocalWithThreadPolicy(IgniteThread thread, Runnable c) {
assert thread.stripe() >= 0 || thread.policy() != GridIoPolicy.UNDEFINED : thread;

if (thread.stripe() >= 0)
ctx.getStripedExecutorService().execute(thread.stripe(), c);
if (thread.stripe() >= 0) {
if (!ctx.isStripedExecutorDisabled())
ctx.getStripedExecutorService().execute(thread.stripe(), c);
else
ctx.getSystemExecutorService().execute(c);
}
else {
try {
ctx.pools().poolForPolicy(thread.policy()).execute(c);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* 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.util;

import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.processors.cache.GridCacheAbstractFailoverSelfTest;

/**
* Failover tests for cache with disabled striped thread pool.
*/
public class DisabledStripedExecutorFailoverTest extends GridCacheAbstractFailoverSelfTest {
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
return super.getConfiguration(igniteInstanceName).setStripedPoolSize(-1);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* 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.util;

import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.processors.cache.GridCacheAbstractFullApiSelfTest;

/**
* Full API cache test with disabled striped thread pool.
*/
public class DisabledStripedExecutorFullApiTest extends GridCacheAbstractFullApiSelfTest {
/** {@inheritDoc} */
@Override protected void beforeTestsStarted() throws Exception {
super.beforeTestsStarted();

// Clear caches.
afterTest();
}

/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
return super.getConfiguration(igniteInstanceName).setStripedPoolSize(-1);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
/*
Copy link
Contributor

Choose a reason for hiding this comment

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

You need to add more tests including full api and fault-tolerance tests with disabled striped pool.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added DisabledStripedExecutorFailoverTest and DisabledStripedExecutorFullApiTest. Please let me know if we need more tests.

* 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.util;

import java.util.concurrent.Callable;
import org.apache.ignite.Ignite;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.GridKernalContext;
import org.apache.ignite.internal.IgniteKernal;
import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
import org.apache.ignite.testframework.GridTestUtils;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;

/**
* Striped thread pool disabling test.
*/
public class DisabledStripedExecutorTest extends GridCommonAbstractTest {
/** */
private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);

/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(gridName);

cfg.setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(IP_FINDER));

return cfg;
}

/**
* @throws Exception If failed.
*/
public void testStripedExecutorService() throws Exception {
checkStripedExecutorService(-1);

checkStripedExecutorService(0);

checkStripedExecutorService(2);
}

/**
* Check that striped pool is disabled if size is not a positive value.
*
* @param stripedPoolSize Striped pool size.
* @throws Exception If failed.
*/
private void checkStripedExecutorService(int stripedPoolSize) throws Exception {
IgniteConfiguration cfg = getConfiguration();

cfg.setStripedPoolSize(stripedPoolSize);

try (Ignite ignite = startGrid("grid" + stripedPoolSize, cfg)) {
final GridKernalContext ctx = ((IgniteKernal)ignite).context();

if (stripedPoolSize < 1) {
assertTrue("Striped Executor should be disabled",
ctx.isStripedExecutorDisabled());

// getStripedExecutorService should throw AssertionError.
GridTestUtils.assertThrows(log, new Callable<Object>() {
@Override public Object call() {
ctx.getStripedExecutorService();

return null;
}
}, AssertionError.class, null);
}
else {
assertFalse("Striped Executor should be enabled",
ctx.isStripedExecutorDisabled());

// getStripedExecutorService should not throw AssertionError.
ctx.getStripedExecutorService();
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@
import org.apache.ignite.internal.processors.compute.IgniteComputeCustomExecutorConfigurationSelfTest;
import org.apache.ignite.internal.processors.compute.IgniteComputeCustomExecutorSelfTest;
import org.apache.ignite.internal.processors.compute.PublicThreadpoolStarvationTest;
import org.apache.ignite.internal.util.DisabledStripedExecutorFailoverTest;
import org.apache.ignite.internal.util.DisabledStripedExecutorFullApiTest;
import org.apache.ignite.internal.util.DisabledStripedExecutorTest;
import org.apache.ignite.internal.util.StripedExecutorTest;
import org.apache.ignite.p2p.GridMultinodeRedeployContinuousModeSelfTest;
import org.apache.ignite.p2p.GridMultinodeRedeployIsolatedModeSelfTest;
Expand Down Expand Up @@ -167,6 +170,9 @@ public static TestSuite suite() throws Exception {
suite.addTestSuite(IgniteRoundRobinErrorAfterClientReconnectTest.class);
suite.addTestSuite(PublicThreadpoolStarvationTest.class);
suite.addTestSuite(StripedExecutorTest.class);
suite.addTestSuite(DisabledStripedExecutorTest.class);
suite.addTestSuite(DisabledStripedExecutorFailoverTest.class);
suite.addTestSuite(DisabledStripedExecutorFullApiTest.class);
suite.addTestSuite(GridJobServicesAddNodeTest.class);

suite.addTestSuite(IgniteComputeCustomExecutorConfigurationSelfTest.class);
Expand Down