You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by ak...@apache.org on 2015/08/04 04:59:24 UTC
incubator-ignite git commit: IGNITE-1155 Review.
Repository: incubator-ignite
Updated Branches:
refs/heads/ignite-1155_1 c64d4af96 -> 1ac8b1ab7
IGNITE-1155 Review.
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/1ac8b1ab
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/1ac8b1ab
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/1ac8b1ab
Branch: refs/heads/ignite-1155_1
Commit: 1ac8b1ab7738d12434b93fa6ca52eec98138840a
Parents: c64d4af
Author: AKuznetsov <ak...@gridgain.com>
Authored: Tue Aug 4 09:59:26 2015 +0700
Committer: AKuznetsov <ak...@gridgain.com>
Committed: Tue Aug 4 09:59:26 2015 +0700
----------------------------------------------------------------------
modules/control-center-agent/README.txt | 26 +--
modules/control-center-agent/pom.xml | 12 +-
.../org/apache/ignite/agent/AgentLauncher.java | 7 +-
.../ignite/agent/AgentLoggingConfigurator.java | 82 +++++++++
.../org/apache/ignite/agent/AgentSocket.java | 2 +-
.../org/apache/ignite/agent/AgentUtils.java | 56 +++++++
.../ignite/agent/LoggingConfigurator.java | 77 ---------
.../org/apache/ignite/agent/RestExecutor.java | 165 -------------------
.../java/org/apache/ignite/agent/Utils.java | 56 -------
.../ignite/agent/handlers/DBExtractor.java | 98 -----------
.../handlers/DatabaseMetadataExtractor.java | 98 +++++++++++
.../ignite/agent/handlers/RestExecutor.java | 2 +-
.../org/apache/ignite/agent/remote/Remote.java | 6 +-
.../apache/ignite/schema/parser/DBReader.java | 127 --------------
.../ignite/schema/parser/DbMetadataReader.java | 127 ++++++++++++++
.../schema/parser/DatabaseMetadataParser.java | 2 +-
.../ignite/schema/ui/SchemaImportApp.java | 4 +-
17 files changed, 398 insertions(+), 549 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1ac8b1ab/modules/control-center-agent/README.txt
----------------------------------------------------------------------
diff --git a/modules/control-center-agent/README.txt b/modules/control-center-agent/README.txt
index 99d14a8..2db8031 100644
--- a/modules/control-center-agent/README.txt
+++ b/modules/control-center-agent/README.txt
@@ -1,13 +1,19 @@
-Apache Ignite Control Center Agent
----------------------------
-Apache Ignite Control Center Agent is a java standalone application that allow to connect grid to control center.
-Control Center Agent communicates with grid nodes via REST interface and connects to Control Center via web-socket.
+Ignite Control Center Agent
+======================================
+Ignite Control Center Agent is a java standalone application that allow to connect grid to Ignite Web Control Center.
+Control Center Agent communicates with grid nodes via REST interface and connects to Web Control Center via web-socket.
+
+Two main functions of Control Center Agent:
+ 1. Proxy between Ignite Web Control Center and Ignite Grid to execute SQL statements and collect metrics for monitoring.
+ 2. Proxy between Ignite Web Control Center and user RDBMS to collect database metadata for later CacheTypeMetadata configuration.
+
+
+Usage example
+======================================
----------------------------
-Usage example:
agent.sh -l john.smith@gmail.com -p qwerty -s wss://control-center.gridgain.com
-Command line arguments:
+Main command line arguments:
-l User's login (email) on web-control-center
-p User's password
-s Link to Ignite Control Center web-socket server.
@@ -15,6 +21,6 @@ Command line arguments:
-c Configure agent using configuration file. Configuration file is a properties file,
see /control-center-agent/src/main/resources/config.properties as example.
----------------------------
-Building module:
-to build module run "mvn package"
+Ignite Control Center Agent Build Instructions
+======================================
+ mvn clean package -DskipTests
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1ac8b1ab/modules/control-center-agent/pom.xml
----------------------------------------------------------------------
diff --git a/modules/control-center-agent/pom.xml b/modules/control-center-agent/pom.xml
index c40b4756..733c00e 100644
--- a/modules/control-center-agent/pom.xml
+++ b/modules/control-center-agent/pom.xml
@@ -39,6 +39,12 @@
<dependencies>
<dependency>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-schema-import-db</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
<groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>websocket-client</artifactId>
<version>${jetty.version}</version>
@@ -61,12 +67,6 @@
<artifactId>httpclient</artifactId>
<version>4.5</version>
</dependency>
-
- <dependency>
- <groupId>org.apache.ignite</groupId>
- <artifactId>ignite-schema-import-db</artifactId>
- <version>${project.version}</version>
- </dependency>
</dependencies>
<build>
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1ac8b1ab/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 5404448..3f04c80 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
@@ -18,6 +18,7 @@
package org.apache.ignite.agent;
import com.beust.jcommander.*;
+import org.apache.ignite.agent.handlers.*;
import org.eclipse.jetty.util.ssl.*;
import org.eclipse.jetty.websocket.client.*;
@@ -26,12 +27,12 @@ import java.net.*;
import java.util.logging.*;
/**
- * Main class.
+ * Control Center Agent launcher.
*/
public class AgentLauncher {
/** Static initializer. */
static {
- LoggingConfigurator.configure();
+ AgentLoggingConfigurator.configure();
}
/** */
@@ -77,6 +78,8 @@ public class AgentLauncher {
* @param args Args.
*/
public static void main(String[] args) throws Exception {
+ log.log(Level.INFO, "Starting Apache Ignite Control Center Agent...");
+
AgentConfiguration cfg = getConfiguration(args);
RestExecutor restExecutor = new RestExecutor(cfg);
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1ac8b1ab/modules/control-center-agent/src/main/java/org/apache/ignite/agent/AgentLoggingConfigurator.java
----------------------------------------------------------------------
diff --git a/modules/control-center-agent/src/main/java/org/apache/ignite/agent/AgentLoggingConfigurator.java b/modules/control-center-agent/src/main/java/org/apache/ignite/agent/AgentLoggingConfigurator.java
new file mode 100644
index 0000000..d0b1d2d
--- /dev/null
+++ b/modules/control-center-agent/src/main/java/org/apache/ignite/agent/AgentLoggingConfigurator.java
@@ -0,0 +1,82 @@
+/*
+ * 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.agent;
+
+import java.io.*;
+import java.util.logging.*;
+
+/**
+ * Configurator for java.util.Logger.
+ */
+public class AgentLoggingConfigurator {
+ /** */
+ private static final String CFG_PATH_PROPERTY = "log.config.path";
+
+ private static final String PROPERTIES_FILE = "logging.properties";
+
+ /**
+ * Perform configure.
+ */
+ public static void configure() {
+ try {
+ if (System.getProperty(CFG_PATH_PROPERTY) != null) {
+ File logCfg = new File(System.getProperty(CFG_PATH_PROPERTY));
+
+ if (!logCfg.isFile()) {
+ System.err.println("Failed to load logging configuration, file not found: " + logCfg);
+
+ System.exit(1);
+ }
+
+ readConfiguration(logCfg);
+
+ return;
+ }
+
+ File agentHome = AgentUtils.getAgentHome();
+
+ if (agentHome != null) {
+ File logCfg = new File(agentHome, PROPERTIES_FILE);
+
+ if (logCfg.isFile()) {
+ readConfiguration(logCfg);
+
+ return;
+ }
+ }
+
+ LogManager.getLogManager().readConfiguration(AgentLauncher.class.getResourceAsStream("/" + PROPERTIES_FILE));
+ }
+ catch (IOException e) {
+ System.err.println("Failed to load logging configuration");
+
+ e.printStackTrace();
+
+ System.exit(1);
+ }
+ }
+
+ /**
+ * @param file File.
+ */
+ private static void readConfiguration(File file) throws IOException {
+ try (InputStream in = new BufferedInputStream(new FileInputStream(file))) {
+ LogManager.getLogManager().readConfiguration(in);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1ac8b1ab/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 e34972c..bab149f 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
@@ -88,7 +88,7 @@ public class AgentSocket implements WebSocketSender {
this.ses = ses;
- remote = RemoteHandler.wrap(this, this, restExecutor, new DBExtractor(cfg));
+ remote = RemoteHandler.wrap(this, this, restExecutor, new DatabaseMetadataExtractor(cfg));
JsonObject authMsg = new JsonObject();
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1ac8b1ab/modules/control-center-agent/src/main/java/org/apache/ignite/agent/AgentUtils.java
----------------------------------------------------------------------
diff --git a/modules/control-center-agent/src/main/java/org/apache/ignite/agent/AgentUtils.java b/modules/control-center-agent/src/main/java/org/apache/ignite/agent/AgentUtils.java
new file mode 100644
index 0000000..0675e3f
--- /dev/null
+++ b/modules/control-center-agent/src/main/java/org/apache/ignite/agent/AgentUtils.java
@@ -0,0 +1,56 @@
+/*
+ * 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.agent;
+
+import java.io.*;
+import java.net.*;
+
+/**
+ * Utility methods.
+ */
+public class AgentUtils {
+ /**
+ * Default constructor.
+ */
+ private AgentUtils() {
+ // No-op.
+ }
+
+ /**
+ * @return Folder where agent.jar is located.
+ */
+ public static File getAgentHome() {
+ URL jarLogCfgUrl = AgentLauncher.class.getResource("/logging.properties");
+
+ String path = jarLogCfgUrl.getFile();
+
+ int jarSeparatorIdx = path.lastIndexOf("!/");
+
+ if (jarSeparatorIdx == -1)
+ return null;
+
+ path = path.substring(0, jarSeparatorIdx);
+
+ if (path.startsWith("file:"))
+ path = path.substring("file:".length());
+
+ File jarFile = new File(path);
+
+ return jarFile.getParentFile();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1ac8b1ab/modules/control-center-agent/src/main/java/org/apache/ignite/agent/LoggingConfigurator.java
----------------------------------------------------------------------
diff --git a/modules/control-center-agent/src/main/java/org/apache/ignite/agent/LoggingConfigurator.java b/modules/control-center-agent/src/main/java/org/apache/ignite/agent/LoggingConfigurator.java
deleted file mode 100644
index 5fb2c6e..0000000
--- a/modules/control-center-agent/src/main/java/org/apache/ignite/agent/LoggingConfigurator.java
+++ /dev/null
@@ -1,77 +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.agent;
-
-import java.io.*;
-import java.util.logging.*;
-
-/**
- * Configurator for java.util.Logger.
- */
-public class LoggingConfigurator {
- /**
- * Perform configure.
- */
- public static void configure() {
- try {
- if (System.getProperty("log.config.path") != null) {
- File logCfg = new File(System.getProperty("log.config.path"));
-
- if (!logCfg.isFile()) {
- System.err.println("Failed to load loggin configuration, file not found: " + logCfg);
-
- System.exit(1);
- }
-
- readConfiguration(logCfg);
-
- return;
- }
-
- File agentHome = Utils.getAgentHome();
-
- if (agentHome != null) {
- File logCfg = new File(agentHome, "logging.properties");
-
- if (logCfg.isFile()) {
- readConfiguration(logCfg);
-
- return;
- }
- }
-
- LogManager.getLogManager().readConfiguration(AgentLauncher.class.getResourceAsStream("/logging.properties"));
- }
- catch (IOException e) {
- System.err.println("Failed to load loggin configuration");
-
- e.printStackTrace();
-
- System.exit(1);
- }
- }
-
- /**
- * @param file File.
- */
- private static void readConfiguration(File file) throws IOException {
- try (InputStream in = new BufferedInputStream(new FileInputStream(file))) {
- LogManager.getLogManager().readConfiguration(in);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1ac8b1ab/modules/control-center-agent/src/main/java/org/apache/ignite/agent/RestExecutor.java
----------------------------------------------------------------------
diff --git a/modules/control-center-agent/src/main/java/org/apache/ignite/agent/RestExecutor.java b/modules/control-center-agent/src/main/java/org/apache/ignite/agent/RestExecutor.java
deleted file mode 100644
index 6477292..0000000
--- a/modules/control-center-agent/src/main/java/org/apache/ignite/agent/RestExecutor.java
+++ /dev/null
@@ -1,165 +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.agent;
-
-import org.apache.commons.codec.*;
-import org.apache.http.*;
-import org.apache.http.client.entity.*;
-import org.apache.http.client.methods.*;
-import org.apache.http.client.utils.*;
-import org.apache.http.entity.*;
-import org.apache.http.impl.client.*;
-import org.apache.ignite.agent.remote.*;
-
-import java.io.*;
-import java.net.*;
-import java.nio.charset.*;
-import java.util.*;
-import java.util.logging.*;
-
-/**
- * Executor for REST requests.
- */
-public class RestExecutor {
- /** */
- private static final Logger log = Logger.getLogger(RestExecutor.class.getName());
-
- /** */
- private final AgentConfiguration cfg;
-
- /** */
- private CloseableHttpClient httpClient;
-
- /**
- * @param cfg Config.
- */
- public RestExecutor(AgentConfiguration cfg) {
- this.cfg = cfg;
- }
-
- /**
- *
- */
- public void start() {
- httpClient = HttpClientBuilder.create().build();
- }
-
- /**
- *
- */
- public void stop() throws IOException {
- if (httpClient != null)
- httpClient.close();
- }
-
- /**
- * @param path Path.
- * @param method Method.
- * @param params Params.
- * @param headers Headers.
- * @param body Body.
- */
- @Remote
- public RestResult executeRest(String path, Map<String, String> params, String method, Map<String, String> headers,
- String body) throws IOException, URISyntaxException {
- URIBuilder builder = new URIBuilder(cfg.getNodeUri());
-
- if (path != null) {
- if (!path.startsWith("/") && !cfg.getNodeUri().toString().endsWith("/"))
- path = '/' + path;
-
- builder.setPath(path);
- }
-
- if (params != null) {
- for (Map.Entry<String, String> entry : params.entrySet())
- builder.addParameter(entry.getKey(), entry.getValue());
- }
-
- HttpRequestBase httpReq;
-
- if ("GET".equalsIgnoreCase(method))
- httpReq = new HttpGet(builder.build());
- else if ("POST".equalsIgnoreCase(method)) {
- HttpPost post;
-
- if (body == null) {
- List<NameValuePair> nvps = builder.getQueryParams();
-
- builder.clearParameters();
-
- post = new HttpPost(builder.build());
-
- if (!nvps.isEmpty())
- post.setEntity(new UrlEncodedFormEntity(nvps));
- }
- else {
- post = new HttpPost(builder.build());
-
- post.setEntity(new StringEntity(body));
- }
-
- httpReq = post;
- }
- else
- throw new IOException("Unknown HTTP-method: " + method);
-
- if (headers != null) {
- for (Map.Entry<String, String> entry : headers.entrySet())
- httpReq.addHeader(entry.getKey(), entry.getValue());
- }
-
- try (CloseableHttpResponse resp = httpClient.execute(httpReq)) {
- ByteArrayOutputStream out = new ByteArrayOutputStream();
-
- resp.getEntity().writeTo(out);
-
- Charset charset = Charsets.UTF_8;
-
- Header encodingHdr = resp.getEntity().getContentEncoding();
-
- if (encodingHdr != null) {
- String encoding = encodingHdr.getValue();
-
- charset = Charsets.toCharset(encoding);
- }
-
- return new RestResult(resp.getStatusLine().getStatusCode(), new String(out.toByteArray(), charset));
- }
- }
-
- /**
- *
- */
- public static class RestResult {
- /** */
- private int code;
-
- /** */
- private String message;
-
- /**
- * @param code Code.
- * @param msg Message.
- */
- public RestResult(int code, String msg) {
- this.code = code;
- message = msg;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1ac8b1ab/modules/control-center-agent/src/main/java/org/apache/ignite/agent/Utils.java
----------------------------------------------------------------------
diff --git a/modules/control-center-agent/src/main/java/org/apache/ignite/agent/Utils.java b/modules/control-center-agent/src/main/java/org/apache/ignite/agent/Utils.java
deleted file mode 100644
index 30661ea..0000000
--- a/modules/control-center-agent/src/main/java/org/apache/ignite/agent/Utils.java
+++ /dev/null
@@ -1,56 +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.agent;
-
-import java.io.*;
-import java.net.*;
-
-/**
- * Utility methods.
- */
-public class Utils {
- /**
- * Default constructor.
- */
- private Utils() {
- // No-op.
- }
-
- /**
- * @return Folder where agent.jar is located.
- */
- public static File getAgentHome() {
- URL jarLogCfgUrl = AgentLauncher.class.getResource("/logging.properties");
-
- String path = jarLogCfgUrl.getFile();
-
- int jarSeparatorIdx = path.lastIndexOf("!/");
-
- if (jarSeparatorIdx == -1)
- return null;
-
- path = path.substring(0, jarSeparatorIdx);
-
- if (path.startsWith("file:"))
- path = path.substring("file:".length());
-
- File jarFile = new File(path);
-
- return jarFile.getParentFile();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1ac8b1ab/modules/control-center-agent/src/main/java/org/apache/ignite/agent/handlers/DBExtractor.java
----------------------------------------------------------------------
diff --git a/modules/control-center-agent/src/main/java/org/apache/ignite/agent/handlers/DBExtractor.java b/modules/control-center-agent/src/main/java/org/apache/ignite/agent/handlers/DBExtractor.java
deleted file mode 100644
index 1288848..0000000
--- a/modules/control-center-agent/src/main/java/org/apache/ignite/agent/handlers/DBExtractor.java
+++ /dev/null
@@ -1,98 +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.agent.handlers;
-
-import org.apache.ignite.agent.*;
-import org.apache.ignite.agent.remote.*;
-import org.apache.ignite.schema.parser.*;
-
-import java.io.*;
-import java.sql.*;
-import java.util.*;
-
-/**
- * Remote API to extract DB metadata.
- */
-public class DBExtractor {
- /** */
- private final AgentConfiguration cfg;
-
- /** */
- private final String driversFolder;
-
- /**
- * @param cfg Config.
- */
- public DBExtractor(AgentConfiguration cfg) {
- this.cfg = cfg;
-
- String driversFolder = cfg.getDriversFolder();
-
- if (driversFolder == null) {
- File agentHome = Utils.getAgentHome();
-
- if (agentHome != null)
- driversFolder = agentHome + "/drivers";
- }
-
- this.driversFolder = driversFolder;
- }
-
- /**
- * @param jdbcDriverJarPath JDBC driver JAR path.
- * @param jdbcDriverCls JDBC driver class.
- * @param jdbcUrl JDBC URL.
- * @param jdbcInfo Properties to connect to database.
- *
- * @return Collection of tables.
- */
- @Remote
- public Collection<DbTable> extractMetadata(String jdbcDriverJarPath, String jdbcDriverCls, String jdbcUrl,
- Properties jdbcInfo, boolean tblsOnly) throws SQLException {
- if (!new File(jdbcDriverJarPath).isAbsolute() && driversFolder != null)
- jdbcDriverJarPath = new File(driversFolder, jdbcDriverJarPath).getPath();
-
- Connection conn = DBReader.getInstance().connect(jdbcDriverJarPath, jdbcDriverCls, jdbcUrl, jdbcInfo);
-
- return DBReader.getInstance().extractMetadata(conn, tblsOnly);
- }
-
- /**
- * @return Drivers in drivers folder
- * @see AgentConfiguration#driversFolder
- */
- @Remote
- public List<String> availableDrivers() {
- if (driversFolder == null)
- return Collections.emptyList();
-
- String[] list = new File(driversFolder).list();
-
- if (list == null)
- return Collections.emptyList();
-
- List<String> res = new ArrayList<>();
-
- for (String fileName : list) {
- if (fileName.endsWith(".jar"))
- res.add(fileName);
- }
-
- return res;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1ac8b1ab/modules/control-center-agent/src/main/java/org/apache/ignite/agent/handlers/DatabaseMetadataExtractor.java
----------------------------------------------------------------------
diff --git a/modules/control-center-agent/src/main/java/org/apache/ignite/agent/handlers/DatabaseMetadataExtractor.java b/modules/control-center-agent/src/main/java/org/apache/ignite/agent/handlers/DatabaseMetadataExtractor.java
new file mode 100644
index 0000000..183f674
--- /dev/null
+++ b/modules/control-center-agent/src/main/java/org/apache/ignite/agent/handlers/DatabaseMetadataExtractor.java
@@ -0,0 +1,98 @@
+/*
+ * 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.agent.handlers;
+
+import org.apache.ignite.agent.*;
+import org.apache.ignite.agent.remote.*;
+import org.apache.ignite.schema.parser.*;
+
+import java.io.*;
+import java.sql.*;
+import java.util.*;
+
+/**
+ * Remote API to extract database metadata.
+ */
+public class DatabaseMetadataExtractor {
+ /** */
+ private final AgentConfiguration cfg;
+
+ /** */
+ private final String driversFolder;
+
+ /**
+ * @param cfg Config.
+ */
+ public DatabaseMetadataExtractor(AgentConfiguration cfg) {
+ this.cfg = cfg;
+
+ String driversFolder = cfg.getDriversFolder();
+
+ if (driversFolder == null) {
+ File agentHome = AgentUtils.getAgentHome();
+
+ if (agentHome != null)
+ driversFolder = agentHome + "/drivers";
+ }
+
+ this.driversFolder = driversFolder;
+ }
+
+ /**
+ * @param jdbcDriverJarPath JDBC driver JAR path.
+ * @param jdbcDriverCls JDBC driver class.
+ * @param jdbcUrl JDBC URL.
+ * @param jdbcInfo Properties to connect to database.
+ *
+ * @return Collection of tables.
+ */
+ @Remote
+ public Collection<DbTable> extractMetadata(String jdbcDriverJarPath, String jdbcDriverCls, String jdbcUrl,
+ Properties jdbcInfo, boolean tblsOnly) throws SQLException {
+ if (!new File(jdbcDriverJarPath).isAbsolute() && driversFolder != null)
+ jdbcDriverJarPath = new File(driversFolder, jdbcDriverJarPath).getPath();
+
+ Connection conn = DbMetadataReader.getInstance().connect(jdbcDriverJarPath, jdbcDriverCls, jdbcUrl, jdbcInfo);
+
+ return DbMetadataReader.getInstance().extractMetadata(conn, tblsOnly);
+ }
+
+ /**
+ * @return Drivers in drivers folder
+ * @see AgentConfiguration#driversFolder
+ */
+ @Remote
+ public List<String> availableDrivers() {
+ if (driversFolder == null)
+ return Collections.emptyList();
+
+ String[] list = new File(driversFolder).list();
+
+ if (list == null)
+ return Collections.emptyList();
+
+ List<String> res = new ArrayList<>();
+
+ for (String fileName : list) {
+ if (fileName.endsWith(".jar"))
+ res.add(fileName);
+ }
+
+ return res;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1ac8b1ab/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 8b0ae98..aec4138 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
@@ -81,7 +81,7 @@ public class RestExecutor {
URIBuilder builder = new URIBuilder(cfg.getNodeUri());
if (path != null) {
- if (!path.startsWith("/") && !cfg.getNodeUri().toString().endsWith("/"))
+ if (!path.startsWith("/") && !cfg.getNodeUri().endsWith("/"))
path = '/' + path;
builder.setPath(path);
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1ac8b1ab/modules/control-center-agent/src/main/java/org/apache/ignite/agent/remote/Remote.java
----------------------------------------------------------------------
diff --git a/modules/control-center-agent/src/main/java/org/apache/ignite/agent/remote/Remote.java b/modules/control-center-agent/src/main/java/org/apache/ignite/agent/remote/Remote.java
index d7950bf..4419281 100644
--- a/modules/control-center-agent/src/main/java/org/apache/ignite/agent/remote/Remote.java
+++ b/modules/control-center-agent/src/main/java/org/apache/ignite/agent/remote/Remote.java
@@ -20,15 +20,15 @@ package org.apache.ignite.agent.remote;
import java.lang.annotation.*;
/**
- * Method annotated by this annotation can be executed remotely from NodeJS server by web-socket command.
+ * Use this annotation to assosiate methods with remote NodeJS server commands.
*/
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface Remote {
/**
* Whether or not method should be executed synchronously.
- * @return {@code true} if method will be executed in separated thread,
- * {@code false} if method executed in web-socket thread.
+ *
+ * @return {@code true} if method will be executed in separated thread otherwise if method will be executed in handler thread.
*/
boolean async() default true;
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1ac8b1ab/modules/schema-import-db/src/main/java/org/apache/ignite/schema/parser/DBReader.java
----------------------------------------------------------------------
diff --git a/modules/schema-import-db/src/main/java/org/apache/ignite/schema/parser/DBReader.java b/modules/schema-import-db/src/main/java/org/apache/ignite/schema/parser/DBReader.java
deleted file mode 100644
index 9e8d236..0000000
--- a/modules/schema-import-db/src/main/java/org/apache/ignite/schema/parser/DBReader.java
+++ /dev/null
@@ -1,127 +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.schema.parser;
-
-import org.apache.ignite.schema.parser.dialect.*;
-
-import java.io.*;
-import java.net.*;
-import java.sql.*;
-import java.util.*;
-import java.util.logging.*;
-
-/**
- * Singleton to extract DataBase
- */
-public class DBReader {
- /** Logger. */
- private static final Logger log = Logger.getLogger(DBReader.class.getName());
-
- /** */
- private static final DBReader INSTANCE = new DBReader();
-
- /** */
- private final Map<String, Driver> drivers = new HashMap<>();
-
- /**
- * Default constructor.
- */
- private DBReader() {
- // No-op.
- }
-
- /**
- * Extract DB metadata.
- *
- * @param conn Connection.
- * @param tblsOnly Tables only flag.
- */
- public Collection<DbTable> extractMetadata(Connection conn, boolean tblsOnly) throws SQLException {
- DatabaseMetadataDialect dialect;
-
- try {
- String dbProductName = conn.getMetaData().getDatabaseProductName();
-
- if ("Oracle".equals(dbProductName))
- dialect = new OracleMetadataDialect();
- else if (dbProductName.startsWith("DB2/"))
- dialect = new DB2MetadataDialect();
- else
- dialect = new JdbcMetadataDialect();
- }
- catch (SQLException e) {
- log.log(Level.SEVERE, "Failed to resolve dialect (JdbcMetaDataDialect will be used.", e);
-
- dialect = new JdbcMetadataDialect();
- }
-
- return dialect.tables(conn, tblsOnly);
- }
-
- /**
- * Connect to database.
- *
- * @param jdbcDrvJarPath Path to JDBC driver.
- * @param jdbcDrvCls JDBC class name.
- * @param jdbcUrl JDBC connection URL.
- * @param jdbcInfo Connection properties.
- * @return Connection to database.
- * @throws SQLException if connection failed.
- */
- public Connection connect(String jdbcDrvJarPath, String jdbcDrvCls, String jdbcUrl, Properties jdbcInfo)
- throws SQLException {
- Driver drv = drivers.get(jdbcDrvCls);
-
- if (drv == null) {
- if (jdbcDrvJarPath.isEmpty())
- throw new IllegalStateException("Driver jar file name is not specified.");
-
- File drvJar = new File(jdbcDrvJarPath);
-
- if (!drvJar.exists())
- throw new IllegalStateException("Driver jar file is not found.");
-
- try {
- URL u = new URL("jar:" + drvJar.toURI() + "!/");
-
- URLClassLoader ucl = URLClassLoader.newInstance(new URL[] {u});
-
- drv = (Driver)Class.forName(jdbcDrvCls, true, ucl).newInstance();
-
- drivers.put(jdbcDrvCls, drv);
- }
- catch (Exception e) {
- throw new IllegalStateException(e);
- }
- }
-
- Connection conn = drv.connect(jdbcUrl, jdbcInfo);
-
- if (conn == null)
- throw new IllegalStateException("Connection was not established (JDBC driver returned null value).");
-
- return conn;
- }
-
- /**
- * @return Instance.
- */
- public static DBReader getInstance() {
- return INSTANCE;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1ac8b1ab/modules/schema-import-db/src/main/java/org/apache/ignite/schema/parser/DbMetadataReader.java
----------------------------------------------------------------------
diff --git a/modules/schema-import-db/src/main/java/org/apache/ignite/schema/parser/DbMetadataReader.java b/modules/schema-import-db/src/main/java/org/apache/ignite/schema/parser/DbMetadataReader.java
new file mode 100644
index 0000000..31466b5
--- /dev/null
+++ b/modules/schema-import-db/src/main/java/org/apache/ignite/schema/parser/DbMetadataReader.java
@@ -0,0 +1,127 @@
+/*
+ * 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.schema.parser;
+
+import org.apache.ignite.schema.parser.dialect.*;
+
+import java.io.*;
+import java.net.*;
+import java.sql.*;
+import java.util.*;
+import java.util.logging.*;
+
+/**
+ * Singleton to extract database metadata.
+ */
+public class DbMetadataReader {
+ /** Logger. */
+ private static final Logger log = Logger.getLogger(DbMetadataReader.class.getName());
+
+ /** */
+ private static final DbMetadataReader INSTANCE = new DbMetadataReader();
+
+ /** */
+ private final Map<String, Driver> drivers = new HashMap<>();
+
+ /**
+ * Default constructor.
+ */
+ private DbMetadataReader() {
+ // No-op.
+ }
+
+ /**
+ * Extract DB metadata.
+ *
+ * @param conn Connection.
+ * @param tblsOnly Tables only flag.
+ */
+ public Collection<DbTable> extractMetadata(Connection conn, boolean tblsOnly) throws SQLException {
+ DatabaseMetadataDialect dialect;
+
+ try {
+ String dbProductName = conn.getMetaData().getDatabaseProductName();
+
+ if ("Oracle".equals(dbProductName))
+ dialect = new OracleMetadataDialect();
+ else if (dbProductName.startsWith("DB2/"))
+ dialect = new DB2MetadataDialect();
+ else
+ dialect = new JdbcMetadataDialect();
+ }
+ catch (SQLException e) {
+ log.log(Level.SEVERE, "Failed to resolve dialect (JdbcMetaDataDialect will be used.", e);
+
+ dialect = new JdbcMetadataDialect();
+ }
+
+ return dialect.tables(conn, tblsOnly);
+ }
+
+ /**
+ * Connect to database.
+ *
+ * @param jdbcDrvJarPath Path to JDBC driver.
+ * @param jdbcDrvCls JDBC class name.
+ * @param jdbcUrl JDBC connection URL.
+ * @param jdbcInfo Connection properties.
+ * @return Connection to database.
+ * @throws SQLException if connection failed.
+ */
+ public Connection connect(String jdbcDrvJarPath, String jdbcDrvCls, String jdbcUrl, Properties jdbcInfo)
+ throws SQLException {
+ Driver drv = drivers.get(jdbcDrvCls);
+
+ if (drv == null) {
+ if (jdbcDrvJarPath.isEmpty())
+ throw new IllegalStateException("Driver jar file name is not specified.");
+
+ File drvJar = new File(jdbcDrvJarPath);
+
+ if (!drvJar.exists())
+ throw new IllegalStateException("Driver jar file is not found.");
+
+ try {
+ URL u = new URL("jar:" + drvJar.toURI() + "!/");
+
+ URLClassLoader ucl = URLClassLoader.newInstance(new URL[] {u});
+
+ drv = (Driver)Class.forName(jdbcDrvCls, true, ucl).newInstance();
+
+ drivers.put(jdbcDrvCls, drv);
+ }
+ catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+ }
+
+ Connection conn = drv.connect(jdbcUrl, jdbcInfo);
+
+ if (conn == null)
+ throw new IllegalStateException("Connection was not established (JDBC driver returned null value).");
+
+ return conn;
+ }
+
+ /**
+ * @return Instance.
+ */
+ public static DbMetadataReader getInstance() {
+ return INSTANCE;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1ac8b1ab/modules/schema-import/src/main/java/org/apache/ignite/schema/parser/DatabaseMetadataParser.java
----------------------------------------------------------------------
diff --git a/modules/schema-import/src/main/java/org/apache/ignite/schema/parser/DatabaseMetadataParser.java b/modules/schema-import/src/main/java/org/apache/ignite/schema/parser/DatabaseMetadataParser.java
index 22cb5ba..b94ace9 100644
--- a/modules/schema-import/src/main/java/org/apache/ignite/schema/parser/DatabaseMetadataParser.java
+++ b/modules/schema-import/src/main/java/org/apache/ignite/schema/parser/DatabaseMetadataParser.java
@@ -44,7 +44,7 @@ public class DatabaseMetadataParser {
Map<String, Collection<PojoDescriptor>> childrens = new HashMap<>();
- for (DbTable tbl : DBReader.getInstance().extractMetadata(conn, tblsOnly)) {
+ for (DbTable tbl : DbMetadataReader.getInstance().extractMetadata(conn, tblsOnly)) {
String schema = tbl.schema();
PojoDescriptor parent = parents.get(schema);
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1ac8b1ab/modules/schema-import/src/main/java/org/apache/ignite/schema/ui/SchemaImportApp.java
----------------------------------------------------------------------
diff --git a/modules/schema-import/src/main/java/org/apache/ignite/schema/ui/SchemaImportApp.java b/modules/schema-import/src/main/java/org/apache/ignite/schema/ui/SchemaImportApp.java
index d85922a..67890fb 100644
--- a/modules/schema-import/src/main/java/org/apache/ignite/schema/ui/SchemaImportApp.java
+++ b/modules/schema-import/src/main/java/org/apache/ignite/schema/ui/SchemaImportApp.java
@@ -342,7 +342,7 @@ public class SchemaImportApp extends Application {
@Override protected Void call() throws Exception {
long started = System.currentTimeMillis();
- try (Connection conn = DBReader.getInstance().connect(jdbcDrvJarPath, jdbcDrvCls, jdbcUrl, jdbcInfo)) {
+ try (Connection conn = DbMetadataReader.getInstance().connect(jdbcDrvJarPath, jdbcDrvCls, jdbcUrl, jdbcInfo)) {
pojos = DatabaseMetadataParser.parse(conn, tblsOnly);
}
@@ -1321,7 +1321,7 @@ public class SchemaImportApp extends Application {
if (customPrefsFile == null)
log.log(Level.WARNING, "Failed to resolve path to file with custom preferences: " +
- customPrefsFile);
+ customPrefsFileName);
else {
Properties customPrefs = new Properties();