@Test public void testSave() { List<TestGlobalEntity> globalEntites = Lists.newArrayList(); for (int i = 0; i < 100; i++) { globalEntites.add(createGlobalEntity()); } pinusClient.saveBatch(globalEntites, false); }
@Override public void save(Object entity) { if (entity == null) { throw new IllegalArgumentException("param should not be null"); } Class<?> clazz = entity.getClass(); if (entityMetaManager.isShardingEntity(clazz)) { CheckUtil.checkShardingEntity(entity); IShardingKey<?> sk = entityMetaManager.getShardingKey(entity); CheckUtil.checkShardingKey(sk); this.shardingUpdater.save(entity, sk); } else { CheckUtil.checkGlobalEntity(entity); String clusterName = entityMetaManager.getClusterName(entity.getClass()); CheckUtil.checkClusterName(clusterName); this.globalUpdater.save(entity, clusterName); } }
DefaultPinusClient implements PinusClient { @Override public void save(Object entity) { if (entity == null) { throw new IllegalArgumentException("param should not be null"); } Class<?> clazz = entity.getClass(); if (entityMetaManager.isShardingEntity(clazz)) { CheckUtil.checkShardingEntity(entity); IShardingKey<?> sk = entityMetaManager.getShardingKey(entity); CheckUtil.checkShardingKey(sk); this.shardingUpdater.save(entity, sk); } else { CheckUtil.checkGlobalEntity(entity); String clusterName = entityMetaManager.getClusterName(entity.getClass()); CheckUtil.checkClusterName(clusterName); this.globalUpdater.save(entity, clusterName); } } }
DefaultPinusClient implements PinusClient { @Override public void save(Object entity) { if (entity == null) { throw new IllegalArgumentException("param should not be null"); } Class<?> clazz = entity.getClass(); if (entityMetaManager.isShardingEntity(clazz)) { CheckUtil.checkShardingEntity(entity); IShardingKey<?> sk = entityMetaManager.getShardingKey(entity); CheckUtil.checkShardingKey(sk); this.shardingUpdater.save(entity, sk); } else { CheckUtil.checkGlobalEntity(entity); String clusterName = entityMetaManager.getClusterName(entity.getClass()); CheckUtil.checkClusterName(clusterName); this.globalUpdater.save(entity, clusterName); } }  }
DefaultPinusClient implements PinusClient { @Override public void save(Object entity) { if (entity == null) { throw new IllegalArgumentException("param should not be null"); } Class<?> clazz = entity.getClass(); if (entityMetaManager.isShardingEntity(clazz)) { CheckUtil.checkShardingEntity(entity); IShardingKey<?> sk = entityMetaManager.getShardingKey(entity); CheckUtil.checkShardingKey(sk); this.shardingUpdater.save(entity, sk); } else { CheckUtil.checkGlobalEntity(entity); String clusterName = entityMetaManager.getClusterName(entity.getClass()); CheckUtil.checkClusterName(clusterName); this.globalUpdater.save(entity, clusterName); } }  void init(); @Override void destroy(); @Override void beginTransaction(); @Override void beginTransaction(EnumTransactionIsolationLevel txLevel); @Override void commit(); @Override void rollback(); @Override void flush(); @Override TaskFuture submit(ITask<T> task, Class<T> clazz); @SuppressWarnings({ "rawtypes", "unchecked" }) @Override TaskFuture submit(ITask<T> task, Class<T> clazz, IQuery<T> query); @Override void save(Object entity); @Override void saveBatch(List<? extends Object> entityList); @Override void saveBatch(List<? extends Object> entityList, boolean autoGeneratedKeys); @Override void update(Object entity); @Override void updateBatch(List<? extends Object> entityList); @Override void delete(Object entity); @Override void delete(List<? extends Object> entityList); @Override void load(Object entity); @Override void load(Object entity, boolean useCache); @Override void load(Object entity, EnumDBMasterSlave masterSlave); @Override void load(Object entity, boolean useCache, EnumDBMasterSlave masterSlave); @Override IQuery<T> createQuery(Class<T> clazz); @Override List<Map<String, Object>> findBySQL(SQL sql, Class<?> clazz); @Override List<Map<String, Object>> findBySQL(SQL sql, String clusterName); @Override IDBCluster getDBCluster(); @Override IPrimaryCache getPrimaryCache(); @Override ISecondCache getSecondCache(); @Override int genClusterUniqueIntId(String name); @Override long genClusterUniqueLongId(String name); @Override long[] genClusterUniqueLongIdBatch(String name, int batchSize); @Override int[] genClusterUniqueIntIdBatch(String name, int batchSize); @Override Lock createLock(String lockName); EnumSyncAction getSyncAction(); @Override void setSyncAction(EnumSyncAction syncAction); String getScanPackage(); @Override void setScanPackage(String scanPackage); }
DefaultPinusClient implements PinusClient { @Override public void save(Object entity) { if (entity == null) { throw new IllegalArgumentException("param should not be null"); } Class<?> clazz = entity.getClass(); if (entityMetaManager.isShardingEntity(clazz)) { CheckUtil.checkShardingEntity(entity); IShardingKey<?> sk = entityMetaManager.getShardingKey(entity); CheckUtil.checkShardingKey(sk); this.shardingUpdater.save(entity, sk); } else { CheckUtil.checkGlobalEntity(entity); String clusterName = entityMetaManager.getClusterName(entity.getClass()); CheckUtil.checkClusterName(clusterName); this.globalUpdater.save(entity, clusterName); } }  void init(); @Override void destroy(); @Override void beginTransaction(); @Override void beginTransaction(EnumTransactionIsolationLevel txLevel); @Override void commit(); @Override void rollback(); @Override void flush(); @Override TaskFuture submit(ITask<T> task, Class<T> clazz); @SuppressWarnings({ "rawtypes", "unchecked" }) @Override TaskFuture submit(ITask<T> task, Class<T> clazz, IQuery<T> query); @Override void save(Object entity); @Override void saveBatch(List<? extends Object> entityList); @Override void saveBatch(List<? extends Object> entityList, boolean autoGeneratedKeys); @Override void update(Object entity); @Override void updateBatch(List<? extends Object> entityList); @Override void delete(Object entity); @Override void delete(List<? extends Object> entityList); @Override void load(Object entity); @Override void load(Object entity, boolean useCache); @Override void load(Object entity, EnumDBMasterSlave masterSlave); @Override void load(Object entity, boolean useCache, EnumDBMasterSlave masterSlave); @Override IQuery<T> createQuery(Class<T> clazz); @Override List<Map<String, Object>> findBySQL(SQL sql, Class<?> clazz); @Override List<Map<String, Object>> findBySQL(SQL sql, String clusterName); @Override IDBCluster getDBCluster(); @Override IPrimaryCache getPrimaryCache(); @Override ISecondCache getSecondCache(); @Override int genClusterUniqueIntId(String name); @Override long genClusterUniqueLongId(String name); @Override long[] genClusterUniqueLongIdBatch(String name, int batchSize); @Override int[] genClusterUniqueIntIdBatch(String name, int batchSize); @Override Lock createLock(String lockName); EnumSyncAction getSyncAction(); @Override void setSyncAction(EnumSyncAction syncAction); String getScanPackage(); @Override void setScanPackage(String scanPackage); static final Logger LOG; static PinusClient instance; }