ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anovi...@apache.org
Subject [1/2] ignite git commit: # GG-843 Changed agent logging, dflt for ports.
Date Thu, 10 Sep 2015 09:29:04 GMT
Repository: ignite
Updated Branches:
  refs/heads/ignite-843 c8e5855bb -> e35c4fb63


# GG-843 Changed agent logging, dflt for ports.


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/e4b42791
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/e4b42791
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/e4b42791

Branch: refs/heads/ignite-843
Commit: e4b42791189521b6c4e4d9b3dfae3bc9297b17a1
Parents: 006baed
Author: Andrey <anovikov@gridgain.com>
Authored: Thu Sep 10 16:29:36 2015 +0700
Committer: Andrey <anovikov@gridgain.com>
Committed: Thu Sep 10 16:29:36 2015 +0700

----------------------------------------------------------------------
 .../apache/ignite/agent/AgentConfiguration.java   | 18 ++++++------------
 .../org/apache/ignite/agent/AgentLauncher.java    | 16 +++++++++-------
 .../java/org/apache/ignite/agent/AgentSocket.java |  4 ++--
 .../ignite/agent/handlers/RestExecutor.java       |  5 +++++
 .../apache/ignite/agent/remote/RemoteHandler.java |  2 +-
 .../agent/testdrive/AgentMetadataTestDrive.java   |  4 ++--
 .../ignite/agent/testdrive/AgentSqlTestDrive.java | 15 +++++++++------
 .../src/main/resources/logging.properties         |  3 ++-
 8 files changed, 36 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/e4b42791/modules/control-center-agent/src/main/java/org/apache/ignite/agent/AgentConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/control-center-agent/src/main/java/org/apache/ignite/agent/AgentConfiguration.java
