You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@eagle.apache.org by ha...@apache.org on 2016/10/19 03:27:57 UTC
[42/50] incubator-eagle git commit: [EAGLE-628] Fix jdbc metadata bugs
[EAGLE-628] Fix jdbc metadata bugs
https://issues.apache.org/jira/browse/EAGLE-628
Author: wujinhu <wu...@126.com>
Closes #520 from wujinhu/master.
Project: http://git-wip-us.apache.org/repos/asf/incubator-eagle/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-eagle/commit/47349674
Tree: http://git-wip-us.apache.org/repos/asf/incubator-eagle/tree/47349674
Diff: http://git-wip-us.apache.org/repos/asf/incubator-eagle/diff/47349674
Branch: refs/heads/master
Commit: 473496747d42b9bfe72f32cb89c312eef1a360bf
Parents: ecda7d5
Author: wujinhu <wu...@126.com>
Authored: Mon Oct 17 19:42:23 2016 +0800
Committer: wujinhu <wu...@126.com>
Committed: Mon Oct 17 19:42:23 2016 +0800
----------------------------------------------------------------------
.../app/module/ApplicationGuiceModule.java | 8 +-
.../eagle-metadata/eagle-metadata-jdbc/pom.xml | 5 +
.../ApplicationEntityServiceJDBCImpl.java | 75 +++++++++++--
.../jdbc/service/SiteEntityServiceJDBCImpl.java | 16 +--
.../orm/ApplicationEntityToRelation.java | 5 +
.../orm/RelationToApplicationEntity.java | 36 ++++--
.../ApplicationEntityServiceJDBCImplTest.java | 40 ++++---
.../store/jdbc/JDBCDataSourceProviderTest.java | 2 +-
.../jdbc/JDBCMetadataQueryServiceTest.java | 2 +-
.../store/jdbc/JDBCMetadataTestBase.java | 109 ++++++++++---------
.../store/jdbc/TestStaticApplication.java | 31 ++++++
...tore.jdbc.TestStaticApplication$Provider.xml | 31 ++++++
...org.apache.eagle.app.spi.ApplicationProvider | 16 +++
.../src/test/resources/init.sql | 7 +-
.../service/JDBCSecurityMetadataDAO.java | 12 +-
.../audit/JDBCSecurityMetadataDAOTest.java | 11 +-
.../src/main/bin/createTables.sql | 40 +++++++
17 files changed, 340 insertions(+), 106 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/47349674/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/module/ApplicationGuiceModule.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/module/ApplicationGuiceModule.java b/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/module/ApplicationGuiceModule.java
index 67c7eec..d796faa 100644
--- a/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/module/ApplicationGuiceModule.java
+++ b/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/module/ApplicationGuiceModule.java
@@ -16,9 +16,11 @@
*/
package org.apache.eagle.app.module;
+import com.typesafe.config.ConfigFactory;
import org.apache.eagle.app.service.ApplicationManagementService;
import org.apache.eagle.app.service.ApplicationProviderService;
import org.apache.eagle.app.service.impl.ApplicationManagementServiceImpl;
+import org.apache.eagle.app.service.impl.ApplicationProviderServiceImpl;
import org.apache.eagle.app.service.impl.ApplicationStatusUpdateServiceImpl;
import org.apache.eagle.metadata.service.ApplicationDescService;
import com.google.inject.AbstractModule;
@@ -27,12 +29,16 @@ import com.google.inject.util.Providers;
import org.apache.eagle.metadata.service.ApplicationStatusUpdateService;
public class ApplicationGuiceModule extends AbstractModule {
- private ApplicationProviderService appProviderInst;
+ private final ApplicationProviderService appProviderInst;
public ApplicationGuiceModule(ApplicationProviderService appProviderInst) {
this.appProviderInst = appProviderInst;
}
+ public ApplicationGuiceModule() {
+ this.appProviderInst = new ApplicationProviderServiceImpl(ConfigFactory.load());
+ }
+
@Override
protected void configure() {
bind(ApplicationProviderService.class).toProvider(Providers.of(appProviderInst));
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/47349674/eagle-core/eagle-metadata/eagle-metadata-jdbc/pom.xml
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-metadata/eagle-metadata-jdbc/pom.xml b/eagle-core/eagle-metadata/eagle-metadata-jdbc/pom.xml
index 940d697..d15f30a 100644
--- a/eagle-core/eagle-metadata/eagle-metadata-jdbc/pom.xml
+++ b/eagle-core/eagle-metadata/eagle-metadata-jdbc/pom.xml
@@ -46,5 +46,10 @@
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.eagle</groupId>
+ <artifactId>eagle-app-base</artifactId>
+ <version>${project.version}</version>
+ </dependency>
</dependencies>
</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/47349674/eagle-core/eagle-metadata/eagle-metadata-jdbc/src/main/java/org/apache/eagle/metadata/store/jdbc/service/ApplicationEntityServiceJDBCImpl.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-metadata/eagle-metadata-jdbc/src/main/java/org/apache/eagle/metadata/store/jdbc/service/ApplicationEntityServiceJDBCImpl.java b/eagle-core/eagle-metadata/eagle-metadata-jdbc/src/main/java/org/apache/eagle/metadata/store/jdbc/service/ApplicationEntityServiceJDBCImpl.java
index 20932b1..1f5ba65 100644
--- a/eagle-core/eagle-metadata/eagle-metadata-jdbc/src/main/java/org/apache/eagle/metadata/store/jdbc/service/ApplicationEntityServiceJDBCImpl.java
+++ b/eagle-core/eagle-metadata/eagle-metadata-jdbc/src/main/java/org/apache/eagle/metadata/store/jdbc/service/ApplicationEntityServiceJDBCImpl.java
@@ -18,6 +18,8 @@
package org.apache.eagle.metadata.store.jdbc.service;
+import org.apache.commons.lang.StringUtils;
+import org.apache.eagle.app.service.ApplicationProviderService;
import org.apache.eagle.metadata.model.ApplicationEntity;
import org.apache.eagle.metadata.service.ApplicationEntityService;
import org.apache.eagle.metadata.store.jdbc.JDBCMetadataQueryService;
@@ -25,6 +27,7 @@ import org.apache.eagle.metadata.store.jdbc.service.orm.ApplicationEntityToRelat
import org.apache.eagle.metadata.store.jdbc.service.orm.RelationToApplicationEntity;
import com.google.inject.Singleton;
+import org.json.simple.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -40,16 +43,18 @@ public class ApplicationEntityServiceJDBCImpl implements ApplicationEntityServic
private static final Logger LOGGER = LoggerFactory.getLogger(ApplicationEntityServiceJDBCImpl.class);
- private static final String insertSql = "INSERT INTO applicationentity (siteid, apptype, appmode, jarpath, appstatus, createdtime, modifiedtime, uuid, appid ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)";
- private static final String selectSql = "SELECT * FROM applicationentity a INNER JOIN siteentity s on a.siteid = s.siteid";
- private static final String selectSqlBySiteIdAndAppType = "SELECT * FROM applicationentity a INNER JOIN siteentity s on a.siteid = s.siteid where a.siteid = ? and a.apptype = ?";
- private static final String selectSqlBySiteId = "SELECT * FROM applicationentity a INNER JOIN siteentity s on a.siteid = s.siteid where a.siteid = ?";
- private static final String selectSqlByUUId = "SELECT * FROM applicationentity a INNER JOIN siteentity s on a.siteid = s.siteid where a.uuid = ?";
- private static final String selectSqlByAppId = "SELECT * FROM applicationentity a INNER JOIN siteentity s on a.siteid = s.siteid where a.appid = ?";
- private static final String deleteSqlByUUID = "DELETE FROM applicationentity where uuid = ?";
+ private static final String insertSql = "INSERT INTO applications (siteid, apptype, appmode, jarpath, appstatus, configuration, createdtime, modifiedtime, uuid, appid ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
+ private static final String selectSql = "SELECT * FROM applications a INNER JOIN sites s on a.siteid = s.siteid";
+ private static final String selectSqlBySiteIdAndAppType = "SELECT * FROM applications a INNER JOIN sites s on a.siteid = s.siteid where a.siteid = ? and a.apptype = ?";
+ private static final String selectSqlBySiteId = "SELECT * FROM applications a INNER JOIN sites s on a.siteid = s.siteid where a.siteid = ?";
+ private static final String selectSqlByUUId = "SELECT * FROM applications a INNER JOIN sites s on a.siteid = s.siteid where a.uuid = ?";
+ private static final String selectSqlByAppId = "SELECT * FROM applications a INNER JOIN sites s on a.siteid = s.siteid where a.appid = ?";
+ private static final String deleteSqlByUUID = "DELETE FROM applications where uuid = ?";
@Inject
JDBCMetadataQueryService queryService;
+ @Inject
+ ApplicationProviderService applicationProviderService;
@Override
public Collection<ApplicationEntity> findBySiteId(String siteId) {
@@ -61,6 +66,7 @@ public class ApplicationEntityServiceJDBCImpl implements ApplicationEntityServic
LOGGER.error("Error to getBySiteIdAndAppType ApplicationEntity: {}", e);
return results;
}
+ fillApplicationDesc(results);
return results;
}
@@ -80,6 +86,7 @@ public class ApplicationEntityServiceJDBCImpl implements ApplicationEntityServic
return null;
}
+ fillApplicationDesc(results);
return results.get(0);
}
@@ -101,6 +108,7 @@ public class ApplicationEntityServiceJDBCImpl implements ApplicationEntityServic
if (results.isEmpty()) {
throw new IllegalArgumentException("Application with appId: " + appId + " not found");
}
+ fillApplicationDesc(results);
return results.get(0);
}
@@ -116,12 +124,49 @@ public class ApplicationEntityServiceJDBCImpl implements ApplicationEntityServic
return entity;
}
- /**
- * TODO: UPDATE ApplicationEntity through JDBC is not supported yet
- */
@Override
public ApplicationEntity update(ApplicationEntity entity) {
- throw new UnsupportedOperationException("UPDATE ApplicationEntity through JDBC is not supported yet");
+ String updateSql = "update applications set ";
+ if (entity.getSite() != null && StringUtils.isNotBlank(entity.getSite().getSiteId())) {
+ updateSql += "siteid = ?, ";
+ }
+ if (entity.getDescriptor() != null && StringUtils.isNotBlank(entity.getDescriptor().getType())) {
+ updateSql += "apptype = ?, ";
+ }
+ if (entity.getMode() != null && StringUtils.isNotBlank(entity.getMode().name())) {
+ updateSql += "appmode = ?, ";
+ }
+ if (StringUtils.isNotBlank(entity.getJarPath())) {
+ updateSql += "jarpath = ?, ";
+ }
+ if (entity.getStatus() != null && StringUtils.isNotBlank(entity.getStatus().name())) {
+ updateSql += "appstatus = ?, ";
+ }
+ if (entity.getConfiguration() != null && !entity.getConfiguration().isEmpty()) {
+ updateSql += "configuration = ?, ";
+ }
+ if (entity.getCreatedTime() > 0) {
+ updateSql += "createdtime = ?, ";
+ }
+ if (entity.getModifiedTime() > 0) {
+ updateSql += "modifiedtime = ?, ";
+ }
+ updateSql = updateSql.substring(0, updateSql.length() - 2);
+ if (StringUtils.isNotBlank(entity.getUuid())) {
+ updateSql += " where uuid = ?";
+ }
+ if (StringUtils.isNotBlank(entity.getAppId())) {
+ updateSql += " and appid = ?";
+ }
+
+ try {
+ if (queryService.update(updateSql, entity, new ApplicationEntityToRelation()) == 0) {
+ LOGGER.warn("failed to execute {}", updateSql);
+ }
+ } catch (SQLException e) {
+ LOGGER.warn("failed to execute {}, {}", updateSql, e);
+ }
+ return getByUUID(entity.getUuid());
}
@Override
@@ -132,9 +177,16 @@ public class ApplicationEntityServiceJDBCImpl implements ApplicationEntityServic
} catch (SQLException e) {
LOGGER.error("Error to findAll ApplicationEntity: {}", e);
}
+ fillApplicationDesc(results);
return results;
}
+ private void fillApplicationDesc(List<ApplicationEntity> entities) {
+ for (ApplicationEntity entity : entities) {
+ entity.setDescriptor(applicationProviderService.getApplicationDescByType(entity.getDescriptor().getType()));
+ }
+ }
+
@Override
public ApplicationEntity getByUUID(String uuid) {
ApplicationEntity applicationEntity = new ApplicationEntity(null, null, null, null, uuid, "");
@@ -147,6 +199,7 @@ public class ApplicationEntityServiceJDBCImpl implements ApplicationEntityServic
if (results.isEmpty()) {
throw new IllegalArgumentException("Application (UUID: " + uuid + ") is not found");
}
+ fillApplicationDesc(results);
return results.get(0);
}
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/47349674/eagle-core/eagle-metadata/eagle-metadata-jdbc/src/main/java/org/apache/eagle/metadata/store/jdbc/service/SiteEntityServiceJDBCImpl.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-metadata/eagle-metadata-jdbc/src/main/java/org/apache/eagle/metadata/store/jdbc/service/SiteEntityServiceJDBCImpl.java b/eagle-core/eagle-metadata/eagle-metadata-jdbc/src/main/java/org/apache/eagle/metadata/store/jdbc/service/SiteEntityServiceJDBCImpl.java
index 436f416..9946f93 100644
--- a/eagle-core/eagle-metadata/eagle-metadata-jdbc/src/main/java/org/apache/eagle/metadata/store/jdbc/service/SiteEntityServiceJDBCImpl.java
+++ b/eagle-core/eagle-metadata/eagle-metadata-jdbc/src/main/java/org/apache/eagle/metadata/store/jdbc/service/SiteEntityServiceJDBCImpl.java
@@ -39,13 +39,13 @@ import javax.inject.Inject;
public class SiteEntityServiceJDBCImpl implements SiteEntityService {
private static final Logger LOGGER = LoggerFactory.getLogger(SiteEntityServiceJDBCImpl.class);
- private static final String insertSql = "INSERT INTO siteentity (siteid, sitename, description, createdtime, modifiedtime, uuid) VALUES (?, ?, ?, ?, ?, ?)";
- private static final String selectSql = "SELECT * FROM siteentity";
- private static final String selectSqlByUUID = "SELECT * FROM siteentity where uuid = ?";
- private static final String selectSqlBySiteId = "SELECT * FROM siteentity where siteid = ?";
- private static final String deleteSqlByUUID = "DELETE FROM siteentity where uuid = ?";
- private static final String deleteSqlBySiteId = "DELETE FROM siteentity where siteid = ?";
- private static final String updateSqlByUUID = "UPDATE siteentity SET siteid = ? , sitename = ? , description = ? , createdtime = ? , modifiedtime = ? where uuid = ?";
+ private static final String insertSql = "INSERT INTO sites (siteid, sitename, description, createdtime, modifiedtime, uuid) VALUES (?, ?, ?, ?, ?, ?)";
+ private static final String selectSql = "SELECT * FROM sites";
+ private static final String selectSqlByUUID = "SELECT * FROM sites where uuid = ?";
+ private static final String selectSqlBySiteId = "SELECT * FROM sites where siteid = ?";
+ private static final String deleteSqlByUUID = "DELETE FROM sites where uuid = ?";
+ private static final String deleteSqlBySiteId = "DELETE FROM sites where siteid = ?";
+ private static final String updateSqlByUUID = "UPDATE sites SET siteid = ? , sitename = ? , description = ? , createdtime = ? , modifiedtime = ? where uuid = ?";
@Inject
JDBCMetadataQueryService queryService;
@@ -158,7 +158,7 @@ public class SiteEntityServiceJDBCImpl implements SiteEntityService {
queryService.insert(insertSql, entities, new SiteEntityToRelation());
} catch (SQLException e) {
LOGGER.error("Error to insert SiteEntity: {}", entity, e);
- throw new IllegalArgumentException("MayBe Duplicated siteId: " + entity.getSiteId());
+ throw new IllegalArgumentException("Error to insert SiteEntity: " + entity + e);
}
return entity;
}
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/47349674/eagle-core/eagle-metadata/eagle-metadata-jdbc/src/main/java/org/apache/eagle/metadata/store/jdbc/service/orm/ApplicationEntityToRelation.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-metadata/eagle-metadata-jdbc/src/main/java/org/apache/eagle/metadata/store/jdbc/service/orm/ApplicationEntityToRelation.java b/eagle-core/eagle-metadata/eagle-metadata-jdbc/src/main/java/org/apache/eagle/metadata/store/jdbc/service/orm/ApplicationEntityToRelation.java
index 69577e4..20144a6 100644
--- a/eagle-core/eagle-metadata/eagle-metadata-jdbc/src/main/java/org/apache/eagle/metadata/store/jdbc/service/orm/ApplicationEntityToRelation.java
+++ b/eagle-core/eagle-metadata/eagle-metadata-jdbc/src/main/java/org/apache/eagle/metadata/store/jdbc/service/orm/ApplicationEntityToRelation.java
@@ -21,6 +21,7 @@ import org.apache.eagle.common.function.ThrowableConsumer2;
import org.apache.eagle.metadata.model.ApplicationEntity;
import org.apache.commons.lang.StringUtils;
+import org.json.simple.JSONObject;
import java.sql.PreparedStatement;
import java.sql.SQLException;
@@ -49,6 +50,10 @@ public class ApplicationEntityToRelation implements ThrowableConsumer2<PreparedS
statement.setString(parameterIndex, entity.getStatus().name());
parameterIndex++;
}
+ if (entity.getConfiguration() != null && !entity.getConfiguration().isEmpty()) {
+ statement.setString(parameterIndex, JSONObject.toJSONString(entity.getConfiguration()));
+ parameterIndex++;
+ }
if (entity.getCreatedTime() > 0) {
statement.setLong(parameterIndex, entity.getCreatedTime());
parameterIndex++;
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/47349674/eagle-core/eagle-metadata/eagle-metadata-jdbc/src/main/java/org/apache/eagle/metadata/store/jdbc/service/orm/RelationToApplicationEntity.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-metadata/eagle-metadata-jdbc/src/main/java/org/apache/eagle/metadata/store/jdbc/service/orm/RelationToApplicationEntity.java b/eagle-core/eagle-metadata/eagle-metadata-jdbc/src/main/java/org/apache/eagle/metadata/store/jdbc/service/orm/RelationToApplicationEntity.java
index 1b705a9..d8fcdad 100644
--- a/eagle-core/eagle-metadata/eagle-metadata-jdbc/src/main/java/org/apache/eagle/metadata/store/jdbc/service/orm/RelationToApplicationEntity.java
+++ b/eagle-core/eagle-metadata/eagle-metadata-jdbc/src/main/java/org/apache/eagle/metadata/store/jdbc/service/orm/RelationToApplicationEntity.java
@@ -21,12 +21,20 @@ import org.apache.eagle.common.function.ThrowableFunction;
import org.apache.eagle.metadata.model.ApplicationDesc;
import org.apache.eagle.metadata.model.ApplicationEntity;
import org.apache.eagle.metadata.model.SiteEntity;
+import org.apache.eagle.metadata.store.jdbc.service.ApplicationEntityServiceJDBCImpl;
+import org.codehaus.jettison.json.JSONObject;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.sql.ResultSet;
import java.sql.SQLException;
+import java.util.Iterator;
+import java.util.Map;
public class RelationToApplicationEntity implements ThrowableFunction<ResultSet, ApplicationEntity, SQLException> {
+
+ private static final Logger LOG = LoggerFactory.getLogger(RelationToApplicationEntity.class);
@Override
public ApplicationEntity apply(ResultSet resultSet) throws SQLException {
@@ -35,12 +43,12 @@ public class RelationToApplicationEntity implements ThrowableFunction<ResultSet,
applicationDesc.setType(appType);
SiteEntity siteEntity = new SiteEntity();
- siteEntity.setUuid(resultSet.getString(10));
- siteEntity.setSiteId(resultSet.getString(11));
- siteEntity.setSiteName(resultSet.getString(12));
- siteEntity.setDescription(resultSet.getString(13));
- siteEntity.setCreatedTime(resultSet.getLong(14));
- siteEntity.setModifiedTime(resultSet.getLong(15));
+ siteEntity.setUuid(resultSet.getString(11));
+ siteEntity.setSiteId(resultSet.getString(12));
+ siteEntity.setSiteName(resultSet.getString(13));
+ siteEntity.setDescription(resultSet.getString(14));
+ siteEntity.setCreatedTime(resultSet.getLong(15));
+ siteEntity.setModifiedTime(resultSet.getLong(16));
ApplicationEntity resultEntity = new ApplicationEntity();
@@ -51,8 +59,20 @@ public class RelationToApplicationEntity implements ThrowableFunction<ResultSet,
resultEntity.setMode(ApplicationEntity.Mode.valueOf(resultSet.getString(5)));
resultEntity.setJarPath(resultSet.getString(6));
resultEntity.setStatus(ApplicationEntity.Status.valueOf(resultSet.getString(7)));
- resultEntity.setCreatedTime(resultSet.getLong(8));
- resultEntity.setModifiedTime(resultSet.getLong(9));
+ try {
+ JSONObject jsonObject = new JSONObject(resultSet.getString(8));
+ Map<String, Object> items = new java.util.HashMap<>();
+ Iterator<String> keyItemItr = jsonObject.keys();
+ while (keyItemItr.hasNext()) {
+ String itemKey = keyItemItr.next();
+ items.put(itemKey, jsonObject.get(itemKey));
+ }
+ resultEntity.setConfiguration(items);
+ } catch (Exception e) {
+ LOG.warn("{}", e);
+ }
+ resultEntity.setCreatedTime(resultSet.getLong(9));
+ resultEntity.setModifiedTime(resultSet.getLong(10));
return resultEntity;
}
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/47349674/eagle-core/eagle-metadata/eagle-metadata-jdbc/src/test/java/org/apache/eagle/metadata/store/jdbc/ApplicationEntityServiceJDBCImplTest.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-metadata/eagle-metadata-jdbc/src/test/java/org/apache/eagle/metadata/store/jdbc/ApplicationEntityServiceJDBCImplTest.java b/eagle-core/eagle-metadata/eagle-metadata-jdbc/src/test/java/org/apache/eagle/metadata/store/jdbc/ApplicationEntityServiceJDBCImplTest.java
index 23db1be..017d829 100644
--- a/eagle-core/eagle-metadata/eagle-metadata-jdbc/src/test/java/org/apache/eagle/metadata/store/jdbc/ApplicationEntityServiceJDBCImplTest.java
+++ b/eagle-core/eagle-metadata/eagle-metadata-jdbc/src/test/java/org/apache/eagle/metadata/store/jdbc/ApplicationEntityServiceJDBCImplTest.java
@@ -17,6 +17,8 @@
package org.apache.eagle.metadata.store.jdbc;
+import org.apache.commons.collections.map.HashedMap;
+import org.apache.eagle.app.service.ApplicationProviderService;
import org.apache.eagle.metadata.exceptions.EntityNotFoundException;
import org.apache.eagle.metadata.model.ApplicationDesc;
import org.apache.eagle.metadata.model.ApplicationEntity;
@@ -29,12 +31,14 @@ import org.junit.Test;
import javax.inject.Inject;
import java.sql.SQLException;
import java.util.Collection;
+import java.util.Map;
public class ApplicationEntityServiceJDBCImplTest extends JDBCMetadataTestBase {
@Inject
ApplicationEntityService applicationEntityService;
-
+ @Inject
+ ApplicationProviderService applicationProviderService;
@Inject
SiteEntityService siteEntityService;
@@ -49,16 +53,16 @@ public class ApplicationEntityServiceJDBCImplTest extends JDBCMetadataTestBase {
String siteuuid = siteEntity.getUuid();
long sitecreateTime = siteEntity.getCreatedTime();
long sitemodifiedTime = siteEntity.getModifiedTime();
- ApplicationDesc applicationDesc = new ApplicationDesc();
- applicationDesc.setType("testtype");
-
+ ApplicationDesc applicationDesc = applicationProviderService.getApplicationDescByType("TEST_APP");
ApplicationEntity applicationEntity = new ApplicationEntity();
applicationEntity.setSite(siteEntity);
applicationEntity.setDescriptor(applicationDesc);
applicationEntity.setMode(ApplicationEntity.Mode.LOCAL);
- applicationEntity.setJarPath("c://");
-
+ applicationEntity.setJarPath(applicationDesc.getJarPath());
+ Map<String, Object> configure = new HashedMap();
+ configure.put("a", "b");
+ applicationEntity.setConfiguration(configure);
applicationEntityService.create(applicationEntity);
String appuuid = applicationEntity.getUuid();
String appId = applicationEntity.getAppId();
@@ -67,7 +71,7 @@ public class ApplicationEntityServiceJDBCImplTest extends JDBCMetadataTestBase {
Collection<ApplicationEntity> results = applicationEntityService.findAll();
Assert.assertEquals(1, results.size());
- ApplicationEntity applicationEntityFromDB = applicationEntityService.getBySiteIdAndAppType("testsiteid", "testtype");
+ ApplicationEntity applicationEntityFromDB = applicationEntityService.getBySiteIdAndAppType("testsiteid", "TEST_APP");
Assert.assertTrue(applicationEntityFromDB != null);
results = applicationEntityService.findBySiteId("testsiteid");
Assert.assertEquals(1, results.size());
@@ -86,9 +90,9 @@ public class ApplicationEntityServiceJDBCImplTest extends JDBCMetadataTestBase {
Assert.assertEquals(appuuid, applicationEntityFromDB.getUuid());
Assert.assertEquals(appId, applicationEntityFromDB.getAppId());
- Assert.assertEquals("testtype", applicationEntityFromDB.getDescriptor().getType());
+ Assert.assertEquals("TEST_APP", applicationEntityFromDB.getDescriptor().getType());
Assert.assertEquals(ApplicationEntity.Mode.LOCAL, applicationEntityFromDB.getMode());
- Assert.assertEquals("c://", applicationEntityFromDB.getJarPath());
+ Assert.assertEquals(applicationDesc.getJarPath(), applicationEntityFromDB.getJarPath());
Assert.assertEquals(ApplicationEntity.Status.INITIALIZED, applicationEntityFromDB.getStatus());
Assert.assertEquals(createTime, applicationEntityFromDB.getCreatedTime());
Assert.assertEquals(modifiedTime, applicationEntityFromDB.getModifiedTime());
@@ -103,16 +107,16 @@ public class ApplicationEntityServiceJDBCImplTest extends JDBCMetadataTestBase {
siteEntity.setSiteName("testsitename");
siteEntity.setDescription("testdesc");
siteEntityService.create(siteEntity);
- ApplicationDesc applicationDesc = new ApplicationDesc();
- applicationDesc.setType("testtype");
-
+ ApplicationDesc applicationDesc = applicationProviderService.getApplicationDescByType("TEST_APP");
ApplicationEntity applicationEntity = new ApplicationEntity();
applicationEntity.setSite(siteEntity);
applicationEntity.setDescriptor(applicationDesc);
applicationEntity.setMode(ApplicationEntity.Mode.LOCAL);
- applicationEntity.setJarPath("c://");
-
+ applicationEntity.setJarPath(applicationDesc.getJarPath());
+ Map<String, Object> configure = new HashedMap();
+ configure.put("a", "b");
+ applicationEntity.setConfiguration(configure);
applicationEntityService.create(applicationEntity);
applicationEntityService.create(applicationEntity);
}
@@ -133,15 +137,17 @@ public class ApplicationEntityServiceJDBCImplTest extends JDBCMetadataTestBase {
siteEntity.setSiteName("testsitename");
siteEntity.setDescription("testdesc");
siteEntityService.create(siteEntity);
- ApplicationDesc applicationDesc = new ApplicationDesc();
- applicationDesc.setType("testtype");
+ ApplicationDesc applicationDesc = applicationProviderService.getApplicationDescByType("TEST_APP");
ApplicationEntity applicationEntity = new ApplicationEntity();
applicationEntity.setSite(siteEntity);
applicationEntity.setDescriptor(applicationDesc);
applicationEntity.setMode(ApplicationEntity.Mode.LOCAL);
- applicationEntity.setJarPath("c://");
+ applicationEntity.setJarPath(applicationDesc.getJarPath());
+ Map<String, Object> configure = new HashedMap();
+ configure.put("a", "b");
+ applicationEntity.setConfiguration(configure);
applicationEntityService.create(applicationEntity);
Collection<ApplicationEntity> results = applicationEntityService.findAll();
Assert.assertEquals(1, results.size());
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/47349674/eagle-core/eagle-metadata/eagle-metadata-jdbc/src/test/java/org/apache/eagle/metadata/store/jdbc/JDBCDataSourceProviderTest.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-metadata/eagle-metadata-jdbc/src/test/java/org/apache/eagle/metadata/store/jdbc/JDBCDataSourceProviderTest.java b/eagle-core/eagle-metadata/eagle-metadata-jdbc/src/test/java/org/apache/eagle/metadata/store/jdbc/JDBCDataSourceProviderTest.java
index 6574a1b..545ade4 100644
--- a/eagle-core/eagle-metadata/eagle-metadata-jdbc/src/test/java/org/apache/eagle/metadata/store/jdbc/JDBCDataSourceProviderTest.java
+++ b/eagle-core/eagle-metadata/eagle-metadata-jdbc/src/test/java/org/apache/eagle/metadata/store/jdbc/JDBCDataSourceProviderTest.java
@@ -26,7 +26,7 @@ import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
-public class JDBCDataSourceProviderTest extends JDBCMetadataTestBase{
+public class JDBCDataSourceProviderTest extends JDBCMetadataTestBase {
@Inject
private DataSource dataSource;
@Inject
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/47349674/eagle-core/eagle-metadata/eagle-metadata-jdbc/src/test/java/org/apache/eagle/metadata/store/jdbc/JDBCMetadataQueryServiceTest.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-metadata/eagle-metadata-jdbc/src/test/java/org/apache/eagle/metadata/store/jdbc/JDBCMetadataQueryServiceTest.java b/eagle-core/eagle-metadata/eagle-metadata-jdbc/src/test/java/org/apache/eagle/metadata/store/jdbc/JDBCMetadataQueryServiceTest.java
index 0840f76..97a06ab 100644
--- a/eagle-core/eagle-metadata/eagle-metadata-jdbc/src/test/java/org/apache/eagle/metadata/store/jdbc/JDBCMetadataQueryServiceTest.java
+++ b/eagle-core/eagle-metadata/eagle-metadata-jdbc/src/test/java/org/apache/eagle/metadata/store/jdbc/JDBCMetadataQueryServiceTest.java
@@ -23,7 +23,7 @@ import javax.inject.Inject;
import java.sql.SQLException;
import java.util.List;
-public class JDBCMetadataQueryServiceTest extends JDBCMetadataTestBase{
+public class JDBCMetadataQueryServiceTest extends JDBCMetadataTestBase {
@Inject
JDBCMetadataQueryService queryService;
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/47349674/eagle-core/eagle-metadata/eagle-metadata-jdbc/src/test/java/org/apache/eagle/metadata/store/jdbc/JDBCMetadataTestBase.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-metadata/eagle-metadata-jdbc/src/test/java/org/apache/eagle/metadata/store/jdbc/JDBCMetadataTestBase.java b/eagle-core/eagle-metadata/eagle-metadata-jdbc/src/test/java/org/apache/eagle/metadata/store/jdbc/JDBCMetadataTestBase.java
index 3e94b8d..3315fc3 100644
--- a/eagle-core/eagle-metadata/eagle-metadata-jdbc/src/test/java/org/apache/eagle/metadata/store/jdbc/JDBCMetadataTestBase.java
+++ b/eagle-core/eagle-metadata/eagle-metadata-jdbc/src/test/java/org/apache/eagle/metadata/store/jdbc/JDBCMetadataTestBase.java
@@ -1,52 +1,57 @@
-/*
- * 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
- * <p/>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p/>
- * 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.eagle.metadata.store.jdbc;
-
-import com.google.inject.Guice;
-import com.google.inject.Inject;
-import com.google.inject.Injector;
-import org.apache.commons.dbcp.BasicDataSource;
-import org.apache.eagle.common.module.CommonGuiceModule;
-import org.junit.After;
-import org.junit.Before;
-
-import javax.sql.DataSource;
-import java.sql.SQLException;
-
-public class JDBCMetadataTestBase {
- private Injector injector;
-
- @Inject
- private DataSource dataSource;
-
- @Before
- public void setUp(){
- injector = Guice.createInjector(new JDBCMetadataStore(),new CommonGuiceModule());
- injector.injectMembers(this);
- }
-
- @After
- public void after() throws SQLException {
- if(dataSource!=null){
- ((BasicDataSource) dataSource).close();
- }
- }
-
- public Injector injector(){
- return injector;
- }
-}
+/*
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.eagle.metadata.store.jdbc;
+
+import com.google.inject.Guice;
+import com.google.inject.Inject;
+import com.google.inject.Injector;
+import com.typesafe.config.ConfigFactory;
+import org.apache.commons.dbcp.BasicDataSource;
+import org.apache.eagle.app.module.ApplicationGuiceModule;
+import org.apache.eagle.app.service.ApplicationProviderService;
+import org.apache.eagle.app.service.impl.ApplicationProviderServiceImpl;
+import org.apache.eagle.common.module.CommonGuiceModule;
+import org.apache.eagle.metadata.store.jdbc.JDBCMetadataStore;
+import org.junit.After;
+import org.junit.Before;
+
+import javax.sql.DataSource;
+import java.sql.SQLException;
+
+public class JDBCMetadataTestBase {
+ private Injector injector;
+
+ @Inject
+ private DataSource dataSource;
+
+ @Before
+ public void setUp(){
+ injector = Guice.createInjector(new JDBCMetadataStore(),new ApplicationGuiceModule(),new CommonGuiceModule());
+ injector.injectMembers(this);
+ }
+
+ @After
+ public void after() throws SQLException {
+ if(dataSource!=null){
+ ((BasicDataSource) dataSource).close();
+ }
+ }
+
+ public Injector injector(){
+ return injector;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/47349674/eagle-core/eagle-metadata/eagle-metadata-jdbc/src/test/java/org/apache/eagle/metadata/store/jdbc/TestStaticApplication.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-metadata/eagle-metadata-jdbc/src/test/java/org/apache/eagle/metadata/store/jdbc/TestStaticApplication.java b/eagle-core/eagle-metadata/eagle-metadata-jdbc/src/test/java/org/apache/eagle/metadata/store/jdbc/TestStaticApplication.java
new file mode 100644
index 0000000..fd81dca
--- /dev/null
+++ b/eagle-core/eagle-metadata/eagle-metadata-jdbc/src/test/java/org/apache/eagle/metadata/store/jdbc/TestStaticApplication.java
@@ -0,0 +1,31 @@
+/*
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.eagle.metadata.store.jdbc;
+
+import org.apache.eagle.app.StaticApplicationProvider;
+import org.junit.Test;
+
+public class TestStaticApplication {
+ public static class Provider extends StaticApplicationProvider {
+
+ }
+
+ @Test
+ public void f() {
+
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/47349674/eagle-core/eagle-metadata/eagle-metadata-jdbc/src/test/resources/META-INF/providers/org.apache.eagle.metadata.store.jdbc.TestStaticApplication$Provider.xml
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-metadata/eagle-metadata-jdbc/src/test/resources/META-INF/providers/org.apache.eagle.metadata.store.jdbc.TestStaticApplication$Provider.xml b/eagle-core/eagle-metadata/eagle-metadata-jdbc/src/test/resources/META-INF/providers/org.apache.eagle.metadata.store.jdbc.TestStaticApplication$Provider.xml
new file mode 100644
index 0000000..ec38d0b
--- /dev/null
+++ b/eagle-core/eagle-metadata/eagle-metadata-jdbc/src/test/resources/META-INF/providers/org.apache.eagle.metadata.store.jdbc.TestStaticApplication$Provider.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+ ~ 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.
+ -->
+
+<application>
+ <type>TEST_APP</type>
+ <name>Test app</name>
+ <version>0.5.0-incubating</version>
+ <configuration>
+ <!-- org.apache.eagle.jpm.mr.history.MRHistoryJobConfig -->
+ <property>
+ <name>jobExtractorConfig.site</name>
+ <displayName>Site ID</displayName>
+ <value>sandbox</value>
+ </property>
+ </configuration>
+</application>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/47349674/eagle-core/eagle-metadata/eagle-metadata-jdbc/src/test/resources/META-INF/services/org.apache.eagle.app.spi.ApplicationProvider
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-metadata/eagle-metadata-jdbc/src/test/resources/META-INF/services/org.apache.eagle.app.spi.ApplicationProvider b/eagle-core/eagle-metadata/eagle-metadata-jdbc/src/test/resources/META-INF/services/org.apache.eagle.app.spi.ApplicationProvider
new file mode 100644
index 0000000..4f0193c
--- /dev/null
+++ b/eagle-core/eagle-metadata/eagle-metadata-jdbc/src/test/resources/META-INF/services/org.apache.eagle.app.spi.ApplicationProvider
@@ -0,0 +1,16 @@
+# 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.
+
+org.apache.eagle.metadata.store.jdbc.TestStaticApplication$Provider
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/47349674/eagle-core/eagle-metadata/eagle-metadata-jdbc/src/test/resources/init.sql
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-metadata/eagle-metadata-jdbc/src/test/resources/init.sql b/eagle-core/eagle-metadata/eagle-metadata-jdbc/src/test/resources/init.sql
index 32e2e1d..4f6ab96 100644
--- a/eagle-core/eagle-metadata/eagle-metadata-jdbc/src/test/resources/init.sql
+++ b/eagle-core/eagle-metadata/eagle-metadata-jdbc/src/test/resources/init.sql
@@ -16,19 +16,20 @@
-- *
-- */
-CREATE TABLE IF NOT EXISTS applicationentity (
+CREATE TABLE IF NOT EXISTS applications (
uuid varchar(50) PRIMARY KEY,
appid varchar(100) DEFAULT NULL,
siteid varchar(100) DEFAULT NULL,
- apptype varchar(10) DEFAULT NULL,
+ apptype varchar(30) DEFAULT NULL,
appmode varchar(10) DEFAULT NULL,
jarpath varchar(255) DEFAULT NULL,
appstatus varchar(20) DEFAULT NULL,
+ configuration mediumtext DEFAULT NULL,
createdtime bigint(20) DEFAULT NULL,
modifiedtime bigint(20) DEFAULT NULL
);
-CREATE TABLE IF NOT EXISTS siteentity (
+CREATE TABLE IF NOT EXISTS sites (
uuid varchar(50) PRIMARY KEY,
siteid varchar(100) DEFAULT NULL,
sitename varchar(100) DEFAULT NULL,
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/47349674/eagle-security/eagle-security-common/src/main/java/org/apache/eagle/security/service/JDBCSecurityMetadataDAO.java
----------------------------------------------------------------------
diff --git a/eagle-security/eagle-security-common/src/main/java/org/apache/eagle/security/service/JDBCSecurityMetadataDAO.java b/eagle-security/eagle-security-common/src/main/java/org/apache/eagle/security/service/JDBCSecurityMetadataDAO.java
index ecbcfe2..e9662e6 100644
--- a/eagle-security/eagle-security-common/src/main/java/org/apache/eagle/security/service/JDBCSecurityMetadataDAO.java
+++ b/eagle-security/eagle-security-common/src/main/java/org/apache/eagle/security/service/JDBCSecurityMetadataDAO.java
@@ -19,6 +19,7 @@
package org.apache.eagle.security.service;
+import com.google.inject.Inject;
import com.typesafe.config.Config;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -55,6 +56,7 @@ public class JDBCSecurityMetadataDAO implements ISecurityMetadataDAO {
private final String OOZIE_INSERT_STATEMENT = "INSERT INTO oozie_sensitivity_entity (site, filedir, sensitivity_type) VALUES (?, ?, ?)";
// get connection url from config
+ @Inject
public JDBCSecurityMetadataDAO(Config config){
this.config = config;
}
@@ -259,9 +261,13 @@ public class JDBCSecurityMetadataDAO implements ISecurityMetadataDAO {
private Connection getJdbcConnection() throws Exception {
Connection connection;
try {
- connection = DriverManager.getConnection(config.getString("metadata.jdbc.url"),
- config.getString("metadata.jdbc.username"),
- config.getString("metadata.jdbc.password"));
+ if (config.hasPath("metadata.jdbc.username")) {
+ connection = DriverManager.getConnection(config.getString("metadata.jdbc.url"),
+ config.getString("metadata.jdbc.username"),
+ config.getString("metadata.jdbc.password"));
+ } else {
+ connection = DriverManager.getConnection(config.getString("metadata.jdbc.url"));
+ }
} catch (Exception e) {
LOG.error("error get connection for {}", config.getString("metadata.jdbc.url"), e);
throw e;
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/47349674/eagle-security/eagle-security-common/src/test/java/org/apache/eagle/security/crawler/audit/JDBCSecurityMetadataDAOTest.java
----------------------------------------------------------------------
diff --git a/eagle-security/eagle-security-common/src/test/java/org/apache/eagle/security/crawler/audit/JDBCSecurityMetadataDAOTest.java b/eagle-security/eagle-security-common/src/test/java/org/apache/eagle/security/crawler/audit/JDBCSecurityMetadataDAOTest.java
index b9e40ba..4cfe25e 100644
--- a/eagle-security/eagle-security-common/src/test/java/org/apache/eagle/security/crawler/audit/JDBCSecurityMetadataDAOTest.java
+++ b/eagle-security/eagle-security-common/src/test/java/org/apache/eagle/security/crawler/audit/JDBCSecurityMetadataDAOTest.java
@@ -17,6 +17,7 @@
package org.apache.eagle.security.crawler.audit;
import com.google.inject.Inject;
+import org.apache.eagle.app.module.ApplicationGuiceModule;
import org.apache.eagle.common.module.CommonGuiceModule;
import org.apache.eagle.common.module.GuiceJUnitRunner;
import org.apache.eagle.common.module.Modules;
@@ -26,6 +27,7 @@ import org.apache.eagle.security.service.HBaseSensitivityEntity;
import org.apache.eagle.security.service.JDBCSecurityMetadataDAO;
import org.junit.After;
import org.junit.Assert;
+import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -34,7 +36,9 @@ import java.util.Collection;
import java.util.Collections;
@RunWith(GuiceJUnitRunner.class)
-@Modules({JDBCMetadataStore.class, CommonGuiceModule.class})
+@Modules({
+ JDBCMetadataStore.class, CommonGuiceModule.class, ApplicationGuiceModule.class
+})
public class JDBCSecurityMetadataDAOTest {
@Inject
private JDBCSecurityMetadataDAO metadataDAO;
@@ -42,6 +46,11 @@ public class JDBCSecurityMetadataDAOTest {
@Inject
private JDBCMetadataQueryService queryService;
+ @Before
+ public void setUp() throws SQLException {
+ queryService.execute("create table hbase_sensitivity_entity (site varchar(20), hbase_resource varchar(100), sensitivity_type varchar(20), primary key (site, hbase_resource));");
+ }
+
@Test
public void testJDBCSecurityMetadataDAO(){
HBaseSensitivityEntity entity = new HBaseSensitivityEntity();
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/47349674/eagle-server-assembly/src/main/bin/createTables.sql
----------------------------------------------------------------------
diff --git a/eagle-server-assembly/src/main/bin/createTables.sql b/eagle-server-assembly/src/main/bin/createTables.sql
new file mode 100644
index 0000000..4f6ab96
--- /dev/null
+++ b/eagle-server-assembly/src/main/bin/createTables.sql
@@ -0,0 +1,40 @@
+-- /*
+-- * 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.
+-- *
+-- */
+
+CREATE TABLE IF NOT EXISTS applications (
+ uuid varchar(50) PRIMARY KEY,
+ appid varchar(100) DEFAULT NULL,
+ siteid varchar(100) DEFAULT NULL,
+ apptype varchar(30) DEFAULT NULL,
+ appmode varchar(10) DEFAULT NULL,
+ jarpath varchar(255) DEFAULT NULL,
+ appstatus varchar(20) DEFAULT NULL,
+ configuration mediumtext DEFAULT NULL,
+ createdtime bigint(20) DEFAULT NULL,
+ modifiedtime bigint(20) DEFAULT NULL
+);
+
+CREATE TABLE IF NOT EXISTS sites (
+ uuid varchar(50) PRIMARY KEY,
+ siteid varchar(100) DEFAULT NULL,
+ sitename varchar(100) DEFAULT NULL,
+ description varchar(255) DEFAULT NULL,
+ createdtime bigint(20) DEFAULT NULL,
+ modifiedtime bigint(20) DEFAULT NULL,
+ UNIQUE (siteid)
+);
\ No newline at end of file