public synchronized static SessionFactory connectEmbedded(String url, Properties prop) { SessionFactory sessionFactory = EMBEDDED_ENGINES.get(url); if (sessionFactory == null) { String configLocation = getConfigLocation(url); sessionFactory = SessionFactoryBuilder.newBuilder().fromXml(configLocation).applySettings(prop).build(); EMBEDDED_ENGINES.put(url, sessionFactory); } return sessionFactory; }
public static SessionFactoryBuilder newBuilder() { return new SessionFactoryBuilder(); }
public SessionFactoryBuilder dbCluster(List<Shard> cluster) { vaildateCluster(cluster); configuration.cluster = cluster; return this; }
/** * Listen for incoming connections. */ public void init() { try { LOGGER.info("{} server init ddal-engine from {}", getServerName(), args.configFile); engine = (Engine)SessionFactoryBuilder.newBuilder().fromXml(args.configFile).build(); LOGGER.info("{} server ddal-engine inited.", getServerName()); } catch (Exception e) { LOGGER.error("Exception happen when init ddal-engine ", e); ServerException convert = ServerException.convert(e); throw convert; } }
private void beforeBuild() { vaildateCluster(configuration.cluster); for (TableRule table : configuration.tableRules) { validateTableRule(table); if (table instanceof ShardedTableRule) { ShardedTableRule shardedTable = (ShardedTableRule) table; Object po = shardedTable.getPartitioner(); try { if(po instanceof Partitioner) { Partitioner partitioner = (Partitioner)po; partitioner.initialize(shardedTable.getObjectNodes()); } else if(po instanceof MultColumnPartitioner) { MultColumnPartitioner partitioner = (MultColumnPartitioner)po; partitioner.initialize(shardedTable.getObjectNodes()); } } catch (Exception e) { String name = table.getName(); throw new IllegalStateException("initialize partitioner for table " + name + " error.", e); } } } if (configuration.provider == null) { throw new IllegalArgumentException("DataSourceProvider is required."); } }
public SessionFactoryBuilder addTableRule(ShardedTableRule table) { validateTableRule(table); configuration.tableRules.add(table); return this; }
public SessionFactory build() { beforeBuild(); System.getProperties().putAll(configuration.settings); Database database = new Database(configuration); Engine engine = new Engine(database); return engine; }
throw new IllegalArgumentException(); validateTableNode(object, objectNodes); break; case TableRule.GLOBAL_NODE_TABLE: throw new IllegalArgumentException(); validateTableNode(object, objectNodes); break; case TableRule.FIXED_NODE_TABLE: throw new IllegalArgumentException(); validateTableNode(object, object.getMetadataNode()); break;
public SessionFactoryBuilder addTableRule(GlobalTableRule table) { validateTableRule(table); configuration.tableRules.add(table); return this; }
public SessionFactoryBuilder addTableRule(TableRule table) { validateTableRule(table); configuration.tableRules.add(table); return this; }
public SessionFactoryBuilder addTableRuleGrop(TableRuleGroup group) { validateTableRule(group); List<ShardedTableRule> tableRules = group.getTableRules(); configuration.tableRules.addAll(tableRules); return this; }