I'm copying Google Cloud Datastore entities from one namespace to an other with java like this:
Key newKey = Key.newBuilder(oldEntity.getKey()).setNamespace(NEW_NAMESPACE).build();
datastore.put(Entity.newBuilder(oldEntity).setKey(newKey).build());
Since the entities have numerid id's generated by Datastore and the id's of the copied entities need to remain the same I need to also let Datastore know to allocate these id's, for that I'm using DatastoreService.allocateIdRange
But this is giving me an error:
Exceeded maximum allocated IDs
Does this mean that there is no way to achieve what I'm trying to achieve?
EDIT 1
The code that allocates the ids:
@POST
public void post(
@QueryParam("namespace") String namespace,
@QueryParam("kind") String kind,
@QueryParam("id") long id,
@QueryParam("parentKind") String parentKind,
@QueryParam("parentName") String parentName,
@QueryParam("parentId") Long parentId
) {
NamespaceManager.set(namespace);
DatastoreService ds = DatastoreServiceFactory.getDatastoreService();
Key parent = null;
if (parentKind != null) {
if (parentName != null)
parent = KeyFactory.createKey(parentKind, parentName);
else
parent = KeyFactory.createKey(parentKind, parentId);
}
ds.allocateIdRange(new KeyRange(parent, kind, id, id));
}
allocateIdRange
? If you're calling it in a loop or something you could actually have allocated all of the IDs. - Venantius