b/modules/control-center-agent/src/main/java/org/apache/ignite/agent/AgentConfiguration.java
index cd27e4f..c3f9de2 100644
--- a/modules/control-center-agent/src/main/java/org/apache/ignite/agent/AgentConfiguration.java
+++ b/modules/control-center-agent/src/main/java/org/apache/ignite/agent/AgentConfiguration.java
@@ -31,9 +31,15 @@ public class AgentConfiguration {
     /** Default server URI. */
     private static final String DFLT_SERVER_URI = "wss://localhost:3001";
 
+    /** Default server port. */
+    public static final int DFLT_SERVER_PORT = 3001;
+
     /** Default Ignite node HTTP URI. */
     private static final String DFLT_NODE_URI = "http://localhost:8080";
 
+    /** Default Ignite node HTTP port. */
+    public static final int DFLT_NODE_PORT = 8080;
+
     /** */
     @Parameter(names = {"-t", "--token"}, description = "User's security token")
     private String token;
@@ -69,10 +75,6 @@ public class AgentConfiguration {
     private Boolean sql;
 
     /** */
-    @Parameter(names = { "-v", "--verbose" }, description = "Show more verbose log output")
-    private Boolean verbose;
-
-    /** */
     @Parameter(names = { "-h", "--help" }, help = true, description = "Print this help message")
     private Boolean help;
 
@@ -168,13 +170,6 @@ public class AgentConfiguration {
     }
 
     /**
-     * @return {@code true} If agent should show more verbose log output.
-     */
-    public Boolean verbose() {
-        return verbose != null ? verbose : false;
-    }
-
-    /**
      * @return {@code true} If agent options usage should be printed.
      */
     public Boolean help() {
@@ -186,7 +181,6 @@ public class AgentConfiguration {
             driversFolder == null &&
             meta == null &&
             sql == null &&
-            verbose == null &&
             help == null;
 
         return noArgs || (help != null ? help : false);

http://git-wip-us.apache.org/repos/asf/ignite/blob/e4b42791/modules/control-center-agent/src/main/java/org/apache/ignite/agent/AgentLauncher.java
----------------------------------------------------------------------
diff --git a/modules/control-center-agent/src/main/java/org/apache/ignite/agent/AgentLauncher.java
b/modules/control-center-agent/src/main/java/org/apache/ignite/agent/AgentLauncher.java
index 935c6c4..5983b63 100644
--- a/modules/control-center-agent/src/main/java/org/apache/ignite/agent/AgentLauncher.java
+++ b/modules/control-center-agent/src/main/java/org/apache/ignite/agent/AgentLauncher.java
@@ -22,11 +22,12 @@ import java.io.File;
 import java.net.URI;
 import java.util.logging.Level;
 import java.util.logging.Logger;
-import java.util.logging.Handler;
 import org.apache.ignite.agent.handlers.RestExecutor;
 import org.eclipse.jetty.util.ssl.SslContextFactory;
 import org.eclipse.jetty.websocket.client.WebSocketClient;
 
+import static org.apache.ignite.agent.AgentConfiguration.DFLT_SERVER_PORT;
+
 /**
  * Control Center Agent launcher.
  */
@@ -61,10 +62,6 @@ public class AgentLauncher {
             return;
         }
 
-        if (cmdCfg.verbose())
-            for(Handler h: Logger.getLogger("").getHandlers())
-                h.setLevel(Level.INFO);
-
         if (cmdCfg.testDriveSql() && cmdCfg.nodeUri() != null)
             log.log(Level.WARNING,
                 "URI for connect to Ignite REST server will be ignored because --test-drive-sql
option was specified.");
@@ -101,9 +98,14 @@ public class AgentLauncher {
                 while (!Thread.interrupted()) {
                     AgentSocket agentSock = new AgentSocket(cfg, restExecutor);
 
-                    log.log(Level.INFO, "Connecting to: " + cfg.serverUri());
+                    log.log(Level.FINE, "Connecting to: " + cfg.serverUri());
+
+                    URI uri = URI.create(cfg.serverUri());
+
+                    if (uri.getPort() == -1)
+                        uri = URI.create(cfg.serverUri() + ":" + DFLT_SERVER_PORT);
 
-                    client.connect(agentSock, URI.create(cfg.serverUri()));
+                    client.connect(agentSock, uri);
 
                     agentSock.waitForClose();
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/e4b42791/modules/control-center-agent/src/main/java/org/apache/ignite/agent/AgentSocket.java
----------------------------------------------------------------------
diff --git a/modules/control-center-agent/src/main/java/org/apache/ignite/agent/AgentSocket.java
b/modules/control-center-agent/src/main/java/org/apache/ignite/agent/AgentSocket.java
index b7c837b..6576dbf 100644
--- a/modules/control-center-agent/src/main/java/org/apache/ignite/agent/AgentSocket.java
+++ b/modules/control-center-agent/src/main/java/org/apache/ignite/agent/AgentSocket.java
@@ -83,7 +83,7 @@ public class AgentSocket implements WebSocketSender {
      */
     @OnWebSocketClose
     public void onClose(int statusCode, String reason) {
-        log.log(Level.INFO, String.format("Connection closed: %d - %s.", statusCode, reason));
+        log.log(Level.WARNING, String.format("Connection closed: %d - %s.", statusCode, reason));
 
         if (remote != null)
             remote.close();
@@ -142,7 +142,7 @@ public class AgentSocket implements WebSocketSender {
     @OnWebSocketError
     public void onError(Session ses, Throwable error) {
         if (error instanceof ConnectException)
-            log.log(Level.INFO, error.getMessage());
+            log.log(Level.WARNING, error.getMessage());
         else
             log.log(Level.SEVERE, "Connection error.", error);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/e4b42791/modules/control-center-agent/src/main/java/org/apache/ignite/agent/handlers/RestExecutor.java
----------------------------------------------------------------------
diff --git a/modules/control-center-agent/src/main/java/org/apache/ignite/agent/handlers/RestExecutor.java
b/modules/control-center-agent/src/main/java/org/apache/ignite/agent/handlers/RestExecutor.java
index 7e8edf8..f745ba5 100644
--- a/modules/control-center-agent/src/main/java/org/apache/ignite/agent/handlers/RestExecutor.java
+++ b/modules/control-center-agent/src/main/java/org/apache/ignite/agent/handlers/RestExecutor.java
@@ -38,6 +38,8 @@ import org.apache.http.impl.client.HttpClientBuilder;
 import org.apache.ignite.agent.AgentConfiguration;
 import org.apache.ignite.agent.remote.Remote;
 
+import static org.apache.ignite.agent.AgentConfiguration.DFLT_NODE_PORT;
+
 /**
  * Executor for REST requests.
  */
@@ -82,6 +84,9 @@ public class RestExecutor {
         String body) throws IOException, URISyntaxException {
         URIBuilder builder = new URIBuilder(cfg.nodeUri());
 
+        if (builder.getPort() == -1)
+            builder.setPort(DFLT_NODE_PORT);
+
         if (path != null) {
             if (!path.startsWith("/") && !cfg.nodeUri().endsWith("/"))
                 path = '/' +  path;

http://git-wip-us.apache.org/repos/asf/ignite/blob/e4b42791/modules/control-center-agent/src/main/java/org/apache/ignite/agent/remote/RemoteHandler.java
----------------------------------------------------------------------
diff --git a/modules/control-center-agent/src/main/java/org/apache/ignite/agent/remote/RemoteHandler.java
b/modules/control-center-agent/src/main/java/org/apache/ignite/agent/remote/RemoteHandler.java
index 203f0fb..9caf515 100644
--- a/modules/control-center-agent/src/main/java/org/apache/ignite/agent/remote/RemoteHandler.java
+++ b/modules/control-center-agent/src/main/java/org/apache/ignite/agent/remote/RemoteHandler.java
@@ -86,7 +86,7 @@ public class RemoteHandler implements AutoCloseable {
      * @param req Request.
      */
     public void onMessage(JsonObject req) {
-        log.log(Level.INFO, "Message: " + req);
+        log.log(Level.FINE, "Message: " + req);
 
         JsonPrimitive reqIdJson = req.getAsJsonPrimitive("reqId");
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/e4b42791/modules/control-center-agent/src/main/java/org/apache/ignite/agent/testdrive/AgentMetadataTestDrive.java
----------------------------------------------------------------------
diff --git a/modules/control-center-agent/src/main/java/org/apache/ignite/agent/testdrive/AgentMetadataTestDrive.java
b/modules/control-center-agent/src/main/java/org/apache/ignite/agent/testdrive/AgentMetadataTestDrive.java
index d3307b7..f0139fb 100644
--- a/modules/control-center-agent/src/main/java/org/apache/ignite/agent/testdrive/AgentMetadataTestDrive.java
+++ b/modules/control-center-agent/src/main/java/org/apache/ignite/agent/testdrive/AgentMetadataTestDrive.java
@@ -42,7 +42,7 @@ public class AgentMetadataTestDrive {
      */
     public static void testDrive() {
         if (initLatch.compareAndSet(false, true)) {
-            log.log(Level.INFO, "TEST-DRIVE: Prepare in-memory H2 database...");
+            log.log(Level.FINE, "TEST-DRIVE: Prepare in-memory H2 database...");
 
             try {
                 Connection conn = DriverManager.getConnection("jdbc:h2:mem:test-drive-db;DB_CLOSE_DELAY=-1",
"sa", "");
@@ -53,7 +53,7 @@ public class AgentMetadataTestDrive {
                     "test-drive.sql");
 
                 RunScript.execute(conn, new FileReader(sqlScript));
-                log.log(Level.INFO, "TEST-DRIVE: Sample tables created.");
+                log.log(Level.FINE, "TEST-DRIVE: Sample tables created.");
 
                 conn.close();
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/e4b42791/modules/control-center-agent/src/main/java/org/apache/ignite/agent/testdrive/AgentSqlTestDrive.java
----------------------------------------------------------------------
diff --git a/modules/control-center-agent/src/main/java/org/apache/ignite/agent/testdrive/AgentSqlTestDrive.java
b/modules/control-center-agent/src/main/java/org/apache/ignite/agent/testdrive/AgentSqlTestDrive.java
index 32cc538..7b3dd80 100644
--- a/modules/control-center-agent/src/main/java/org/apache/ignite/agent/testdrive/AgentSqlTestDrive.java
+++ b/modules/control-center-agent/src/main/java/org/apache/ignite/agent/testdrive/AgentSqlTestDrive.java
@@ -30,6 +30,7 @@ import org.apache.ignite.internal.IgniteEx;
 import org.apache.ignite.internal.IgniteNodeAttributes;
 import org.apache.ignite.internal.util.typedef.F;
 import org.apache.ignite.lang.IgniteBiTuple;
+import org.apache.ignite.logger.NullLogger;
 import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
 
@@ -269,7 +270,7 @@ public class AgentSqlTestDrive {
      * @param name Cache name.
      */
     private static void populateCacheEmployee(Ignite ignite, String name) {
-        log.log(Level.INFO, "TEST-DRIVE: Start population cache: '" + name + "' with data...");
+        log.log(Level.FINE, "TEST-DRIVE: Start population cache: '" + name + "' with data...");
 
         IgniteCache<CountryKey, Country> cacheCountry = ignite.cache(name);
 
@@ -304,7 +305,7 @@ public class AgentSqlTestDrive {
                     round(r * 5000, 2) , mgrId, rnd.nextInt(DEP_CNT)));
         }
 
-        log.log(Level.INFO, "TEST-DRIVE: Finished population cache: '" + name + "' with data.");
+        log.log(Level.FINE, "TEST-DRIVE: Finished population cache: '" + name + "' with data.");
     }
 
     /**
@@ -312,7 +313,7 @@ public class AgentSqlTestDrive {
      * @param name Cache name.
      */
     private static void populateCacheCar(Ignite ignite, String name) {
-        log.log(Level.INFO, "TEST-DRIVE: Start population cache: '" + name + "' with data...");
+        log.log(Level.FINE, "TEST-DRIVE: Start population cache: '" + name + "' with data...");
 
         IgniteCache<ParkingKey, Parking> cacheParking = ignite.cache(name);
 
@@ -325,7 +326,7 @@ public class AgentSqlTestDrive {
             cacheDepartment.put(new CarKey(i), new Car(i, rnd.nextInt(PARK_CNT), "Car " +
(i + 1)));
 
 
-        log.log(Level.INFO, "TEST-DRIVE: Finished population cache: '" + name + "' with data.");
+        log.log(Level.FINE, "TEST-DRIVE: Finished population cache: '" + name + "' with data.");
     }
 
     /**
@@ -333,7 +334,7 @@ public class AgentSqlTestDrive {
      */
     public static void testDrive(AgentConfiguration acfg) {
         if (initLatch.compareAndSet(false, true)) {
-            log.log(Level.INFO, "TEST-DRIVE: Prepare node configuration...");
+            log.log(Level.FINE, "TEST-DRIVE: Prepare node configuration...");
 
             try {
                 IgniteConfiguration cfg = new IgniteConfiguration();
@@ -342,6 +343,8 @@ public class AgentSqlTestDrive {
 
                 cfg.setMetricsLogFrequency(0);
 
+                cfg.setGridLogger(new NullLogger());
+
                 // Configure discovery SPI.
                 TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
 
@@ -355,7 +358,7 @@ public class AgentSqlTestDrive {
 
                 cfg.setCacheConfiguration(cacheEmployee(EMPLOYEE_CACHE_NAME), cacheCar(CAR_CACHE_NAME));
 
-                log.log(Level.INFO, "TEST-DRIVE: Start embedded node with indexed enabled
caches...");
+                log.log(Level.FINE, "TEST-DRIVE: Start embedded node with indexed enabled
caches...");
 
                 IgniteEx ignite = (IgniteEx)Ignition.start(cfg);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/e4b42791/modules/control-center-agent/src/main/resources/logging.properties
----------------------------------------------------------------------
diff --git a/modules/control-center-agent/src/main/resources/logging.properties b/modules/control-center-agent/src/main/resources/logging.properties
index 747fc2a..661f52c 100644
--- a/modules/control-center-agent/src/main/resources/logging.properties
+++ b/modules/control-center-agent/src/main/resources/logging.properties
@@ -14,6 +14,7 @@
 # limitations under the License.
 
 handlers =java.util.logging.ConsoleHandler
-.level = WARNING
+.level=FINE
+java.util.logging.ConsoleHandler.level=INFO
 java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
 java.util.logging.SimpleFormatter.format=%1$tl:%1$tM:%1$tS %1$Tp %4$s: %5$s%n


Mime
View raw message