WorkflowInstance writeActiveState(WorkflowInstance workflowInstance, RunState state) throws IOException { return storeWithRetries(() -> runInTransaction(tx -> tx.writeActiveState(workflowInstance, state))); }
void storeResource(Resource resource) throws IOException { storeWithRetries(() -> runInTransaction(transaction -> { transaction.store(resource); return null; })); }
void store(Workflow workflow) throws IOException { storeWithRetries(() -> runInTransaction(tx -> tx.store(workflow))); }
void patchState(WorkflowId workflowId, WorkflowState state) throws IOException { storeWithRetries(() -> runInTransaction(tx -> tx.patchState(workflowId, state))); }
public void updateNextNaturalTrigger(WorkflowId workflowId, TriggerInstantSpec triggerSpec) throws IOException { storeWithRetries(() -> runInTransaction(tx -> tx.updateNextNaturalTrigger(workflowId, triggerSpec))); }
void deleteActiveState(WorkflowInstance workflowInstance) throws IOException { storeWithRetries(() -> runInTransaction(tx -> tx.deleteActiveState(workflowInstance))); }
void storeBackfill(Backfill backfill) throws IOException { storeWithRetries(() -> runInTransaction(tx -> tx.store(backfill))); }
void delete(WorkflowId workflowId) throws IOException { storeWithRetries(() -> { datastore.delete(workflowKey(datastore.newKeyFactory(), workflowId)); return null; }); }
private void deleteShardsForCounter(String counterId) throws IOException { final List<Key> shards = new ArrayList<>(); datastore.query(EntityQuery.newEntityQueryBuilder() .setKind(KIND_COUNTER_SHARD) .setFilter(PropertyFilter.eq(PROPERTY_COUNTER_ID, counterId)) .build(), entity -> shards.add(entity.getKey())); // this is a safe guard to not to exceed max number of entities in one batch write // because in practice number of shards is much smaller for (List<Key> batch : Lists.partition(shards, MAX_NUMBER_OF_ENTITIES_IN_ONE_BATCH_WRITE)) { storeWithRetries(() -> { datastore.delete(batch.toArray(new Key[0])); return null; }); } }
/** * Delete resource by id. Deletes both counter shards and counter limit if it exists. * * <p>Due to Datastore limitations (modify max 25 entity groups per transaction), * we cannot do everything in one transaction. */ void deleteResource(String id) throws IOException { storeWithRetries(() -> { datastore.delete(datastore.newKeyFactory().setKind(KIND_COUNTER_LIMIT).newKey(id)); return null; }); deleteShardsForCounter(id); }