Source:
<code>public ClusteredTierClientEntity fetchOrCreateClusteredStoreEntity(UUID clientId, String clusterTierManagerIdentifier, String storeIdentifier, ServerStoreConfiguration clientStoreConfiguration, boolean autoCreate) throws EntityNotFoundException, CachePersistenceException { EntityRef<ClusteredTierClientEntity, ClusteredTierEntityConfiguration> entityRef; try { <START> entityRef = connection.getEntityRef(ClusteredTierClientEntity.class, ENTITY_VERSION, clusterTierManagerIdentifier + storeIdentifier); <END> } catch (EntityNotProvidedException e) { throw new AssertionError(e); } if (autoCreate) { while (true) { try { entityRef.create(new ClusteredTierEntityConfiguration(clusterTierManagerIdentifier, storeIdentifier, clientStoreConfiguration)); } catch (EntityAlreadyExistsException e) { } catch (EntityConfigurationException e) { throw new CachePersistenceException("Unable to create clustered tier", e); } catch (EntityException e) { throw new AssertionError(e); } try { ClusteredTierClientEntity entity = entityRef.fetchEntity(); entity.setClientId(clientId); entity.setStoreIdentifier(storeIdentifier); entity.setTimeouts(entityTimeouts); return entity; } catch (EntityNotFoundException e) { } catch (EntityException e) { throw new AssertionError(e); } } } else { try { ClusteredTierClientEntity entity = entityRef.fetchEntity(); entity.setClientId(clientId); entity.setStoreIdentifier(storeIdentifier); entity.setTimeouts(entityTimeouts); return entity; } catch (EntityNotFoundException e) { throw e; } catch (EntityException e) { throw new AssertionError(e); } } }</code><technical_language>acquireleadership/lock concept for cache-entity lifecycle is in cachemanager-entity lifecycle. IMHO purpose served acquireleadership/lock concept apply caches cachemanager respective entities concerned. in ehcache way. in case of cache lock for cache, wdyt</technical_language>

Target:
public ClusteredTierClientEntity fetchOrCreateClusteredStoreEntity(UUID clientId, String clusterTierManagerIdentifier, String storeIdentifier, ServerStoreConfiguration clientStoreConfiguration, boolean autoCreate) throws EntityNotFoundException, CachePersistenceException { EntityRef<InternalClusterTierClientEntity, ClusteredTierEntityConfiguration> entityRef; try { entityRef = connection.getEntityRef(InternalClusterTierClientEntity.class, ENTITY_VERSION, clusterTierManagerIdentifier + storeIdentifier); } catch (EntityNotProvidedException e) { throw new AssertionError(e); } if (autoCreate) { while (true) { try { entityRef.create(new ClusteredTierEntityConfiguration(clusterTierManagerIdentifier, storeIdentifier, clientStoreConfiguration)); } catch (EntityAlreadyExistsException e) { } catch (EntityConfigurationException e) { throw new CachePersistenceException("Unable to create clustered tier", e); } catch (EntityException e) { throw new AssertionError(e); } try { InternalClusterTierClientEntity entity = entityRef.fetchEntity(); entity.setClientId(clientId); entity.setStoreIdentifier(storeIdentifier); entity.setTimeouts(entityTimeouts); return entity; } catch (EntityNotFoundException e) { } catch (EntityException e) { throw new AssertionError(e); } } } else { try { InternalClusterTierClientEntity entity = entityRef.fetchEntity(); entity.setClientId(clientId); entity.setStoreIdentifier(storeIdentifier); entity.setTimeouts(entityTimeouts); return entity; } catch (EntityNotFoundException e) { throw e; } catch (EntityException e) { throw new AssertionError(e); } } }