You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by sb...@apache.org on 2016/11/11 14:19:00 UTC
[11/17] ignite git commit: IGNITE-4053: Moved task error output from
console to logger. This closes #1160.
IGNITE-4053: Moved task error output from console to logger. This closes #1160.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/8bb8bdda
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/8bb8bdda
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/8bb8bdda
Branch: refs/heads/ignite-4154-opt2
Commit: 8bb8bdda2e846dcc92a2fd449e64d7594b2700ed
Parents: a70f0ba
Author: tledkov-gridgain <tl...@gridgain.com>
Authored: Fri Nov 11 15:01:14 2016 +0300
Committer: devozerov <vo...@gridgain.com>
Committed: Fri Nov 11 15:01:14 2016 +0300
----------------------------------------------------------------------
.../internal/ComputeTaskInternalFuture.java | 11 +++
.../internal/util/future/GridFutureAdapter.java | 12 ++-
...ComputeJobExecutionErrorToLogManualTest.java | 88 ++++++++++++++++++++
3 files changed, 109 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/8bb8bdda/modules/core/src/main/java/org/apache/ignite/internal/ComputeTaskInternalFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/ComputeTaskInternalFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/ComputeTaskInternalFuture.java
index d511480..d6c54d7 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/ComputeTaskInternalFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/ComputeTaskInternalFuture.java
@@ -24,6 +24,7 @@ import java.util.Map;
import java.util.UUID;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteException;
+import org.apache.ignite.IgniteLogger;
import org.apache.ignite.compute.ComputeJobSibling;
import org.apache.ignite.compute.ComputeTask;
import org.apache.ignite.compute.ComputeTaskFuture;
@@ -59,6 +60,9 @@ public class ComputeTaskInternalFuture<R> extends GridFutureAdapter<R> {
@GridToStringExclude
private ComputeFuture<R> userFut;
+ /** */
+ private transient IgniteLogger log;
+
/**
* @param ses Task session instance.
* @param ctx Kernal context.
@@ -71,6 +75,8 @@ public class ComputeTaskInternalFuture<R> extends GridFutureAdapter<R> {
this.ctx = ctx;
userFut = new ComputeFuture<>(this);
+
+ log = ctx.log(ComputeTaskInternalFuture.class);
}
/**
@@ -247,6 +253,11 @@ public class ComputeTaskInternalFuture<R> extends GridFutureAdapter<R> {
return S.toString(ComputeTaskInternalFuture.class, this, "super", super.toString());
}
+ /** {@inheritDoc} */
+ @Override public IgniteLogger logger() {
+ return log;
+ }
+
/**
*
*/
http://git-wip-us.apache.org/repos/asf/ignite/blob/8bb8bdda/modules/core/src/main/java/org/apache/ignite/internal/util/future/GridFutureAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/future/GridFutureAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/util/future/GridFutureAdapter.java
index ea7a202..2cd534e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/future/GridFutureAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/future/GridFutureAdapter.java
@@ -21,6 +21,7 @@ import java.util.Arrays;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.AbstractQueuedSynchronizer;
import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.IgniteLogger;
import org.apache.ignite.internal.IgniteFutureCancelledCheckedException;
import org.apache.ignite.internal.IgniteFutureTimeoutCheckedException;
import org.apache.ignite.internal.IgniteInternalFuture;
@@ -263,11 +264,11 @@ public class GridFutureAdapter<R> extends AbstractQueuedSynchronizer implements
lsnr.apply(this);
}
catch (IllegalStateException e) {
- U.error(null, "Failed to notify listener (is grid stopped?) [fut=" + this +
+ U.error(logger(), "Failed to notify listener (is grid stopped?) [fut=" + this +
", lsnr=" + lsnr + ", err=" + e.getMessage() + ']', e);
}
catch (RuntimeException | Error e) {
- U.error(null, "Failed to notify listener: " + lsnr, e);
+ U.error(logger(), "Failed to notify listener: " + lsnr, e);
throw e;
}
@@ -413,6 +414,13 @@ public class GridFutureAdapter<R> extends AbstractQueuedSynchronizer implements
return s == INIT ? "INIT" : s == CANCELLED ? "CANCELLED" : "DONE";
}
+ /**
+ * @return Logger instance.
+ */
+ @Nullable public IgniteLogger logger() {
+ return null;
+ }
+
/** {@inheritDoc} */
@Override public String toString() {
return S.toString(GridFutureAdapter.class, this, "state", state());
http://git-wip-us.apache.org/repos/asf/ignite/blob/8bb8bdda/modules/core/src/test/java/org/apache/ignite/internal/processors/compute/GridComputeJobExecutionErrorToLogManualTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/compute/GridComputeJobExecutionErrorToLogManualTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/compute/GridComputeJobExecutionErrorToLogManualTest.java
new file mode 100644
index 0000000..691bc9f
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/compute/GridComputeJobExecutionErrorToLogManualTest.java
@@ -0,0 +1,88 @@
+/*
+ * 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.compute;
+
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCompute;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.lang.IgniteFuture;
+import org.apache.ignite.lang.IgniteInClosure;
+import org.apache.ignite.lang.IgniteRunnable;
+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.junits.common.GridCommonAbstractTest;
+
+/**
+ * Manual test to reproduce IGNITE-4053
+ */
+public class GridComputeJobExecutionErrorToLogManualTest extends GridCommonAbstractTest {
+ /** */
+ private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
+
+ /** */
+ private static final int GRID_CNT = 2;
+
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+ TcpDiscoverySpi disco = new TcpDiscoverySpi();
+
+ disco.setIpFinder(ipFinder);
+
+ cfg.setDiscoverySpi(disco);
+
+ return cfg;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void beforeTestsStarted() throws Exception {
+ startGridsMultiThreaded(GRID_CNT, true);
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTestsStopped() throws Exception {
+ stopAllGrids();
+ }
+
+ /**
+ * @throws Exception If fails.
+ */
+ public void testRuntimeException() throws Exception {
+ Ignite ignite = grid(0);
+
+ IgniteCompute async = ignite.compute().withAsync();
+ async.run(new IgniteRunnable() {
+ @Override public void run() {
+ try {
+ Thread.sleep(500);
+ }
+ catch (InterruptedException e) {
+ // No-op.
+ }
+ }
+ });
+
+ async.future().listen(new IgniteInClosure<IgniteFuture<Object>>() {
+ @Override public void apply(IgniteFuture<Object> future) {
+ throw new RuntimeException();
+ }
+ });
+ }
+}
\ No newline at end of file