@Override protected void validate(List<TableInfo> tableInfos) { if (!clusterManager.hasBucket(databaseName)) { throw new SchemaGenerationException("Bucket [" + databaseName + "] does not exist."); } }
Assert.fail(sgex.getMessage());
errors.add("com.impetus.kundera.configure.schema.SchemaGenerationException: Column AGE does not exist in column family CassandraEntitySimple"); errors.add("com.impetus.kundera.configure.schema.SchemaGenerationException: Column PERSON_NAME does not exist in column family CassandraEntitySimple"); Assert.assertTrue(errors.contains(e.getMessage()));
@Override public void dropSchema() { try { if (operation != null && ("create-drop").equalsIgnoreCase(operation)) { r.dbDrop(databaseName); } } catch (Exception e) { logger.error("Error while dropping schema", e); throw new SchemaGenerationException(e, "RethinkDB"); } }
errors.add("com.impetus.kundera.configure.schema.SchemaGenerationException: Column PERSON_NAME does not exist in column family CassandraEntitySimple"); errors.add("com.impetus.kundera.configure.schema.SchemaGenerationException: column family CassandraEntitySimple does not exist in keyspace KunderaCoreExmples"); Assert.assertTrue(errors.contains(sgex.getMessage().trim()));
/** * Creates schema and table for the list of tableInfos. * * @param tableInfos * list of TableInfos. */ protected void create(List<TableInfo> tableInfos) { try { createOrUpdateKeyspace(tableInfos); } catch (Exception ex) { throw new SchemaGenerationException(ex); } }
errors.add("column " + "AGE" + " does not exist in table " + TABLE + ""); errors.add("column " + "PERSON_NAME" + " does not exist in table " + TABLE + ""); Assert.assertTrue(errors.contains(sgex.getMessage()));
/** * update method update schema and table for the list of tableInfos. * * @param tableInfos * list of TableInfos. */ protected void update(List<TableInfo> tableInfos) { try { createOrUpdateKeyspace(tableInfos); } catch (Exception ex) { log.error("Error occurred while creating {}, Caused by: .", databaseName, ex); throw new SchemaGenerationException(ex); } }
/** * drop schema method drop the table from keyspace. * */ public void dropSchema() { if (operation != null && operation.equalsIgnoreCase("create-drop")) { try { dropKeyspaceOrCFs(); } catch (Exception ex) { log.error("Error during dropping schema in cassandra, Caused by: .", ex); throw new SchemaGenerationException(ex, "Cassandra"); } } cassandra_client = null; }
@Override protected boolean initiateClient() { for (String host : hosts) { if (host == null || !StringUtils.isNumeric(port) || port.isEmpty()) { logger.error("Host or port should not be null / port should be numeric"); throw new IllegalArgumentException("Host or port should not be null / port should be numeric"); } try { client = new KuduClient.KuduClientBuilder(host + ":" + port).build(); } catch (Exception e) { logger.error("Database host cannot be resolved, Caused by: " + e.getMessage()); throw new SchemaGenerationException("Database host cannot be resolved, Caused by: " + e.getMessage()); } } return true; }
throw new SchemaGenerationException(nfe);
@Override public void dropSchema() { for (TableInfo tableInfo : tableInfos) { try { client.deleteTable(tableInfo.getTableName()); } catch (Exception ex) { logger.error("Error during deleting tables in kudu, Caused by: ", ex); throw new SchemaGenerationException(ex, "Kudu"); } } }
if (!result.isSuccessful()) throw new SchemaGenerationException("Unable to CREATE Index with Index Name [" + indexName + "] for table [" + tableName + "]");
@Override public void dropSchema() { // dropping all the tables in the Oracle NoSQL store if (operation != null && operation.equalsIgnoreCase("create-drop")) { for (TableInfo tableInfo : tableInfos) { try { StatementResult result = tableAPI.executeSync("DROP TABLE IF EXISTS " + tableInfo.getTableName()); if (!result.isSuccessful()) { throw new SchemaGenerationException("Unable to DROP TABLE " + tableInfo.getTableName()); } } catch (IllegalArgumentException e) { logger.error("Invalid DROP TABLE Statement. Caused By: ", e); throw new SchemaGenerationException(e, "Invalid DROP TABLE Statement. Caused By: "); } catch (FaultException e) { logger.error("DROP TABLE Statement couldn't be executed. Caused By: ", e); throw new SchemaGenerationException(e, "Invalid DROP TABLE Statement is executed. Caused By: "); } } } }
/** * validate method validate schema and table for the list of tableInfos. * * @param tableInfos * list of TableInfos. */ protected void validate(List<TableInfo> tableInfos) { try { KsDef ksDef = cassandra_client.describe_keyspace(databaseName); onValidateTables(tableInfos, ksDef); } catch (Exception ex) { log.error("Error occurred while validating {}, Caused by: .", databaseName, ex); throw new SchemaGenerationException(ex); } }
@Override protected boolean initiateClient() { for (String host : hosts) { if (host == null || !StringUtils.isNumeric(port) || port.isEmpty()) { logger.error("Host or port should not be null / port should be numeric"); throw new IllegalArgumentException("Host or port should not be null / port should be numeric"); } try { connection = r.connection().hostname(host).port(Integer.parseInt(port)).connect(); } catch (Exception e) { logger.error("Database host/port cannot be resolved, Caused by: " + e.getMessage()); throw new SchemaGenerationException("Database host/port cannot be resolved, Caused by: " + e.getMessage()); } } return true; }
/** * Checks if is namespace available. * * @param databaseName * the database name * @return true, if is namespace available */ private boolean isNamespaceAvailable(String databaseName) { try { for (NamespaceDescriptor ns : admin.listNamespaceDescriptors()) { if (ns.getName().equals(databaseName)) { return true; } } return false; } catch (IOException ioex) { logger.error("Either table isn't in enabled state or some network problem, Caused by: ", ioex); throw new SchemaGenerationException(ioex, "Either table isn't in enabled state or some network problem."); } }
throw new SchemaGenerationException(nfe);
throw new SchemaGenerationException(nfe); throw new SchemaGenerationException(nfe);
throw new SchemaGenerationException(nfe);