public void saveExternalFilter(ExternalFilterDesc desc) throws IOException { try (AutoLock lock = extFilterMapLock.lockForWrite()) { extFilterCrud.save(desc); } }
public void saveSourceTable(TableDesc srcTable, String prj) throws IOException { try (AutoLock lock = srcTableMapLock.lockForWrite()) { srcTable.init(config, prj); srcTableCrud.save(srcTable); } }
private ProjectInstance save(ProjectInstance prj) throws IOException { crud.save(prj); clearL2Cache(prj.getName()); return prj; }
private void updateTempStatementWithRetry(TempStatementEntity entity, int retry) throws IOException { try { crud.save(entity); } catch (WriteConflictException ise) { logger.warn("Write conflict to update temp statement" + entity.statementId + " at try " + retry + ", will retry..."); if (retry >= 7) { logger.error("Retried 7 times till got error, abandoning...", ise); throw ise; } TempStatementEntity reload = crud.reload(entity.resourceName()); entity = prepareToOverwrite(entity, reload); updateTempStatementWithRetry(entity, ++retry); } }
public void addTableACL(String project, String name, String table, String type) throws IOException { try (AutoLock l = lock.lockForWrite()) { TableACL tableACL = loadTableACL(project).add(name, table, type); crud.save(tableACL); } }
@Override public MutableAcl updateAcl(MutableAcl mutableAcl) throws NotFoundException { try (AutoLock l = lock.lockForWrite()) { AclRecord record = ((MutableAclRecord) mutableAcl).getAclRecord(); crud.save(record); logger.debug("ACL of " + mutableAcl.getObjectIdentity() + " updated successfully."); } catch (IOException e) { throw new InternalErrorException(e); } return mutableAcl; }
public StreamingConfig createStreamingConfig(StreamingConfig streamingConfig) throws IOException { try (AutoLock l = lock.lockForWrite()) { if (streamingConfig == null || StringUtils.isEmpty(streamingConfig.getName())) { throw new IllegalArgumentException(); } if (streamingMap.containsKey(streamingConfig.resourceName())) throw new IllegalArgumentException( "StreamingConfig '" + streamingConfig.getName() + "' already exists"); streamingConfig.updateRandomUuid(); return crud.save(streamingConfig); } }
public void deleteTableACL(String project, String name, String table, String type) throws IOException { try (AutoLock l = lock.lockForWrite()) { TableACL tableACL = loadTableACL(project).delete(name, table, type); crud.save(tableACL); } }
public void deleteTableACLByTbl(String project, String table) throws IOException { try (AutoLock l = lock.lockForWrite()) { TableACL tableACL = loadTableACL(project).deleteByTbl(table); crud.save(tableACL); } }
public void deleteTableACL(String project, String name, String type) throws IOException { try (AutoLock l = lock.lockForWrite()) { TableACL tableACL = loadTableACL(project).delete(name, type); crud.save(tableACL); } }
public StreamingConfig updateStreamingConfig(StreamingConfig desc) throws IOException { try (AutoLock l = lock.lockForWrite()) { if (desc.getUuid() == null || desc.getName() == null) { throw new IllegalArgumentException("SteamingConfig Illegal."); } if (!streamingMap.containsKey(desc.resourceName())) { throw new IllegalArgumentException("StreamingConfig '" + desc.getName() + "' does not exist."); } return crud.save(desc); } }
public KafkaConfig updateKafkaConfig(KafkaConfig kafkaConfig) throws IOException { try (AutoLock l = lock.lockForWrite()) { if (!kafkaMap.containsKey(kafkaConfig.resourceName())) throw new IllegalArgumentException("KafkaConfig '" + kafkaConfig.getName() + "' does not exist."); checkKafkaConfig(kafkaConfig); return crud.save(kafkaConfig); } }
public void update(ManagedUser user) { try (AutoReadWriteLock.AutoLock l = lock.lockForWrite()) { ManagedUser exist = userMap.get(user.getUsername()); if (exist != null) { user.setLastModified(exist.getLastModified()); } user.setUsername(user.getUsername().toUpperCase(Locale.ROOT)); crud.save(user); } catch (IOException e) { throw new RuntimeException("Can not update user.", e); } }
public boolean createKafkaConfig(KafkaConfig kafkaConfig) throws IOException { try (AutoLock l = lock.lockForWrite()) { if (kafkaMap.containsKey(kafkaConfig.resourceName())) throw new IllegalArgumentException("KafkaConfig '" + kafkaConfig.getName() + "' already exists"); kafkaConfig.updateRandomUuid(); checkKafkaConfig(kafkaConfig); crud.save(kafkaConfig); return true; } }
private MutableAclRecord updateAclWithRetry(MutableAclRecord acl, AclRecordUpdater updater) { int retry = 7; while (retry-- > 0) { AclRecord record = acl.getAclRecord(); updater.update(record); try { crud.save(record); return acl; // here we are done } catch (WriteConflictException ise) { if (retry <= 0) { logger.error("Retry is out, till got error, abandoning...", ise); throw ise; } logger.warn("Write conflict to update ACL " + resourceKey(record.getObjectIdentity()) + " retry remaining " + retry + ", will retry..."); acl = readAcl(acl.getObjectIdentity()); } catch (IOException e) { throw new InternalErrorException(e); } } throw new RuntimeException("should not reach here"); }
@Override public MutableAcl createAcl(ObjectIdentity objectIdentity) throws AlreadyExistsException { try (AutoLock l = lock.lockForWrite()) { AclRecord aclRecord = getAclRecordByCache(objID(objectIdentity)); if (aclRecord != null) { throw new AlreadyExistsException("ACL of " + objectIdentity + " exists!"); } AclRecord record = newPrjACL(objectIdentity); crud.save(record); logger.debug("ACL of " + objectIdentity + " created successfully."); } catch (IOException e) { throw new InternalErrorException(e); } return (MutableAcl) readAclById(objectIdentity); }
crud.save(desc);
private DataModelDesc saveDataModelDesc(DataModelDesc dataModelDesc) throws IOException { String prj = ProjectManager.getInstance(config).getProjectOfModel(dataModelDesc.getName()).getName(); if (!dataModelDesc.isDraft()) dataModelDesc.init(config, this.getAllTablesMap(prj), getModels(prj), false); crud.save(dataModelDesc); return dataModelDesc; }
public void saveTableExt(TableExtDesc tableExt, String prj) throws IOException { try (AutoLock lock = srcExtMapLock.lockForWrite()) { if (tableExt.getUuid() == null || tableExt.getIdentity() == null) { throw new IllegalArgumentException(); } // updating a legacy global table if (tableExt.getProject() == null) { if (getTableExt(tableExt.getIdentity(), prj).getProject() != null) throw new IllegalStateException( "Updating a legacy global TableExtDesc while a project level version exists: " + tableExt.getIdentity() + ", " + prj); prj = tableExt.getProject(); } tableExt.init(prj); // what is this doing?? String path = TableExtDesc.concatResourcePath(tableExt.getIdentity(), prj); ResourceStore store = getStore(); TableExtDesc t = store.getResource(path, TABLE_EXT_SERIALIZER); if (t != null && t.getIdentity() == null) store.deleteResource(path); srcExtCrud.save(tableExt); } }
@Test public void testSave() throws IOException { CachedCrudAssist<TestEntity> crudAssist = new CachedCrudAssist<TestEntity>(getStore() // , "/test" // , TestEntity.class // , new CaseInsensitiveStringCache<TestEntity>(getTestConfig(), "test")) { // @Override protected TestEntity initEntityAfterReload(TestEntity entity, String resourceName) { return entity; } }; TestEntity entity = new TestEntity(); Assert.assertNull(entity.getUuid()); crudAssist.save(entity); Assert.assertNotNull(entity.getUuid()); }