} catch (AlreadyExistsException e) {
// It's ok, ignore
}
if (entity instanceof PaasTableEntity) {
// first create/check if schema db exists
PaasTableEntity tableEnt = (PaasTableEntity) entity;
String schemaName = tableEnt.getSchemaName();
String storage = tableEnt.getStorage();
try {
// String payLoad = tableEnt.getPayLoad();
if (storage!=null && storage.contains("mysql")) {
MySqlService.createDbInMySql(schemaName);
} //else {
session.execute(String.format(
PaasUtils.CREATE_KEYSPACE_SIMPLE_FORMAT, schemaName, 1));
//}//create counterpart in cassandra
} catch (AlreadyExistsException e) {
// It's ok, ignore
}
// if schema/db already exists now create the table
try {
Thread.sleep(10);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
String query = BuildQuery(tableEnt);
Print(query);
if (storage!=null && storage.contains("mysql")) {
MySqlService.createTableInDb(schemaName, query);
} else {
storage="cassandra";
session.execute(query);
}
List<String> tables = dbToTableMap.get(tableEnt.getSchemaName());
if (tables==null) tables = new ArrayList<String>();
tables.add(tableEnt.getName());
tableToStorageMap.put(tableEnt.getName(), storage);
// List<String> primaryKeys = entity.getPrimaryKey();
}
if (entity instanceof PaasTimeseriesEntity) {
// first create/check if schema db exists
PaasTimeseriesEntity tableEnt = (PaasTimeseriesEntity) entity;
try {
String schemaName = tableEnt.getSchemaName();
session.execute(String.format(
PaasUtils.CREATE_KEYSPACE_SIMPLE_FORMAT, schemaName, 1));
} catch (AlreadyExistsException e) {
// It's ok, ignore
}
// if schema/db already exists now create the table
try {
Thread.sleep(10);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
String query = BuildQuery(tableEnt);
Print(query);
session.execute(query);
List<String> tables = dbToTimeseriesMap.get(tableEnt.getSchemaName());
if (tables==null) tables = new ArrayList<String>();
tables.add(tableEnt.getName().substring(tableEnt.getName().indexOf(".")+1));
// List<String> primaryKeys = entity.getPrimaryKey();
}
JsonObject obj = new JsonObject("{\"status\":\"ok\"}");
return obj.toString();
}