Repository: incubator-ignite Updated Branches: refs/heads/ignite-194 5d27bda8b -> cc7aa6225
#ignite-128: Remove LOG command. Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/c4e2bd4c Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/c4e2bd4c Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/c4e2bd4c Branch: refs/heads/ignite-194 Commit: c4e2bd4c92cc12620161adf85f21cf35fefa5be2 Parents: 1b33438 Author: vozerov-gridgain <voze...@gridgain.com> Authored: Wed Feb 4 13:06:34 2015 +0300 Committer: vozerov-gridgain <voze...@gridgain.com> Committed: Wed Feb 4 13:06:34 2015 +0300 ---------------------------------------------------------------------- .../ClientAbstractMultiNodeSelfTest.java | 6 - .../integration/ClientAbstractSelfTest.java | 123 -------- .../rest/RestBinaryProtocolSelfTest.java | 46 --- .../processors/rest/TestBinaryClient.java | 16 - .../ClientConnectionConfiguration.java | 27 -- .../org/apache/ignite/internal/IgnitionEx.java | 1 - .../internal/client/GridClientCompute.java | 57 ---- .../client/impl/GridClientComputeImpl.java | 30 -- .../impl/connection/GridClientConnection.java | 14 - .../connection/GridClientNioTcpConnection.java | 12 - .../processors/rest/GridRestProcessor.java | 3 - .../client/message/GridClientLogRequest.java | 141 --------- .../handlers/log/GridLogCommandHandler.java | 306 ------------------- .../processors/rest/handlers/log/package.html | 23 -- .../protocols/tcp/GridTcpRestNioListener.java | 13 - .../visor/node/VisorRestConfiguration.java | 1 - 16 files changed, 819 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c4e2bd4c/modules/clients/src/test/java/org/apache/ignite/internal/client/integration/ClientAbstractMultiNodeSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/client/integration/ClientAbstractMultiNodeSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/client/integration/ClientAbstractMultiNodeSelfTest.java index a1beae0..af69a08 100644 --- a/modules/clients/src/test/java/org/apache/ignite/internal/client/integration/ClientAbstractMultiNodeSelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/internal/client/integration/ClientAbstractMultiNodeSelfTest.java @@ -306,12 +306,6 @@ public abstract class ClientAbstractMultiNodeSelfTest extends GridCommonAbstract GridTestUtils.assertThrows(log(), new Callable<Object>() { @Override public Object call() throws Exception { - return dflt.projection(noneFilter).log(-1, -1); - } - }, GridServerUnreachableException.class, null); - - GridTestUtils.assertThrows(log(), new Callable<Object>() { - @Override public Object call() throws Exception { return singleNodePrj.projection(second); } }, GridClientException.class, null); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c4e2bd4c/modules/clients/src/test/java/org/apache/ignite/internal/client/integration/ClientAbstractSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/client/integration/ClientAbstractSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/client/integration/ClientAbstractSelfTest.java index fff8c9e..9787948 100644 --- a/modules/clients/src/test/java/org/apache/ignite/internal/client/integration/ClientAbstractSelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/internal/client/integration/ClientAbstractSelfTest.java @@ -27,7 +27,6 @@ import org.apache.ignite.configuration.*; import org.apache.ignite.internal.client.*; import org.apache.ignite.internal.client.ssl.*; import org.apache.ignite.internal.util.typedef.*; -import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.lang.*; import org.apache.ignite.spi.discovery.tcp.*; import org.apache.ignite.spi.discovery.tcp.ipfinder.*; @@ -37,7 +36,6 @@ import org.apache.ignite.testframework.junits.common.*; import org.jetbrains.annotations.*; import javax.cache.configuration.*; -import java.io.*; import java.util.*; import java.util.concurrent.*; import java.util.concurrent.atomic.*; @@ -197,10 +195,6 @@ public abstract class ClientAbstractSelfTest extends GridCommonAbstractTest { clientCfg.setRestTcpPort(BINARY_PORT); - clientCfg.setRestAccessibleFolders( - U.getGridGainHome() + "/work/log", - U.resolveGridGainPath("modules/core/src/test/resources/log").getAbsolutePath()); - if (useSsl()) { clientCfg.setRestTcpSslEnabled(true); @@ -348,8 +342,6 @@ public abstract class ClientAbstractSelfTest extends GridCommonAbstractTest { futs.put("refreshById", compute.refreshNodeAsync(UUID.randomUUID(), true, true)); futs.put("refreshByIP", compute.refreshNodeAsync("nodeIP", true, true)); futs.put("refreshTop", compute.refreshTopologyAsync(true, true)); - futs.put("log", compute.logAsync(-1, -1)); - futs.put("logForPath", compute.logAsync("path/to/log", -1, -1)); GridClientFactory.stop(client.id(), false); @@ -1298,121 +1290,6 @@ public abstract class ClientAbstractSelfTest extends GridCommonAbstractTest { } /** - * @throws Exception If failed. - */ - @SuppressWarnings("ThrowableResultOfMethodCallIgnored") - public void testLog() throws Exception { - final GridClientCompute compute = client.compute(); - - /* Usually this log file is created by log4j, but some times it doesn't exists. */ - new File(U.getGridGainHome(), "work/log/gridgain.log").createNewFile(); - - List<String> log = compute.log(6, 7); - assertNotNull(log); - - log = compute.log(-7, -6); - assertNotNull(log); - - log = compute.log(-6, -7); - assertNotNull(log); - assertTrue(log.isEmpty()); - - String path = "work/log/gridgain.log." + System.currentTimeMillis(); - - File file = new File(U.getGridGainHome(), path); - - assert !file.exists(); - - FileWriter writer = new FileWriter(file); - - String sep = System.getProperty("line.separator"); - - writer.write("Line 1" + sep); - writer.write(sep); - writer.write("Line 2" + sep); - writer.write("Line 3" + sep); - - writer.flush(); - writer.close(); - - log = compute.log(path, -1, -1); - assertNotNull(log); - assertEquals(1, log.size()); - assertEquals("Line 3", log.get(0)); - - // Indexing from 0. - log = compute.log(path, 2, 3); - assertNotNull(log); - assertEquals(2, log.size()); - assertEquals("Line 2", log.get(0)); - assertEquals("Line 3", log.get(1)); - - // Backward reading. - log = compute.log(path, -3, -1); - assertNotNull(log); - assertEquals(3, log.size()); - assertEquals("", log.get(0)); - assertEquals("Line 2", log.get(1)); - assertEquals("Line 3", log.get(2)); - - log = compute.log(path, -4, -3); - assertNotNull(log); - assertEquals(2, log.size()); - assertEquals("Line 1", log.get(0)); - assertEquals("", log.get(1)); - - log = compute.log(path, -5, -8); - assertNotNull(log); - assertEquals(0, log.size()); - - assert file.delete(); - - log = compute.log(TEST_LOG_PATH, -9, -5); - assertNotNull(log); - assertEquals(5, log.size()); - - log = compute.log(TEST_LOG_PATH, -1, -1); - assertNotNull(log); - assertEquals(1, log.size()); - assertEquals("[14:23:34,336][INFO ][main][GridTaskContinuousMapperSelfTest] >>> Stopping test: " + - "testContinuousMapperNegative in 2633 ms <<<", - log.get(0)); - - log = compute.log(TEST_LOG_PATH, -13641, -13640); - assertNotNull(log); - assertEquals(1, log.size()); - assertEquals("[14:14:22,515][INFO ][main][GridListenActorSelfTest] ", log.get(0)); - - assertThrows( - log(), - new Callable<Object>() { - @Override public Object call() throws Exception { - compute.log("wrong/path", -1, -1); - - return null; - } - }, - GridClientException.class, - null - ); - - assertThrows( - log(), - new Callable<Object>() { - @Override public Object call() throws Exception { - new File(U.getGridGainHome(), "work/security.log").createNewFile(); - - compute.log("work/log/../security.log", -1, -1); - - return null; - } - }, - GridClientException.class, - null - ); - } - - /** * Test if all user objects passed interception. * * @throws Exception If failed. http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c4e2bd4c/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/RestBinaryProtocolSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/RestBinaryProtocolSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/RestBinaryProtocolSelfTest.java index d9c7a26..b4d100d 100644 --- a/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/RestBinaryProtocolSelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/RestBinaryProtocolSelfTest.java @@ -24,7 +24,6 @@ import org.apache.ignite.configuration.*; import org.apache.ignite.internal.*; import org.apache.ignite.internal.processors.rest.client.message.*; import org.apache.ignite.internal.util.typedef.*; -import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.spi.discovery.tcp.*; import org.apache.ignite.spi.discovery.tcp.ipfinder.*; import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*; @@ -32,7 +31,6 @@ import org.apache.ignite.testframework.*; import org.apache.ignite.testframework.junits.common.*; import org.jetbrains.annotations.*; -import java.io.*; import java.lang.reflect.*; import java.util.*; import java.util.concurrent.*; @@ -550,50 +548,6 @@ public class RestBinaryProtocolSelfTest extends GridCommonAbstractTest { } /** - * @throws Exception If failed. - */ - public void testLog() throws Exception { - String path = "work/log/ignite.log." + System.currentTimeMillis(); - - File file = new File(U.getGridGainHome(), path); - - assert !file.exists(); - - FileWriter writer = new FileWriter(file); - - String sep = System.getProperty("line.separator"); - - writer.write("Line 1" + sep); - writer.write(sep); - writer.write("Line 2" + sep); - writer.write("Line 3" + sep); - - writer.flush(); - writer.close(); - - List<String> log = client.log(path, 0, 10); - - assertNotNull(log); - assertEquals(4, log.size()); - - file.delete(); - - GridTestUtils.assertThrows( - log(), - new Callable<Object>() { - @Override - public Object call() throws Exception { - client.log("wrong/path", 0, 10); - - return null; - } - }, - IgniteCheckedException.class, - null - ); - } - - /** * Test task. */ private static class TestTask extends ComputeTaskSplitAdapter<List<Object>, Integer> { http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c4e2bd4c/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/TestBinaryClient.java ---------------------------------------------------------------------- diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/TestBinaryClient.java b/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/TestBinaryClient.java index 8b13eac..ae09467 100644 --- a/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/TestBinaryClient.java +++ b/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/TestBinaryClient.java @@ -573,22 +573,6 @@ final class TestBinaryClient { } /** - * @param path Log file path. - * @return Log file contents. - * @throws IgniteCheckedException In case of error. - */ - public List<String> log(@Nullable String path, int from, int to) throws IgniteCheckedException { - GridClientLogRequest msg = new GridClientLogRequest(); - - msg.requestId(idCntr.getAndIncrement()); - msg.path(path); - msg.from(from); - msg.to(to); - - return makeRequest(msg).getObject(); - } - - /** * Response data. */ private static class Response { http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c4e2bd4c/modules/core/src/main/java/org/apache/ignite/configuration/ClientConnectionConfiguration.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/ClientConnectionConfiguration.java b/modules/core/src/main/java/org/apache/ignite/configuration/ClientConnectionConfiguration.java index 785df6b..bf29ff7 100644 --- a/modules/core/src/main/java/org/apache/ignite/configuration/ClientConnectionConfiguration.java +++ b/modules/core/src/main/java/org/apache/ignite/configuration/ClientConnectionConfiguration.java @@ -100,9 +100,6 @@ public class ClientConnectionConfiguration { /** Port range */ private int restPortRange = DFLT_REST_PORT_RANGE; - /** Folders accessible by REST. */ - private String[] restAccessibleFolders; - /** REST requests executor service. */ private ExecutorService restExecSvc; @@ -129,7 +126,6 @@ public class ClientConnectionConfiguration { assert cfg != null; clientMsgInterceptor = cfg.getClientMessageInterceptor(); - restAccessibleFolders = cfg.getRestAccessibleFolders(); restExecSvc = cfg.getRestExecutorService(); restSvcShutdown = cfg.isRestExecutorServiceShutdown(); restIdleTimeout = cfg.getRestIdleTimeout(); @@ -470,29 +466,6 @@ public class ClientConnectionConfiguration { } /** - * Gets list of folders that are accessible for log reading command. When remote client requests - * a log file, file path is checked against this list. If requested file is not located in any - * sub-folder of these folders, request is not processed. - * <p> - * By default, list consists of a single {@code IGNITE_HOME} folder. If {@code IGNITE_HOME} - * could not be detected and property is not specified, no restrictions applied. - * - * @return Array of folders that are allowed be read by remote clients. - */ - public String[] getRestAccessibleFolders() { - return restAccessibleFolders; - } - - /** - * Sets array of folders accessible by REST processor for log reading command. - * - * @param restAccessibleFolders Array of folder paths. - */ - public void setRestAccessibleFolders(String... restAccessibleFolders) { - this.restAccessibleFolders = restAccessibleFolders; - } - - /** * Should return an instance of fully configured thread pool to be used for * processing of client messages (REST requests). * <p> http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c4e2bd4c/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java b/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java index 7380e15..a45c93d 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java @@ -1437,7 +1437,6 @@ public class IgnitionEx { clientCfg = new ClientConnectionConfiguration(); clientCfg.setClientMessageInterceptor(cfg.getClientMessageInterceptor()); - clientCfg.setRestAccessibleFolders(cfg.getRestAccessibleFolders()); clientCfg.setRestExecutorService(cfg.getRestExecutorService()); clientCfg.setRestExecutorServiceShutdown(cfg.getRestExecutorServiceShutdown()); clientCfg.setRestIdleTimeout(cfg.getRestIdleTimeout()); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c4e2bd4c/modules/core/src/main/java/org/apache/ignite/internal/client/GridClientCompute.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/client/GridClientCompute.java b/modules/core/src/main/java/org/apache/ignite/internal/client/GridClientCompute.java index 3835a8d..5dc8a9f 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/client/GridClientCompute.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/client/GridClientCompute.java @@ -413,63 +413,6 @@ public interface GridClientCompute { public GridClientFuture<List<GridClientNode>> refreshTopologyAsync(boolean includeAttrs, boolean includeMetrics); /** - * Gets contents of default log file ({@code IGNITE_HOME/work/log/gridgain.log}). - * Note that backward reading (with negative line indexes) supported for only 8-bit character encodings. - * - * @param lineFrom Index of line from which log is get, inclusive. Negative values mean line numbers - * from the end of the file. - * @param lineTo Index of line to which log is get, inclusive. Negative values mean line numbers - * from the end of the file. - * @return Log contents. - * @throws GridClientException In case of error. - * @throws GridServerUnreachableException If none of the servers can be reached. - * @throws GridClientClosedException If client was closed manually. - */ - public List<String> log(int lineFrom, int lineTo) throws GridClientException; - - /** - * Asynchronously gets contents of default log file - * ({@code IGNITE_HOME/work/log/gridgain.log}). - * Note that backward reading (with negative line indexes) supported for only 8-bit character encodings. - * - * @param lineFrom Index of line from which log is get, inclusive. Negative values mean line numbers - * from the end of the file. - * @param lineTo Index of line to which log is get, inclusive. Negative values mean line numbers - * from the end of the file. - * @return Future for this operation. - */ - public GridClientFuture<List<String>> logAsync(int lineFrom, int lineTo); - - /** - * Gets contents of custom log file, i.e. log file in a non-default location. - * Note that backward reading (with negative line indexes) supported for only 8-bit character encodings. - * - * @param path Log file path. Can be absolute or relative to IGNITE_HOME. - * @param lineFrom Index of line from which log is get, inclusive. Negative values mean line numbers - * from the end of the file. - * @param lineTo Index of line to which log is get, inclusive. Negative values mean line numbers - * from the end of the file. - * @return Log contents. - * @throws GridClientException In case of error. - * @throws GridServerUnreachableException If none of the servers can be reached. - * @throws GridClientClosedException If client was closed manually. - */ - public List<String> log(String path, int lineFrom, int lineTo) throws GridClientException; - - /** - * Asynchronously gets contents of custom log file. - * Note that backward reading (with negative line indexes) supported for only 8-bit character encodings. - * - * @param path Log file path. Can be absolute or relative to IGNITE_HOME. - * @param lineFrom Index of line from which log is get, inclusive. Negative values mean line numbers - * from the end of the file. - * @param lineTo Index of line to which log is get, inclusive. Negative values mean line numbers - * from the end of the file. - * @return Future. - */ - public GridClientFuture<List<String>> logAsync(String path, int lineFrom, int lineTo); - - /** * Sets keep portables flag for the next task execution in the current thread. */ public GridClientCompute withKeepPortables(); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c4e2bd4c/modules/core/src/main/java/org/apache/ignite/internal/client/impl/GridClientComputeImpl.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/client/impl/GridClientComputeImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/client/impl/GridClientComputeImpl.java index d61a92b..e86aa42 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/client/impl/GridClientComputeImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/client/impl/GridClientComputeImpl.java @@ -246,36 +246,6 @@ class GridClientComputeImpl extends GridClientAbstractProjection<GridClientCompu } /** {@inheritDoc} */ - @Override public List<String> log(int lineFrom, int lineTo) throws GridClientException { - return logAsync(lineFrom, lineTo).get(); - } - - /** {@inheritDoc} */ - @Override public GridClientFuture<List<String>> logAsync(final int lineFrom, final int lineTo) { - return withReconnectHandling(new ClientProjectionClosure<List<String>>() { - @Override public GridClientFuture<List<String>> apply(GridClientConnection conn, UUID destNodeId) - throws GridClientConnectionResetException, GridClientClosedException { - return conn.log(null, lineFrom, lineTo, destNodeId); - } - }); - } - - /** {@inheritDoc} */ - @Override public List<String> log(String path, int lineFrom, int lineTo) throws GridClientException { - return logAsync(path, lineFrom, lineTo).get(); - } - - /** {@inheritDoc} */ - @Override public GridClientFuture<List<String>> logAsync(final String path, final int lineFrom, final int lineTo) { - return withReconnectHandling(new ClientProjectionClosure<List<String>>() { - @Override public GridClientFuture<List<String>> apply(GridClientConnection conn, UUID destNodeId) - throws GridClientConnectionResetException, GridClientClosedException { - return conn.log(path, lineFrom, lineTo, destNodeId); - } - }); - } - - /** {@inheritDoc} */ @Override public GridClientCompute withKeepPortables() { KEEP_PORTABLES.set(true); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c4e2bd4c/modules/core/src/main/java/org/apache/ignite/internal/client/impl/connection/GridClientConnection.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/client/impl/connection/GridClientConnection.java b/modules/core/src/main/java/org/apache/ignite/internal/client/impl/connection/GridClientConnection.java index 19d0bd6..c643e0a 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/client/impl/connection/GridClientConnection.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/client/impl/connection/GridClientConnection.java @@ -362,20 +362,6 @@ public abstract class GridClientConnection { @Nullable UUID destNodeId) throws GridClientConnectionResetException, GridClientClosedException; /** - * Gets log entries. - * - * @param path Log file path. If {@code null}, then default path will be used. - * @param fromLine Index of start line that should be retrieved. - * @param toLine Index of end line that should be retrieved. - * @param destNodeId Destination node ID. - * @return Log file contents. - * @throws GridClientConnectionResetException In case of error. - * @throws GridClientClosedException If client was manually closed before request was sent over network. - */ - public abstract GridClientFuture<List<String>> log(@Nullable String path, int fromLine, int toLine, UUID destNodeId) - throws GridClientConnectionResetException, GridClientClosedException; - - /** * Forwards a message in raw form to the connected node. This method supposed to be used only inside router. * The exact types of acceptable arguments and return values depend on connection implementation. * http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c4e2bd4c/modules/core/src/main/java/org/apache/ignite/internal/client/impl/connection/GridClientNioTcpConnection.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/client/impl/connection/GridClientNioTcpConnection.java b/modules/core/src/main/java/org/apache/ignite/internal/client/impl/connection/GridClientNioTcpConnection.java index 156df6d..1882663 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/client/impl/connection/GridClientNioTcpConnection.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/client/impl/connection/GridClientNioTcpConnection.java @@ -927,18 +927,6 @@ public class GridClientNioTcpConnection extends GridClientConnection { } /** {@inheritDoc} */ - @Override public GridClientFuture<List<String>> log(String path, int fromLine, int toLine, UUID destNodeId) - throws GridClientConnectionResetException, GridClientClosedException { - GridClientLogRequest msg = new GridClientLogRequest(); - - msg.from(fromLine); - msg.to(toLine); - msg.path(path); - - return makeRequest(msg, destNodeId); - } - - /** {@inheritDoc} */ @Override public GridClientFutureAdapter<GridRouterRequest> forwardMessage(Object msg) throws GridClientException { assert msg instanceof GridRouterRequest; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c4e2bd4c/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestProcessor.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestProcessor.java index e024435..215805f 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestProcessor.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestProcessor.java @@ -26,7 +26,6 @@ import org.apache.ignite.internal.processors.*; import org.apache.ignite.internal.processors.rest.client.message.*; import org.apache.ignite.internal.processors.rest.handlers.*; import org.apache.ignite.internal.processors.rest.handlers.cache.*; -import org.apache.ignite.internal.processors.rest.handlers.log.*; import org.apache.ignite.internal.processors.rest.handlers.metadata.*; import org.apache.ignite.internal.processors.rest.handlers.task.*; import org.apache.ignite.internal.processors.rest.handlers.top.*; @@ -253,7 +252,6 @@ public class GridRestProcessor extends GridProcessorAdapter { addHandler(new GridTaskCommandHandler(ctx)); addHandler(new GridTopologyCommandHandler(ctx)); addHandler(new GridVersionCommandHandler(ctx)); - addHandler(new GridLogCommandHandler(ctx)); addHandler(new GridPortableMetadataHandler(ctx)); // Start protocols. @@ -592,7 +590,6 @@ public class GridRestProcessor extends GridProcessorAdapter { case TOPOLOGY: case NODE: case VERSION: - case LOG: case NOOP: case QUIT: case GET_PORTABLE_METADATA: http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c4e2bd4c/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientLogRequest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientLogRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientLogRequest.java deleted file mode 100644 index 2bd8735..0000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientLogRequest.java +++ /dev/null @@ -1,141 +0,0 @@ -/* - * 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.rest.client.message; - -import org.apache.ignite.internal.util.typedef.internal.*; -import org.apache.ignite.portables.*; - -import java.io.*; - -/** - * Request for a log file. - */ -public class GridClientLogRequest extends GridClientAbstractMessage { - /** */ - private static final long serialVersionUID = 0L; - - /** Task name. */ - private String path; - - /** From line, inclusive, indexing from 0. */ - private int from = -1; - - /** To line, inclusive, indexing from 0, can exceed count of lines in log. */ - private int to = -1; - - /** - * @return Path to log file. - */ - public String path() { - return path; - } - - /** - * @param path Path to log file. - */ - public void path(String path) { - this.path = path; - } - - /** - * @return From line, inclusive, indexing from 0. - */ - public int from() { - return from; - } - - /** - * @param from From line, inclusive, indexing from 0. - */ - public void from(int from) { - this.from = from; - } - - /** - * @return To line, inclusive, indexing from 0. - */ - public int to() { - return to; - } - - /** - * @param to To line, inclusive, indexing from 0. - */ - public void to(int to) { - this.to = to; - } - - /** {@inheritDoc} */ - @Override public void writePortable(PortableWriter writer) throws PortableException { - super.writePortable(writer); - - PortableRawWriter raw = writer.rawWriter(); - - raw.writeString(path); - raw.writeInt(from); - raw.writeInt(to); - } - - /** {@inheritDoc} */ - @Override public void readPortable(PortableReader reader) throws PortableException { - super.readPortable(reader); - - PortableRawReader raw = reader.rawReader(); - - path = raw.readString(); - from = raw.readInt(); - to = raw.readInt(); - } - - /** {@inheritDoc} */ - @Override public void writeExternal(ObjectOutput out) throws IOException { - super.writeExternal(out); - - U.writeString(out, path); - - out.writeInt(from); - out.writeInt(to); - } - - /** {@inheritDoc} */ - @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { - super.readExternal(in); - - path = U.readString(in); - - from = in.readInt(); - to = in.readInt(); - } - - /** {@inheritDoc} */ - @Override public String toString() { - StringBuilder b = new StringBuilder(). - append("GridClientLogRequest [path="). - append(path); - - if (from != -1) - b.append(", from=").append(from); - - if (to != -1) - b.append(", to=").append(to); - - b.append(']'); - - return b.toString(); - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c4e2bd4c/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/log/GridLogCommandHandler.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/log/GridLogCommandHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/log/GridLogCommandHandler.java deleted file mode 100644 index 0786ca7..0000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/log/GridLogCommandHandler.java +++ /dev/null @@ -1,306 +0,0 @@ -/* - * 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.rest.handlers.log; - -import org.apache.ignite.*; -import org.apache.ignite.internal.*; -import org.apache.ignite.internal.processors.rest.*; -import org.apache.ignite.internal.processors.rest.handlers.*; -import org.apache.ignite.internal.processors.rest.request.*; -import org.apache.ignite.internal.util.future.*; -import org.apache.ignite.internal.util.io.*; -import org.apache.ignite.internal.util.typedef.*; -import org.apache.ignite.internal.util.typedef.internal.*; - -import java.io.*; -import java.net.*; -import java.util.*; - -import static org.apache.ignite.internal.processors.rest.GridRestCommand.*; - -/** - * Handler for {@link GridRestCommand#LOG} command. - */ -public class GridLogCommandHandler extends GridRestCommandHandlerAdapter { - /** Supported commands. */ - private static final Collection<GridRestCommand> SUPPORTED_COMMANDS = U.sealList(LOG); - - /** Default log path. */ - private static final String DFLT_PATH = "work/log/ignite.log"; - - /** Approximate line length. */ - private static final int LINE_LENGTH = 120; - - /** Folders accessible for log reading. */ - private List<File> accessibleFolders; - - /** @param ctx Context. */ - public GridLogCommandHandler(GridKernalContext ctx) { - super(ctx); - - assert ctx.config().getClientConnectionConfiguration() != null; - - String[] accessiblePaths = ctx.config().getClientConnectionConfiguration().getRestAccessibleFolders(); - - if (accessiblePaths == null) { - String ggHome = U.getGridGainHome(); - - if (ggHome != null) - accessiblePaths = new String[] {ggHome}; - } - - if (accessiblePaths != null) { - accessibleFolders = new ArrayList<>(); - - for (String accessiblePath : accessiblePaths) - accessibleFolders.add(new File(accessiblePath)); - } - else if (log.isDebugEnabled()) - log.debug("Neither restAccessibleFolders nor IGNITE_HOME properties are not set, will not restrict " + - "log files access"); - } - - /** {@inheritDoc} */ - @Override public Collection<GridRestCommand> supportedCommands() { - return SUPPORTED_COMMANDS; - } - - /** {@inheritDoc} */ - @Override public IgniteInternalFuture<GridRestResponse> handleAsync(GridRestRequest req) { - assert req instanceof GridRestLogRequest : "Invalid command for topology handler: " + req; - - assert SUPPORTED_COMMANDS.contains(req.command()); - - GridRestLogRequest req0 = (GridRestLogRequest) req; - - String path = req0.path(); - - int from = req0.from(); - int to = req0.to(); - - if (path == null) - path = DFLT_PATH; - - try { - return new GridFinishedFuture<>(ctx, new GridRestResponse(readLog(path, from, to))); - } - catch (IgniteCheckedException e) { - return new GridFinishedFuture<>(ctx, e); - } - catch (IOException e) { - return new GridFinishedFuture<>(ctx, e); - } - } - - /** - * Reads log. - * - * @param path Path where read log located. - * @param from Number of line to start from. - * @param to Number tof line to finish on. - * @return List of read lines. - * @throws IgniteCheckedException If argumets are illegal. - * @throws IOException If file couldn't be accessed or read failed. - */ - private List<String> readLog(String path, int from, int to) throws IgniteCheckedException, IOException { - URL url = U.resolveGridGainUrl(path); - - if (url == null) - throw new IgniteCheckedException("Log file not found: " + path); - - if (!isAccessible(url)) - throw new IgniteCheckedException("File is not accessible through REST" + - " (check restAccessibleFolders configuration property): " + path); - - if (from >= 0 && to >= 0) - return readLinesForward(url, from, to); - else if (from < 0 && to < 0) - return readLinesBackward(url, from, to); - else - throw new IgniteCheckedException( - "Illegal arguments (both should be positive or negative) [from=" + from + ", to=" + to + ']'); - } - - /** - * Read lines from log backwards. - * - * @param url URL of the log. - * @param from Number of line to start from. Should be negative, representing number of line from the end. - * @param to Number tof line to finish on. Should be negative, representing number of line from the end. - * @return List of read lines. - * @throws IgniteCheckedException If arguments are illegal. - * @throws IOException If file couldn't be accessed or read failed. - */ - @SuppressWarnings("TooBroadScope") - private List<String> readLinesBackward(URL url, final int from, final int to) throws IgniteCheckedException, IOException { - File file = new File(url.getFile()); - - if (!file.exists() || !file.isFile()) - throw new IgniteCheckedException("File doesn't exists: " + url); - - int linesToRead = to - from + 1; - int linesRead = 0; - - if (linesToRead <= 0) - return Collections.emptyList(); - - LinkedList<String> lines = new LinkedList<>(); - - RandomAccessFile raf = null; - - try { - raf = new RandomAccessFile(file, "r"); - - byte[] buf = new byte[Math.min(16 * 1024, linesToRead * LINE_LENGTH)]; - - long endPos = raf.length(); - - String lastLineEnding = null; - - do { - long startPos = endPos - buf.length; - - if (startPos < 0) - startPos = 0; - - raf.seek(startPos); - - // Limiting number of bytes read to protect from line duplication near file start, - int bytesRead = raf.read(buf, 0, (int)(endPos - startPos)); - - Scanner rdr = new Scanner(new GridByteArrayInputStream(buf, 0, bytesRead)); - - // Read lines into temporary, forward ordered collection. - List<String> tmpLines = new LinkedList<>(); - - boolean firstLine = true; - - // Temporary variable to keep a new lastLineEnding value - // while old is still required. - String fst = null; - - while (rdr.hasNextLine()) { - String line = rdr.nextLine(); - - // Skip the first line as it could be incomplete. - if (firstLine) { - firstLine = false; - - // If we started from the beginning add it. - if (startPos > 0) - fst = lastLineEnding != null && !rdr.hasNextLine() ? line + lastLineEnding : line; - else - tmpLines.add(lastLineEnding != null ? line + lastLineEnding : line); - } - else if (rdr.hasNextLine()) - // If it's a last line in buffer add previously read part. - tmpLines.add(line); - else - tmpLines.add(lastLineEnding != null ? line + lastLineEnding : line); - } - - lastLineEnding = fst; - - // Limit next read to end of the first line. - endPos = startPos; - - // Save lines, if they are requested, in backward order into result collection. - for (ListIterator<String> it = tmpLines.listIterator(tmpLines.size()); it.hasPrevious(); ) { - linesRead++; - - String prev = it.previous(); - - if ((linesRead >= -to) && (linesRead <= -from)) - lines.addFirst(prev); - } - } while (linesRead < -from && endPos > 0); - } - finally { - U.close(raf, log); - } - - return lines; - } - - /** - * Reads log forward, using {@link Reader} API. - * - * @param url URL of the log file. - * @param from Number of line to start from. - * @param to Number tof line to finish on. - * @return List of read lines. - * @throws IOException If file couldn't be accessed or read failed. - */ - private List<String> readLinesForward(URL url, int from, int to) throws IOException { - BufferedReader reader = null; - - try { - reader = new BufferedReader(new InputStreamReader(url.openStream())); - - List<String> lines = new LinkedList<>(); - - String line; - - int i = 0; - - while ((line = reader.readLine()) != null) { - i++; - - if (from != -1 && i - 1 < from) - continue; - - if (to != -1 && i - 1 > to) - break; - - lines.add(line); - } - - return lines; - } - finally { - U.close(reader, log); - } - } - - /** - * Checks whether given url is accessible against configuration. - * - * @param url URL to check. - * @return {@code True} if file is accessible (i.e. located in one of the sub-folders of - * {@code restAccessibleFolders} list. - */ - private boolean isAccessible(URL url) throws IOException { - // No check is made if configuration is undefined. - if (accessibleFolders == null) - return true; - - File f = new File(url.getFile()); - - f = f.getCanonicalFile(); - - do { - if (F.contains(accessibleFolders, f)) - return true; - - f = f.getParentFile(); - } - while (f != null); - - return false; - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c4e2bd4c/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/log/package.html ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/log/package.html b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/log/package.html deleted file mode 100644 index 87386a0..0000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/log/package.html +++ /dev/null @@ -1,23 +0,0 @@ -<!-- - 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. - --> -<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> -<html> -<body> -<!-- Package description. --> - REST log commands. -</body> -</html> http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c4e2bd4c/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpRestNioListener.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpRestNioListener.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpRestNioListener.java index 6355938..db59939 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpRestNioListener.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpRestNioListener.java @@ -350,19 +350,6 @@ public class GridTcpRestNioListener extends GridNioServerListenerAdapter<GridCli restReq = restTopReq; } - else if (msg instanceof GridClientLogRequest) { - GridClientLogRequest req = (GridClientLogRequest) msg; - - GridRestLogRequest restLogReq = new GridRestLogRequest(); - - restLogReq.command(LOG); - - restLogReq.path(req.path()); - restLogReq.from(req.from()); - restLogReq.to(req.to()); - - restReq = restLogReq; - } if (restReq != null) { restReq.destinationId(msg.destinationId()); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c4e2bd4c/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorRestConfiguration.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorRestConfiguration.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorRestConfiguration.java index a6158e0..37ce00d 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorRestConfiguration.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorRestConfiguration.java @@ -76,7 +76,6 @@ public class VisorRestConfiguration implements Serializable { if (restEnabled) { cfg.tcpSslEnabled(clnCfg.isRestTcpSslEnabled()); - cfg.accessibleFolders(clnCfg.getRestAccessibleFolders()); cfg.jettyPath(clnCfg.getRestJettyPath()); cfg.jettyHost(getProperty(IGNITE_JETTY_HOST)); cfg.jettyPort(intValue(IGNITE_JETTY_PORT, null));