null check when installing adapters contained in an external library
diff --git a/asterix-app/src/main/java/edu/uci/ics/asterix/hyracks/bootstrap/ExternalLibraryBootstrap.java b/asterix-app/src/main/java/edu/uci/ics/asterix/hyracks/bootstrap/ExternalLibraryBootstrap.java
index e0d7e6e..d2f3345 100755
--- a/asterix-app/src/main/java/edu/uci/ics/asterix/hyracks/bootstrap/ExternalLibraryBootstrap.java
+++ b/asterix-app/src/main/java/edu/uci/ics/asterix/hyracks/bootstrap/ExternalLibraryBootstrap.java
@@ -178,31 +178,58 @@
MetadataManager.INSTANCE.addDataverse(mdTxnCtx, new Dataverse(dataverse,
NonTaggedDataFormat.NON_TAGGED_DATA_FORMAT, IMetadataEntity.PENDING_NO_OP));
}
- for (LibraryFunction function : library.getLibraryFunctions().getLibraryFunction()) {
- String[] fargs = function.getArguments().trim().split(",");
- List<String> args = new ArrayList<String>();
- for (String arg : fargs) {
- args.add(arg);
+ if (library.getLibraryFunctions() != null) {
+ for (LibraryFunction function : library.getLibraryFunctions().getLibraryFunction()) {
+ String[] fargs = function.getArguments().trim().split(",");
+ List<String> args = new ArrayList<String>();
+ for (String arg : fargs) {
+ args.add(arg);
+ }
+ edu.uci.ics.asterix.metadata.entities.Function f = new edu.uci.ics.asterix.metadata.entities.Function(
+ dataverse, libraryName + "#" + function.getName(), args.size(), args,
+ function.getReturnType(), function.getDefinition(), library.getLanguage(),
+ function.getFunctionType());
+ MetadataManager.INSTANCE.addFunction(mdTxnCtx, f);
+ if (LOGGER.isLoggable(Level.INFO)) {
+ LOGGER.info("Installed function: " + libraryName + "#" + function.getName());
+ }
}
- edu.uci.ics.asterix.metadata.entities.Function f = new edu.uci.ics.asterix.metadata.entities.Function(
- dataverse, libraryName + "#" + function.getName(), args.size(), args, function.getReturnType(),
- function.getDefinition(), library.getLanguage(), function.getFunctionType());
- MetadataManager.INSTANCE.addFunction(mdTxnCtx, f);
}
- for (LibraryAdapter adapter : library.getLibraryAdapters().getLibraryAdapter()) {
- String adapterFactoryClass = adapter.getFactoryClass();
- String adapterName = libraryName + "#" + adapter.getName();
- AdapterIdentifier aid = new AdapterIdentifier(dataverse, adapterName);
- DatasourceAdapter dsa = new DatasourceAdapter(aid, adapterFactoryClass, AdapterType.EXTERNAL);
- MetadataManager.INSTANCE.addAdapter(mdTxnCtx, dsa);
+ if (LOGGER.isLoggable(Level.INFO)) {
+ LOGGER.info("Installed functions contain in library :" + libraryName);
+ }
+
+ if (library.getLibraryAdapters() != null) {
+ for (LibraryAdapter adapter : library.getLibraryAdapters().getLibraryAdapter()) {
+ String adapterFactoryClass = adapter.getFactoryClass();
+ String adapterName = libraryName + "#" + adapter.getName();
+ AdapterIdentifier aid = new AdapterIdentifier(dataverse, adapterName);
+ DatasourceAdapter dsa = new DatasourceAdapter(aid, adapterFactoryClass, AdapterType.EXTERNAL);
+ MetadataManager.INSTANCE.addAdapter(mdTxnCtx, dsa);
+ if (LOGGER.isLoggable(Level.INFO)) {
+ LOGGER.info("Installed adapter: " + adapterName);
+ }
+ }
+ }
+
+ if (LOGGER.isLoggable(Level.INFO)) {
+ LOGGER.info("Installed adapters contain in library :" + libraryName);
}
MetadataManager.INSTANCE.addLibrary(mdTxnCtx, new edu.uci.ics.asterix.metadata.entities.Library(dataverse,
libraryName));
+
+ if (LOGGER.isLoggable(Level.INFO)) {
+ LOGGER.info("Added library " + libraryName + "to Metadata");
+ }
+
MetadataManager.INSTANCE.commitTransaction(mdTxnCtx);
} catch (Exception e) {
e.printStackTrace();
+ if (LOGGER.isLoggable(Level.SEVERE)) {
+ LOGGER.info("Exception in installing library " + libraryName);
+ }
MetadataManager.INSTANCE.abortTransaction(mdTxnCtx);
}
}
diff --git a/asterix-installer/src/test/java/edu/uci/ics/asterix/installer/test/AsterixExternalLibraryIT.java b/asterix-installer/src/test/java/edu/uci/ics/asterix/installer/test/AsterixExternalLibraryIT.java
index daa8bb5..b993aab 100644
--- a/asterix-installer/src/test/java/edu/uci/ics/asterix/installer/test/AsterixExternalLibraryIT.java
+++ b/asterix-installer/src/test/java/edu/uci/ics/asterix/installer/test/AsterixExternalLibraryIT.java
@@ -28,58 +28,51 @@
public class AsterixExternalLibraryIT {
- private static final String LIBRARY_NAME = "testlib";
- private static final String LIBRARY_DATAVERSE = "externallibtest";
- private static final String PATH_BASE = "src/test/resources/integrationts/library";
- private static final String PATH_ACTUAL = "ittest/";
- private static final String LIBRARY_PATH = "asterix-external-data"
- + File.separator + "target" + File.separator
- + "testlib-zip-binary-assembly.zip";
- private static final Logger LOGGER = Logger
- .getLogger(AsterixExternalLibraryIT.class.getName());
- private static List<TestCaseContext> testCaseCollection;
+ private static final String LIBRARY_NAME = "testlib";
+ private static final String LIBRARY_DATAVERSE = "externallibtest";
+ private static final String PATH_BASE = "src/test/resources/integrationts/library";
+ private static final String PATH_ACTUAL = "ittest/";
+ private static final String LIBRARY_PATH = "asterix-external-data" + File.separator + "target" + File.separator
+ + "testlib-zip-binary-assembly.zip";
+ private static final Logger LOGGER = Logger.getLogger(AsterixExternalLibraryIT.class.getName());
+ private static List<TestCaseContext> testCaseCollection;
- @BeforeClass
- public static void setUp() throws Exception {
- AsterixInstallerIntegrationUtil.init();
- File asterixInstallerProjectDir = new File(System
- .getProperty("user.dir"));
- String asterixExternalLibraryPath = asterixInstallerProjectDir
- .getParentFile().getAbsolutePath()
- + File.separator + LIBRARY_PATH;
- LOGGER.info("Installing library :" + LIBRARY_NAME + " located at "
- + asterixExternalLibraryPath + " in dataverse "
- + LIBRARY_DATAVERSE);
- AsterixInstallerIntegrationUtil.installLibrary(LIBRARY_NAME,
- LIBRARY_DATAVERSE, asterixExternalLibraryPath);
- AsterixInstallerIntegrationUtil
- .transformIntoRequiredState(State.ACTIVE);
- TestCaseContext.Builder b = new TestCaseContext.Builder();
- testCaseCollection = b.build(new File(PATH_BASE));
- }
+ @BeforeClass
+ public static void setUp() throws Exception {
+ AsterixInstallerIntegrationUtil.init();
+ File asterixInstallerProjectDir = new File(System.getProperty("user.dir"));
+ String asterixExternalLibraryPath = asterixInstallerProjectDir.getParentFile().getAbsolutePath()
+ + File.separator + LIBRARY_PATH;
+ LOGGER.info("Installing library :" + LIBRARY_NAME + " located at " + asterixExternalLibraryPath
+ + " in dataverse " + LIBRARY_DATAVERSE);
+ AsterixInstallerIntegrationUtil.installLibrary(LIBRARY_NAME, LIBRARY_DATAVERSE, asterixExternalLibraryPath);
+ AsterixInstallerIntegrationUtil.transformIntoRequiredState(State.ACTIVE);
+ TestCaseContext.Builder b = new TestCaseContext.Builder();
+ testCaseCollection = b.build(new File(PATH_BASE));
+ }
- @AfterClass
- public static void tearDown() throws Exception {
- AsterixInstallerIntegrationUtil.deinit();
- }
+ @AfterClass
+ public static void tearDown() throws Exception {
+ AsterixInstallerIntegrationUtil.deinit();
+ }
- @Test
- public void test() throws Exception {
- for (TestCaseContext testCaseCtx : testCaseCollection) {
- TestsUtils.executeTest(PATH_ACTUAL, testCaseCtx);
- }
- }
+ @Test
+ public void test() throws Exception {
+ for (TestCaseContext testCaseCtx : testCaseCollection) {
+ TestsUtils.executeTest(PATH_ACTUAL, testCaseCtx);
+ }
+ }
- public static void main(String[] args) throws Exception {
- try {
- setUp();
- new AsterixExternalLibraryIT().test();
- } catch (Exception e) {
- e.printStackTrace();
- LOGGER.info("TEST CASES FAILED");
- } finally {
- tearDown();
- }
- }
+ public static void main(String[] args) throws Exception {
+ try {
+ setUp();
+ new AsterixExternalLibraryIT().test();
+ } catch (Exception e) {
+ e.printStackTrace();
+ LOGGER.info("TEST CASES FAILED");
+ } finally {
+ tearDown();
+ }
+ }
}
diff --git a/asterix-installer/src/test/java/edu/uci/ics/asterix/installer/test/AsterixInstallerIntegrationUtil.java b/asterix-installer/src/test/java/edu/uci/ics/asterix/installer/test/AsterixInstallerIntegrationUtil.java
index 1096a4d..4574f45 100644
--- a/asterix-installer/src/test/java/edu/uci/ics/asterix/installer/test/AsterixInstallerIntegrationUtil.java
+++ b/asterix-installer/src/test/java/edu/uci/ics/asterix/installer/test/AsterixInstallerIntegrationUtil.java
@@ -62,6 +62,8 @@
public static void init() throws Exception {
File asterixProjectDir = new File(System.getProperty("user.dir"));
+
+
File installerTargetDir = new File(asterixProjectDir, "target");
String managixHomeDirName = installerTargetDir
.list(new FilenameFilter() {
diff --git a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/bootstrap/MetadataBootstrap.java b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/bootstrap/MetadataBootstrap.java
index f2c8b5c..a1f6c38 100644
--- a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/bootstrap/MetadataBootstrap.java
+++ b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/bootstrap/MetadataBootstrap.java
@@ -169,6 +169,11 @@
for (int i = 0; i < secondaryIndexes.length; i++) {
enlistMetadataDataset(secondaryIndexes[i], true, mdTxnCtx);
}
+
+ if (LOGGER.isLoggable(Level.INFO)) {
+ LOGGER.info("Finished enlistment of metadata B-trees in new universe");
+ }
+
insertInitialDataverses(mdTxnCtx);
insertInitialDatasets(mdTxnCtx);
insertInitialDatatypes(mdTxnCtx);
@@ -191,7 +196,7 @@
}
if (LOGGER.isLoggable(Level.INFO)) {
- LOGGER.info("Finished enlistment of metadata B-trees.");
+ LOGGER.info("Finished enlistment of metadata B-trees in old universe.");
}
}
@@ -248,6 +253,9 @@
id, new HashMap<String, String>(), DatasetType.INTERNAL, primaryIndexes[i].getDatasetId().getId(),
IMetadataEntity.PENDING_NO_OP));
}
+ if (LOGGER.isLoggable(Level.INFO)) {
+ LOGGER.info("Finished inserting initial datasets.");
+ }
}
public static void getBuiltinTypes(ArrayList<IAType> types) throws Exception {
@@ -271,6 +279,9 @@
MetadataManager.INSTANCE.addDatatype(mdTxnCtx, new Datatype(dataverseName, types.get(i).getTypeName(),
types.get(i), false));
}
+ if (LOGGER.isLoggable(Level.INFO)) {
+ LOGGER.info("Finished inserting initial datatypes.");
+ }
}
public static void insertInitialIndexes(MetadataTransactionContext mdTxnCtx) throws Exception {
@@ -279,6 +290,9 @@
secondaryIndexes[i].getIndexedDatasetName(), secondaryIndexes[i].getIndexName(), IndexType.BTREE,
secondaryIndexes[i].getPartitioningExpr(), false, IMetadataEntity.PENDING_NO_OP));
}
+ if (LOGGER.isLoggable(Level.INFO)) {
+ LOGGER.info("Finished inserting initial indexes.");
+ }
}
public static void insertNodes(MetadataTransactionContext mdTxnCtx) throws Exception {
@@ -325,12 +339,18 @@
adapter = getAdapter(adapterClassName);
MetadataManager.INSTANCE.addAdapter(mdTxnCtx, adapter);
}
+ if (LOGGER.isLoggable(Level.INFO)) {
+ LOGGER.info("Finished inserting built-in adapters.");
+ }
}
private static void insertInitialFeedPolicies(MetadataTransactionContext mdTxnCtx) throws Exception {
for (FeedPolicy feedPolicy : BuiltinFeedPolicies.policies) {
MetadataManager.INSTANCE.addFeedPolicy(mdTxnCtx, feedPolicy);
}
+ if (LOGGER.isLoggable(Level.INFO)) {
+ LOGGER.info("Finished adding built-in feed policies.");
+ }
}
private static void insertInitialCompactionPolicies(MetadataTransactionContext mdTxnCtx) throws Exception {