You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by cr...@apache.org on 2013/12/09 17:28:34 UTC
git commit: AMBARI-3585. Remove dependencies on sqlite. (Trevor McKay
via croberts)
Updated Branches:
refs/heads/trunk ca8b0ad84 -> 110fc144a
AMBARI-3585. Remove dependencies on sqlite. (Trevor McKay via croberts)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/110fc144
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/110fc144
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/110fc144
Branch: refs/heads/trunk
Commit: 110fc144a97b946dce004fec3c60a5098501e9fc
Parents: ca8b0ad
Author: Chad Roberts <cr...@redhat.com>
Authored: Mon Dec 9 11:27:02 2013 -0500
Committer: Chad Roberts <cr...@redhat.com>
Committed: Mon Dec 9 11:27:31 2013 -0500
----------------------------------------------------------------------
ambari-server/pom.xml | 5 --
.../controller/jdbc/JDBCProviderModule.java | 39 ---------
.../jdbc/SQLiteConnectionFactory.java | 64 --------------
.../server/controller/utilities/DBHelper.java | 87 --------------------
.../controller/internal/TestProviderModule.java | 74 -----------------
5 files changed, 269 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/110fc144/ambari-server/pom.xml
----------------------------------------------------------------------
diff --git a/ambari-server/pom.xml b/ambari-server/pom.xml
index 9f9f48b..40cdd82 100644
--- a/ambari-server/pom.xml
+++ b/ambari-server/pom.xml
@@ -799,11 +799,6 @@
<version>3.3.1</version>
</dependency>
<dependency>
- <groupId>org.xerial</groupId>
- <artifactId>sqlite-jdbc</artifactId>
- <version>3.7.2</version>
- </dependency>
- <dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
<version>3.0</version>
http://git-wip-us.apache.org/repos/asf/ambari/blob/110fc144/ambari-server/src/main/java/org/apache/ambari/server/controller/jdbc/JDBCProviderModule.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/jdbc/JDBCProviderModule.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/jdbc/JDBCProviderModule.java
deleted file mode 100644
index e0275f7..0000000
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/jdbc/JDBCProviderModule.java
+++ /dev/null
@@ -1,39 +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.ambari.server.controller.jdbc;
-
-import org.apache.ambari.server.controller.internal.AbstractProviderModule;
-import org.apache.ambari.server.controller.spi.Resource;
-import org.apache.ambari.server.controller.spi.ResourceProvider;
-import org.apache.ambari.server.controller.utilities.DBHelper;
-import org.apache.ambari.server.controller.utilities.PropertyHelper;
-
-/**
- * A provider module implementation that uses the JDBC resource provider.
- */
-public class JDBCProviderModule extends AbstractProviderModule {
- // ----- utility methods ---------------------------------------------------
-
- @Override
- protected ResourceProvider createResourceProvider(Resource.Type type) {
- return new JDBCResourceProvider(DBHelper.CONNECTION_FACTORY, type,
- PropertyHelper.getPropertyIds(type),
- PropertyHelper.getKeyPropertyIds(type));
- }
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/110fc144/ambari-server/src/main/java/org/apache/ambari/server/controller/jdbc/SQLiteConnectionFactory.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/jdbc/SQLiteConnectionFactory.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/jdbc/SQLiteConnectionFactory.java
deleted file mode 100644
index 205e358..0000000
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/jdbc/SQLiteConnectionFactory.java
+++ /dev/null
@@ -1,64 +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.ambari.server.controller.jdbc;
-
-import java.sql.Connection;
-import java.sql.DriverManager;
-import java.sql.SQLException;
-
-/**
- * Connection factory implementation for SQLite.
- */
-public class SQLiteConnectionFactory implements ConnectionFactory {
-
- /**
- * The connection URL minus the db file.
- */
- private static final String CONNECTION_URL = "jdbc:sqlite:";
-
- /**
- * The filename of the SQLite db file.
- */
- private final String dbFile;
-
-
- // ----- Constructors ------------------------------------------------------
-
- /**
- * Create a connection factory.
- *
- * @param dbFile the SQLite DB filename
- */
- public SQLiteConnectionFactory(String dbFile) {
- this.dbFile = dbFile;
- try {
- Class.forName("org.sqlite.JDBC");
- } catch (ClassNotFoundException e) {
- throw new IllegalStateException("Can't load SQLite.", e);
- }
- }
-
-
- // ----- ConnectionFactory -------------------------------------------------
-
- @Override
- public Connection getConnection() throws SQLException {
- return DriverManager.getConnection(CONNECTION_URL + dbFile);
- }
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/110fc144/ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/DBHelper.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/DBHelper.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/DBHelper.java
deleted file mode 100644
index e23de5e..0000000
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/DBHelper.java
+++ /dev/null
@@ -1,87 +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.ambari.server.controller.utilities;
-
-import org.apache.ambari.server.controller.jdbc.ConnectionFactory;
-import org.apache.ambari.server.controller.jdbc.SQLiteConnectionFactory;
-import org.codehaus.jackson.map.ObjectMapper;
-import org.codehaus.jackson.type.TypeReference;
-
-import java.io.IOException;
-import java.sql.Connection;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- *
- */
-public class DBHelper {
- private static String DB_FILE_NAME = System.getProperty("ambariapi.dbfile", "src/test/resources/data.db");
-
- public static final ConnectionFactory CONNECTION_FACTORY = new SQLiteConnectionFactory(DB_FILE_NAME);
-
- private static final Map<String, String> HOSTS = readHosts();
-
- public static Map<String, String> getHosts() {
- return HOSTS;
- }
-
- private static Map<String, String> readHosts() {
- Map<String, String> hosts = new HashMap<String, String>();
-
- try {
- Connection connection = CONNECTION_FACTORY.getConnection();
-
- try {
- String sql = "select attributes from hosts";
-
- Statement statement = connection.createStatement();
-
- ResultSet rs = statement.executeQuery(sql);
-
- ObjectMapper mapper = new ObjectMapper();
-
- while (rs.next()) {
- String attributes = rs.getString(1);
-
- if (!attributes.startsWith("[]")) {
- try {
- Map<String, String> attributeMap = mapper.readValue(attributes, new TypeReference<Map<String, String>>() {
- });
- hosts.put(attributeMap.get("privateFQDN"), attributeMap.get("publicFQDN"));
- } catch (IOException e) {
- throw new IllegalStateException("Can't read hosts " + attributes, e);
- }
- }
- }
-
- statement.close();
- } finally {
- connection.close();
- }
-
- } catch (SQLException e) {
- throw new IllegalStateException("Can't access DB.", e);
- }
-
- return hosts;
- }
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/110fc144/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/TestProviderModule.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/TestProviderModule.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/TestProviderModule.java
deleted file mode 100644
index abc0b76..0000000
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/TestProviderModule.java
+++ /dev/null
@@ -1,74 +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.ambari.server.controller.internal;
-
-import org.apache.ambari.server.controller.jdbc.TestJDBCResourceProvider;
-import org.apache.ambari.server.controller.spi.PropertyProvider;
-import org.apache.ambari.server.controller.spi.ProviderModule;
-import org.apache.ambari.server.controller.spi.Resource;
-import org.apache.ambari.server.controller.spi.ResourceProvider;
-import org.apache.ambari.server.controller.utilities.DBHelper;
-import org.apache.ambari.server.controller.utilities.PropertyHelper;
-
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Module to plug in the JDBC resource provider.
- */
-public class TestProviderModule implements ProviderModule {
- private static final Map<Resource.Type, ResourceProvider> resourceProviders = new HashMap<Resource.Type, ResourceProvider>();
- private static final Map<Resource.Type, List<PropertyProvider>> propertyProviders = new HashMap<Resource.Type, List<PropertyProvider>>();
-
- static {
-
- for (Resource.Type type : Resource.Type.values()) {
- resourceProviders.put(type, new TestJDBCResourceProvider(
- DBHelper.CONNECTION_FACTORY,
- type,
- PropertyHelper.getPropertyIds(type),
- PropertyHelper.getKeyPropertyIds(type)));
- }
-
- propertyProviders.put(Resource.Type.Cluster, new LinkedList<PropertyProvider>());
- propertyProviders.put(Resource.Type.Service, new LinkedList<PropertyProvider>());
- propertyProviders.put(Resource.Type.Component, new LinkedList<PropertyProvider>());
- propertyProviders.put(Resource.Type.Host, new LinkedList<PropertyProvider>());
-
- List<PropertyProvider> providers = new LinkedList<PropertyProvider>();
-
- propertyProviders.put(Resource.Type.Component, providers);
-
- providers = new LinkedList<PropertyProvider>();
-
- propertyProviders.put(Resource.Type.HostComponent, providers);
- }
-
- @Override
- public ResourceProvider getResourceProvider(Resource.Type type) {
- return resourceProviders.get(type);
- }
-
- @Override
- public List<PropertyProvider> getPropertyProviders(Resource.Type type) {
- return propertyProviders.get(type);
- }
-}