public class UniqueIdGenerator
extends Object
Generate a unique ID that fits within a long value quickly, will never create a duplicate value,
even if called insanely fast, and it incorporates part of the IP address so that machines in
a cluster will not create duplicates. It guarantees no duplicates because it keeps
the last 100 generated, and compares those against the value generated, if it matches, it
will continue generating until it does not match. It will generate 100 per millisecond without
matching. Once the requests for more than 100 unique IDs per millisecond is exceeded, the
caller will be slowed down, because it will be retrying. Keep in mind, 100 per millisecond is
10 microseconds continuously without interruption.
- Author:
- John DeRegnaucourt ([email protected])
Copyright (c) Cedar Software LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.