@Test(expected = IllegalArgumentException.class) public void outOfBoundsClusterIDNegativeTest() { LocalUniqueIDGeneratorFactory.generatorFor(0, -1); }
public synchronized static IDGenerator generatorFor(int generatorId, int clusterId) { assertParameterWithinBounds("generatorId", 0, Blueprint.MAX_GENERATOR_ID, generatorId); assertParameterWithinBounds("clusterId", 0, Blueprint.MAX_CLUSTER_ID, clusterId); String generatorAndCluster = String.format("%d_%d", generatorId, clusterId); if (!instances.containsKey(generatorAndCluster)) { GeneratorIdentityHolder identityHolder = LocalGeneratorIdentity.with(clusterId, generatorId); instances.putIfAbsent(generatorAndCluster, new BaseUniqueIDGenerator(identityHolder)); } return instances.get(generatorAndCluster); }
LocalUniqueIDGeneratorFactory { public synchronized static IDGenerator generatorFor(int generatorId, int clusterId) { assertParameterWithinBounds("generatorId", 0, Blueprint.MAX_GENERATOR_ID, generatorId); assertParameterWithinBounds("clusterId", 0, Blueprint.MAX_CLUSTER_ID, clusterId); String generatorAndCluster = String.format("%d_%d", generatorId, clusterId); if (!instances.containsKey(generatorAndCluster)) { GeneratorIdentityHolder identityHolder = LocalGeneratorIdentity.with(clusterId, generatorId); instances.putIfAbsent(generatorAndCluster, new BaseUniqueIDGenerator(identityHolder)); } return instances.get(generatorAndCluster); } }
LocalUniqueIDGeneratorFactory { public synchronized static IDGenerator generatorFor(int generatorId, int clusterId) { assertParameterWithinBounds("generatorId", 0, Blueprint.MAX_GENERATOR_ID, generatorId); assertParameterWithinBounds("clusterId", 0, Blueprint.MAX_CLUSTER_ID, clusterId); String generatorAndCluster = String.format("%d_%d", generatorId, clusterId); if (!instances.containsKey(generatorAndCluster)) { GeneratorIdentityHolder identityHolder = LocalGeneratorIdentity.with(clusterId, generatorId); instances.putIfAbsent(generatorAndCluster, new BaseUniqueIDGenerator(identityHolder)); } return instances.get(generatorAndCluster); }  }
LocalUniqueIDGeneratorFactory { public synchronized static IDGenerator generatorFor(int generatorId, int clusterId) { assertParameterWithinBounds("generatorId", 0, Blueprint.MAX_GENERATOR_ID, generatorId); assertParameterWithinBounds("clusterId", 0, Blueprint.MAX_CLUSTER_ID, clusterId); String generatorAndCluster = String.format("%d_%d", generatorId, clusterId); if (!instances.containsKey(generatorAndCluster)) { GeneratorIdentityHolder identityHolder = LocalGeneratorIdentity.with(clusterId, generatorId); instances.putIfAbsent(generatorAndCluster, new BaseUniqueIDGenerator(identityHolder)); } return instances.get(generatorAndCluster); }  synchronized static IDGenerator generatorFor(int generatorId, int clusterId); }
LocalUniqueIDGeneratorFactory { public synchronized static IDGenerator generatorFor(int generatorId, int clusterId) { assertParameterWithinBounds("generatorId", 0, Blueprint.MAX_GENERATOR_ID, generatorId); assertParameterWithinBounds("clusterId", 0, Blueprint.MAX_CLUSTER_ID, clusterId); String generatorAndCluster = String.format("%d_%d", generatorId, clusterId); if (!instances.containsKey(generatorAndCluster)) { GeneratorIdentityHolder identityHolder = LocalGeneratorIdentity.with(clusterId, generatorId); instances.putIfAbsent(generatorAndCluster, new BaseUniqueIDGenerator(identityHolder)); } return instances.get(generatorAndCluster); }  synchronized static IDGenerator generatorFor(int generatorId, int clusterId);  }