Java AtomicInteger getPortOffset()

Here you can find the source of getPortOffset()

Description

The port offset is the range of ports that should not be used to find an open server port.

License

Apache License

Return

the offset to apply for port search

Declaration

static int getPortOffset() 

Method Source Code

//package com.java2s;
/*/* w w  w  .  jav  a  2 s . c  om*/
 * Copyright 2015-2016 DevCon5 GmbH, info@devcon5.ch
 *
 * 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.
 */

import java.util.concurrent.atomic.AtomicInteger;

public class Main {
    /**
     * The port offset may be configured at system level using the system property {@code scribble.net.portOffset}. The
     * offset defines the range of port-numbers used for random port search. The default range is 1024-65535. Any offset
     * will increase the lower bound, but not the upper. For example, setting a port offset of 10000 will result in a
     * range of 11024-65535. The port offset is an atomic integer value that is initialized using the system property
     * (default is 0). It may be set during runtime by setting the value of the port offset directly.
     */
    public static final AtomicInteger PORT_OFFSET = new AtomicInteger(
            Integer.parseInt(System.getProperty("scribble.net.portOffset", "0")));

    /**
     * The port offset is the range of ports that should not be used to find an open server port. The portrange is
     * always above 1024 to not collide with the standard ports below 1024. Further, the scribble system property for
     * defining an offset is applied. The default scribble offset is 0.
     *
     * @return the offset to apply for port search
     */
    static int getPortOffset() {

        return 1024 + PORT_OFFSET.get();
    }
}

Related

  1. getInstanceCounter(String name)
  2. getLock()
  3. getNextCounter(AtomicInteger counter)
  4. getNextId()
  5. getNextTempQueueName()
  6. getPrefix(final String namespace, final Map namespacesPrefixesMap)
  7. getPrefixedTerm(String namespace, String localName)
  8. getQueryCounters()
  9. getRandom()